Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

Commit 1e5c93c

Browse files
fix: dump_decalared_classes fix goerli (#1295)
fix: dump_declared_classes fix goerli
1 parent f6a3721 commit 1e5c93c

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

crates/dump_declared_classes/src/main.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ use clap::{Arg, Command};
22
use papyrus_storage::utils::dump_declared_classes_table_by_block_range;
33

44
/// This executable dumps the declared_classes table from the storage to a file.
5-
65
fn main() {
76
let cli_params = get_cli_params();
87
match dump_declared_classes_table_by_block_range(
98
cli_params.start_block,
109
cli_params.end_block,
1110
&cli_params.file_path,
11+
&cli_params.chain_id,
1212
) {
1313
Ok(_) => println!("Dumped declared_classes table to file: {} .", cli_params.file_path),
14-
Err(e) => println!("Failed dumping declared_classes table with error: {} .", e),
14+
Err(e) => println!("Failed dumping declared_classes table with error: {}", e),
1515
}
1616
}
1717

1818
struct CliParams {
1919
start_block: u64,
2020
end_block: u64,
2121
file_path: String,
22+
chain_id: String,
2223
}
2324

2425
/// The start_block and end_block arguments are mandatory and define the block range to dump,
@@ -47,10 +48,17 @@ fn get_cli_params() -> CliParams {
4748
.required(true)
4849
.help("The block number to end dumping at."),
4950
)
51+
.arg(
52+
Arg::new("chain_id")
53+
.short('c')
54+
.long("chain_id")
55+
.required(true)
56+
.help("The chain id SN_MAIN/SN_GOERLI, default value is SN_MAIN."),
57+
)
5058
.get_matches();
5159

5260
let file_path =
53-
matches.get_one::<String>("file_path").expect("Failed parsing file_path").as_str();
61+
matches.get_one::<String>("file_path").expect("Failed parsing file_path").to_string();
5462
let start_block = matches
5563
.get_one::<String>("start_block")
5664
.expect("Failed parsing start_block")
@@ -64,5 +72,7 @@ fn get_cli_params() -> CliParams {
6472
if start_block >= end_block {
6573
panic!("start_block must be smaller than end_block");
6674
}
67-
CliParams { start_block, end_block, file_path: file_path.to_string() }
75+
let chain_id =
76+
matches.get_one::<String>("chain_id").expect("Failed parsing chain_id").to_string();
77+
CliParams { start_block, end_block, file_path, chain_id }
6878
}

crates/papyrus_storage/src/utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::io::{BufWriter, Write};
99

1010
use serde::Serialize;
1111
use starknet_api::block::BlockNumber;
12-
use starknet_api::core::{ClassHash, CompiledClassHash};
12+
use starknet_api::core::{ChainId, ClassHash, CompiledClassHash};
1313
use starknet_api::hash::StarkFelt;
1414
use starknet_api::state::{EntryPoint, EntryPointType};
1515

@@ -61,8 +61,10 @@ pub fn dump_declared_classes_table_by_block_range(
6161
start_block: u64,
6262
end_block: u64,
6363
file_path: &str,
64+
chain_id: &str,
6465
) -> StorageResult<()> {
65-
let storage_config = StorageConfig::default();
66+
let mut storage_config = StorageConfig::default();
67+
storage_config.db_config.chain_id = ChainId(chain_id.to_string());
6668
let (storage_reader, _) = open_storage(storage_config)?;
6769
let txn = storage_reader.begin_ro_txn()?;
6870
let compiled_class_marker = txn.get_compiled_class_marker()?;

0 commit comments

Comments
 (0)