diff --git a/README.md b/README.md index 7a6f610..02974a8 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Options: --use-ots Whether to query Otterscan's `ots` namespace --use-tempo Whether to query Tempo's `tempo` namespace --minimal Whether either node runs with `--minimal` pruning + --skip-historical-state Skip transaction replays at the parent block (`eth_call`, `eth_estimateGas`, simulations and traced calls) and contract code and storage reads at the tested block --ws1 WS URL of rpc1's node. Enables the `eth_subscribe` checks, which need `--ws2` too --ws2 WS URL of rpc2's node --ws-timeout Maximum time to wait for the next subscription message in seconds [default: 60] diff --git a/crates/rpc-tester-cli/src/main.rs b/crates/rpc-tester-cli/src/main.rs index e154f0a..16fb7f7 100644 --- a/crates/rpc-tester-cli/src/main.rs +++ b/crates/rpc-tester-cli/src/main.rs @@ -74,6 +74,14 @@ pub struct CliArgs { #[arg(long)] pub minimal: bool, + /// Skip transaction replays at the parent block (`eth_call`, `eth_estimateGas`, simulations + /// and traced calls) and contract code and storage reads at the tested block. + /// + /// For a node whose history index may not cover accounts unchanged since before its earliest + /// changeset, such as one restored from a snapshot without its indices. + #[arg(long)] + pub skip_historical_state: bool, + /// WS URL of rpc1's node. Enables the `eth_subscribe` checks, which need `--ws2` too. /// /// Heads, logs and receipts are collected for `--num-blocks` new blocks on both nodes and @@ -152,6 +160,7 @@ async fn main() -> eyre::Result<()> { .with_tempo(args.use_tempo) .with_history_floor(history_floor) .with_minimal(args.minimal) + .skip_historical_state(args.skip_historical_state) .with_rate_limit(args.rate_limit) .build(); diff --git a/crates/rpc-tester/src/tester.rs b/crates/rpc-tester/src/tester.rs index 5303757..2097655 100644 --- a/crates/rpc-tester/src/tester.rs +++ b/crates/rpc-tester/src/tester.rs @@ -74,6 +74,9 @@ pub struct RpcTester> { /// and keeps receipts for only the newest 64 blocks, so lookups by hash and anything read from /// receipts are skipped. minimal: bool, + /// Whether to skip replaying transactions at their parent block and reading contract code and + /// storage at the tested block, which read account state at a past block. + skip_historical_state: bool, /// Maximum requests per second for rate limiting. rate_limit_rps: Option, /// Last timestamp for rate limiting. @@ -248,9 +251,12 @@ where rpc_raw!(self, trace_call, JsonValue, parity_call_args), rpc_raw!(self, tempo_simulateV1, JsonValue, tempo_simulate_args), ]; - tests.extend(exec_calls); + // Replays and state reads at a past block are skipped with --skip-historical-state. + if !self.skip_historical_state { + tests.extend(exec_calls); + } - if self.use_tempo { + if self.use_tempo && !self.skip_historical_state { // Replays with the transaction's own fees, fee token and authorizations, which // the fee-free replays drop. Calls, estimates and traced calls still resolve // and validate the fee token but skip fee collection, so only the simulation @@ -279,7 +285,7 @@ where tests.extend(fee_calls); } - if !self.skip_extended_eth { + if !self.skip_extended_eth && !self.skip_historical_state { // Simulation builds a block around the call, with receipts, logs and // synthetic transfer logs that `eth_call` does not return. let simulate_args = ( @@ -312,7 +318,7 @@ where .and_then(JsonValue::as_str) .and_then(|to| to.parse().ok()), }; - if let Some(address) = state_address { + if let Some(address) = state_address.filter(|_| !self.skip_historical_state) { #[rustfmt::skip] let state_calls = vec![ rpc_with_block!(self, get_code_at, address; block_id), @@ -1096,6 +1102,8 @@ pub struct RpcTesterBuilder> { history_floor: BlockNumber, /// Whether either node runs with `--minimal` pruning. minimal: bool, + /// Whether to skip calls that read account state at a past block. + skip_historical_state: bool, /// Maximum requests per second for rate limiting. rate_limit_rps: Option, } @@ -1116,6 +1124,7 @@ impl> RpcTesterBuilder

{ use_tempo: false, history_floor: 0, minimal: false, + skip_historical_state: false, rate_limit_rps: None, } } @@ -1188,6 +1197,13 @@ impl> RpcTesterBuilder

{ self } + /// Enables or disables skipping transaction replays at the parent block and contract code and + /// storage reads at the tested block. + pub const fn skip_historical_state(mut self, skip: bool) -> Self { + self.skip_historical_state = skip; + self + } + /// Sets the rate limit in requests per second. /// If None, no rate limiting is applied. pub const fn with_rate_limit(mut self, rps: Option) -> Self { @@ -1210,6 +1226,7 @@ impl> RpcTesterBuilder

{ use_tempo: self.use_tempo, history_floor: self.history_floor, minimal: self.minimal, + skip_historical_state: self.skip_historical_state, rate_limit_rps: self.rate_limit_rps, last_request_time: tokio::sync::Mutex::new(std::time::Instant::now()), }