Skip to content

Commit

Permalink
fix(dump): rpc sanity check for trace_replayBlockTransactions befor…
Browse files Browse the repository at this point in the history
…e dump (#491)
  • Loading branch information
Jon-Becker authored Sep 2, 2024
1 parent 25913c3 commit 9193870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions crates/dump/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ pub async fn dump(args: DumpArgs) -> Result<HashMap<FixedBytes<32>, FixedBytes<3
let block_count = block_range.end() - block_range.start() + 1;
debug!("dumping storage from block range: {:?}", block_range);

// a quick check to see if the rpc supports trace_ namespace
// TODO: dump support via `debug_traceBlockByNumber` w/ prestateTracer as another option
let _ = get_block_state_diff(
(*block_range.start()).try_into().expect("block number overflow"),
&args.rpc_url,
)
.await
.map_err(|_| eyre!("failed to `trace_replayBlockTransactions`. does your rpc support it?"))?;

// create a semaphore with the correct number of permits
let semaphore = Arc::new(Semaphore::new(args.threads));
let handles = block_range.map(|block_number| {
Expand Down
4 changes: 2 additions & 2 deletions crates/dump/src/interfaces/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub struct DumpArgs {
pub threads: usize,

/// The block number to start dumping from.
#[clap(long, default_value = "0", hide_default_value = true)]
#[clap(long, short, default_value = "0", hide_default_value = true, alias = "start_block")]
pub from_block: u128,

/// The block number to stop dumping at.
#[clap(long)]
#[clap(long, short, alias = "end_block")]
pub to_block: Option<u128>,

/// The name for the output file
Expand Down

0 comments on commit 9193870

Please sign in to comment.