From 91938708d1dc6389b04ebe7711d4d578f6fc653e Mon Sep 17 00:00:00 2001 From: Jonathan Becker Date: Mon, 2 Sep 2024 10:07:02 -0700 Subject: [PATCH] fix(dump): rpc sanity check for `trace_replayBlockTransactions` before dump (#491) --- crates/dump/src/core/mod.rs | 9 +++++++++ crates/dump/src/interfaces/args.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/dump/src/core/mod.rs b/crates/dump/src/core/mod.rs index 1e7a2e85..c9f27213 100644 --- a/crates/dump/src/core/mod.rs +++ b/crates/dump/src/core/mod.rs @@ -33,6 +33,15 @@ pub async fn dump(args: DumpArgs) -> Result, 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| { diff --git a/crates/dump/src/interfaces/args.rs b/crates/dump/src/interfaces/args.rs index d6c62c17..686723a3 100644 --- a/crates/dump/src/interfaces/args.rs +++ b/crates/dump/src/interfaces/args.rs @@ -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, /// The name for the output file