From b7ec67eb2340b621786647a2ac3c364aff98986b Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Tue, 27 Oct 2026 18:05:58 +0800 Subject: [PATCH 01/12] fix(state-test): bound fixture inputs and validate transactions --- crates/mega-state-test/AGENTS.md | 5 +- crates/mega-state-test/README.md | 15 + .../mega-state-test/src/blockchain/chain.rs | 9 + crates/mega-state-test/src/blockchain/mod.rs | 6 +- crates/mega-state-test/src/input.rs | 261 ++++++++++++++++++ crates/mega-state-test/src/lib.rs | 1 + crates/mega-state-test/src/runner.rs | 60 ++-- crates/mega-state-test/src/skips.rs | 67 ++++- crates/mega-state-test/src/witness.rs | 1 + .../VMTests/vmPerformance/loopMul.json | 257 +++++++++++++++++ .../Call50000_sha256.json | 191 +++++++++++++ .../CALLBlake2f_MaxRounds.json | 130 +++++++++ .../static_Call50000_sha256.json | 205 ++++++++++++++ .../Call50000_sha256.json | 134 +++++++++ .../static_Call50000_sha256.json | 128 +++++++++ .../tests/fixtures/slow/LICENSE | 7 + .../tests/fixtures/slow/README.md | 8 + crates/mega-state-test/tests/input_limits.rs | 148 ++++++++++ crates/mega-state-test/tests/runner.rs | 87 ++++++ crates/mega-state-test/tests/witness.rs | 4 +- crates/state-test/src/btest.rs | 18 +- crates/state-test/src/main.rs | 20 +- crates/state-test/tests/input_discovery.rs | 37 +++ 23 files changed, 1746 insertions(+), 53 deletions(-) create mode 100644 crates/mega-state-test/src/input.rs create mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json create mode 100644 crates/mega-state-test/tests/fixtures/slow/LICENSE create mode 100644 crates/mega-state-test/tests/fixtures/slow/README.md create mode 100644 crates/mega-state-test/tests/input_limits.rs create mode 100644 crates/state-test/tests/input_discovery.rs diff --git a/crates/mega-state-test/AGENTS.md b/crates/mega-state-test/AGENTS.md index c353eb2ab..53550061d 100644 --- a/crates/mega-state-test/AGENTS.md +++ b/crates/mega-state-test/AGENTS.md @@ -7,7 +7,8 @@ The `state-test` CLI (`crates/state-test`) is a thin front end over this crate. `README.md` says what the two modes are and how a test is judged. ## STRUCTURE -- `src/runner.rs`: discovery, parallel execution, judging a test, the report, the summary and the gate. +- `src/runner.rs`: parallel execution, judging a test, the report, the summary and the gate. +- `src/input.rs`: bounded fixture discovery and reads, and account/storage-slot cardinality checks before materializing state or hashing it. - `src/mode.rs`: the two configurations a test runs under, built from `mega-evm`'s `test_utils::{neutral_cfg, neutralize_evm}`. - `src/fork.rs`: the fixture forks a run executes (Osaka, Amsterdam). - `src/exceptions.rs`: validation errors mapped to the execution-spec exception names. @@ -23,10 +24,12 @@ The `state-test` CLI (`crates/state-test`) is a thin front end over this crate. The fixture types are the revm fork's own (`revm::statetest_types`, the `test-types` feature), re-exported as `state_test::types`. ## KEY PATTERNS +- Discovery and input/state bounds fail explicitly when exceeded; never truncate the corpus or a state and report it as complete. - A fixture's expectation is Ethereum's; a test here that needs one fills it from revm's mainnet EVM, never from `MegaEvm`. - Every failure is a `FailureKind`; equivalence mode names the deviation that explains it, and one it does not name is unattributed. - A deviation lists the exact entries it explains — file, test, data, gas and value indices — with the hashes Satin produces; a failure is its only with those hashes, and `--expect-deviations` requires every listed entry to fail exactly as listed. - Skips mirror the reference runner's, so the executed and skipped counts equal the ones `.github/workflows/exec-spec.yml` pins for it. +- Slow state-test fixtures are identified by their raw content hashes, not their names; the blockchain runner's skips remain separate. - A blockchain test is skipped only for a class decided from its content (`src/blockchain/skips.rs`); a block that differs passes only when a deviation the registry already has lists that test and block with exactly the outcome Satin produces, and the chain is imported on from Satin's state, so a listed block exempts no later one. - An account is taken out of a blockchain test's state root only by `SATIN_ACCOUNTS`, only when the pre-state does not hold it and it holds exactly what the seed or a Satin block put there. diff --git a/crates/mega-state-test/README.md b/crates/mega-state-test/README.md index b97af158f..682e6c4f4 100644 --- a/crates/mega-state-test/README.md +++ b/crates/mega-state-test/README.md @@ -44,6 +44,9 @@ Base fees go to Optimism's base-fee vault on Satin, where Ethereum burns them. The runner takes the vault back out of the post-state only when the fee routing made it: the pre-state has no vault, and the vault holds exactly the base fee of the gas the transaction used. The runner skips what the reference runner skips (`src/skips.rs`), for the same reasons: the EIP-7610 collision fixtures with storage, which revm cannot see, and a transaction that cannot be built when the fixture expects it to be invalid — here only when the fixture names the reason it cannot be, an invalid signature or a blob or EIP-7702 transaction without a recipient. +That recipient check also applies after construction when an explicit transaction type bypasses the fixture types' inferred-type guard. +The four known slow fixture names are bound to the raw-file content hashes recorded in `src/skips.rs`, so renaming a known file preserves its skip and replacing its contents does not. +The hashes identify the Cancun files and two older Constantinople variants at `ethereum/legacytests` revision `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`; the pinned Osaka fixture release contains none of them. So the two runners execute the same population, and the executed and skipped counts equal the reference runner's. ## Running it @@ -58,6 +61,18 @@ cargo run --release -p state-test -- --mode satin --fork Osaka
/state_test `--expect-executed`, `--expect-skipped` and `--expect-deviations` turn a full run into the pinned gate CI runs (`.github/workflows/exec-spec-satin.yml`). `--json-outcome` prints one JSON line per test, a failure's produced hashes included, and `--trace` runs each test under an EIP-3155 tracer. +## Fixture input limits + +Discovery accepts at most 100,000 fixture files across all input paths and entries at most 64 levels below each input directory. +A traversal error or an exceeded limit fails the run; neither a deep subtree nor excess files are silently omitted. +Symlinks to JSON files are accepted; directory symlinks are refused rather than traversed or silently omitted. +The state-test runner accepts fixture files up to 64 MiB; the blockchain-test runner accepts up to 256 MiB because a file bundles many block sequences, and the pinned execution-spec fixtures include files around 160 MiB. +Both reject oversized files before reading their contents and cap the read itself in case a file grows. +Before materializing a fixture's state or computing its root, the runners require at most 100,000 accounts, 1,000,000 storage slots per account and 1,000,000 slots across the whole state. +The blockchain runner checks both the fixture's pre-state and its expected post-state, and the witness runner checks its pre-state too. +An exceeded state limit is a fixture error; a truncated state is never used to compute a root. +These are input bounds for the developer tools, separate from the protocol limits on execution. + ## The outcome digest A verdict is the post-state root and the logs hash, so a change that moves gas between ledgers and keeps the receipt's total, or changes the bytes a limit counted, leaves every verdict as it was. diff --git a/crates/mega-state-test/src/blockchain/chain.rs b/crates/mega-state-test/src/blockchain/chain.rs index 2ab2410d1..4f2897ef8 100644 --- a/crates/mega-state-test/src/blockchain/chain.rs +++ b/crates/mega-state-test/src/blockchain/chain.rs @@ -206,6 +206,7 @@ pub(crate) fn plain_account(account: &Account) -> Result { /// The root of a state the fixture writes out, such as its post-state. pub(crate) fn fixture_state_root(accounts: &BTreeMap) -> Result { + crate::input::check_state_size(accounts.values().map(|account| account.storage.len()))?; let plain = accounts .iter() .map(|(address, account)| Ok((*address, plain_account(account)?))) @@ -269,6 +270,7 @@ impl Chain { chain_id: u64, blob_base_fee_update_fraction: u64, ) -> Result { + crate::input::check_state_size(pre.values().map(|account| account.storage.len()))?; let mut state = CacheState::new(); for (address, account) in pre { let plain = plain_account(account).map_err(|error| format!("{address}: {error}"))?; @@ -289,6 +291,9 @@ impl Chain { let storage = storage.into_iter().filter(|(_, value)| !value.is_zero()).collect(); state.insert_account_with_storage(address, info, storage); } + crate::input::check_state_size( + state.trie_account().into_iter().map(|(_, account)| account.storage.len()), + )?; Ok(Self { state, hashes: BTreeMap::from([genesis]), @@ -407,6 +412,10 @@ impl Chain { } }?; + crate::input::check_state_size( + state.cache.trie_account().into_iter().map(|(_, account)| account.storage.len()), + ) + .map_err(|detail| Refusal { names: &[], detail })?; let routed_base_fee = self.routed_base_fee + U256::from(header.base_fee_per_gas.unwrap_or_default()) * U256::from(gas_used); self.state = state.cache; diff --git a/crates/mega-state-test/src/blockchain/mod.rs b/crates/mega-state-test/src/blockchain/mod.rs index 2a52cfa1e..7209aebd9 100644 --- a/crates/mega-state-test/src/blockchain/mod.rs +++ b/crates/mega-state-test/src/blockchain/mod.rs @@ -498,7 +498,7 @@ pub fn run(files: &[PathBuf], config: Config) -> Report { /// not be read. pub fn run_file(path: &Path, config: Config) -> Result, Failure> { let path_str = path.to_string_lossy().into_owned(); - let json = std::fs::read_to_string(path) + let json = crate::input::read_blockchain_fixture(path) .map_err(|error| Failure::new(FailureKind::Fixture, None, format!("read: {error}")))?; let suite = serde_json::from_str::>(&json) .map_err(|error| Failure::new(FailureKind::Fixture, None, format!("parse: {error}")))?; @@ -708,6 +708,10 @@ fn import_test( witness: Option<(DigestForm, &TestId)>, ) -> Result<(), Failure> { let fixture = |detail: String| Failure::new(FailureKind::Fixture, None, detail); + crate::input::check_state_size(test.pre.values().map(|account| account.storage.len())) + .map_err(|error| fixture(format!("pre-state: {error}")))?; + crate::input::check_state_size(test.post_state.values().map(|account| account.storage.len())) + .map_err(|error| fixture(format!("post-state: {error}")))?; let chain_id = u64::try_from(test.config.chainid) .map_err(|_| fixture(format!("chain id {} does not fit a u64", test.config.chainid)))?; let fraction = test diff --git a/crates/mega-state-test/src/input.rs b/crates/mega-state-test/src/input.rs new file mode 100644 index 000000000..1c0bffeef --- /dev/null +++ b/crates/mega-state-test/src/input.rs @@ -0,0 +1,261 @@ +//! Bounds on fixture discovery, input bytes and the state materialized by a test. + +use std::{ + fs::File, + io::{self, Read}, + path::{Path, PathBuf}, +}; + +use walkdir::WalkDir; + +/// The largest state-test fixture file the runner reads: 64 MiB. +pub const MAX_FIXTURE_BYTES: u64 = 64 * 1024 * 1024; +/// The largest blockchain-test fixture file: 256 MiB, accommodating bundled block sequences. +pub const MAX_BLOCKCHAIN_FIXTURE_BYTES: u64 = 256 * 1024 * 1024; +/// The largest collection of JSON files one discovery accepts, across all input paths. +pub const MAX_FIXTURE_FILES: usize = 100_000; +/// The deepest entry discovery accepts, relative to each input directory. +pub const MAX_FIXTURE_DEPTH: usize = 64; +/// The largest state a fixture may materialize, in accounts. +pub const MAX_STATE_ACCOUNTS: usize = 100_000; +/// The largest storage of any one account a fixture may materialize, in slots. +pub const MAX_ACCOUNT_SLOTS: usize = 1_000_000; +/// The largest state a fixture may materialize, in storage slots across all accounts. +pub const MAX_STATE_SLOTS: usize = 1_000_000; + +/// Reads a UTF-8 fixture, refusing an oversized file before allocating its contents. +pub fn read_fixture(path: &Path) -> io::Result { + read_with_limit(File::open(path)?, MAX_FIXTURE_BYTES) +} + +/// Reads a blockchain fixture under its larger bound, using the same guarded reader. +pub(crate) fn read_blockchain_fixture(path: &Path) -> io::Result { + read_with_limit(File::open(path)?, MAX_BLOCKCHAIN_FIXTURE_BYTES) +} + +fn read_with_limit(file: File, limit: u64) -> io::Result { + if file.metadata()?.len() > limit { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + format!("fixture exceeds {limit} bytes"), + )); + } + read_bounded(file, limit) +} + +fn read_bounded(reader: impl Read, limit: u64) -> io::Result { + // The same opened file may grow after metadata was read. Never read it past this sentinel. + let mut json = String::new(); + reader.take(limit + 1).read_to_string(&mut json)?; + if json.len() as u64 > limit { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + format!("fixture exceeds {limit} bytes"), + )); + } + Ok(json) +} + +/// Every JSON file under `path`, or `path` itself when it is a file, in path order. +/// Walking errors and exceeded limits fail discovery rather than dropping any input. +pub fn find_json_files(path: &Path) -> io::Result> { + let mut files = Vec::new(); + discover(path, &mut files, MAX_FIXTURE_DEPTH, MAX_FIXTURE_FILES)?; + files.sort(); + Ok(files) +} + +/// Discovers all `paths` under one file-count budget; an empty input directory is an error. +pub fn find_json_files_in_paths(paths: &[PathBuf]) -> io::Result> { + let mut files = Vec::new(); + for path in paths { + let before = files.len(); + discover(path, &mut files, MAX_FIXTURE_DEPTH, MAX_FIXTURE_FILES)?; + if files.len() == before { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("no JSON fixtures under {}", path.display()), + )); + } + } + files.sort(); + Ok(files) +} + +fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) -> io::Result<()> { + if path.metadata()?.is_file() { + return add_file(path.to_path_buf(), files, limit); + } + if path.symlink_metadata()?.file_type().is_symlink() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture discovery refuses directory symlink: {}", path.display()), + )); + } + for entry in WalkDir::new(path) { + let entry = entry?; + // WalkDir::max_depth would silently omit descendants, so inspect the first excess entry. + if entry.depth() > depth { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture directory depth exceeds {depth}: {}", entry.path().display()), + )); + } + let is_file = if entry.file_type().is_symlink() { + let target = entry.path().metadata()?; + if target.is_dir() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!( + "fixture discovery refuses directory symlink: {}", + entry.path().display() + ), + )); + } + target.is_file() + } else { + entry.file_type().is_file() + }; + if is_file && entry.path().extension().is_some_and(|ext| ext == "json") { + add_file(entry.into_path(), files, limit)?; + } + } + Ok(()) +} + +fn add_file(path: PathBuf, files: &mut Vec, limit: usize) -> io::Result<()> { + if files.len() >= limit { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture file count exceeds {limit}"), + )); + } + files.push(path); + Ok(()) +} + +/// Checks account and slot cardinality before copying fixture state or building its tries. +pub(crate) fn check_state_size(slot_counts: impl IntoIterator) -> Result<(), String> { + StateLimits { + accounts: MAX_STATE_ACCOUNTS, + account_slots: MAX_ACCOUNT_SLOTS, + slots: MAX_STATE_SLOTS, + } + .check(slot_counts) +} + +struct StateLimits { + accounts: usize, + account_slots: usize, + slots: usize, +} + +impl StateLimits { + fn check(&self, slot_counts: impl IntoIterator) -> Result<(), String> { + let mut total_slots = 0usize; + for (index, slots) in slot_counts.into_iter().enumerate() { + if index >= self.accounts { + return Err(format!("state account count exceeds {}", self.accounts)); + } + if slots > self.account_slots { + return Err(format!("account storage exceeds {} slots", self.account_slots)); + } + total_slots = total_slots + .checked_add(slots) + .filter(|total| *total <= self.slots) + .ok_or_else(|| format!("state storage exceeds {} total slots", self.slots))?; + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use std::io::{Seek, Write}; + + use super::*; + + #[test] + fn test_discovery_fails_instead_of_truncating_at_depth_limit() { + let root = tempfile::tempdir().unwrap(); + let nested = root.path().join("a"); + std::fs::create_dir(&nested).unwrap(); + std::fs::write(nested.join("one.json"), "{}").unwrap(); + assert!(discover(root.path(), &mut Vec::new(), 2, 1).is_ok()); + let error = discover(root.path(), &mut Vec::new(), 1, 1).unwrap_err(); + assert!(error.to_string().contains("depth exceeds 1")); + } + + #[test] + fn test_discovery_file_budget_is_shared_between_roots() { + let root = tempfile::tempdir().unwrap(); + let mut files = Vec::new(); + for name in ["one.json", "two.json"] { + let path = root.path().join(name); + std::fs::write(&path, "{}").unwrap(); + discover(&path, &mut files, 1, 2).unwrap(); + } + let error = discover(&root.path().join("one.json"), &mut files, 1, 2).unwrap_err(); + assert!(error.to_string().contains("file count exceeds 2")); + } + + #[test] + fn test_discovery_propagates_missing_root() { + let root = tempfile::tempdir().unwrap(); + assert!(find_json_files(&root.path().join("absent")).is_err()); + assert!(find_json_files_in_paths(&[root.path().to_path_buf()]).is_err()); + } + + #[cfg(unix)] + #[test] + fn test_discovery_refuses_a_broken_symlink_root() { + let root = tempfile::tempdir().unwrap(); + let broken = root.path().join("broken"); + std::os::unix::fs::symlink(root.path().join("absent"), &broken).unwrap(); + assert!(discover(&broken, &mut Vec::new(), 4, 4).is_err()); + } + + #[cfg(unix)] + #[test] + fn test_discovery_keeps_json_file_symlinks_and_refuses_directory_symlinks() { + let root = tempfile::tempdir().unwrap(); + let target = root.path().join("source"); + std::fs::write(&target, "{}").unwrap(); + let alias = root.path().join("alias.json"); + std::os::unix::fs::symlink(&target, &alias).unwrap(); + assert_eq!(find_json_files(root.path()).unwrap(), vec![alias]); + let directory = root.path().join("subtree"); + std::os::unix::fs::symlink(root.path(), &directory).unwrap(); + let error = find_json_files(root.path()).unwrap_err(); + assert!(error.to_string().contains("directory symlink")); + assert!(find_json_files(&directory).unwrap_err().to_string().contains("directory symlink")); + } + + #[test] + fn test_read_limit_accepts_exact_size_and_rejects_one_more_byte() { + let mut file = tempfile::tempfile().unwrap(); + file.write_all(b"{}\n").unwrap(); + file.rewind().unwrap(); + assert_eq!(read_with_limit(file.try_clone().unwrap(), 3).unwrap(), "{}\n"); + file.rewind().unwrap(); + assert!(read_with_limit(file, 2).unwrap_err().to_string().contains("exceeds 2 bytes")); + } + + #[test] + fn test_reader_refuses_growth_past_the_metadata_bound() { + let contents = std::io::Cursor::new(b"{}\nmore bytes"); + let error = read_bounded(contents, 3).unwrap_err(); + assert!(error.to_string().contains("exceeds 3 bytes")); + } + + #[test] + fn test_state_limits_accept_boundaries_and_reject_each_dimension() { + let limits = StateLimits { accounts: 2, account_slots: 3, slots: 4 }; + assert!(limits.check([1, 3]).is_ok()); + assert!(limits.check([0, 0, 0]).unwrap_err().contains("account count")); + assert!(limits.check([4]).unwrap_err().contains("account storage")); + assert!(limits.check([2, 3]).unwrap_err().contains("total slots")); + let overflow = StateLimits { accounts: 2, account_slots: usize::MAX, slots: usize::MAX }; + assert!(overflow.check([usize::MAX, 1]).is_err()); + } +} diff --git a/crates/mega-state-test/src/lib.rs b/crates/mega-state-test/src/lib.rs index d25456f3d..75e469cd1 100644 --- a/crates/mega-state-test/src/lib.rs +++ b/crates/mega-state-test/src/lib.rs @@ -28,6 +28,7 @@ pub mod deviations; pub mod digest; pub mod exceptions; mod fork; +pub mod input; mod mode; pub mod roots; pub mod runner; diff --git a/crates/mega-state-test/src/runner.rs b/crates/mega-state-test/src/runner.rs index f53ff005e..3ff9473a4 100644 --- a/crates/mega-state-test/src/runner.rs +++ b/crates/mega-state-test/src/runner.rs @@ -49,7 +49,7 @@ use mega_evm::{ database::{EmptyDB, State}, inspector::{inspectors::TracerEip3155, Inspector, NoOpInspector}, interpreter::interpreter::EthInterpreter, - primitives::{Bytes, B256, KECCAK_EMPTY, U256}, + primitives::{Bytes, TxKind, B256, KECCAK_EMPTY, U256}, DatabaseCommit, ExecuteCommitEvm, }, test_utils::{RecordingDatabase, RecordingEnvFactory, SharedWitnessRecord}, @@ -60,7 +60,6 @@ use serde::{ de::{Error as _, MapAccess, Visitor}, Deserialize, Deserializer, Serialize, }; -use walkdir::WalkDir; use crate::{ deviations::{self, Deviation}, @@ -68,7 +67,7 @@ use crate::{ exceptions::{self, Mismatch}, mode::MAX_BLOBS_PER_TX, roots::{logs_hash, state_root}, - skips::{skip_file, SkipReason}, + skips::{skip_file, skip_slow_file, SkipReason}, types::{Test, TestSuite, TestUnit}, Fork, Mode, }; @@ -451,20 +450,7 @@ impl fmt::Display for TestId { } } -/// Every JSON file under `path`, or `path` itself when it is a file, in path order. -pub fn find_json_files(path: &Path) -> Vec { - if path.is_file() { - return vec![path.to_path_buf()]; - } - let mut files: Vec<_> = WalkDir::new(path) - .into_iter() - .filter_map(Result::ok) - .filter(|entry| entry.path().extension().is_some_and(|ext| ext == "json")) - .map(walkdir::DirEntry::into_path) - .collect(); - files.sort(); - files -} +pub use crate::input::{find_json_files, find_json_files_in_paths}; /// Executes every entry `files` define for `config.fork`, in `config.mode`, and reports each. pub fn run(files: &[PathBuf], config: Config) -> Report { @@ -503,12 +489,12 @@ pub fn run(files: &[PathBuf], config: Config) -> Report { /// the file could not be read. pub fn run_file(path: &Path, config: Config) -> Result, Failure> { let path_str = path.to_string_lossy().into_owned(); - let json = std::fs::read_to_string(path) + let json = crate::input::read_fixture(path) .map_err(|error| Failure::new(FailureKind::Fixture, format!("read: {error}")))?; let suite = serde_json::from_str::(&json) .map_err(|error| Failure::new(FailureKind::Fixture, format!("parse: {error}")))? .0; - let skip = skip_file(&path_str); + let skip = skip_file(&path_str).or_else(|| skip_slow_file(json.as_bytes())); let mut results = Vec::new(); for (name, unit) in &suite.0 { @@ -721,6 +707,8 @@ fn execute_and_check( Err(reason) => return Ok(Some(reason)), }; + crate::input::check_state_size(unit.pre.values().map(|account| account.storage.len())) + .map_err(|error| Failure::new(FailureKind::Fixture, format!("pre-state: {error}")))?; let basefee = block.basefee; let mut state = State::builder().with_cached_prestate(unit.state()).with_bundle_update().build(); @@ -821,6 +809,14 @@ pub(crate) fn prepare( test: &Test, ) -> Result, Failure> { let chain_id = chain_id(unit)?; + if let Some(excess) = unit.env.current_excess_blob_gas { + u64::try_from(excess).map_err(|_| { + Failure::new( + FailureKind::Fixture, + format!("currentExcessBlobGas {excess} does not fit a u64"), + ) + })?; + } let mut eth_cfg = CfgEnv::new(); eth_cfg.chain_id = chain_id; @@ -843,6 +839,28 @@ pub(crate) fn prepare( return Err(Failure::new(FailureKind::Fixture, format!("transaction: {error}"))) } }; + // An explicit type bypasses TransactionParts::tx_type's inferred-type create guard. + // Apply the same rejection to the transaction the fixture types actually built. + let creation_exception: &'static [&'static str] = match (tx.tx_type, tx.kind) { + (3, TxKind::Create) => &["TYPE_3_TX_CONTRACT_CREATION"], + (4, TxKind::Create) => &["TYPE_4_TX_CONTRACT_CREATION"], + _ => &[], + }; + if !creation_exception.is_empty() { + return match &test.expect_exception { + Some(expected) if exceptions::check_names(expected, creation_exception).is_ok() => { + Ok(Err(SkipReason::UnbuildableInvalidTransaction)) + } + Some(expected) => Err(Failure::new( + FailureKind::WrongException, + format!("expected {expected}, rejected as {}", creation_exception[0]), + )), + None => Err(Failure::new( + FailureKind::Fixture, + format!("transaction: {}", creation_exception[0]), + )), + }; + } let tx = OpTx(OpTransaction { base: tx, enveloped_tx: Some(Bytes::new()), ..Default::default() }); Ok(Ok(Ready { chain_id, block, tx })) @@ -913,6 +931,10 @@ fn check( } let logs: &[_] = result.as_ref().map(ExecutionResult::logs).unwrap_or_default(); let logs_hash = logs_hash(logs); + crate::input::check_state_size( + state.cache.trie_account().into_iter().map(|(_, account)| account.storage.len()), + ) + .map_err(|error| Failure::new(FailureKind::Fixture, format!("post-state: {error}")))?; let root = state_root(state.cache.trie_account()); let executed = result.as_ref().map(|r| format!("; {}", describe(r))).unwrap_or_default(); if logs_hash != test.logs { diff --git a/crates/mega-state-test/src/skips.rs b/crates/mega-state-test/src/skips.rs index 6b8ae5571..b302e4bb6 100644 --- a/crates/mega-state-test/src/skips.rs +++ b/crates/mega-state-test/src/skips.rs @@ -5,6 +5,7 @@ //! number for number. Satin inherits every one of the reasons from revm: none of them is a place //! Satin differs from Ethereum, which is what a [deviation](crate::deviations) is. +use mega_evm::revm::primitives::{b256, keccak256, B256}; use serde::Serialize; /// Why a test was not executed. @@ -47,8 +48,40 @@ impl SkipReason { /// The directory of the EIP-7610 collision tests, every one of which collides with storage. const CREATE_COLLISION_DIR: &str = "paris/eip7610_create_collision"; +/// Raw-file identities of the reference runner's four slow fixture names, including the two +/// older variants. These are `ethereum/legacytests` `GeneralStateTests` at +/// `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`: the Cancun files and the two Constantinople files. +/// The byte lengths avoid hashing every unrelated fixture; the hash decides whether to skip. +const SLOW_FILES: [(usize, B256); 6] = [ + // Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json + (21579, b256!("2bf893c9a593ae34e289a8938a57ec2e29ee093e2dfe4f2154dfde2a39775c79")), + // Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json + (10237, b256!("39ee8aaa9d540a9ff4df3b25cee4b85dbb400728b7d9650e19b8277eaf35eaa0")), + // Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json + (9525, b256!("1db1a1c4c8d1ecfab848565dc5d266a9fb60959995d03619e2837a7d863d70fd")), + // Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json + (11751, b256!("9f20d4d227a41fd7caa577612255d013b38d90668971db19f9228e7061be92b4")), + // Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json + (5400, b256!("937c269ce29890164f14617f1da277189d49d4049b63507309479e2b29d36346")), + // Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json + (5290, b256!("2e2d37b3c3ed48c2da697e2a443d653b300b4aee7d7c56da8d9eff30dc49b93d")), +]; + +/// Whether `contents` is one of the reference runner's known slow fixtures, independent of its +/// file name. A different file that borrows a slow fixture's name must still execute. +pub fn skip_slow_file(contents: &[u8]) -> Option { + if !SLOW_FILES.iter().any(|(size, _)| *size == contents.len()) { + return None; + } + let hash = keccak256(contents); + SLOW_FILES + .iter() + .any(|(size, known)| *size == contents.len() && *known == hash) + .then_some(SkipReason::Slow) +} + /// Whether the file at `path` is skipped whole, and why: the reference runner's list, file for -/// file. +/// file, except that slow fixtures are identified by [`skip_slow_file`] from their content. pub fn skip_file(path: &str) -> Option { if path.replace('\\', "/").contains(CREATE_COLLISION_DIR) { return Some(SkipReason::CreateCollisionWithStorage); @@ -67,10 +100,6 @@ pub fn skip_file(path: &str) -> Option { "InitCollisionParis.json" | "test_init_collision_create_opcode.json" => Some(SkipReason::CreateCollisionWithStorage), "ValueOverflow.json" | "ValueOverflowParis.json" => Some(SkipReason::MalformedValue), - "Call50000_sha256.json" | - "static_Call50000_sha256.json" | - "loopMul.json" | - "CALLBlake2f_MaxRounds.json" => Some(SkipReason::Slow), _ => None, } } @@ -98,7 +127,7 @@ mod tests { Some(SkipReason::CreateCollisionWithStorage) ); assert_eq!(skip_file("a/ValueOverflow.json"), Some(SkipReason::MalformedValue)); - assert_eq!(skip_file("a/loopMul.json"), Some(SkipReason::Slow)); + assert_eq!(skip_file("a/loopMul.json"), None); assert_eq!(skip_file("a/xloopMul.json"), None); assert_eq!(skip_file("a/loopMul.json.bak"), None); assert_eq!(skip_file("osaka/eip7951_p256verify_precompiles/test_valid.json"), None); @@ -110,4 +139,30 @@ mod tests { let names: std::collections::BTreeSet<_> = SkipReason::ALL.map(SkipReason::name).into(); assert_eq!(names.len(), SkipReason::ALL.len()); } + + /// The checked-in files retain their upstream bytes, so this catches a wrong pin as well as + /// a regression to matching the filename or accepting edited content. + #[test] + fn test_pinned_slow_fixtures_follow_content_when_renamed_and_reject_edits() { + let files: &[&[u8]] = &[ + include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json"), + include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json"), + include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json"), + include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json"), + include_bytes!("../tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json"), + include_bytes!("../tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json"), + ]; + assert_eq!(files.len(), SLOW_FILES.len(), "exercise every pinned content identity"); + for bytes in files { + assert_eq!(skip_slow_file(bytes), Some(SkipReason::Slow)); + let renamed = "renamed-fixture.json"; + assert_eq!( + skip_file(renamed).or_else(|| skip_slow_file(bytes)), + Some(SkipReason::Slow) + ); + let mut edited = bytes.to_vec(); + edited[0] ^= 1; + assert_eq!(skip_slow_file(&edited), None, "same-length content edits must execute"); + } + } } diff --git a/crates/mega-state-test/src/witness.rs b/crates/mega-state-test/src/witness.rs index 96d82bdd8..8bc81f92c 100644 --- a/crates/mega-state-test/src/witness.rs +++ b/crates/mega-state-test/src/witness.rs @@ -140,6 +140,7 @@ pub fn check_replay( Err(reason) => return Ok(Replayed::Skipped(reason)), }; + crate::input::check_state_size(unit.pre.values().map(|account| account.storage.len()))?; let record = SharedWitnessRecord::default(); let recorded = run( mode, diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json new file mode 100644 index 000000000..250076b2f --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json @@ -0,0 +1,257 @@ +{ + "loopMul" : { + "_info" : { + "comment" : "Ori Pomerantz qbzzt1@gmail.com", + "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", + "filling-tool-version" : "retesteth-0.3.2-cancun+commit.021b8dfd.Linux.g++", + "generatedTestHash" : "ac4b25eb17aff99ce8fc3c8f3489aa3c8d3742bff57bc17110cb11671dcdde0e", + "labels" : { + "0" : "add-10M", + "1" : "divadd-10M", + "2" : "mulmod-2M" + }, + "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", + "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", + "source" : "src/GeneralStateTestsFiller/VMTests/vmPerformance/loopMulFiller.yml", + "sourceHash" : "a26434ba94c8763c9e3f5593af7f924c2652f0a1dc2242c87100e0bfe09ba168" + }, + "env" : { + "currentBaseFee" : "0x0a", + "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x020000", + "currentExcessBlobGas" : "0x00", + "currentGasLimit" : "0x7fffffffffffffff", + "currentNumber" : "0x01", + "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", + "currentTimestamp" : "0x03e8" + }, + "post" : { + "Berlin" : [ + { + "hash" : "0x751df352e4a7d5a36c7edd2e692ebf2f9895fc32d376520810ccf0f9e1a07172", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0xf64f3960665c922e7fbb52182073b45ae7d0e0904aa4ea7d0fcdc8611aa74f48", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0x3161388f9c3e0d6fbd283ad9224be8cc1736ba0a2582110576be4e64d5abe459", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ], + "Cancun" : [ + { + "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ], + "Istanbul" : [ + { + "hash" : "0x919e0e3eba9736de6345243d9fae413910c5861ed5d396ef01f1930e9df91740", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0xd82016b4a51a4f830d7dfa20270b384215c69d88cb21a4ba98bb63f1588fef05", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0xe7a99e585fe86edde8fd96e85cf759b40460b2bc8a1c133fd058c4c133f8ca54", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ], + "London" : [ + { + "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ], + "Paris" : [ + { + "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ], + "Shanghai" : [ + { + "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" + }, + { + "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" + }, + { + "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", + "indexes" : { + "data" : 2, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" + } + ] + }, + "pre" : { + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x7fffffffffffffff00", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + }, + "0xcccccccccccccccccccccccccccccccccccccccc" : { + "balance" : "0x0ba1a9ce0ba1a9ce", + "code" : "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806315d423271461005157806359e3e1ea14610081578063c4f8b9fb146100b1578063e01330bb146100e1575b600080fd5b61006b60048036038101906100669190610268565b610111565b60405161007891906102de565b60405180910390f35b61009b60048036038101906100969190610268565b61015e565b6040516100a891906102de565b60405180910390f35b6100cb60048036038101906100c691906102f9565b6101b3565b6040516100d891906102de565b60405180910390f35b6100fb60048036038101906100f691906102f9565b6101f0565b60405161010891906102de565b60405180910390f35b60008085905060005b8381101561014a5784806101315761013061034c565b5b868309915060018161014391906103aa565b905061011a565b508060008190555080915050949350505050565b60008085905060005b8381101561019f57858261017b91906103de565b9150848261018991906103aa565b915060018161019891906103aa565b9050610167565b508060008190555080915050949350505050565b60008084905060005b838110156101dd5784820191506001816101d691906103aa565b90506101bc565b5080600081905550809150509392505050565b60008084905060005b8381101561021a57848202915060018161021391906103aa565b90506101f9565b5080600081905550809150509392505050565b600080fd5b6000819050919050565b61024581610232565b811461025057600080fd5b50565b6000813590506102628161023c565b92915050565b600080600080608085870312156102825761028161022d565b5b600061029087828801610253565b94505060206102a187828801610253565b93505060406102b287828801610253565b92505060606102c387828801610253565b91505092959194509250565b6102d881610232565b82525050565b60006020820190506102f360008301846102cf565b92915050565b6000806000606084860312156103125761031161022d565b5b600061032086828701610253565b935050602061033186828701610253565b925050604061034286828701610253565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103b582610232565b91506103c083610232565b92508282019050808211156103d8576103d761037b565b5b92915050565b60006103e982610232565b91506103f483610232565b9250826104045761040361034c565b5b82820490509291505056fea264697066735822122068e1b815c01e7140e2ba71cdc985de077b5af76a27ae9139fee87f708e3dc41864736f6c63430008150033", + "nonce" : "0x01", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0xc4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5010000000000000000000000000000000000000000000000000000000000989680", + "0x59e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff00000000000000000000000000000000000000000000000000000000000000989680", + "0x15d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e8480" + ], + "gasLimit" : [ + "0x7fffffffffffffff" + ], + "gasPrice" : "0x0a", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0xcccccccccccccccccccccccccccccccccccccccc", + "value" : [ + "0x00" + ] + } + } +} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json new file mode 100644 index 000000000..8847ff9f7 --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json @@ -0,0 +1,191 @@ +{ + "Call50000_sha256" : { + "_info" : { + "comment" : "", + "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", + "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", + "generatedTestHash" : "1ba3a2f9e77a0e7fd56065a03bd06937c302b71ee9c4304c3c429c49c6a1262e", + "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", + "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", + "source" : "src/GeneralStateTestsFiller/stQuadraticComplexityTest/Call50000_sha256Filler.json", + "sourceHash" : "c89657175c195cf1d15d69c3df40b2090a606fedebac17732d531360cb579528" + }, + "env" : { + "currentBaseFee" : "0x0a", + "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "0x020000", + "currentExcessBlobGas" : "0x00", + "currentGasLimit" : "0xe9f2bf40", + "currentNumber" : "0x01", + "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", + "currentTimestamp" : "0x03e8" + }, + "post" : { + "Berlin" : [ + { + "hash" : "0x125a127cd275c6afb98c12cfd10bfd894282215636e0be99a763984d26dce68a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x0d39e570f98fce02a7240124f0cceef1e6b26e86024d24275b94272436782d52", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ], + "Cancun" : [ + { + "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ], + "Istanbul" : [ + { + "hash" : "0x125a127cd275c6afb98c12cfd10bfd894282215636e0be99a763984d26dce68a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x0d39e570f98fce02a7240124f0cceef1e6b26e86024d24275b94272436782d52", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ], + "London" : [ + { + "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ], + "Paris" : [ + { + "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ], + "Shanghai" : [ + { + "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" + }, + { + "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" + } + ] + }, + "pre" : { + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + }, + "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602d576000600061c35060006001600262013178f16000556001608051016080526000565b60805160015500", + "nonce" : "0x00", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0x" + ], + "gasLimit" : [ + "0x0249f0", + "0x0ee6b280" + ], + "gasPrice" : "0x0a", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : [ + "0x0a" + ] + } + } +} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json new file mode 100644 index 000000000..581c48cd2 --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json @@ -0,0 +1,130 @@ +{ + "CALLBlake2f_MaxRounds" : { + "_info" : { + "comment" : "currentGasLimit is > trGaslimit because when run as a blockchain transaction comes within the block#1 which can has less gasLimit than genesis", + "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", + "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", + "generatedTestHash" : "92d6d2c0b59e9684e2a1893aeee014a3a7bbf25a4cfaf9b4c938be318bd1e486", + "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", + "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", + "source" : "src/GeneralStateTestsFiller/stTimeConsuming/CALLBlake2f_MaxRoundsFiller.json", + "sourceHash" : "2dc49ff1ebbf07bf10cc6c32b001dd39f6b33d242123c0bd0d3523b9f9ad81f2" + }, + "env" : { + "currentBaseFee" : "0x0a", + "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x020000", + "currentExcessBlobGas" : "0x00", + "currentGasLimit" : "0x0254a47a80", + "currentNumber" : "0x01", + "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", + "currentTimestamp" : "0x03e8" + }, + "post" : { + "Berlin" : [ + { + "hash" : "0x569311304bd15c83986e123c9ebb1d8af2348bb6a9358986237287ebf2eb966d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ], + "Cancun" : [ + { + "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ], + "Istanbul" : [ + { + "hash" : "0xcc6960984c3702d7760244701aaee6e343afc5ff4b5587b7e10562c71b844ae6", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ], + "London" : [ + { + "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ], + "Paris" : [ + { + "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ], + "Shanghai" : [ + { + "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" + } + ] + }, + "pre" : { + "0x1000000000000000000000000000000000000000" : { + "balance" : "0x00", + "code" : "0x36600060003760406103e8366000600060095af16001556103e8516002556104085160035500", + "nonce" : "0x00", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x3635c9adc5dea00000", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0xffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001" + ], + "gasLimit" : [ + "0x02540be400" + ], + "gasPrice" : "0x0a", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0x1000000000000000000000000000000000000000", + "value" : [ + "0x00" + ] + } + } +} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json new file mode 100644 index 000000000..023e357aa --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json @@ -0,0 +1,205 @@ +{ + "static_Call50000_sha256" : { + "_info" : { + "comment" : "", + "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", + "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", + "generatedTestHash" : "32924a7a3b6e5fee383d4d6b1905934b06adf41ce460be9dcbe79af2945ee72c", + "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", + "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", + "source" : "src/GeneralStateTestsFiller/stTimeConsuming/static_Call50000_sha256Filler.json", + "sourceHash" : "a78222cbabf8f2683ff00446b9208cf2c2c0347415ee8dc7891997a8a2c0f422" + }, + "env" : { + "currentBaseFee" : "0x0a", + "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "0x020000", + "currentExcessBlobGas" : "0x00", + "currentGasLimit" : "0x09237b7880", + "currentNumber" : "0x01", + "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", + "currentTimestamp" : "0x03e8" + }, + "post" : { + "Berlin" : [ + { + "hash" : "0xf591a379eee0b124fc34c66ff5987c70dae30af9d0a5d2875e2532904e5cce7b", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0x71109a01177322cf7c1284efa1174169f297ec52c5d3d61c4b08ee84fb8d252d", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ], + "Cancun" : [ + { + "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ], + "Istanbul" : [ + { + "hash" : "0x3dcc46e694eaf2287adfdeeb9cdf06c2f434b4cecf1f83461b529ac0f05ba84c", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0xe6f8e443c1036537138bdeffacd400a5a63e2283beda6b62c570ca1f1b1458cf", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ], + "London" : [ + { + "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ], + "Paris" : [ + { + "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ], + "Shanghai" : [ + { + "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" + }, + { + "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" + } + ] + }, + "pre" : { + "0x1000000000000000000000000000000000000000" : { + "balance" : "0x00", + "code" : "0x6000600060006000346000355af1600055600160015500", + "nonce" : "0x00", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + }, + "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000556001608051016080526000565b60805160015500", + "nonce" : "0x00", + "storage" : { + } + }, + "0xcccf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000526001608051016080526000565b60805160205200", + "nonce" : "0x00", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0x000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "0x000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b" + ], + "gasLimit" : [ + "0xe9f2bf40" + ], + "gasPrice" : "0x0a", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0x1000000000000000000000000000000000000000", + "value" : [ + "0x0a" + ] + } + } +} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json new file mode 100644 index 000000000..a36df2253 --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json @@ -0,0 +1,134 @@ +{ + "Call50000_sha256" : { + "_info" : { + "comment" : "", + "filledwith" : "testeth 1.7.0-alpha.0+commit.2b11ce5c", + "lllcversion" : "Version: 0.5.0-develop.2018.11.9+commit.9709dfe0.Linux.g++", + "source" : "src/GeneralStateTestsFiller/stQuadraticComplexityTest/Call50000_sha256Filler.json", + "sourceHash" : "691a51cf9afec00db3f8756def0c9abb3429ac1e142c4788dc8798a23ff029f4" + }, + "env" : { + "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "0x020000", + "currentGasLimit" : "0xe9f2bf40", + "currentNumber" : "0x01", + "currentTimestamp" : "0x03e8", + "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "post" : { + "Byzantium" : [ + { + "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ], + "Constantinople" : [ + { + "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ], + "ConstantinopleFix" : [ + { + "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ], + "Homestead" : [ + { + "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", + "indexes" : { + "data" : 0, + "gas" : 1, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + }, + "pre" : { + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + }, + "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602d576000600061c35060006001600262013178f16000556001608051016080526000565b608051600155", + "nonce" : "0x00", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0x" + ], + "gasLimit" : [ + "0x0249f0", + "0x0ee6b280" + ], + "gasPrice" : "0x01", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : [ + "0x0a" + ] + } + } +} diff --git a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json new file mode 100644 index 000000000..ea5534ff1 --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json @@ -0,0 +1,128 @@ +{ + "static_Call50000_sha256" : { + "_info" : { + "comment" : "", + "filledwith" : "testeth 1.7.0-alpha.0+commit.2b11ce5c", + "lllcversion" : "Version: 0.5.0-develop.2018.11.9+commit.9709dfe0.Linux.g++", + "source" : "src/GeneralStateTestsFiller/stTimeConsuming/static_Call50000_sha256Filler.json", + "sourceHash" : "0b9d3b0f98ca3f190a564dac1fa0c832ad11f812b37fb5223c0abfe1b242aee9" + }, + "env" : { + "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "0x020000", + "currentGasLimit" : "0x09237b7880", + "currentNumber" : "0x01", + "currentTimestamp" : "0x03e8", + "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "post" : { + "Byzantium" : [ + { + "hash" : "0xaf00fbc3ebd221608c528fe17d937e0fe5d2ba954bfc81e5e13167b21aeaa27d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ], + "Constantinople" : [ + { + "hash" : "0x7428351b6625e7da42f0cc8684542fdb38dbd887c689c7541ae2385e086f98a5", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ], + "ConstantinopleFix" : [ + { + "hash" : "0xaf00fbc3ebd221608c528fe17d937e0fe5d2ba954bfc81e5e13167b21aeaa27d", + "indexes" : { + "data" : 0, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", + "indexes" : { + "data" : 1, + "gas" : 0, + "value" : 0 + }, + "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + }, + "pre" : { + "0x1000000000000000000000000000000000000000" : { + "balance" : "0x00", + "code" : "0x6000600060006000346000355af16000555a600155", + "nonce" : "0x00", + "storage" : { + } + }, + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "0x", + "nonce" : "0x00", + "storage" : { + } + }, + "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000556001608051016080526000565b608051600155", + "nonce" : "0x00", + "storage" : { + } + }, + "0xcccf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0x0fffffffffffff", + "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000526001608051016080526000565b608051602052", + "nonce" : "0x00", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "0x000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "0x000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b" + ], + "gasLimit" : [ + "0xe9f2bf40" + ], + "gasPrice" : "0x01", + "nonce" : "0x00", + "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "0x1000000000000000000000000000000000000000", + "value" : [ + "0x0a" + ] + } + } +} diff --git a/crates/mega-state-test/tests/fixtures/slow/LICENSE b/crates/mega-state-test/tests/fixtures/slow/LICENSE new file mode 100644 index 000000000..65f52d6f5 --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/LICENSE @@ -0,0 +1,7 @@ +Copyright 2014 Ethereum Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/crates/mega-state-test/tests/fixtures/slow/README.md b/crates/mega-state-test/tests/fixtures/slow/README.md new file mode 100644 index 000000000..99064b08e --- /dev/null +++ b/crates/mega-state-test/tests/fixtures/slow/README.md @@ -0,0 +1,8 @@ +# Slow fixture identities + +These six files are copied byte for byte from [`ethereum/legacytests` at `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`](https://github.com/ethereum/legacytests/tree/1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb), with their upstream paths retained. +They cover the four slow state-test names the reference runner skips, including the two older Constantinople variants. +They are test data for the content-hash skip policy, not execution inputs to the Satin gate. +Keep their original bytes: formatting them changes the identities being tested. + +The upstream MIT license and Ethereum Foundation copyright notice are reproduced in [LICENSE](LICENSE). diff --git a/crates/mega-state-test/tests/input_limits.rs b/crates/mega-state-test/tests/input_limits.rs new file mode 100644 index 000000000..d3c54dff1 --- /dev/null +++ b/crates/mega-state-test/tests/input_limits.rs @@ -0,0 +1,148 @@ +//! Input limits refuse whole fixtures rather than reporting a partial corpus or state as valid. + +use std::fs::File; + +use state_test::{ + blockchain, + input::{find_json_files, MAX_BLOCKCHAIN_FIXTURE_BYTES, MAX_FIXTURE_BYTES, MAX_FIXTURE_DEPTH}, + runner, Fork, Mode, +}; + +#[test] +fn test_both_runners_refuse_oversized_files_before_parsing() { + let root = tempfile::tempdir().unwrap(); + let path = root.path().join("oversized.json"); + File::create(&path).unwrap().set_len(MAX_FIXTURE_BYTES + 1).unwrap(); + + let failure = runner::run_file( + &path, + runner::Config { + mode: Mode::Equivalence, + fork: Fork::Osaka, + threads: 1, + json_outcome: false, + trace: false, + digest: None, + witness: None, + limits: None, + deviations: &[], + }, + ) + .unwrap_err(); + assert_eq!(failure.kind, runner::FailureKind::Fixture); + assert!(failure.detail.contains("exceeds 67108864 bytes"), "{failure:?}"); + File::create(&path).unwrap().set_len(MAX_BLOCKCHAIN_FIXTURE_BYTES + 1).unwrap(); + let failure = blockchain::run_file( + &path, + blockchain::Config { threads: 1, json_outcome: false, witness: None, deviations: &[] }, + ) + .unwrap_err(); + assert_eq!(failure.kind, blockchain::FailureKind::Fixture); + assert!(failure.detail.contains("exceeds 268435456 bytes"), "{failure:?}"); +} + +#[test] +fn test_discovery_refuses_excessive_depth_even_without_json_below_it() { + let root = tempfile::tempdir().unwrap(); + std::fs::write(root.path().join("visible.json"), "{}").unwrap(); + let mut nested = root.path().to_path_buf(); + for _ in 0..MAX_FIXTURE_DEPTH { + nested.push("d"); + } + std::fs::create_dir_all(&nested).unwrap(); + assert_eq!(find_json_files(root.path()).unwrap().len(), 1); + std::fs::create_dir(nested.join("one-too-deep")).unwrap(); + let error = find_json_files(root.path()).unwrap_err(); + assert!(error.to_string().contains("depth exceeds 64"), "{error}"); +} + +/// A compact but over-wide state stays below the byte limit; cardinality must reject it. +fn oversized_state() -> String { + let mut state = String::from("{"); + for index in 0..=state_test::input::MAX_STATE_ACCOUNTS { + if index != 0 { + state.push(','); + } + state.push_str(&format!( + "\"0x{index:040x}\":{{\"balance\":\"0x0\",\"code\":\"0x\",\"nonce\":\"0x0\",\"storage\":{{}}}}" + )); + } + state.push('}'); + assert!(state.len() < MAX_FIXTURE_BYTES as usize); + state +} + +#[test] +fn test_state_runner_rejects_wide_prestate_before_materializing_or_hashing_it() { + let root = tempfile::tempdir().unwrap(); + let path = root.path().join("wide.json"); + let fixture = format!( + r#"{{"wide":{{ + "env":{{"currentCoinbase":"0x0000000000000000000000000000000000000000", + "currentGasLimit":"0x1000000","currentNumber":"0x1","currentTimestamp":"0x1", + "currentBaseFee":"0x7","currentRandom":"0x0000000000000000000000000000000000000000000000000000000000000000", + "currentExcessBlobGas":"0x0"}}, + "pre":{}, + "transaction":{{"data":["0x"],"gasLimit":["0x5208"],"gasPrice":"0xa", + "nonce":"0x0","secretKey":"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to":"0x0000000000000000000000000000000000000001","value":["0x0"]}}, + "post":{{"Osaka":[{{"indexes":{{"data":0,"gas":0,"value":0}}, + "hash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "logs":"0x0000000000000000000000000000000000000000000000000000000000000000"}}]}} + }}}}"#, + oversized_state() + ); + std::fs::write(&path, fixture).unwrap(); + let results = runner::run_file( + &path, + runner::Config { + mode: Mode::Equivalence, + fork: Fork::Osaka, + threads: 1, + json_outcome: false, + trace: false, + digest: None, + witness: None, + limits: None, + deviations: &[], + }, + ) + .unwrap(); + let [result] = &results[..] else { panic!("expected one result") }; + let runner::Outcome::Failed(failure) = &result.outcome else { + panic!("oversized pre-state was accepted: {:?}", result.outcome) + }; + assert_eq!(failure.kind, runner::FailureKind::Fixture); + assert!(failure.detail.contains("pre-state: state account count exceeds"), "{failure:?}"); +} + +#[test] +fn test_blockchain_runner_rejects_wide_pre_and_post_states_before_hashing() { + let root = tempfile::tempdir().unwrap(); + let path = root.path().join("wide.json"); + let state = oversized_state(); + for (pre, post, label) in [(&*state, "{}", "pre-state"), ("{}", &*state, "post-state")] { + let fixture = format!( + r#"{{"wide":{{"network":"Osaka","genesisRLP":"0x","blocks":[], + "pre":{pre},"postState":{post}, + "lastblockhash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "config":{{"chainid":"0x1","blobSchedule":{{"Osaka":{{"baseFeeUpdateFraction":"0x1"}}}}}} + }}}}"# + ); + std::fs::write(&path, fixture).unwrap(); + let results = blockchain::run_file( + &path, + blockchain::Config { threads: 1, json_outcome: false, witness: None, deviations: &[] }, + ) + .unwrap(); + let [result] = &results[..] else { panic!("expected one result") }; + let blockchain::Outcome::Failed(failure) = &result.outcome else { + panic!("oversized {label} was accepted: {:?}", result.outcome) + }; + assert_eq!(failure.kind, blockchain::FailureKind::Fixture); + assert!( + failure.detail.contains(&format!("{label}: state account count exceeds")), + "{failure:?}" + ); + } +} diff --git a/crates/mega-state-test/tests/runner.rs b/crates/mega-state-test/tests/runner.rs index 874234f57..6d1bf8382 100644 --- a/crates/mega-state-test/tests/runner.rs +++ b/crates/mega-state-test/tests/runner.rs @@ -300,6 +300,93 @@ fn test_what_is_counted_and_what_is_skipped() { ); } +/// An explicit transaction type must not bypass the fixture types' inferred-type rejection of +/// blob and EIP-7702 creates. Only the corresponding expected exception permits the skip. +#[test] +fn test_explicit_blob_and_authorization_creates_are_rejected_for_the_named_reason() { + let dir = tempfile::tempdir().unwrap(); + for (ty, exception) in [(3, "TYPE_3_TX_CONTRACT_CREATION"), (4, "TYPE_4_TX_CONTRACT_CREATION")] + { + let mut expected = unit(&[Fork::Osaka], json!({ "type": ty, "to": "" })); + expected["post"]["Osaka"][0]["expectException"] = + json!(format!("TransactionException.{exception}")); + let mut wrong = expected.clone(); + wrong["post"]["Osaka"][0]["expectException"] = + json!("TransactionException.INVALID_SIGNATURE_VRS"); + let missing = unit(&[Fork::Osaka], json!({ "type": ty, "to": "" })); + let path = write( + dir.path(), + &format!("type{ty}.json"), + json!({ "a_expected": expected, "b_wrong": wrong, "c_missing": missing }), + ); + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + let outcomes = outcomes(&report); + assert_eq!( + outcomes[0], + &Outcome::Skipped { reason: SkipReason::UnbuildableInvalidTransaction }, + "type {ty}" + ); + assert_eq!(failure_kind(outcomes[1]), Some(FailureKind::WrongException)); + assert_eq!(failure_kind(outcomes[2]), Some(FailureKind::Fixture)); + } +} + +/// The inferred forms keep the same expected-invalid handling as their explicit counterparts. +#[test] +fn test_inferred_blob_and_authorization_creates_keep_their_expected_invalid_skips() { + let dir = tempfile::tempdir().unwrap(); + for (fields, exception) in [ + (json!({ "maxFeePerBlobGas": "0x01", "to": "" }), "TYPE_3_TX_CONTRACT_CREATION"), + (json!({ "authorizationList": [], "to": "" }), "TYPE_4_TX_CONTRACT_CREATION"), + ] { + let mut expected = unit(&[Fork::Osaka], fields); + expected["post"]["Osaka"][0]["expectException"] = + json!(format!("TransactionException.{exception}")); + let path = write(dir.path(), "inferred.json", json!({ "invalid": expected })); + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + assert_eq!( + outcomes(&report), + [&Outcome::Skipped { reason: SkipReason::UnbuildableInvalidTransaction }] + ); + } +} + +/// Reject the wide public fixture value before `block_env` attempts its panicking conversion, +/// even when the transaction itself is expected to be invalid. +#[test] +fn test_excess_blob_gas_overflow_is_a_fixture_failure_instead_of_a_panic() { + let dir = tempfile::tempdir().unwrap(); + let mut wide = unit(&[Fork::Osaka], json!({})); + wide["env"]["currentExcessBlobGas"] = json!("0x10000000000000000"); + wide["post"]["Osaka"][0]["expectException"] = + json!("TransactionException.INVALID_SIGNATURE_VRS"); + let path = write(dir.path(), "wide.json", json!({ "wide": wide })); + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + let Outcome::Failed(failure) = &report.results[0].outcome else { + panic!("must reject fixture") + }; + assert_eq!(failure.kind, FailureKind::Fixture); + assert!(failure.detail.contains("currentExcessBlobGas")); + assert!(failure.detail.contains("u64")); +} + +/// A borrowed slow-test basename does not exempt unrelated fixture content from execution. +#[test] +fn test_slow_test_names_do_not_skip_replacement_content() { + let dir = tempfile::tempdir().unwrap(); + let fixture = fill_from_ethereum(unit(&[Fork::Osaka], json!({}))); + for name in [ + "Call50000_sha256.json", + "static_Call50000_sha256.json", + "loopMul.json", + "CALLBlake2f_MaxRounds.json", + ] { + let path = write(dir.path(), name, json!({ "replacement": fixture })); + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + assert_eq!(outcomes(&report), [&Outcome::Passed], "{name}"); + } +} + /// A test name that appears twice in a file fails the file, rather than the second test silently /// replacing the first. #[test] diff --git a/crates/mega-state-test/tests/witness.rs b/crates/mega-state-test/tests/witness.rs index f3ca0b993..6cd3f19ca 100644 --- a/crates/mega-state-test/tests/witness.rs +++ b/crates/mega-state-test/tests/witness.rs @@ -132,7 +132,7 @@ fn test_a_sample_of_the_fixtures_replays_from_its_witness() { let mode: Mode = std::env::var("MEGA_STATE_TEST_MODE").map_or(Mode::Satin, |m| m.parse().expect("a mode")); - let files = find_json_files(&root); + let files = find_json_files(&root).expect("fixture discovery succeeds"); assert!(!files.is_empty(), "no fixtures under {}", root.display()); let stride = files.len().checked_div(sample).unwrap_or(1).max(1); let sampled: Vec<_> = @@ -140,7 +140,7 @@ fn test_a_sample_of_the_fixtures_replays_from_its_witness() { let (mut both, mut record_only, mut skipped, mut failed) = (0, 0, 0, Vec::new()); for path in &sampled { - let json = std::fs::read_to_string(path).expect("a readable fixture"); + let json = state_test::input::read_fixture(path).expect("a readable fixture"); let suite: TestSuite = match serde_json::from_str(&json) { Ok(suite) => suite, Err(error) => { diff --git a/crates/state-test/src/btest.rs b/crates/state-test/src/btest.rs index 16ffa19e9..b18930de7 100644 --- a/crates/state-test/src/btest.rs +++ b/crates/state-test/src/btest.rs @@ -13,7 +13,7 @@ use clap::Parser; use state_test::{ blockchain::{run, Config, Outcome, Report, SkipReason, Summary, TestResult, NETWORK}, deviations, - runner::find_json_files, + runner::find_json_files_in_paths, }; /// How many unattributed failures, and how many unreproduced tests, the summary lists. @@ -77,19 +77,13 @@ pub(crate) fn main(args: impl IntoIterator) -> ExitCo return ExitCode::FAILURE; } } - let mut files = Vec::new(); - for path in &cmd.paths { - if !path.exists() { - eprintln!("error: {} does not exist", path.display()); + let files = match find_json_files_in_paths(&cmd.paths) { + Ok(files) => files, + Err(error) => { + eprintln!("error: {error}"); return ExitCode::FAILURE; } - let found = find_json_files(path); - if found.is_empty() { - eprintln!("error: no JSON fixtures under {}", path.display()); - return ExitCode::FAILURE; - } - files.extend(found); - } + }; let threads = cmd.threads.unwrap_or_else(|| std::thread::available_parallelism().map_or(1, |n| n.get())); diff --git a/crates/state-test/src/main.rs b/crates/state-test/src/main.rs index de8bdec7e..84241ad7d 100644 --- a/crates/state-test/src/main.rs +++ b/crates/state-test/src/main.rs @@ -17,7 +17,9 @@ use std::{path::PathBuf, process::ExitCode}; use clap::Parser; use state_test::{ deviations, - runner::{find_json_files, run, Config, DigestForm, Outcome, Report, Summary, TestResult}, + runner::{ + find_json_files_in_paths, run, Config, DigestForm, Outcome, Report, Summary, TestResult, + }, EvmTxRuntimeLimits, Fork, Mode, }; @@ -110,19 +112,13 @@ fn main() -> ExitCode { return btest::main(std::env::args_os().skip(1)); } let cmd = Cmd::parse(); - let mut files = Vec::new(); - for path in &cmd.paths { - if !path.exists() { - eprintln!("error: {} does not exist", path.display()); - return ExitCode::FAILURE; - } - let found = find_json_files(path); - if found.is_empty() { - eprintln!("error: no JSON fixtures under {}", path.display()); + let files = match find_json_files_in_paths(&cmd.paths) { + Ok(files) => files, + Err(error) => { + eprintln!("error: {error}"); return ExitCode::FAILURE; } - files.extend(found); - } + }; let threads = if cmd.trace { 1 diff --git a/crates/state-test/tests/input_discovery.rs b/crates/state-test/tests/input_discovery.rs new file mode 100644 index 000000000..6169c3281 --- /dev/null +++ b/crates/state-test/tests/input_discovery.rs @@ -0,0 +1,37 @@ +//! Discovery limits must fail the CLI rather than execute an incomplete collection. + +use std::process::Command; + +fn check_discovery_depth(args: &[&str]) { + let root = tempfile::tempdir().unwrap(); + std::fs::write(root.path().join("visible.json"), "{}").unwrap(); + let mut nested = root.path().to_path_buf(); + for _ in 0..63 { + nested.push("d"); + } + std::fs::create_dir_all(&nested).unwrap(); + std::fs::write(nested.join("boundary.json"), "{}").unwrap(); + let run = || { + Command::new(env!("CARGO_BIN_EXE_state-test")).args(args).arg(root.path()).output().unwrap() + }; + let boundary = run(); + assert!(boundary.status.success(), "{}", String::from_utf8_lossy(&boundary.stderr)); + assert!(String::from_utf8_lossy(&boundary.stdout).contains("2 files")); + + nested.push("one-too-deep"); + std::fs::create_dir(&nested).unwrap(); + std::fs::write(nested.join("hidden.json"), "{}").unwrap(); + let output = run(); + assert!(!output.status.success(), "deep fixture tree was accepted"); + assert!(String::from_utf8_lossy(&output.stderr).contains("depth exceeds 64")); +} + +#[test] +fn test_state_cli_refuses_excessive_fixture_depth() { + check_discovery_depth(&["--fork", "Osaka"]); +} + +#[test] +fn test_blockchain_cli_refuses_excessive_fixture_depth() { + check_discovery_depth(&["btest"]); +} From 41d15536bed622dbcf055423da58eb636aa20d3f Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Tue, 27 Oct 2026 18:05:58 +0800 Subject: [PATCH 02/12] fix(evme): redact endpoint credentials and sanitize diagnostics --- bin/mega-evme/src/cmd.rs | 2 +- bin/mega-evme/src/common/logging.rs | 11 +- bin/mega-evme/src/common/provider/mod.rs | 102 +++++++++++-- .../src/common/provider/transport.rs | 131 ++++++++++++++++ bin/mega-evme/tests/output_safety.rs | 143 ++++++++++++++++++ bin/mega-evme/tests/provider.rs | 11 +- .../configuration/state-management.md | 4 + 7 files changed, 389 insertions(+), 15 deletions(-) create mode 100644 bin/mega-evme/tests/output_safety.rs diff --git a/bin/mega-evme/src/cmd.rs b/bin/mega-evme/src/cmd.rs index 065cfa99b..25258b45b 100644 --- a/bin/mega-evme/src/cmd.rs +++ b/bin/mega-evme/src/cmd.rs @@ -183,7 +183,7 @@ impl MainCmd { Commands::Replay(cmd) => cmd.run().await, }; result.map_err(Error::from).inspect_err(|e| { - error!(err = ?e, "Error executing command"); + error!(err = %sanitize_terminal_text(&format!("{e:?}")), "Error executing command"); }) } } diff --git a/bin/mega-evme/src/common/logging.rs b/bin/mega-evme/src/common/logging.rs index 14ae1ed53..81222d07f 100644 --- a/bin/mega-evme/src/common/logging.rs +++ b/bin/mega-evme/src/common/logging.rs @@ -12,6 +12,8 @@ use clap::Parser; use tracing::Level; use tracing_subscriber::{fmt, EnvFilter}; +use super::sanitize_terminal_text; + /// Logging configuration arguments. #[derive(Debug, Clone, Default, Parser)] pub struct LogArgs { @@ -73,7 +75,14 @@ impl LogArgs { .init(); } Err(e) => { - eprintln!("Failed to create log file '{}': {}", log_file.display(), e); + eprintln!( + "{}", + sanitize_terminal_text(&format!( + "Failed to create log file '{}': {}", + log_file.display(), + e + )) + ); fmt() .with_env_filter(filter) .with_target(show_target) diff --git a/bin/mega-evme/src/common/provider/mod.rs b/bin/mega-evme/src/common/provider/mod.rs index ae6f54f45..94a6a6c3d 100644 --- a/bin/mega-evme/src/common/provider/mod.rs +++ b/bin/mega-evme/src/common/provider/mod.rs @@ -35,7 +35,7 @@ use tracing::{debug, info, warn}; pub use self::cache_store::{ExternalEnvSnapshot, RpcCacheStore}; use self::{ cache_store::CacheFileEnvelope, - transport::{CachingTransport, ReplayTransport, TransportCache}, + transport::{CachingTransport, ReplayTransport, RpcHttp, TransportCache}, }; use super::{EvmeError, Result}; @@ -166,7 +166,7 @@ impl RpcArgs { } let provider = build_bare_op_provider(self.build_retry_client(url)); info!( - rpc_url = %redact_rpc_url(rpc_url_str), + rpc_url = %display_rpc_url(rpc_url_str), max_retries = self.max_retries, backoff_ms = self.backoff_ms, "Built RPC provider (cache disabled)", @@ -226,7 +226,7 @@ impl RpcArgs { .connect_client(client); info!( - rpc_url = %redact_rpc_url(rpc_url_str), + rpc_url = %display_rpc_url(rpc_url_str), cache_size = self.cache_size, max_retries = self.max_retries, backoff_ms = self.backoff_ms, @@ -338,7 +338,7 @@ impl RpcArgs { // envelope first, a stale eth_chainId entry would short-circuit the // cross-chain validation. let transport_cache = TransportCache::new(); - let http = alloy_transport_http::Http::new(url.clone()); + let http = RpcHttp::new(url.clone()); let caching = CachingTransport::new(http, transport_cache.clone()); let client = self.build_client(caching, &url); let provider = ProviderBuilder::new() @@ -350,7 +350,7 @@ impl RpcArgs { let chain_id = provider.get_chain_id().await.map_err(|e| { EvmeError::RpcError(format!( "Failed to fetch chain ID from '{}': {e}", - redact_rpc_url(rpc_url_str) + display_rpc_url(rpc_url_str) )) })?; @@ -372,7 +372,7 @@ impl RpcArgs { } info!( - rpc_url = %redact_rpc_url(rpc_url_str), + rpc_url = %display_rpc_url(rpc_url_str), path = %path.display(), chain_id, "Built RPC provider (capture to cache file)", @@ -390,7 +390,7 @@ impl RpcArgs { /// Build an `RpcClient` over HTTP, wired with the configured retry layer. fn build_retry_client(&self, url: alloy_transport_http::reqwest::Url) -> RpcClient { - self.build_client(alloy_transport_http::Http::new(url.clone()), &url) + self.build_client(RpcHttp::new(url.clone()), &url) } /// Build an `RpcClient` over an arbitrary transport, wired with the configured @@ -422,7 +422,7 @@ impl RpcArgs { /// Resolve the chain ID by issuing `eth_chainId` against a throwaway /// cache-less provider using the configured retry policy. async fn resolve_chain_id(&self, url: alloy_transport_http::reqwest::Url) -> Result { - let url_str = redact_rpc_url(url.as_str()); + let url_str = display_rpc_url(url.as_str()); let bare = build_bare_op_provider(self.build_retry_client(url)); bare.get_chain_id().await.map_err(|e| { EvmeError::RpcError(format!("Failed to fetch chain ID from '{}': {e}", url_str)) @@ -461,7 +461,7 @@ fn build_bare_op_provider(client: RpcClient) -> OpProvider { ) } -/// The URL with any userinfo removed, for a log line, an error, or a cache file name. +/// The normalized endpoint identity used for cache file names, with any userinfo removed. /// /// Userinfo is the part of the authority before its last `@`, as the URL standard reads it, so a /// password holding an `@` goes whole. It is removed from the text itself, so it holds for a URL @@ -484,16 +484,47 @@ fn normalized(raw: &str) -> String { .map_or_else(|_| raw.to_string(), |u| u.to_string()) } +/// The public origin of an RPC URL, without userinfo, path, query or fragment. +/// +/// This is for logs and errors only: cache keys keep the whole endpoint identity through +/// `redact_rpc_url`. An unparseable URL is hidden whole rather than guessed at. +pub(crate) fn display_rpc_url(raw: &str) -> String { + raw.parse::() + .ok() + .filter(|url| url.host_str().is_some()) + .map_or_else(|| "".to_string(), |url| url.origin().ascii_serialization()) +} + +/// Redacts URLs echoed by RPC errors, without changing successful RPC results. +fn redact_rpc_urls_in_text(text: &str) -> String { + let mut out = String::with_capacity(text.len()); + let mut rest = text; + while let Some(colon) = rest.find("://") { + let start = rest[..colon] + .rfind(|c: char| !c.is_ascii_alphanumeric() && !matches!(c, '+' | '-' | '.')) + .map_or(0, |at| at + rest[at..].chars().next().expect("a character").len_utf8()); + // Punctuation can be part of a credential-bearing path or query. Consume the whole + // non-whitespace token, including surrounding punctuation if present, to fail closed. + let end = + rest[colon + 3..].find(char::is_whitespace).map_or(rest.len(), |at| colon + 3 + at); + out.push_str(&rest[..start]); + out.push_str(&display_rpc_url(&rest[start..end])); + rest = &rest[end..]; + } + out.push_str(rest); + out +} + /// Parses `--rpc`. The transport speaks HTTP, so any other scheme is refused here, before the URL /// reaches a library whose error text would repeat it whole. fn parse_rpc_url(raw: &str) -> Result { let url: alloy_transport_http::reqwest::Url = raw.parse().map_err(|e| { - EvmeError::RpcError(format!("Invalid RPC URL '{}': {e}", redact_rpc_url(raw))) + EvmeError::RpcError(format!("Invalid RPC URL '{}': {e}", display_rpc_url(raw))) })?; if !matches!(url.scheme(), "http" | "https") { return Err(EvmeError::InvalidInput(format!( "Invalid RPC URL '{}': it has to start with http:// or https://", - redact_rpc_url(raw) + display_rpc_url(raw) ))); } Ok(url) @@ -555,6 +586,55 @@ mod tests { use super::*; + #[test] + fn test_display_rpc_url_hides_every_credential_location() { + for url in [ + "https://alice:secret@rpc.example:8443/v2/path-secret?key=query-secret#fragment-secret", + "https://rpc.example:8443/another-secret", + ] { + assert_eq!(display_rpc_url(url), "https://rpc.example:8443"); + } + for url in ["alice:secret@rpc.example/path-secret", "http://bad host/path-secret"] { + assert_eq!(display_rpc_url(url), ""); + } + } + + #[test] + fn test_display_redaction_does_not_merge_cache_endpoints() { + let first = "https://rpc.example/key-one?key=one"; + assert_eq!(rpc_cache_file_name(4326, first), "rpc-cache-4326-4b33965d.json"); + assert_eq!(display_rpc_url(first), display_rpc_url("https://rpc.example/key-two?key=two")); + assert_ne!( + rpc_cache_file_name(4326, first), + rpc_cache_file_name(4326, "https://rpc.example/key-two?key=one") + ); + assert_ne!( + rpc_cache_file_name(4326, first), + rpc_cache_file_name(4326, "https://rpc.example/key-one?key=two") + ); + assert_eq!( + rpc_cache_file_name(4326, "http://example.com/rpc"), + "rpc-cache-4326-e2afa302.json" + ); + } + + #[test] + fn test_urls_echoed_in_error_text_are_redacted_through_punctuation() { + for text in [ + "request failed for https://rpc.example/v2/(secret-key)", + "request failed for https://rpc.example/v2/key'with'apostrophes?key=secret-key", + "request failed for https://rpc.example/v2/%28secret-key%29?key=secret-key", + "{\"url\":\"https://rpc.example/v2/secret-key\"}", + ] { + let safe = redact_rpc_urls_in_text(text); + assert!(!safe.contains("secret-key"), "{safe}"); + assert!( + safe.starts_with("request failed for ") || safe.starts_with("{\"url\":\""), + "{safe}" + ); + } + } + /// Explicit `--rpc.cache-dir` is used verbatim. The file names the chain and a hash of the /// endpoint, and the hash does not change when only the userinfo does. #[test] diff --git a/bin/mega-evme/src/common/provider/transport.rs b/bin/mega-evme/src/common/provider/transport.rs index 077395552..5ba2212e9 100644 --- a/bin/mega-evme/src/common/provider/transport.rs +++ b/bin/mega-evme/src/common/provider/transport.rs @@ -20,6 +20,116 @@ use serde::{Deserialize, Serialize}; use crate::common::{EvmeError, Result}; +/// HTTP with the same RPC/status handling as alloy's transport, but without URL-bearing +/// tracing spans or reqwest errors. Endpoint paths and queries commonly hold credentials. +#[derive(Clone)] +pub(super) struct RpcHttp { + client: alloy_transport_http::reqwest::Client, + url: alloy_transport_http::reqwest::Url, +} + +impl std::fmt::Debug for RpcHttp { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("RpcHttp") + .field("origin", &super::display_rpc_url(self.url.as_str())) + .finish() + } +} + +impl RpcHttp { + pub(super) fn new(url: alloy_transport_http::reqwest::Url) -> Self { + Self { client: alloy_transport_http::reqwest::Client::new(), url } + } +} + +impl tower::Service for RpcHttp { + type Response = ResponsePacket; + type Error = TransportError; + type Future = TransportFut<'static>; + + fn poll_ready( + &mut self, + _cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + std::task::Poll::Ready(Ok(())) + } + + fn call(&mut self, req: RequestPacket) -> Self::Future { + let this = self.clone(); + Box::pin(async move { + let response = this + .client + .post(this.url) + .json(&req) + .headers(req.headers()) + .send() + .await + .map_err(|e| TransportErrorKind::custom(e.without_url()))?; + let status = response.status(); + let body = + response.bytes().await.map_err(|e| TransportErrorKind::custom(e.without_url()))?; + let parsed = serde_json::from_slice::(&body); + if !status.is_success() && !parsed.as_ref().is_ok_and(ResponsePacket::is_error) { + return Err(TransportErrorKind::http_error( + status.as_u16(), + "".to_string(), + )); + } + let mut parsed = parsed.map_err(|error| { + TransportError::deser_err( + // A serde error can quote an offending JSON string, including its URL. + serde_json::Error::io(std::io::Error::new( + std::io::ErrorKind::InvalidData, + format!( + "invalid RPC response at line {}, column {}", + error.line(), + error.column() + ), + )), + "", + ) + })?; + // Preserve successful results verbatim; only errors are displayed as diagnostics. + match &mut parsed { + ResponsePacket::Single(response) => redact_error(response), + ResponsePacket::Batch(responses) => responses.iter_mut().for_each(redact_error), + } + Ok(parsed) + }) + } +} + +fn redact_error(response: &mut alloy_json_rpc::Response) { + if let alloy_json_rpc::ResponsePayload::Failure(error) = &mut response.payload { + error.message = super::redact_rpc_urls_in_text(&error.message).into(); + if let Some(data) = error.data.take() { + // RawValue accepts values (large numbers or deep nesting) Value cannot represent. + // Omit data we cannot inspect, rather than panic or echo it without redaction. + if let Ok(mut value) = serde_json::from_str::(data.get()) { + redact_error_data(&mut value); + error.data = serde_json::value::to_raw_value(&value).ok(); + } + } + } +} + +fn redact_error_data(value: &mut serde_json::Value) { + match value { + serde_json::Value::String(text) => *text = super::redact_rpc_urls_in_text(text), + serde_json::Value::Array(values) => values.iter_mut().for_each(redact_error_data), + serde_json::Value::Object(values) => { + *values = std::mem::take(values) + .into_iter() + .map(|(key, mut value)| { + redact_error_data(&mut value); + (super::redact_rpc_urls_in_text(&key), value) + }) + .collect(); + } + _ => {} + } +} + /// A single entry in the transport-level cache. #[derive(Debug, Serialize, Deserialize)] struct TransportCacheEntry { @@ -264,6 +374,27 @@ mod tests { use super::*; + #[test] + fn test_rpc_error_data_that_cannot_be_inspected_is_omitted() { + for data in ["1e400".to_string(), format!("{}0{}", "[".repeat(200), "]".repeat(200))] { + let mut response = alloy_json_rpc::Response { + id: alloy_json_rpc::Id::Number(0), + payload: alloy_json_rpc::ResponsePayload::Failure(alloy_json_rpc::ErrorPayload { + code: -32603, + message: "upstream error".into(), + data: Some(serde_json::value::RawValue::from_string(data).unwrap()), + }), + }; + redact_error(&mut response); + let alloy_json_rpc::ResponsePayload::Failure(error) = response.payload else { + panic!("error") + }; + assert_eq!(error.code, -32603); + assert_eq!(error.message, "upstream error"); + assert!(error.data.is_none()); + } + } + /// The replay transport is always ready. /// Single-request cache misses return a descriptive Custom error (safe because /// the retry layer is never installed on the replay path). diff --git a/bin/mega-evme/tests/output_safety.rs b/bin/mega-evme/tests/output_safety.rs new file mode 100644 index 000000000..bd7047e77 --- /dev/null +++ b/bin/mega-evme/tests/output_safety.rs @@ -0,0 +1,143 @@ +//! Diagnostic output must not render terminal controls or endpoint credentials. + +use std::process::Command; + +use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; + +fn cli() -> Command { + let mut cmd = Command::new(env!("CARGO_BIN_EXE_mega-evme")); + cmd.env_remove("RUST_LOG").arg("--log.no-color"); + cmd +} + +#[test] +fn test_verbose_command_errors_are_filtered_on_stderr_and_in_a_log_file() { + let dir = tempfile::tempdir().unwrap(); + for to_file in [false, true] { + let log = dir.path().join("command.log"); + let mut cmd = cli(); + cmd.args([ + "run", + "0x00", + "--spec", + "Satin", + "--sender.balance", + "1bogus\u{202e}unit", + "-v", + ]); + if to_file { + cmd.arg("--log.file").arg(&log); + } + let output = cmd.output().unwrap(); + assert_eq!(output.status.code(), Some(1)); + let stderr = String::from_utf8(output.stderr).unwrap(); + let logged = if to_file { std::fs::read_to_string(&log).unwrap() } else { stderr.clone() }; + assert!(logged.contains("Error executing command"), "{logged}"); + for text in [&stderr, &logged] { + assert!(!text.contains('\u{202e}') && !text.contains('\u{1b}'), "{text:?}"); + } + } +} + +#[test] +fn test_a_log_file_creation_failure_filters_the_path() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("\u{1b}[2J\u{202e}missing-parent").join("tool.log"); + let output = cli() + .args(["run", "0x00", "--spec", "Satin", "-v"]) + .arg("--log.file") + .arg(&path) + .output() + .unwrap(); + assert!(output.status.success()); + let stderr = String::from_utf8(output.stderr).unwrap(); + assert!( + stderr.contains("Failed to create log file") && stderr.contains("tool.log"), + "{stderr}" + ); + assert!(!stderr.contains('\u{202e}') && !stderr.contains('\u{1b}'), "{stderr:?}"); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_endpoint_paths_and_queries_reach_no_diagnostic_output() { + for response_kind in [ + "connection", + "http", + "malformed", + "escaped-http", + "escaped-malformed", + "wrong-type", + "rpc", + "large-number", + "deep-data", + ] { + let server = MockServer::start().await; + let url = if response_kind == "connection" { + "http://alice:userinfo-secret@127.0.0.1:9/v2/(path-secret)?key=query-secret#fragment-secret".to_string() + } else { + format!("{}/v2/(path-secret)?key=query-secret#fragment-secret", server.uri()) + }; + if response_kind != "connection" { + let body = if matches!(response_kind, "large-number" | "deep-data") { + let data = if response_kind == "large-number" { + "1e400".to_string() + } else { + format!("{}\"{url}\"{}", "[".repeat(200), "]".repeat(200)) + }; + format!("{{\"jsonrpc\":\"2.0\",\"id\":0,\"error\":{{\"code\":-32603,\"message\":\"failed\",\"data\":{data}}}}}") + } else if response_kind == "wrong-type" { + serde_json::to_string(&url).unwrap() + } else if matches!(response_kind, "escaped-http" | "escaped-malformed") { + format!("{{\"url\":\"{}\"}}", url.replace('/', "\\/")) + } else if response_kind == "rpc" { + serde_json::json!({"jsonrpc":"2.0", "id":0, "error":{ + "code":-32603, "message":format!("failed {url}"), "data":{(url.clone()):url.clone()} + }}).to_string() + } else { + format!("upstream rejected {url}") + }; + Mock::given(matchers::method("POST")) + .respond_with( + ResponseTemplate::new(if matches!(response_kind, "http" | "escaped-http") { + 503 + } else { + 200 + }) + .set_body_string(body), + ) + .mount(&server) + .await; + } + let dir = tempfile::tempdir().unwrap(); + for to_file in [false, true] { + let log = dir.path().join("rpc.log"); + let mut cmd = cli(); + cmd.env("RUST_LOG", "mega_evme=debug,alloy_transport_http=debug"); + cmd.args(["replay", &format!("0x{}", "11".repeat(32)), "--override.spec", "Satin"]) + .args(["--rpc", &url, "--rpc.max-retries", "0", "--rpc.no-cache-file", "-vvvv"]); + if to_file { + cmd.arg("--log.file").arg(&log); + } + let output = tokio::task::spawn_blocking(move || cmd.output()).await.unwrap().unwrap(); + assert_eq!(output.status.code(), Some(1), "{response_kind}"); + let mut text = format!( + "{}{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + if to_file { + text.push_str(&std::fs::read_to_string(&log).unwrap()); + } + assert!(text.contains("Provider mode: online RPC"), "{response_kind}: {text}"); + assert!( + !text.contains("Custom backtrace") && !text.contains("panicked"), + "{response_kind}: {text}" + ); + for secret in + ["path-secret", "query-secret", "fragment-secret", "userinfo-secret", "alice"] + { + assert!(!text.contains(secret), "{response_kind}, {to_file}: {text}"); + } + } + } +} diff --git a/bin/mega-evme/tests/provider.rs b/bin/mega-evme/tests/provider.rs index bfc24c798..9029cab55 100644 --- a/bin/mega-evme/tests/provider.rs +++ b/bin/mega-evme/tests/provider.rs @@ -145,11 +145,18 @@ async fn test_build_provider_with_cache_names_file_from_fetched_chain_id() { #[tokio::test(flavor = "multi_thread")] async fn test_build_provider_invalid_url() { - let args = RpcArgs::parse_from(["mega-evme", "--rpc", "not a url", "--rpc.cache-size", "0"]); + let args = RpcArgs::parse_from([ + "mega-evme", + "--rpc", + "http://bad host/path-secret?key=query-secret", + "--rpc.cache-size", + "0", + ]); let err = args.build_provider().await.expect_err("build_provider should fail"); match err { EvmeError::RpcError(msg) => { - assert!(msg.contains("not a url"), "error must echo the original input, got: {msg}"); + assert!(msg.contains("Invalid RPC URL ''"), "{msg}"); + assert!(!msg.contains("path-secret") && !msg.contains("query-secret"), "{msg}"); } other => panic!("expected EvmeError::RpcError, got {other:?}"), } diff --git a/docs/mega-evme/configuration/state-management.md b/docs/mega-evme/configuration/state-management.md index eb47a04b4..a69b568fa 100644 --- a/docs/mega-evme/configuration/state-management.md +++ b/docs/mega-evme/configuration/state-management.md @@ -227,10 +227,14 @@ When using fork mode, `mega-evme` caches RPC responses to avoid redundant networ These options take effect only when an RPC endpoint is actually contacted: on `run` and `tx` that requires `--fork` (without `--fork` they are accepted but silently ignored); on `replay` they apply to its `--rpc` fetches (an offline `--rpc.replay-file` run contacts no endpoint and does not use them). +On Satin, RPC URL diagnostics show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs echoed in HTTP errors. +This applies to verbose logs and log files as well as stderr. + ### Per-Endpoint Cache Files Each endpoint of a chain gets its own cache file named `rpc-cache-{chain_id}-{endpoint}.json`. `{endpoint}` is a short hash of the URL with any userinfo removed, so the name does not contain the URL. +The hash still includes the path and query, even though diagnostic output hides them, so endpoints that differ there keep separate cache files. A cache populated from one endpoint cannot be loaded for another, including another endpoint of the same chain. The default cache directory is the platform cache directory: From 625f05122036e562c3a99805a2448bb17b3a5a34 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Tue, 27 Oct 2026 18:05:58 +0800 Subject: [PATCH 03/12] fix(replay): validate parent context before transaction replay --- bin/mega-evme/AGENTS.md | 6 +- bin/mega-evme/src/replay/cmd.rs | 56 ++++++++++++----- bin/mega-evme/tests/replay_paths.rs | 96 +++++++++++++++++++++++++++++ docs/mega-evme/commands/replay.md | 5 ++ 4 files changed, 145 insertions(+), 18 deletions(-) diff --git a/bin/mega-evme/AGENTS.md b/bin/mega-evme/AGENTS.md index 96d1408c1..eead81f67 100644 --- a/bin/mega-evme/AGENTS.md +++ b/bin/mega-evme/AGENTS.md @@ -22,9 +22,13 @@ Two engines: the in-tree sources run Satin; a spec from `Equivalence` to `Rex6` - Command handlers follow staged flow: parse inputs → build state/env → execute → print summary/receipt/trace. - Replay uses block executor flow, including pre-execution system calls and preceding transactions. - Logging is structured via tracing macros, with explicit progress milestones. +- RPC diagnostics use `display_rpc_url`, which hides userinfo, path, query and fragment; cache identity uses `redact_rpc_url` and keeps the path and query. + Keep the two separate, and remove reqwest's URL before an HTTP error reaches a diagnostic. - Output paths keep both human-readable summaries and optional machine artifacts (trace/state dump). -- The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. A transaction replay's engine is decided at the timestamp of the block the replay runs it in (its own, or the latest for a pending one), the one whose schedule it runs under: keep a new site to the same pair. +- The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. + A transaction replay's engine is decided at the timestamp of its mined block, the one whose schedule it runs under: keep a new site to the same pair. + Satin transaction replay refuses pending and genesis transactions and checks the fetched parent's number and hash before using its state. - Output on Satin is additive to the legacy output: every legacy field keeps its name and meaning, and what only Satin counts goes in the `satin` object (`tests/integration.rs` checks it on every fixture pair). ## ANTI-PATTERNS diff --git a/bin/mega-evme/src/replay/cmd.rs b/bin/mega-evme/src/replay/cmd.rs index b2256685e..d39eaf8fd 100644 --- a/bin/mega-evme/src/replay/cmd.rs +++ b/bin/mega-evme/src/replay/cmd.rs @@ -135,8 +135,8 @@ impl Cmd { /// Without an override this reads the chain id, and, only on a chain that switches engines /// at a scheduled timestamp, the timestamp of the block the replay runs the transaction in, /// from the source the replay itself reads, through a provider that persists nothing: the - /// transaction's block, or for a pending transaction the latest block, whose environment and - /// schedule the replay runs it in. Under `--genesis` a chain other than the file's is refused + /// transaction's block. Pending transactions have no canonical replay context and are refused. + /// Under `--genesis` a chain other than the file's is refused /// once the chain id is read, before an engine is picked for it. pub async fn engine(&self) -> Result { let tx_hash = self.tx_hash(); @@ -154,10 +154,7 @@ impl Cmd { .map_err(|e| ReplayError::RpcError(format!("Failed to fetch transaction: {e}")))? .ok_or(ReplayError::TransactionNotFound(tx_hash))?; let transport = |e| ReplayError::RpcError(format!("RPC transport error: {e}")); - let number = match tx.block_number { - Some(number) => number, - None => provider.get_block_number().await.map_err(transport)?, - }; + let number = mined_block_number(tx_hash, tx.block_number)?; let timestamp = provider .get_block_by_number(number.into()) .await @@ -280,7 +277,7 @@ impl Cmd { info!(path = %path.display(), "Provider mode: offline replay from cache file"); self.rpc_args.build_replay_provider().await? } else if let Some(rpc) = &self.rpc_args.rpc_url { - info!(rpc = %crate::redact_rpc_url(rpc), "Provider mode: online RPC"); + info!(rpc = %crate::display_rpc_url(rpc), "Provider mode: online RPC"); self.rpc_args.build_provider().await? } else { return Err(ReplayError::Other( @@ -308,19 +305,11 @@ impl Cmd { .ok_or(ReplayError::TransactionNotFound(tx_hash))?; debug!(block_number = ?target_tx.block_number, "Transaction found"); - let (state_base_block, block_number, is_pending) = if let Some(n) = target_tx.block_number { - (n - 1, n, false) - } else { - let latest = provider - .get_block_number() - .await - .map_err(|e| ReplayError::RpcError(format!("RPC transport error: {e}")))?; - (latest, latest, true) - }; + let block_number = mined_block_number(tx_hash, target_tx.block_number)?; + let state_base_block = block_number - 1; debug!( state_base_block = state_base_block, block = block_number, - is_pending, "Block numbers determined", ); @@ -335,6 +324,18 @@ impl Cmd { .map_err(|e| ReplayError::RpcError(format!("RPC transport error: {e}")))? .ok_or(ReplayError::BlockNotFound(block_number))?; + if parent_block.number() != state_base_block || + parent_block.hash() != block.header.parent_hash() + { + return Err(ReplayError::Other(format!( + "parent block does not match block {block_number}: expected \ + {state_base_block} ({}), fetched {} ({})", + block.header.parent_hash(), + parent_block.number(), + parent_block.hash() + ))); + } + let preceding_tx_hashes = preceding_transactions( tx_hash, target_tx.block_number, @@ -674,6 +675,19 @@ fn predecessor_error(error: &BlockExecutionError) -> PredecessorError { } } +/// A historical replay needs a mined block and its predecessor. +fn mined_block_number(hash: B256, number: Option) -> Result { + match number { + Some(0) => Err(ReplayError::Other(format!( + "transaction {hash} is in genesis; replay requires a parent block" + ))), + Some(number) => Ok(number), + None => Err(ReplayError::Other(format!( + "transaction {hash} is pending; replay requires a mined transaction" + ))), + } +} + /// Hashes of the transactions before `target_hash` in the fetched block. /// /// A pending transaction has no block yet, so it has no predecessors here. A mined transaction @@ -873,6 +887,14 @@ mod tests { } } + #[test] + fn test_replay_requires_a_mined_block_with_a_predecessor() { + let hash = B256::repeat_byte(1); + assert!(mined_block_number(hash, None).unwrap_err().to_string().contains("pending")); + assert!(mined_block_number(hash, Some(0)).unwrap_err().to_string().contains("genesis")); + assert_eq!(mined_block_number(hash, Some(1)).unwrap(), 1); + } + #[test] fn test_preceding_transactions_stop_at_the_target() { let target = B256::repeat_byte(1); diff --git a/bin/mega-evme/tests/replay_paths.rs b/bin/mega-evme/tests/replay_paths.rs index 4762cf033..37d98158a 100644 --- a/bin/mega-evme/tests/replay_paths.rs +++ b/bin/mega-evme/tests/replay_paths.rs @@ -214,6 +214,102 @@ fn checked(rows: &[Value], held: Option) -> Vec { picks } +#[tokio::test(flavor = "multi_thread")] +async fn test_replay_rejects_an_unlinked_parent_before_reading_state() { + for wrong_hash in [true, false] { + let recorded = read_block(fixtures(), BLOCK); + let target = recorded.block["transactions"][1]["hash"].as_str().unwrap().to_owned(); + let recording = + Recording { block: recorded, parent_timestamp: None, codes: HashMap::default() }; + let mut parent = recording.parent(); + if wrong_hash { + parent["hash"] = json!(B256::repeat_byte(0x42)); + } else { + parent["number"] = json!(format!("0x{:x}", BLOCK - 2)); + } + let server = Server::start(recording.block).await; + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByNumber", "params": [format!("0x{:x}", BLOCK - 1), false] + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", "id": body["id"], "result": parent + })) + }) + .with_priority(1) + .expect(1) + .mount(&server.0) + .await; + let run = run_evme(&[ + "replay", + &target, + "--rpc", + &server.0.uri(), + "--rpc.no-cache-file", + "--rpc.max-retries", + "0", + "--override.spec", + "Satin", + ]); + assert_ne!(run.code, 0, "the mismatched parent must be rejected"); + assert!(run.stderr.contains("parent block does not match"), "{}{}", run.stdout, run.stderr); + let requests = server.0.received_requests().await.unwrap(); + assert!( + requests.iter().all(|request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + matches!( + body["method"].as_str(), + Some("eth_chainId" | "eth_getTransactionByHash" | "eth_getBlockByNumber") + ) + }), + "a mismatched parent is rejected before reading state or receipts" + ); + } +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_replay_rejects_a_pending_transaction_before_fetching_blocks() { + let recorded = read_block(fixtures(), BLOCK); + let mut tx = recorded.block["transactions"][1].clone(); + let target = tx["hash"].as_str().unwrap().to_owned(); + tx["blockNumber"] = Value::Null; + tx["blockHash"] = Value::Null; + tx["transactionIndex"] = Value::Null; + let server = Server::start(recorded).await; + Mock::given(matchers::body_partial_json(json!({"method": "eth_getTransactionByHash"}))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", "id": body["id"], "result": tx + })) + }) + .with_priority(1) + .expect(1) + .mount(&server.0) + .await; + let run = run_evme(&[ + "replay", + &target, + "--rpc", + &server.0.uri(), + "--rpc.no-cache-file", + "--rpc.max-retries", + "0", + "--override.spec", + "Satin", + ]); + assert_ne!(run.code, 0); + assert!(run.stderr.contains("pending"), "{}{}", run.stdout, run.stderr); + assert!( + server.0.received_requests().await.unwrap().iter().all(|request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + matches!(body["method"].as_str(), Some("eth_chainId" | "eth_getTransactionByHash")) + }), + "a pending transaction must not fetch a block or read state" + ); +} + #[tokio::test(flavor = "multi_thread")] async fn test_a_transaction_replayed_alone_is_the_one_the_block_replay_runs() { let recorded = read_block(fixtures(), BLOCK); diff --git a/docs/mega-evme/commands/replay.md b/docs/mega-evme/commands/replay.md index cf7682795..6c82028e0 100644 --- a/docs/mega-evme/commands/replay.md +++ b/docs/mega-evme/commands/replay.md @@ -8,6 +8,11 @@ Re-execute a historical transaction locally using an RPC endpoint or a previousl In online mode, `mega-evme` fetches the transaction, block environment, and pre-state from the RPC and re-executes locally. In offline mode (`--rpc.replay-file`), all data is served from a local fixture captured by an earlier run — no network access is required. +A Satin transaction replay requires a mined transaction in a block after genesis. +Pending transactions have no canonical block context and are refused. +Before reading the parent state, replay checks that the fetched parent has the preceding block number and the hash named by the transaction's block. +A mismatch aborts the replay; retry with a consistent RPC endpoint or recording. + With `--block`, `replay` re-executes whole blocks instead and compares every receipt with the chain's; see [Replaying Whole Blocks](#replaying-whole-blocks). ## Usage From c7ab0b07b424d7f8ed0973cbb5452a7493e1c9f1 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Wed, 28 Oct 2026 00:45:55 +0800 Subject: [PATCH 04/12] fix(devtools): simplify validation and preserve RPC retries --- bin/mega-evme/AGENTS.md | 1 + bin/mega-evme/src/cmd.rs | 2 +- bin/mega-evme/src/common/provider/mod.rs | 42 ++- .../src/common/provider/transport.rs | 163 +++++------ bin/mega-evme/src/replay/cmd.rs | 8 +- bin/mega-evme/tests/integration.rs | 90 ++++++ bin/mega-evme/tests/output_safety.rs | 143 ---------- bin/mega-evme/tests/provider.rs | 81 ++++-- crates/mega-state-test/AGENTS.md | 2 +- crates/mega-state-test/README.md | 8 +- crates/mega-state-test/src/blockchain/mod.rs | 4 - crates/mega-state-test/src/exceptions.rs | 87 +++--- crates/mega-state-test/src/input.rs | 131 +++------ crates/mega-state-test/src/lib.rs | 2 +- crates/mega-state-test/src/runner.rs | 45 ++- crates/mega-state-test/src/skips.rs | 70 +---- crates/mega-state-test/src/witness.rs | 1 - crates/mega-state-test/tests/blockchain.rs | 33 +++ .../VMTests/vmPerformance/loopMul.json | 257 ------------------ .../Call50000_sha256.json | 191 ------------- .../CALLBlake2f_MaxRounds.json | 130 --------- .../static_Call50000_sha256.json | 205 -------------- .../Call50000_sha256.json | 134 --------- .../static_Call50000_sha256.json | 128 --------- .../tests/fixtures/slow/LICENSE | 7 - .../tests/fixtures/slow/README.md | 8 - crates/mega-state-test/tests/input_limits.rs | 148 ---------- crates/mega-state-test/tests/runner.rs | 122 ++++----- crates/mega-state-test/tests/witness.rs | 2 +- crates/state-test/tests/cli.rs | 32 +++ crates/state-test/tests/input_discovery.rs | 37 --- 31 files changed, 465 insertions(+), 1849 deletions(-) delete mode 100644 bin/mega-evme/tests/output_safety.rs delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json delete mode 100644 crates/mega-state-test/tests/fixtures/slow/LICENSE delete mode 100644 crates/mega-state-test/tests/fixtures/slow/README.md delete mode 100644 crates/mega-state-test/tests/input_limits.rs delete mode 100644 crates/state-test/tests/input_discovery.rs diff --git a/bin/mega-evme/AGENTS.md b/bin/mega-evme/AGENTS.md index eead81f67..b4cccbbc9 100644 --- a/bin/mega-evme/AGENTS.md +++ b/bin/mega-evme/AGENTS.md @@ -24,6 +24,7 @@ Two engines: the in-tree sources run Satin; a spec from `Equivalence` to `Rex6` - Logging is structured via tracing macros, with explicit progress milestones. - RPC diagnostics use `display_rpc_url`, which hides userinfo, path, query and fragment; cache identity uses `redact_rpc_url` and keeps the path and query. Keep the two separate, and remove reqwest's URL before an HTTP error reaches a diagnostic. + `RedactedTransport` wraps the retry layer: the dependency classifies the original errors and consumes backoff hints before final diagnostics are redacted. - Output paths keep both human-readable summaries and optional machine artifacts (trace/state dump). - The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. diff --git a/bin/mega-evme/src/cmd.rs b/bin/mega-evme/src/cmd.rs index 25258b45b..065cfa99b 100644 --- a/bin/mega-evme/src/cmd.rs +++ b/bin/mega-evme/src/cmd.rs @@ -183,7 +183,7 @@ impl MainCmd { Commands::Replay(cmd) => cmd.run().await, }; result.map_err(Error::from).inspect_err(|e| { - error!(err = %sanitize_terminal_text(&format!("{e:?}")), "Error executing command"); + error!(err = ?e, "Error executing command"); }) } } diff --git a/bin/mega-evme/src/common/provider/mod.rs b/bin/mega-evme/src/common/provider/mod.rs index 94a6a6c3d..6ec6bd142 100644 --- a/bin/mega-evme/src/common/provider/mod.rs +++ b/bin/mega-evme/src/common/provider/mod.rs @@ -35,7 +35,7 @@ use tracing::{debug, info, warn}; pub use self::cache_store::{ExternalEnvSnapshot, RpcCacheStore}; use self::{ cache_store::CacheFileEnvelope, - transport::{CachingTransport, ReplayTransport, RpcHttp, TransportCache}, + transport::{CachingTransport, RedactedTransport, ReplayTransport, TransportCache}, }; use super::{EvmeError, Result}; @@ -338,7 +338,7 @@ impl RpcArgs { // envelope first, a stale eth_chainId entry would short-circuit the // cross-chain validation. let transport_cache = TransportCache::new(); - let http = RpcHttp::new(url.clone()); + let http = alloy_transport_http::Http::new(url.clone()); let caching = CachingTransport::new(http, transport_cache.clone()); let client = self.build_client(caching, &url); let provider = ProviderBuilder::new() @@ -390,7 +390,7 @@ impl RpcArgs { /// Build an `RpcClient` over HTTP, wired with the configured retry layer. fn build_retry_client(&self, url: alloy_transport_http::reqwest::Url) -> RpcClient { - self.build_client(RpcHttp::new(url.clone()), &url) + self.build_client(alloy_transport_http::Http::new(url.clone()), &url) } /// Build an `RpcClient` over an arbitrary transport, wired with the configured @@ -403,6 +403,7 @@ impl RpcArgs { ) -> RpcClient { let is_local = url.host_str().is_some_and(|h| h == "localhost" || h == "127.0.0.1" || h == "::1"); + let max_retries = self.max_retries; if self.max_retries > 0 { let policy = RateLimitRetryPolicy::default().or(|err: &TransportError| { matches!(err, RpcError::Transport(TransportErrorKind::Custom(_))) @@ -413,9 +414,15 @@ impl RpcArgs { self.compute_units_per_sec, policy, ); - ClientBuilder::default().layer(retry).transport(transport, is_local) + ClientBuilder::default() + .layer(tower::layer::layer_fn(move |inner| { + RedactedTransport::new(inner, max_retries) + })) + .layer(retry) + .transport(transport, is_local) } else { - ClientBuilder::default().transport(transport, is_local) + ClientBuilder::default() + .transport(RedactedTransport::new(transport, max_retries), is_local) } } @@ -599,25 +606,6 @@ mod tests { } } - #[test] - fn test_display_redaction_does_not_merge_cache_endpoints() { - let first = "https://rpc.example/key-one?key=one"; - assert_eq!(rpc_cache_file_name(4326, first), "rpc-cache-4326-4b33965d.json"); - assert_eq!(display_rpc_url(first), display_rpc_url("https://rpc.example/key-two?key=two")); - assert_ne!( - rpc_cache_file_name(4326, first), - rpc_cache_file_name(4326, "https://rpc.example/key-two?key=one") - ); - assert_ne!( - rpc_cache_file_name(4326, first), - rpc_cache_file_name(4326, "https://rpc.example/key-one?key=two") - ); - assert_eq!( - rpc_cache_file_name(4326, "http://example.com/rpc"), - "rpc-cache-4326-e2afa302.json" - ); - } - #[test] fn test_urls_echoed_in_error_text_are_redacted_through_punctuation() { for text in [ @@ -648,6 +636,12 @@ mod tests { assert!(!name.contains("secret") && !name.contains("alice") && !name.contains("example")); assert_eq!(name, rpc_cache_file_name(4326, "http://example.com/rpc")); assert_ne!(name, rpc_cache_file_name(4326, "http://other.example/rpc")); + assert_ne!(name, rpc_cache_file_name(4326, "http://example.com/another-path")); + assert_ne!(name, rpc_cache_file_name(4326, "http://example.com/rpc?key=one")); + assert_ne!( + rpc_cache_file_name(4326, "http://example.com/rpc?key=one"), + rpc_cache_file_name(4326, "http://example.com/rpc?key=two"), + ); } #[test] diff --git a/bin/mega-evme/src/common/provider/transport.rs b/bin/mega-evme/src/common/provider/transport.rs index 5ba2212e9..ca16415c8 100644 --- a/bin/mega-evme/src/common/provider/transport.rs +++ b/bin/mega-evme/src/common/provider/transport.rs @@ -20,113 +20,97 @@ use serde::{Deserialize, Serialize}; use crate::common::{EvmeError, Result}; -/// HTTP with the same RPC/status handling as alloy's transport, but without URL-bearing -/// tracing spans or reqwest errors. Endpoint paths and queries commonly hold credentials. +/// Hides transport diagnostics only after the dependency has applied its retry policy. +/// The inner future runs without tracing because dependency spans can contain the endpoint URL. #[derive(Clone)] -pub(super) struct RpcHttp { - client: alloy_transport_http::reqwest::Client, - url: alloy_transport_http::reqwest::Url, -} - -impl std::fmt::Debug for RpcHttp { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("RpcHttp") - .field("origin", &super::display_rpc_url(self.url.as_str())) - .finish() - } +pub(super) struct RedactedTransport { + inner: T, + max_retries: u32, } -impl RpcHttp { - pub(super) fn new(url: alloy_transport_http::reqwest::Url) -> Self { - Self { client: alloy_transport_http::reqwest::Client::new(), url } +impl RedactedTransport { + pub(super) fn new(inner: T, max_retries: u32) -> Self { + Self { inner, max_retries } } } -impl tower::Service for RpcHttp { +impl tower::Service for RedactedTransport { type Response = ResponsePacket; type Error = TransportError; type Future = TransportFut<'static>; fn poll_ready( &mut self, - _cx: &mut std::task::Context<'_>, + cx: &mut std::task::Context<'_>, ) -> std::task::Poll> { - std::task::Poll::Ready(Ok(())) + self.inner.poll_ready(cx).map_err(|error| redact_transport_error(error, self.max_retries)) } fn call(&mut self, req: RequestPacket) -> Self::Future { - let this = self.clone(); + use tracing::{instrument::WithSubscriber, subscriber::NoSubscriber}; + + let future = + tracing::subscriber::with_default(NoSubscriber::default(), || self.inner.call(req)); + let max_retries = self.max_retries; Box::pin(async move { - let response = this - .client - .post(this.url) - .json(&req) - .headers(req.headers()) - .send() + let mut response = future + .with_subscriber(NoSubscriber::default()) .await - .map_err(|e| TransportErrorKind::custom(e.without_url()))?; - let status = response.status(); - let body = - response.bytes().await.map_err(|e| TransportErrorKind::custom(e.without_url()))?; - let parsed = serde_json::from_slice::(&body); - if !status.is_success() && !parsed.as_ref().is_ok_and(ResponsePacket::is_error) { - return Err(TransportErrorKind::http_error( - status.as_u16(), - "".to_string(), - )); - } - let mut parsed = parsed.map_err(|error| { - TransportError::deser_err( - // A serde error can quote an offending JSON string, including its URL. - serde_json::Error::io(std::io::Error::new( - std::io::ErrorKind::InvalidData, - format!( - "invalid RPC response at line {}, column {}", - error.line(), - error.column() - ), - )), - "", - ) - })?; - // Preserve successful results verbatim; only errors are displayed as diagnostics. - match &mut parsed { - ResponsePacket::Single(response) => redact_error(response), - ResponsePacket::Batch(responses) => responses.iter_mut().for_each(redact_error), + .map_err(|error| redact_transport_error(error, max_retries))?; + match &mut response { + ResponsePacket::Single(response) => redact_error_response(response), + ResponsePacket::Batch(responses) => { + responses.iter_mut().for_each(redact_error_response) + } } - Ok(parsed) + Ok(response) }) } } -fn redact_error(response: &mut alloy_json_rpc::Response) { +fn redact_error_payload(error: &mut alloy_json_rpc::ErrorPayload) { + error.message = super::redact_rpc_urls_in_text(&error.message).into(); + // Arbitrary error data need not be interpreted or re-serialized for a diagnostic. + // Backoff hints have already been consumed by the inner retry layer. + error.data = None; +} + +fn redact_error_response(response: &mut alloy_json_rpc::Response) { if let alloy_json_rpc::ResponsePayload::Failure(error) = &mut response.payload { - error.message = super::redact_rpc_urls_in_text(&error.message).into(); - if let Some(data) = error.data.take() { - // RawValue accepts values (large numbers or deep nesting) Value cannot represent. - // Omit data we cannot inspect, rather than panic or echo it without redaction. - if let Ok(mut value) = serde_json::from_str::(data.get()) { - redact_error_data(&mut value); - error.data = serde_json::value::to_raw_value(&value).ok(); - } - } + redact_error_payload(error); } } -fn redact_error_data(value: &mut serde_json::Value) { - match value { - serde_json::Value::String(text) => *text = super::redact_rpc_urls_in_text(text), - serde_json::Value::Array(values) => values.iter_mut().for_each(redact_error_data), - serde_json::Value::Object(values) => { - *values = std::mem::take(values) - .into_iter() - .map(|(key, mut value)| { - redact_error_data(&mut value); - (super::redact_rpc_urls_in_text(&key), value) - }) - .collect(); +fn redact_transport_error(error: TransportError, max_retries: u32) -> TransportError { + use alloy_provider::transport::RpcError; + match error { + RpcError::ErrorResp(mut error) => { + redact_error_payload(&mut error); + RpcError::ErrorResp(error) } - _ => {} + RpcError::Transport(TransportErrorKind::Custom(error)) => { + match error.downcast::() { + Ok(error) => TransportErrorKind::custom((*error).without_url()), + Err(error) if error.to_string().starts_with("Max retries exceeded ") => { + TransportErrorKind::custom_str(&format!( + "Max retries exceeded ({max_retries} retries; details redacted)" + )) + } + Err(_) => TransportErrorKind::custom_str("RPC transport error (details redacted)"), + } + } + RpcError::Transport(TransportErrorKind::HttpError(mut error)) => { + error.body = "".to_string(); + RpcError::Transport(TransportErrorKind::HttpError(error)) + } + RpcError::DeserError { err, .. } => RpcError::DeserError { + err: serde_json::Error::io(std::io::Error::new( + std::io::ErrorKind::InvalidData, + format!("invalid RPC response at line {}, column {}", err.line(), err.column()), + )), + text: "".to_string(), + }, + error => error, } } @@ -374,27 +358,6 @@ mod tests { use super::*; - #[test] - fn test_rpc_error_data_that_cannot_be_inspected_is_omitted() { - for data in ["1e400".to_string(), format!("{}0{}", "[".repeat(200), "]".repeat(200))] { - let mut response = alloy_json_rpc::Response { - id: alloy_json_rpc::Id::Number(0), - payload: alloy_json_rpc::ResponsePayload::Failure(alloy_json_rpc::ErrorPayload { - code: -32603, - message: "upstream error".into(), - data: Some(serde_json::value::RawValue::from_string(data).unwrap()), - }), - }; - redact_error(&mut response); - let alloy_json_rpc::ResponsePayload::Failure(error) = response.payload else { - panic!("error") - }; - assert_eq!(error.code, -32603); - assert_eq!(error.message, "upstream error"); - assert!(error.data.is_none()); - } - } - /// The replay transport is always ready. /// Single-request cache misses return a descriptive Custom error (safe because /// the retry layer is never installed on the replay path). diff --git a/bin/mega-evme/src/replay/cmd.rs b/bin/mega-evme/src/replay/cmd.rs index d39eaf8fd..fb2c88a59 100644 --- a/bin/mega-evme/src/replay/cmd.rs +++ b/bin/mega-evme/src/replay/cmd.rs @@ -135,7 +135,8 @@ impl Cmd { /// Without an override this reads the chain id, and, only on a chain that switches engines /// at a scheduled timestamp, the timestamp of the block the replay runs the transaction in, /// from the source the replay itself reads, through a provider that persists nothing: the - /// transaction's block. Pending transactions have no canonical replay context and are refused. + /// transaction's block, or for a pending transaction the latest block. The selected engine + /// decides whether it can replay a pending transaction. /// Under `--genesis` a chain other than the file's is refused /// once the chain id is read, before an engine is picked for it. pub async fn engine(&self) -> Result { @@ -154,7 +155,10 @@ impl Cmd { .map_err(|e| ReplayError::RpcError(format!("Failed to fetch transaction: {e}")))? .ok_or(ReplayError::TransactionNotFound(tx_hash))?; let transport = |e| ReplayError::RpcError(format!("RPC transport error: {e}")); - let number = mined_block_number(tx_hash, tx.block_number)?; + let number = match tx.block_number { + Some(number) => number, + None => provider.get_block_number().await.map_err(transport)?, + }; let timestamp = provider .get_block_by_number(number.into()) .await diff --git a/bin/mega-evme/tests/integration.rs b/bin/mega-evme/tests/integration.rs index 6a07f0416..5d8e9c98b 100644 --- a/bin/mega-evme/tests/integration.rs +++ b/bin/mega-evme/tests/integration.rs @@ -11,6 +11,7 @@ use std::{path::Path, process::Command}; use rstest::rstest; use serde::Deserialize; +use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; /// A test fixture: CLI args + expected JSON output. #[derive(Deserialize)] @@ -336,6 +337,8 @@ fn test_the_rpc_url_userinfo_reaches_no_output() { "http://alice:s3cret@127.0.0.1:9/", "http://alice:s3c@ret@127.0.0.1:9/", "alice:s3cret@127.0.0.1:9", + "http://alice:s3cret@127.0.0.1:9/v2/path-secret?key=query-secret#fragment-secret", + "http://bad host/path-secret?key=query-secret", ] { let output = Command::new(env!("CARGO_BIN_EXE_mega-evme")) .args(["replay", &format!("0x{}", "11".repeat(32)), "--override.spec", "Satin"]) @@ -350,6 +353,93 @@ fn test_the_rpc_url_userinfo_reaches_no_output() { assert_eq!(output.status.code(), Some(1), "{url}: {text}"); assert!(!text.contains("s3c") && !text.contains("ret@"), "{url}: {text}"); assert!(!text.contains("alice"), "{url}: {text}"); + for secret in ["path-secret", "query-secret", "fragment-secret"] { + assert!(!text.contains(secret), "{url}: {text}"); + } + } +} + +#[test] +fn test_a_log_file_creation_failure_filters_the_path() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("\u{1b}[2J\u{202e}missing-parent").join("tool.log"); + let output = Command::new(env!("CARGO_BIN_EXE_mega-evme")) + .env_remove("RUST_LOG") + .arg("--log.no-color") + .args(["run", "0x00", "--spec", "Satin", "-v"]) + .arg("--log.file") + .arg(&path) + .output() + .unwrap(); + assert!(output.status.success()); + let stderr = String::from_utf8(output.stderr).unwrap(); + assert!( + stderr.contains("Failed to create log file") && stderr.contains("tool.log"), + "{stderr}" + ); + assert!(!stderr.contains('\u{202e}') && !stderr.contains('\u{1b}'), "{stderr:?}"); +} + +/// The CLI must also hide raw response diagnostics and dependency spans, on both log writers. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_rpc_response_errors_hide_credentials_in_stderr_and_log_files() { + let server = MockServer::start().await; + let url = format!( + "{}/v2/(path-secret)?key=query-secret#fragment-secret", + server.uri().replacen("http://", "http://alice:userinfo-secret@", 1) + ); + Mock::given(matchers::method("POST")) + .respond_with( + ResponseTemplate::new(503) + .set_body_string(format!("{{\"url\":\"{}\"}}", url.replace('/', "\\/"))), + ) + .mount(&server) + .await; + let dir = tempfile::tempdir().unwrap(); + for to_file in [false, true] { + let path = dir.path().join("rpc.log"); + let before = server.received_requests().await.unwrap().len(); + let mut cmd = Command::new(env!("CARGO_BIN_EXE_mega-evme")); + cmd.env("RUST_LOG", "mega_evme=debug,alloy_transport_http=trace,alloy_transport=trace") + .args([ + "--log.no-color", + "replay", + &format!("0x{}", "11".repeat(32)), + "--override.spec", + "Satin", + ]) + .args([ + "--rpc", + &url, + "--rpc.max-retries", + "1", + "--rpc.backoff-ms", + "1", + "--rpc.no-cache-file", + "-vvvv", + ]); + if to_file { + cmd.arg("--log.file").arg(&path); + } + let output = tokio::task::spawn_blocking(move || cmd.output()).await.unwrap().unwrap(); + assert_eq!(output.status.code(), Some(1)); + assert_eq!(server.received_requests().await.unwrap().len() - before, 2); + let mut text = format!( + "{}{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + if to_file { + text.push_str(&std::fs::read_to_string(&path).unwrap()); + } + assert!( + text.contains("Failed to fetch chain ID") && text.contains("Max retries exceeded"), + "{text}" + ); + for secret in ["alice", "userinfo-secret", "path-secret", "query-secret", "fragment-secret"] + { + assert!(!text.contains(secret), "{text}"); + } } } diff --git a/bin/mega-evme/tests/output_safety.rs b/bin/mega-evme/tests/output_safety.rs deleted file mode 100644 index bd7047e77..000000000 --- a/bin/mega-evme/tests/output_safety.rs +++ /dev/null @@ -1,143 +0,0 @@ -//! Diagnostic output must not render terminal controls or endpoint credentials. - -use std::process::Command; - -use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; - -fn cli() -> Command { - let mut cmd = Command::new(env!("CARGO_BIN_EXE_mega-evme")); - cmd.env_remove("RUST_LOG").arg("--log.no-color"); - cmd -} - -#[test] -fn test_verbose_command_errors_are_filtered_on_stderr_and_in_a_log_file() { - let dir = tempfile::tempdir().unwrap(); - for to_file in [false, true] { - let log = dir.path().join("command.log"); - let mut cmd = cli(); - cmd.args([ - "run", - "0x00", - "--spec", - "Satin", - "--sender.balance", - "1bogus\u{202e}unit", - "-v", - ]); - if to_file { - cmd.arg("--log.file").arg(&log); - } - let output = cmd.output().unwrap(); - assert_eq!(output.status.code(), Some(1)); - let stderr = String::from_utf8(output.stderr).unwrap(); - let logged = if to_file { std::fs::read_to_string(&log).unwrap() } else { stderr.clone() }; - assert!(logged.contains("Error executing command"), "{logged}"); - for text in [&stderr, &logged] { - assert!(!text.contains('\u{202e}') && !text.contains('\u{1b}'), "{text:?}"); - } - } -} - -#[test] -fn test_a_log_file_creation_failure_filters_the_path() { - let dir = tempfile::tempdir().unwrap(); - let path = dir.path().join("\u{1b}[2J\u{202e}missing-parent").join("tool.log"); - let output = cli() - .args(["run", "0x00", "--spec", "Satin", "-v"]) - .arg("--log.file") - .arg(&path) - .output() - .unwrap(); - assert!(output.status.success()); - let stderr = String::from_utf8(output.stderr).unwrap(); - assert!( - stderr.contains("Failed to create log file") && stderr.contains("tool.log"), - "{stderr}" - ); - assert!(!stderr.contains('\u{202e}') && !stderr.contains('\u{1b}'), "{stderr:?}"); -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_endpoint_paths_and_queries_reach_no_diagnostic_output() { - for response_kind in [ - "connection", - "http", - "malformed", - "escaped-http", - "escaped-malformed", - "wrong-type", - "rpc", - "large-number", - "deep-data", - ] { - let server = MockServer::start().await; - let url = if response_kind == "connection" { - "http://alice:userinfo-secret@127.0.0.1:9/v2/(path-secret)?key=query-secret#fragment-secret".to_string() - } else { - format!("{}/v2/(path-secret)?key=query-secret#fragment-secret", server.uri()) - }; - if response_kind != "connection" { - let body = if matches!(response_kind, "large-number" | "deep-data") { - let data = if response_kind == "large-number" { - "1e400".to_string() - } else { - format!("{}\"{url}\"{}", "[".repeat(200), "]".repeat(200)) - }; - format!("{{\"jsonrpc\":\"2.0\",\"id\":0,\"error\":{{\"code\":-32603,\"message\":\"failed\",\"data\":{data}}}}}") - } else if response_kind == "wrong-type" { - serde_json::to_string(&url).unwrap() - } else if matches!(response_kind, "escaped-http" | "escaped-malformed") { - format!("{{\"url\":\"{}\"}}", url.replace('/', "\\/")) - } else if response_kind == "rpc" { - serde_json::json!({"jsonrpc":"2.0", "id":0, "error":{ - "code":-32603, "message":format!("failed {url}"), "data":{(url.clone()):url.clone()} - }}).to_string() - } else { - format!("upstream rejected {url}") - }; - Mock::given(matchers::method("POST")) - .respond_with( - ResponseTemplate::new(if matches!(response_kind, "http" | "escaped-http") { - 503 - } else { - 200 - }) - .set_body_string(body), - ) - .mount(&server) - .await; - } - let dir = tempfile::tempdir().unwrap(); - for to_file in [false, true] { - let log = dir.path().join("rpc.log"); - let mut cmd = cli(); - cmd.env("RUST_LOG", "mega_evme=debug,alloy_transport_http=debug"); - cmd.args(["replay", &format!("0x{}", "11".repeat(32)), "--override.spec", "Satin"]) - .args(["--rpc", &url, "--rpc.max-retries", "0", "--rpc.no-cache-file", "-vvvv"]); - if to_file { - cmd.arg("--log.file").arg(&log); - } - let output = tokio::task::spawn_blocking(move || cmd.output()).await.unwrap().unwrap(); - assert_eq!(output.status.code(), Some(1), "{response_kind}"); - let mut text = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); - if to_file { - text.push_str(&std::fs::read_to_string(&log).unwrap()); - } - assert!(text.contains("Provider mode: online RPC"), "{response_kind}: {text}"); - assert!( - !text.contains("Custom backtrace") && !text.contains("panicked"), - "{response_kind}: {text}" - ); - for secret in - ["path-secret", "query-secret", "fragment-secret", "userinfo-secret", "alice"] - { - assert!(!text.contains(secret), "{response_kind}, {to_file}: {text}"); - } - } - } -} diff --git a/bin/mega-evme/tests/provider.rs b/bin/mega-evme/tests/provider.rs index 9029cab55..c8a10c1db 100644 --- a/bin/mega-evme/tests/provider.rs +++ b/bin/mega-evme/tests/provider.rs @@ -15,7 +15,9 @@ use alloy_primitives::B256; use alloy_provider::Provider; use clap::Parser; use mega_evme::common::{BuildProviderOutput, EvmeError, RpcArgs}; +use rstest::rstest; use tempfile::tempdir; +use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; mod common; use common::{rpc_cache_path, test_rpc_args, test_rpc_args_cached, MockRpcServer}; @@ -162,25 +164,29 @@ async fn test_build_provider_invalid_url() { } } -/// A chain-id failure reports the endpoint without the URL's userinfo. +/// HTTP, response-decoding and JSON-RPC errors hide endpoint credentials echoed by the server. +#[rstest] +#[case::http(500, "failed {rpc}")] +#[case::malformed(200, r#"{"url":"{rpc}"}"#)] +#[case::rpc(200, r#"{"jsonrpc":"2.0","id":0,"error":{"code":-32603,"message":"failed {rpc}","data":{"url":"{rpc}"}}}"#)] #[tokio::test(flavor = "multi_thread")] -async fn test_chain_id_error_omits_rpc_userinfo() { - let server = MockRpcServer::start().await; - server.respond_status_always(500).await; - let url = server.uri().replacen("http://", "http://alice:secret@", 1); - let args = RpcArgs::parse_from([ - "mega-evme", - "--rpc", - &url, - "--rpc.cache-size", - "0", - "--rpc.max-retries", - "0", - ]); - let err = args.build_provider().await.expect_err("chain id fetch fails"); - let msg = err.to_string(); - assert!(msg.contains("Failed to fetch chain ID"), "{msg}"); - assert!(!msg.contains("secret") && !msg.contains("alice"), "{msg}"); +async fn test_chain_id_error_omits_rpc_credentials(#[case] status: u16, #[case] body: &str) { + let server = MockServer::start().await; + let url = format!( + "{}/v2/(path-secret)?key=query-secret#fragment-secret", + server.uri().replacen("http://", "http://alice:userinfo-secret@", 1) + ); + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(status).set_body_string(body.replace("{rpc}", &url))) + .mount(&server) + .await; + let error = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("request fails"); + assert_eq!(server.received_requests().await.unwrap().len(), 1); + let message = error.to_string(); + assert!(message.contains("Failed to fetch chain ID"), "{message}"); + for secret in ["alice", "userinfo-secret", "path-secret", "query-secret", "fragment-secret"] { + assert!(!message.contains(secret), "{message}"); + } } // ─── Chain-id resolution ───────────────────────────────────────────────────── @@ -469,19 +475,34 @@ async fn test_build_provider_auto_creates_cache_dir() { // ─── Retry layer behavior tests ────────────────────────────────────────────── -/// Server fails 503 twice then succeeds; `max-retries=3` must reach success. -/// `eth_chainId` mock at highest priority ensures `build_provider` succeeds. +/// Status errors and nonstandard rate-limit bodies keep the dependency's retry behavior. +#[rstest] +#[case::http_503(503, "temporarily unavailable")] +#[case::bare_429(200, r#"{"code":429,"message":"rate limit"}"#)] +#[case::missing_id(200, r#"{"jsonrpc":"2.0","error":{"code":-32005,"message":"rate limit"}}"#)] #[tokio::test(flavor = "multi_thread")] -async fn test_retry_layer_retries_on_503_then_succeeds() { - let server = MockRpcServer::start().await; - server.respond_eth_chain_id(4326, 1).await; - server.respond_status_n_times(503, 2, 2).await; - server.respond_jsonrpc_result("0x10e6", 3).await; - - let BuildProviderOutput { provider, .. } = - test_rpc_args(&server.uri(), Some(3)).build_provider().await.expect("build_provider"); - let block = provider.get_block_number().await.expect("must succeed after 2 retries"); - assert_eq!(block, 0x10e6); +async fn test_retry_layer_retries_transient_response_then_succeeds( + #[case] status: u16, + #[case] body: &str, +) { + let server = MockServer::start().await; + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(status).set_body_string(body)) + .up_to_n_times(2) + .with_priority(1) + .mount(&server) + .await; + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "jsonrpc":"2.0", "id":0, "result":"0x10e6" + }))) + .with_priority(2) + .mount(&server) + .await; + + let result = test_rpc_args(&server.uri(), Some(3)).build_provider().await; + assert_eq!(server.received_requests().await.unwrap().len(), 3, "{result:?}"); + assert_eq!(result.expect("must succeed after two transient errors").chain_id, 4326); } /// `max-retries=0` must surface the first 503 immediately, with no retries. diff --git a/crates/mega-state-test/AGENTS.md b/crates/mega-state-test/AGENTS.md index 53550061d..52514bc87 100644 --- a/crates/mega-state-test/AGENTS.md +++ b/crates/mega-state-test/AGENTS.md @@ -29,7 +29,7 @@ The fixture types are the revm fork's own (`revm::statetest_types`, the `test-ty - Every failure is a `FailureKind`; equivalence mode names the deviation that explains it, and one it does not name is unattributed. - A deviation lists the exact entries it explains — file, test, data, gas and value indices — with the hashes Satin produces; a failure is its only with those hashes, and `--expect-deviations` requires every listed entry to fail exactly as listed. - Skips mirror the reference runner's, so the executed and skipped counts equal the ones `.github/workflows/exec-spec.yml` pins for it. -- Slow state-test fixtures are identified by their raw content hashes, not their names; the blockchain runner's skips remain separate. +- Historical slow-test filenames do not skip fixtures for the supported forks; the blockchain runner's skips remain separate. - A blockchain test is skipped only for a class decided from its content (`src/blockchain/skips.rs`); a block that differs passes only when a deviation the registry already has lists that test and block with exactly the outcome Satin produces, and the chain is imported on from Satin's state, so a listed block exempts no later one. - An account is taken out of a blockchain test's state root only by `SATIN_ACCOUNTS`, only when the pre-state does not hold it and it holds exactly what the seed or a Satin block put there. diff --git a/crates/mega-state-test/README.md b/crates/mega-state-test/README.md index 682e6c4f4..ef3757d79 100644 --- a/crates/mega-state-test/README.md +++ b/crates/mega-state-test/README.md @@ -45,8 +45,7 @@ The runner takes the vault back out of the post-state only when the fee routing The runner skips what the reference runner skips (`src/skips.rs`), for the same reasons: the EIP-7610 collision fixtures with storage, which revm cannot see, and a transaction that cannot be built when the fixture expects it to be invalid — here only when the fixture names the reason it cannot be, an invalid signature or a blob or EIP-7702 transaction without a recipient. That recipient check also applies after construction when an explicit transaction type bypasses the fixture types' inferred-type guard. -The four known slow fixture names are bound to the raw-file content hashes recorded in `src/skips.rs`, so renaming a known file preserves its skip and replacing its contents does not. -The hashes identify the Cancun files and two older Constantinople variants at `ethereum/legacytests` revision `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`; the pinned Osaka fixture release contains none of them. +Historical slow-test filenames do not exempt Osaka or Amsterdam fixtures from execution. So the two runners execute the same population, and the executed and skipped counts equal the reference runner's. ## Running it @@ -65,12 +64,11 @@ cargo run --release -p state-test -- --mode satin --fork Osaka
/state_test Discovery accepts at most 100,000 fixture files across all input paths and entries at most 64 levels below each input directory. A traversal error or an exceeded limit fails the run; neither a deep subtree nor excess files are silently omitted. -Symlinks to JSON files are accepted; directory symlinks are refused rather than traversed or silently omitted. The state-test runner accepts fixture files up to 64 MiB; the blockchain-test runner accepts up to 256 MiB because a file bundles many block sequences, and the pinned execution-spec fixtures include files around 160 MiB. Both reject oversized files before reading their contents and cap the read itself in case a file grows. -Before materializing a fixture's state or computing its root, the runners require at most 100,000 accounts, 1,000,000 storage slots per account and 1,000,000 slots across the whole state. +Before materializing a fixture's state or computing its root, the runners require at most 100,000 accounts and 1,000,000 storage slots across the whole state. The blockchain runner checks both the fixture's pre-state and its expected post-state, and the witness runner checks its pre-state too. -An exceeded state limit is a fixture error; a truncated state is never used to compute a root. +An exceeded state limit fails the test; a truncated state is never used to compute a root. These are input bounds for the developer tools, separate from the protocol limits on execution. ## The outcome digest diff --git a/crates/mega-state-test/src/blockchain/mod.rs b/crates/mega-state-test/src/blockchain/mod.rs index 7209aebd9..47ed06ab5 100644 --- a/crates/mega-state-test/src/blockchain/mod.rs +++ b/crates/mega-state-test/src/blockchain/mod.rs @@ -708,10 +708,6 @@ fn import_test( witness: Option<(DigestForm, &TestId)>, ) -> Result<(), Failure> { let fixture = |detail: String| Failure::new(FailureKind::Fixture, None, detail); - crate::input::check_state_size(test.pre.values().map(|account| account.storage.len())) - .map_err(|error| fixture(format!("pre-state: {error}")))?; - crate::input::check_state_size(test.post_state.values().map(|account| account.storage.len())) - .map_err(|error| fixture(format!("post-state: {error}")))?; let chain_id = u64::try_from(test.config.chainid) .map_err(|_| fixture(format!("chain id {} does not fit a u64", test.config.chainid)))?; let fraction = test diff --git a/crates/mega-state-test/src/exceptions.rs b/crates/mega-state-test/src/exceptions.rs index 3c8b04618..127ae1af6 100644 --- a/crates/mega-state-test/src/exceptions.rs +++ b/crates/mega-state-test/src/exceptions.rs @@ -93,12 +93,19 @@ pub fn check( /// for a blob or EIP-7702 transaction without a recipient. Empty for anything else. pub fn unbuildable_names(error: &TestError, unit: &TestUnit) -> &'static [&'static str] { let invalid_type = || { - if unit.transaction.max_fee_per_blob_gas.is_some() { - &["TYPE_3_TX_CONTRACT_CREATION"][..] - } else if unit.transaction.authorization_list.is_some() { - &["TYPE_4_TX_CONTRACT_CREATION"][..] - } else { - &[][..] + if unit.transaction.to.is_some() { + return &[][..]; + } + match unit.transaction.tx_type { + Some(3) => &["TYPE_3_TX_CONTRACT_CREATION"][..], + Some(4) => &["TYPE_4_TX_CONTRACT_CREATION"][..], + None if unit.transaction.max_fee_per_blob_gas.is_some() => { + &["TYPE_3_TX_CONTRACT_CREATION"][..] + } + None if unit.transaction.authorization_list.is_some() => { + &["TYPE_4_TX_CONTRACT_CREATION"][..] + } + _ => &[][..], } }; match error { @@ -272,6 +279,12 @@ mod tests { let blob = unit(serde_json::json!({ "maxFeePerBlobGas": "0x01" })); let auth = unit(serde_json::json!({ "authorizationList": [] })); + let explicit_blob = unit(serde_json::json!({ "type": 3 })); + let explicit_auth = unit(serde_json::json!({ "type": 4, "maxFeePerBlobGas": "0x01" })); + let other_type = unit(serde_json::json!({ "type": 2, "maxFeePerBlobGas": "0x01" })); + let call = unit(serde_json::json!({ + "type": 3, "to": "0x0000000000000000000000000000000000000001", + })); for error in [ TestError::InvalidTransactionType, TestError::UnexpectedException { @@ -279,36 +292,42 @@ mod tests { got_exception: Some("Invalid transaction type".into()), }, ] { - assert_eq!( - check_unbuildable( - "TransactionException.TYPE_3_TX_CONTRACT_CREATION", - &error, - &blob - ), - Ok(()) - ); - assert!(check_unbuildable( - "TransactionException.TYPE_4_TX_CONTRACT_CREATION", - &error, - &blob - ) - .is_err()); - assert_eq!( - check_unbuildable( + for transaction in [&blob, &explicit_blob] { + assert_eq!( + check_unbuildable( + "TransactionException.TYPE_3_TX_CONTRACT_CREATION", + &error, + transaction + ), + Ok(()) + ); + assert!(check_unbuildable( "TransactionException.TYPE_4_TX_CONTRACT_CREATION", &error, - &auth - ), - Ok(()) - ); - assert_eq!( - check_unbuildable( - "TransactionException.TYPE_3_TX_CONTRACT_CREATION", - &error, - &plain - ), - Err(Mismatch::Unnamed) - ); + transaction + ) + .is_err()); + } + for transaction in [&auth, &explicit_auth] { + assert_eq!( + check_unbuildable( + "TransactionException.TYPE_4_TX_CONTRACT_CREATION", + &error, + transaction + ), + Ok(()) + ); + } + for transaction in [&plain, &other_type, &call] { + assert_eq!( + check_unbuildable( + "TransactionException.TYPE_3_TX_CONTRACT_CREATION", + &error, + transaction + ), + Err(Mismatch::Unnamed) + ); + } } let overflow = TestError::UnexpectedException { expected_exception: None, diff --git a/crates/mega-state-test/src/input.rs b/crates/mega-state-test/src/input.rs index 1c0bffeef..0a1988cc6 100644 --- a/crates/mega-state-test/src/input.rs +++ b/crates/mega-state-test/src/input.rs @@ -9,22 +9,20 @@ use std::{ use walkdir::WalkDir; /// The largest state-test fixture file the runner reads: 64 MiB. -pub const MAX_FIXTURE_BYTES: u64 = 64 * 1024 * 1024; +const MAX_FIXTURE_BYTES: u64 = 64 * 1024 * 1024; /// The largest blockchain-test fixture file: 256 MiB, accommodating bundled block sequences. -pub const MAX_BLOCKCHAIN_FIXTURE_BYTES: u64 = 256 * 1024 * 1024; +const MAX_BLOCKCHAIN_FIXTURE_BYTES: u64 = 256 * 1024 * 1024; /// The largest collection of JSON files one discovery accepts, across all input paths. -pub const MAX_FIXTURE_FILES: usize = 100_000; +const MAX_FIXTURE_FILES: usize = 100_000; /// The deepest entry discovery accepts, relative to each input directory. -pub const MAX_FIXTURE_DEPTH: usize = 64; +const MAX_FIXTURE_DEPTH: usize = 64; /// The largest state a fixture may materialize, in accounts. -pub const MAX_STATE_ACCOUNTS: usize = 100_000; -/// The largest storage of any one account a fixture may materialize, in slots. -pub const MAX_ACCOUNT_SLOTS: usize = 1_000_000; +const MAX_STATE_ACCOUNTS: usize = 100_000; /// The largest state a fixture may materialize, in storage slots across all accounts. -pub const MAX_STATE_SLOTS: usize = 1_000_000; +const MAX_STATE_SLOTS: usize = 1_000_000; /// Reads a UTF-8 fixture, refusing an oversized file before allocating its contents. -pub fn read_fixture(path: &Path) -> io::Result { +pub(crate) fn read_fixture(path: &Path) -> io::Result { read_with_limit(File::open(path)?, MAX_FIXTURE_BYTES) } @@ -83,15 +81,12 @@ pub fn find_json_files_in_paths(paths: &[PathBuf]) -> io::Result> { } fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) -> io::Result<()> { - if path.metadata()?.is_file() { + let metadata = path + .metadata() + .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display())))?; + if metadata.is_file() { return add_file(path.to_path_buf(), files, limit); } - if path.symlink_metadata()?.file_type().is_symlink() { - return Err(io::Error::new( - io::ErrorKind::InvalidInput, - format!("fixture discovery refuses directory symlink: {}", path.display()), - )); - } for entry in WalkDir::new(path) { let entry = entry?; // WalkDir::max_depth would silently omit descendants, so inspect the first excess entry. @@ -101,22 +96,7 @@ fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) - format!("fixture directory depth exceeds {depth}: {}", entry.path().display()), )); } - let is_file = if entry.file_type().is_symlink() { - let target = entry.path().metadata()?; - if target.is_dir() { - return Err(io::Error::new( - io::ErrorKind::InvalidInput, - format!( - "fixture discovery refuses directory symlink: {}", - entry.path().display() - ), - )); - } - target.is_file() - } else { - entry.file_type().is_file() - }; - if is_file && entry.path().extension().is_some_and(|ext| ext == "json") { + if entry.path().extension().is_some_and(|ext| ext == "json") { add_file(entry.into_path(), files, limit)?; } } @@ -127,7 +107,7 @@ fn add_file(path: PathBuf, files: &mut Vec, limit: usize) -> io::Result if files.len() >= limit { return Err(io::Error::new( io::ErrorKind::InvalidInput, - format!("fixture file count exceeds {limit}"), + format!("fixture file count exceeds {limit}: {}", path.display()), )); } files.push(path); @@ -136,37 +116,17 @@ fn add_file(path: PathBuf, files: &mut Vec, limit: usize) -> io::Result /// Checks account and slot cardinality before copying fixture state or building its tries. pub(crate) fn check_state_size(slot_counts: impl IntoIterator) -> Result<(), String> { - StateLimits { - accounts: MAX_STATE_ACCOUNTS, - account_slots: MAX_ACCOUNT_SLOTS, - slots: MAX_STATE_SLOTS, - } - .check(slot_counts) -} - -struct StateLimits { - accounts: usize, - account_slots: usize, - slots: usize, -} - -impl StateLimits { - fn check(&self, slot_counts: impl IntoIterator) -> Result<(), String> { - let mut total_slots = 0usize; - for (index, slots) in slot_counts.into_iter().enumerate() { - if index >= self.accounts { - return Err(format!("state account count exceeds {}", self.accounts)); - } - if slots > self.account_slots { - return Err(format!("account storage exceeds {} slots", self.account_slots)); - } - total_slots = total_slots - .checked_add(slots) - .filter(|total| *total <= self.slots) - .ok_or_else(|| format!("state storage exceeds {} total slots", self.slots))?; + let mut total_slots = 0usize; + for (index, slots) in slot_counts.into_iter().enumerate() { + if index >= MAX_STATE_ACCOUNTS { + return Err(format!("state account count exceeds {MAX_STATE_ACCOUNTS}")); } - Ok(()) + total_slots = total_slots + .checked_add(slots) + .filter(|total| *total <= MAX_STATE_SLOTS) + .ok_or_else(|| format!("state storage exceeds {MAX_STATE_SLOTS} total slots"))?; } + Ok(()) } #[cfg(test)] @@ -182,8 +142,9 @@ mod tests { std::fs::create_dir(&nested).unwrap(); std::fs::write(nested.join("one.json"), "{}").unwrap(); assert!(discover(root.path(), &mut Vec::new(), 2, 1).is_ok()); - let error = discover(root.path(), &mut Vec::new(), 1, 1).unwrap_err(); - assert!(error.to_string().contains("depth exceeds 1")); + std::fs::create_dir_all(nested.join("b").join("c")).unwrap(); + let error = discover(root.path(), &mut Vec::new(), 2, 1).unwrap_err(); + assert!(error.to_string().contains("depth exceeds 2")); } #[test] @@ -202,35 +163,12 @@ mod tests { #[test] fn test_discovery_propagates_missing_root() { let root = tempfile::tempdir().unwrap(); - assert!(find_json_files(&root.path().join("absent")).is_err()); + let missing = root.path().join("absent"); + let error = find_json_files(&missing).unwrap_err(); + assert!(error.to_string().contains(&missing.display().to_string())); assert!(find_json_files_in_paths(&[root.path().to_path_buf()]).is_err()); } - #[cfg(unix)] - #[test] - fn test_discovery_refuses_a_broken_symlink_root() { - let root = tempfile::tempdir().unwrap(); - let broken = root.path().join("broken"); - std::os::unix::fs::symlink(root.path().join("absent"), &broken).unwrap(); - assert!(discover(&broken, &mut Vec::new(), 4, 4).is_err()); - } - - #[cfg(unix)] - #[test] - fn test_discovery_keeps_json_file_symlinks_and_refuses_directory_symlinks() { - let root = tempfile::tempdir().unwrap(); - let target = root.path().join("source"); - std::fs::write(&target, "{}").unwrap(); - let alias = root.path().join("alias.json"); - std::os::unix::fs::symlink(&target, &alias).unwrap(); - assert_eq!(find_json_files(root.path()).unwrap(), vec![alias]); - let directory = root.path().join("subtree"); - std::os::unix::fs::symlink(root.path(), &directory).unwrap(); - let error = find_json_files(root.path()).unwrap_err(); - assert!(error.to_string().contains("directory symlink")); - assert!(find_json_files(&directory).unwrap_err().to_string().contains("directory symlink")); - } - #[test] fn test_read_limit_accepts_exact_size_and_rejects_one_more_byte() { let mut file = tempfile::tempfile().unwrap(); @@ -250,12 +188,11 @@ mod tests { #[test] fn test_state_limits_accept_boundaries_and_reject_each_dimension() { - let limits = StateLimits { accounts: 2, account_slots: 3, slots: 4 }; - assert!(limits.check([1, 3]).is_ok()); - assert!(limits.check([0, 0, 0]).unwrap_err().contains("account count")); - assert!(limits.check([4]).unwrap_err().contains("account storage")); - assert!(limits.check([2, 3]).unwrap_err().contains("total slots")); - let overflow = StateLimits { accounts: 2, account_slots: usize::MAX, slots: usize::MAX }; - assert!(overflow.check([usize::MAX, 1]).is_err()); + assert!(check_state_size(std::iter::repeat_n(0, MAX_STATE_ACCOUNTS)).is_ok()); + let error = check_state_size(std::iter::repeat_n(0, MAX_STATE_ACCOUNTS + 1)).unwrap_err(); + assert!(error.contains("account count")); + assert!(check_state_size([MAX_STATE_SLOTS / 2, MAX_STATE_SLOTS / 2]).is_ok()); + assert!(check_state_size([MAX_STATE_SLOTS, 1]).unwrap_err().contains("total slots")); + assert!(check_state_size([1, usize::MAX]).is_err()); } } diff --git a/crates/mega-state-test/src/lib.rs b/crates/mega-state-test/src/lib.rs index 75e469cd1..581de0f57 100644 --- a/crates/mega-state-test/src/lib.rs +++ b/crates/mega-state-test/src/lib.rs @@ -28,7 +28,7 @@ pub mod deviations; pub mod digest; pub mod exceptions; mod fork; -pub mod input; +mod input; mod mode; pub mod roots; pub mod runner; diff --git a/crates/mega-state-test/src/runner.rs b/crates/mega-state-test/src/runner.rs index 3ff9473a4..5f22bca66 100644 --- a/crates/mega-state-test/src/runner.rs +++ b/crates/mega-state-test/src/runner.rs @@ -49,7 +49,7 @@ use mega_evm::{ database::{EmptyDB, State}, inspector::{inspectors::TracerEip3155, Inspector, NoOpInspector}, interpreter::interpreter::EthInterpreter, - primitives::{Bytes, TxKind, B256, KECCAK_EMPTY, U256}, + primitives::{Bytes, B256, KECCAK_EMPTY, U256}, DatabaseCommit, ExecuteCommitEvm, }, test_utils::{RecordingDatabase, RecordingEnvFactory, SharedWitnessRecord}, @@ -67,8 +67,8 @@ use crate::{ exceptions::{self, Mismatch}, mode::MAX_BLOBS_PER_TX, roots::{logs_hash, state_root}, - skips::{skip_file, skip_slow_file, SkipReason}, - types::{Test, TestSuite, TestUnit}, + skips::{skip_file, SkipReason}, + types::{Test, TestError, TestSuite, TestUnit}, Fork, Mode, }; @@ -494,7 +494,7 @@ pub fn run_file(path: &Path, config: Config) -> Result, Failure> let suite = serde_json::from_str::(&json) .map_err(|error| Failure::new(FailureKind::Fixture, format!("parse: {error}")))? .0; - let skip = skip_file(&path_str).or_else(|| skip_slow_file(json.as_bytes())); + let skip = skip_file(&path_str); let mut results = Vec::new(); for (name, unit) in &suite.0 { @@ -707,8 +707,6 @@ fn execute_and_check( Err(reason) => return Ok(Some(reason)), }; - crate::input::check_state_size(unit.pre.values().map(|account| account.storage.len())) - .map_err(|error| Failure::new(FailureKind::Fixture, format!("pre-state: {error}")))?; let basefee = block.basefee; let mut state = State::builder().with_cached_prestate(unit.state()).with_bundle_update().build(); @@ -824,7 +822,16 @@ pub(crate) fn prepare( eth_cfg.set_max_blobs_per_tx(MAX_BLOBS_PER_TX); let block = unit.block_env(&mut eth_cfg); - let tx = match (test.tx_env(unit), &test.expect_exception) { + // An explicit type bypasses the fixture types' inferred-type recipient guard. Reject the + // built transaction through the same exception-matching path as an inferred invalid type. + let tx = test.tx_env(unit).and_then(|tx| { + if matches!(tx.tx_type, 3 | 4) && tx.kind.is_create() { + Err(TestError::InvalidTransactionType) + } else { + Ok(tx) + } + }); + let tx = match (tx, &test.expect_exception) { (Ok(tx), _) => tx, (Err(error), Some(expected)) => { return match exceptions::check_unbuildable(expected, &error, unit) { @@ -839,28 +846,8 @@ pub(crate) fn prepare( return Err(Failure::new(FailureKind::Fixture, format!("transaction: {error}"))) } }; - // An explicit type bypasses TransactionParts::tx_type's inferred-type create guard. - // Apply the same rejection to the transaction the fixture types actually built. - let creation_exception: &'static [&'static str] = match (tx.tx_type, tx.kind) { - (3, TxKind::Create) => &["TYPE_3_TX_CONTRACT_CREATION"], - (4, TxKind::Create) => &["TYPE_4_TX_CONTRACT_CREATION"], - _ => &[], - }; - if !creation_exception.is_empty() { - return match &test.expect_exception { - Some(expected) if exceptions::check_names(expected, creation_exception).is_ok() => { - Ok(Err(SkipReason::UnbuildableInvalidTransaction)) - } - Some(expected) => Err(Failure::new( - FailureKind::WrongException, - format!("expected {expected}, rejected as {}", creation_exception[0]), - )), - None => Err(Failure::new( - FailureKind::Fixture, - format!("transaction: {}", creation_exception[0]), - )), - }; - } + crate::input::check_state_size(unit.pre.values().map(|account| account.storage.len())) + .map_err(|error| Failure::new(FailureKind::Fixture, format!("pre-state: {error}")))?; let tx = OpTx(OpTransaction { base: tx, enveloped_tx: Some(Bytes::new()), ..Default::default() }); Ok(Ok(Ready { chain_id, block, tx })) diff --git a/crates/mega-state-test/src/skips.rs b/crates/mega-state-test/src/skips.rs index b302e4bb6..f357e4551 100644 --- a/crates/mega-state-test/src/skips.rs +++ b/crates/mega-state-test/src/skips.rs @@ -5,7 +5,6 @@ //! number for number. Satin inherits every one of the reasons from revm: none of them is a place //! Satin differs from Ethereum, which is what a [deviation](crate::deviations) is. -use mega_evm::revm::primitives::{b256, keccak256, B256}; use serde::Serialize; /// Why a test was not executed. @@ -48,40 +47,8 @@ impl SkipReason { /// The directory of the EIP-7610 collision tests, every one of which collides with storage. const CREATE_COLLISION_DIR: &str = "paris/eip7610_create_collision"; -/// Raw-file identities of the reference runner's four slow fixture names, including the two -/// older variants. These are `ethereum/legacytests` `GeneralStateTests` at -/// `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`: the Cancun files and the two Constantinople files. -/// The byte lengths avoid hashing every unrelated fixture; the hash decides whether to skip. -const SLOW_FILES: [(usize, B256); 6] = [ - // Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json - (21579, b256!("2bf893c9a593ae34e289a8938a57ec2e29ee093e2dfe4f2154dfde2a39775c79")), - // Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json - (10237, b256!("39ee8aaa9d540a9ff4df3b25cee4b85dbb400728b7d9650e19b8277eaf35eaa0")), - // Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json - (9525, b256!("1db1a1c4c8d1ecfab848565dc5d266a9fb60959995d03619e2837a7d863d70fd")), - // Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json - (11751, b256!("9f20d4d227a41fd7caa577612255d013b38d90668971db19f9228e7061be92b4")), - // Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json - (5400, b256!("937c269ce29890164f14617f1da277189d49d4049b63507309479e2b29d36346")), - // Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json - (5290, b256!("2e2d37b3c3ed48c2da697e2a443d653b300b4aee7d7c56da8d9eff30dc49b93d")), -]; - -/// Whether `contents` is one of the reference runner's known slow fixtures, independent of its -/// file name. A different file that borrows a slow fixture's name must still execute. -pub fn skip_slow_file(contents: &[u8]) -> Option { - if !SLOW_FILES.iter().any(|(size, _)| *size == contents.len()) { - return None; - } - let hash = keccak256(contents); - SLOW_FILES - .iter() - .any(|(size, known)| *size == contents.len() && *known == hash) - .then_some(SkipReason::Slow) -} - /// Whether the file at `path` is skipped whole, and why: the reference runner's list, file for -/// file, except that slow fixtures are identified by [`skip_slow_file`] from their content. +/// file. pub fn skip_file(path: &str) -> Option { if path.replace('\\', "/").contains(CREATE_COLLISION_DIR) { return Some(SkipReason::CreateCollisionWithStorage); @@ -127,7 +94,14 @@ mod tests { Some(SkipReason::CreateCollisionWithStorage) ); assert_eq!(skip_file("a/ValueOverflow.json"), Some(SkipReason::MalformedValue)); - assert_eq!(skip_file("a/loopMul.json"), None); + for name in [ + "Call50000_sha256.json", + "static_Call50000_sha256.json", + "loopMul.json", + "CALLBlake2f_MaxRounds.json", + ] { + assert_eq!(skip_file(name), None); + } assert_eq!(skip_file("a/xloopMul.json"), None); assert_eq!(skip_file("a/loopMul.json.bak"), None); assert_eq!(skip_file("osaka/eip7951_p256verify_precompiles/test_valid.json"), None); @@ -139,30 +113,4 @@ mod tests { let names: std::collections::BTreeSet<_> = SkipReason::ALL.map(SkipReason::name).into(); assert_eq!(names.len(), SkipReason::ALL.len()); } - - /// The checked-in files retain their upstream bytes, so this catches a wrong pin as well as - /// a regression to matching the filename or accepting edited content. - #[test] - fn test_pinned_slow_fixtures_follow_content_when_renamed_and_reject_edits() { - let files: &[&[u8]] = &[ - include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json"), - include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json"), - include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json"), - include_bytes!("../tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json"), - include_bytes!("../tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json"), - include_bytes!("../tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json"), - ]; - assert_eq!(files.len(), SLOW_FILES.len(), "exercise every pinned content identity"); - for bytes in files { - assert_eq!(skip_slow_file(bytes), Some(SkipReason::Slow)); - let renamed = "renamed-fixture.json"; - assert_eq!( - skip_file(renamed).or_else(|| skip_slow_file(bytes)), - Some(SkipReason::Slow) - ); - let mut edited = bytes.to_vec(); - edited[0] ^= 1; - assert_eq!(skip_slow_file(&edited), None, "same-length content edits must execute"); - } - } } diff --git a/crates/mega-state-test/src/witness.rs b/crates/mega-state-test/src/witness.rs index 8bc81f92c..96d82bdd8 100644 --- a/crates/mega-state-test/src/witness.rs +++ b/crates/mega-state-test/src/witness.rs @@ -140,7 +140,6 @@ pub fn check_replay( Err(reason) => return Ok(Replayed::Skipped(reason)), }; - crate::input::check_state_size(unit.pre.values().map(|account| account.storage.len()))?; let record = SharedWitnessRecord::default(); let recorded = run( mode, diff --git a/crates/mega-state-test/tests/blockchain.rs b/crates/mega-state-test/tests/blockchain.rs index c46a66133..2621483bb 100644 --- a/crates/mega-state-test/tests/blockchain.rs +++ b/crates/mega-state-test/tests/blockchain.rs @@ -443,6 +443,39 @@ fn test_a_chain_filled_from_ethereum_passes() { .all(|p| !p.contains("executed"))); } +#[test] +fn test_oversized_fixture_fails_before_parsing() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("oversized.json"); + std::fs::File::create(&path).unwrap().set_len(256 * 1024 * 1024 + 1).unwrap(); + let failure = state_test::blockchain::run_file(&path, config(&[])).unwrap_err(); + assert_eq!(failure.kind, FailureKind::Fixture); + assert!(failure.detail.contains("exceeds 268435456 bytes"), "{failure:?}"); +} + +/// Input-state bounds reject the whole fixture before materialization or root construction. +#[test] +fn test_wide_pre_and_post_states_fail_instead_of_hashing_partial_state() { + let clean = chain(&[BlockSpec::valid(vec![])]); + assert_eq!(outcome(&run_one(clean.clone())), &Outcome::Passed); + for (field, label) in [("pre", "pre-state"), ("postState", "post-state")] { + let mut test = clean.clone(); + let accounts = (0..=100_000) + .map(|index| (format!("0x{index:040x}"), account(U256::ZERO, "0x", 0))) + .collect(); + test[field] = Value::Object(accounts); + let report = run_one(test); + let Outcome::Failed(failure) = outcome(&report) else { + panic!("oversized {label} was accepted: {report:?}") + }; + assert_eq!(failure.kind, FailureKind::Fixture); + assert!( + failure.detail.contains(&format!("{label}: state account count exceeds")), + "{failure:?}" + ); + } +} + /// A block the fixture expects to be invalid for its nonce is refused for that reason, and the /// chain stays at the previous block: the fixture's last block and post-state are the first /// block's. diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json deleted file mode 100644 index 250076b2f..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/VMTests/vmPerformance/loopMul.json +++ /dev/null @@ -1,257 +0,0 @@ -{ - "loopMul" : { - "_info" : { - "comment" : "Ori Pomerantz qbzzt1@gmail.com", - "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", - "filling-tool-version" : "retesteth-0.3.2-cancun+commit.021b8dfd.Linux.g++", - "generatedTestHash" : "ac4b25eb17aff99ce8fc3c8f3489aa3c8d3742bff57bc17110cb11671dcdde0e", - "labels" : { - "0" : "add-10M", - "1" : "divadd-10M", - "2" : "mulmod-2M" - }, - "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", - "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", - "source" : "src/GeneralStateTestsFiller/VMTests/vmPerformance/loopMulFiller.yml", - "sourceHash" : "a26434ba94c8763c9e3f5593af7f924c2652f0a1dc2242c87100e0bfe09ba168" - }, - "env" : { - "currentBaseFee" : "0x0a", - "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x020000", - "currentExcessBlobGas" : "0x00", - "currentGasLimit" : "0x7fffffffffffffff", - "currentNumber" : "0x01", - "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", - "currentTimestamp" : "0x03e8" - }, - "post" : { - "Berlin" : [ - { - "hash" : "0x751df352e4a7d5a36c7edd2e692ebf2f9895fc32d376520810ccf0f9e1a07172", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0xf64f3960665c922e7fbb52182073b45ae7d0e0904aa4ea7d0fcdc8611aa74f48", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0x3161388f9c3e0d6fbd283ad9224be8cc1736ba0a2582110576be4e64d5abe459", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ], - "Cancun" : [ - { - "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ], - "Istanbul" : [ - { - "hash" : "0x919e0e3eba9736de6345243d9fae413910c5861ed5d396ef01f1930e9df91740", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0xd82016b4a51a4f830d7dfa20270b384215c69d88cb21a4ba98bb63f1588fef05", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0xe7a99e585fe86edde8fd96e85cf759b40460b2bc8a1c133fd058c4c133f8ca54", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ], - "London" : [ - { - "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ], - "Paris" : [ - { - "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ], - "Shanghai" : [ - { - "hash" : "0x58983db6d4517a9fd671d4f2d646f99d837f0f6e58347ad0dca8f8193f3ea8a2", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ca800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b864c4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf50100000000000000000000000000000000000000000000000000000000009896801ca08a7c05b7e7c1f7e12f9bdfe00f6a30776f978ccb79875aa504e1eca871e59d64a0104545b5ce4795b9d4398058650189209854641f3f1f183e4e318aa41704ae98" - }, - { - "hash" : "0x7309359062a36eacfd4fa6f668e222ebe35e759f28be7cf8c6e4e49abb07f5b5", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88459e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff000000000000000000000000000000000000000000000000000000000000009896801ba0650cf298f339bee60c1c150bcb6cf3f1174e90c539843e4be6ff4b2dbd639937a06204660931c9f99cdf0ad36cf587281839cbb6c24efb630c3378bb229603c6d1" - }, - { - "hash" : "0x600f7064ca69b5a7fee1181ff64708332f84acade128335f9e2c8985cfb06ae1", - "indexes" : { - "data" : 2, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf8ea800a887fffffffffffffff94cccccccccccccccccccccccccccccccccccccccc80b88415d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e84801ca06368792390f8ea16f2392fb5166884f061ae4ada88292842b97c6cbc232fe709a04308f5703284115cea86857d04ab8b99f7722b4ce597bf7bbe9dd84f77a2f72c" - } - ] - }, - "pre" : { - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x7fffffffffffffff00", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "0xcccccccccccccccccccccccccccccccccccccccc" : { - "balance" : "0x0ba1a9ce0ba1a9ce", - "code" : "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806315d423271461005157806359e3e1ea14610081578063c4f8b9fb146100b1578063e01330bb146100e1575b600080fd5b61006b60048036038101906100669190610268565b610111565b60405161007891906102de565b60405180910390f35b61009b60048036038101906100969190610268565b61015e565b6040516100a891906102de565b60405180910390f35b6100cb60048036038101906100c691906102f9565b6101b3565b6040516100d891906102de565b60405180910390f35b6100fb60048036038101906100f691906102f9565b6101f0565b60405161010891906102de565b60405180910390f35b60008085905060005b8381101561014a5784806101315761013061034c565b5b868309915060018161014391906103aa565b905061011a565b508060008190555080915050949350505050565b60008085905060005b8381101561019f57858261017b91906103de565b9150848261018991906103aa565b915060018161019891906103aa565b9050610167565b508060008190555080915050949350505050565b60008084905060005b838110156101dd5784820191506001816101d691906103aa565b90506101bc565b5080600081905550809150509392505050565b60008084905060005b8381101561021a57848202915060018161021391906103aa565b90506101f9565b5080600081905550809150509392505050565b600080fd5b6000819050919050565b61024581610232565b811461025057600080fd5b50565b6000813590506102628161023c565b92915050565b600080600080608085870312156102825761028161022d565b5b600061029087828801610253565b94505060206102a187828801610253565b93505060406102b287828801610253565b92505060606102c387828801610253565b91505092959194509250565b6102d881610232565b82525050565b60006020820190506102f360008301846102cf565b92915050565b6000806000606084860312156103125761031161022d565b5b600061032086828701610253565b935050602061033186828701610253565b925050604061034286828701610253565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103b582610232565b91506103c083610232565b92508282019050808211156103d8576103d761037b565b5b92915050565b60006103e982610232565b91506103f483610232565b9250826104045761040361034c565b5b82820490509291505056fea264697066735822122068e1b815c01e7140e2ba71cdc985de077b5af76a27ae9139fee87f708e3dc41864736f6c63430008150033", - "nonce" : "0x01", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0xc4f8b9fb8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5018edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5010000000000000000000000000000000000000000000000000000000000989680", - "0x59e3e1ea8edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffaaffffffffffffffffbbffffffffffffff00000000000000000000000000000000000000000000000000000000000000989680", - "0x15d423278edad8b55b1586805ea8c245d8c16b06a5102b791fc6eb60693731c0677bf5011c68db1c179cd35ab3fc60c63704aa7fcbea40f19782b1611aaba86726a7686cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000001e8480" - ], - "gasLimit" : [ - "0x7fffffffffffffff" - ], - "gasPrice" : "0x0a", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0xcccccccccccccccccccccccccccccccccccccccc", - "value" : [ - "0x00" - ] - } - } -} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json deleted file mode 100644 index 8847ff9f7..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "Call50000_sha256" : { - "_info" : { - "comment" : "", - "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", - "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", - "generatedTestHash" : "1ba3a2f9e77a0e7fd56065a03bd06937c302b71ee9c4304c3c429c49c6a1262e", - "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", - "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", - "source" : "src/GeneralStateTestsFiller/stQuadraticComplexityTest/Call50000_sha256Filler.json", - "sourceHash" : "c89657175c195cf1d15d69c3df40b2090a606fedebac17732d531360cb579528" - }, - "env" : { - "currentBaseFee" : "0x0a", - "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "currentDifficulty" : "0x020000", - "currentExcessBlobGas" : "0x00", - "currentGasLimit" : "0xe9f2bf40", - "currentNumber" : "0x01", - "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", - "currentTimestamp" : "0x03e8" - }, - "post" : { - "Berlin" : [ - { - "hash" : "0x125a127cd275c6afb98c12cfd10bfd894282215636e0be99a763984d26dce68a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x0d39e570f98fce02a7240124f0cceef1e6b26e86024d24275b94272436782d52", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ], - "Cancun" : [ - { - "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ], - "Istanbul" : [ - { - "hash" : "0x125a127cd275c6afb98c12cfd10bfd894282215636e0be99a763984d26dce68a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x0d39e570f98fce02a7240124f0cceef1e6b26e86024d24275b94272436782d52", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ], - "London" : [ - { - "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ], - "Paris" : [ - { - "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ], - "Shanghai" : [ - { - "hash" : "0xbaa915a9c9d1f8d850c7710ae3a24677716de3016ecf13e3598793de3f60788a", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf861800a840ee6b28094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0462186579a4be0ad8a63224059a11693b4c0684b9939f6c2394d1fbe045275f2a059d73f99e037295a5f8c0e656acdb5c8b9acd28ec73c320c277df61f2e2d54f9" - }, - { - "hash" : "0x09879d303324495ac64046ebc9b7af04682a656314e19432a883cd4551b7ffa6", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf860800a830249f094bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba06843bbbe573744c46cf47f1c126c11a53cffa1bcc3eeb0e0d328e6a73ecc5447a02062c2fbb34bfea606f3cf268b5a94a81d68e748d4d896c514061c03e8acb774" - } - ] - }, - "pre" : { - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0xffffffffffffffffffffffffffffffff", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602d576000600061c35060006001600262013178f16000556001608051016080526000565b60805160015500", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0x" - ], - "gasLimit" : [ - "0x0249f0", - "0x0ee6b280" - ], - "gasPrice" : "0x0a", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : [ - "0x0a" - ] - } - } -} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json deleted file mode 100644 index 581c48cd2..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "CALLBlake2f_MaxRounds" : { - "_info" : { - "comment" : "currentGasLimit is > trGaslimit because when run as a blockchain transaction comes within the block#1 which can has less gasLimit than genesis", - "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", - "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", - "generatedTestHash" : "92d6d2c0b59e9684e2a1893aeee014a3a7bbf25a4cfaf9b4c938be318bd1e486", - "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", - "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", - "source" : "src/GeneralStateTestsFiller/stTimeConsuming/CALLBlake2f_MaxRoundsFiller.json", - "sourceHash" : "2dc49ff1ebbf07bf10cc6c32b001dd39f6b33d242123c0bd0d3523b9f9ad81f2" - }, - "env" : { - "currentBaseFee" : "0x0a", - "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x020000", - "currentExcessBlobGas" : "0x00", - "currentGasLimit" : "0x0254a47a80", - "currentNumber" : "0x01", - "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", - "currentTimestamp" : "0x03e8" - }, - "post" : { - "Berlin" : [ - { - "hash" : "0x569311304bd15c83986e123c9ebb1d8af2348bb6a9358986237287ebf2eb966d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ], - "Cancun" : [ - { - "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ], - "Istanbul" : [ - { - "hash" : "0xcc6960984c3702d7760244701aaee6e343afc5ff4b5587b7e10562c71b844ae6", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ], - "London" : [ - { - "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ], - "Paris" : [ - { - "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ], - "Shanghai" : [ - { - "hash" : "0xf324c3351e5fa633e4ae2317ec68acd6650fe87df3dbd2760741081da0bd9670", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf90138800a8502540be40094100000000000000000000000000000000000000080b8d5ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011ba0302aed232e0a310edd38ed159758fb8f4c32407763deddde991ab3c0a77a42d3a029c4350773c8cf8ec6d1859332c6bf6345b00d7ccc7f5ae823b003bf7cc750b5" - } - ] - }, - "pre" : { - "0x1000000000000000000000000000000000000000" : { - "balance" : "0x00", - "code" : "0x36600060003760406103e8366000600060095af16001556103e8516002556104085160035500", - "nonce" : "0x00", - "storage" : { - } - }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x3635c9adc5dea00000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0xffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001" - ], - "gasLimit" : [ - "0x02540be400" - ], - "gasPrice" : "0x0a", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0x1000000000000000000000000000000000000000", - "value" : [ - "0x00" - ] - } - } -} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json deleted file mode 100644 index 023e357aa..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Cancun/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json +++ /dev/null @@ -1,205 +0,0 @@ -{ - "static_Call50000_sha256" : { - "_info" : { - "comment" : "", - "filling-rpc-server" : "evm version 1.13.11-unstable-765f2904-20240124", - "filling-tool-version" : "retesteth-0.3.2-cancun+commit.ea13235b.Linux.g++", - "generatedTestHash" : "32924a7a3b6e5fee383d4d6b1905934b06adf41ce460be9dcbe79af2945ee72c", - "lllcversion" : "Version: 0.5.14-develop.2023.7.11+commit.c58ab2c6.mod.Linux.g++", - "solidity" : "Version: 0.8.21+commit.d9974bed.Linux.g++", - "source" : "src/GeneralStateTestsFiller/stTimeConsuming/static_Call50000_sha256Filler.json", - "sourceHash" : "a78222cbabf8f2683ff00446b9208cf2c2c0347415ee8dc7891997a8a2c0f422" - }, - "env" : { - "currentBaseFee" : "0x0a", - "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "currentDifficulty" : "0x020000", - "currentExcessBlobGas" : "0x00", - "currentGasLimit" : "0x09237b7880", - "currentNumber" : "0x01", - "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", - "currentTimestamp" : "0x03e8" - }, - "post" : { - "Berlin" : [ - { - "hash" : "0xf591a379eee0b124fc34c66ff5987c70dae30af9d0a5d2875e2532904e5cce7b", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0x71109a01177322cf7c1284efa1174169f297ec52c5d3d61c4b08ee84fb8d252d", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ], - "Cancun" : [ - { - "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ], - "Istanbul" : [ - { - "hash" : "0x3dcc46e694eaf2287adfdeeb9cdf06c2f434b4cecf1f83461b529ac0f05ba84c", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0xe6f8e443c1036537138bdeffacd400a5a63e2283beda6b62c570ca1f1b1458cf", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ], - "London" : [ - { - "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ], - "Paris" : [ - { - "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ], - "Shanghai" : [ - { - "hash" : "0xeaa13fc03ed3face9ef1dfff23dfb67941aa18eedce17997e3c33a445e25ac3d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0f6ff161c8a1e7aee0627569354baeb1466aeda5c2594621cf0a4f7e3c316508ea016853ae60d1819a733888504687b4f844fbf56682aad6bf1932b8883fbccfb5e" - }, - { - "hash" : "0xadc3ed68166c4fa4ad29862654683394dc613fb47446b39b6cd8d7b6e8a0331f", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "txbytes" : "0xf881800a84e9f2bf409410000000000000000000000000000000000000000aa0000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b1ba0e9fdda6ed4379767508dedfc02ea1e6d71a02037556b72676b9d25235f4ff7e1a07560e92292e977106fa1aee44e37d1635db0df4d2e54bb0c90ac0999c58ce021" - } - ] - }, - "pre" : { - "0x1000000000000000000000000000000000000000" : { - "balance" : "0x00", - "code" : "0x6000600060006000346000355af1600055600160015500", - "nonce" : "0x00", - "storage" : { - } - }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0xffffffffffffffffffffffffffffffff", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000556001608051016080526000565b60805160015500", - "nonce" : "0x00", - "storage" : { - } - }, - "0xcccf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000526001608051016080526000565b60805160205200", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0x000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b" - ], - "gasLimit" : [ - "0xe9f2bf40" - ], - "gasPrice" : "0x0a", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0x1000000000000000000000000000000000000000", - "value" : [ - "0x0a" - ] - } - } -} \ No newline at end of file diff --git a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json deleted file mode 100644 index a36df2253..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stQuadraticComplexityTest/Call50000_sha256.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "Call50000_sha256" : { - "_info" : { - "comment" : "", - "filledwith" : "testeth 1.7.0-alpha.0+commit.2b11ce5c", - "lllcversion" : "Version: 0.5.0-develop.2018.11.9+commit.9709dfe0.Linux.g++", - "source" : "src/GeneralStateTestsFiller/stQuadraticComplexityTest/Call50000_sha256Filler.json", - "sourceHash" : "691a51cf9afec00db3f8756def0c9abb3429ac1e142c4788dc8798a23ff029f4" - }, - "env" : { - "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "currentDifficulty" : "0x020000", - "currentGasLimit" : "0xe9f2bf40", - "currentNumber" : "0x01", - "currentTimestamp" : "0x03e8", - "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "post" : { - "Byzantium" : [ - { - "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ], - "Constantinople" : [ - { - "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ], - "ConstantinopleFix" : [ - { - "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ], - "Homestead" : [ - { - "hash" : "0xd145456acb4bde15a5465e1eae80bbb67f01113a8efc6b0cbe5cba4a04318885", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x6c436e76d01c619063be64d44041e66a4390fc121940151088c4ee78a89fa2b2", - "indexes" : { - "data" : 0, - "gas" : 1, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - }, - "pre" : { - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0xffffffffffffffffffffffffffffffff", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602d576000600061c35060006001600262013178f16000556001608051016080526000565b608051600155", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0x" - ], - "gasLimit" : [ - "0x0249f0", - "0x0ee6b280" - ], - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : [ - "0x0a" - ] - } - } -} diff --git a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json b/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json deleted file mode 100644 index ea5534ff1..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/Constantinople/GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "static_Call50000_sha256" : { - "_info" : { - "comment" : "", - "filledwith" : "testeth 1.7.0-alpha.0+commit.2b11ce5c", - "lllcversion" : "Version: 0.5.0-develop.2018.11.9+commit.9709dfe0.Linux.g++", - "source" : "src/GeneralStateTestsFiller/stTimeConsuming/static_Call50000_sha256Filler.json", - "sourceHash" : "0b9d3b0f98ca3f190a564dac1fa0c832ad11f812b37fb5223c0abfe1b242aee9" - }, - "env" : { - "currentCoinbase" : "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "currentDifficulty" : "0x020000", - "currentGasLimit" : "0x09237b7880", - "currentNumber" : "0x01", - "currentTimestamp" : "0x03e8", - "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "post" : { - "Byzantium" : [ - { - "hash" : "0xaf00fbc3ebd221608c528fe17d937e0fe5d2ba954bfc81e5e13167b21aeaa27d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ], - "Constantinople" : [ - { - "hash" : "0x7428351b6625e7da42f0cc8684542fdb38dbd887c689c7541ae2385e086f98a5", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ], - "ConstantinopleFix" : [ - { - "hash" : "0xaf00fbc3ebd221608c528fe17d937e0fe5d2ba954bfc81e5e13167b21aeaa27d", - "indexes" : { - "data" : 0, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "hash" : "0x8952830477bfcf66f7fdf134884f209728e591666336e55700f994e76b5b3b16", - "indexes" : { - "data" : 1, - "gas" : 0, - "value" : 0 - }, - "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - }, - "pre" : { - "0x1000000000000000000000000000000000000000" : { - "balance" : "0x00", - "code" : "0x6000600060006000346000355af16000555a600155", - "nonce" : "0x00", - "storage" : { - } - }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0xffffffffffffffffffffffffffffffff", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000556001608051016080526000565b608051600155", - "nonce" : "0x00", - "storage" : { - } - }, - "0xcccf5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0fffffffffffff", - "code" : "0x5b61c3506080511015602b576000600061c3506000600262013178fa6000526001608051016080526000565b608051602052", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "0x000000000000000000000000bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x000000000000000000000000cccf5374fce5edbc8e2a8697c15331677e6ebf0b" - ], - "gasLimit" : [ - "0xe9f2bf40" - ], - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "sender" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "to" : "0x1000000000000000000000000000000000000000", - "value" : [ - "0x0a" - ] - } - } -} diff --git a/crates/mega-state-test/tests/fixtures/slow/LICENSE b/crates/mega-state-test/tests/fixtures/slow/LICENSE deleted file mode 100644 index 65f52d6f5..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2014 Ethereum Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/crates/mega-state-test/tests/fixtures/slow/README.md b/crates/mega-state-test/tests/fixtures/slow/README.md deleted file mode 100644 index 99064b08e..000000000 --- a/crates/mega-state-test/tests/fixtures/slow/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Slow fixture identities - -These six files are copied byte for byte from [`ethereum/legacytests` at `1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb`](https://github.com/ethereum/legacytests/tree/1f581b8ccdc4c63acf5f2c5c1b155c690c32a8eb), with their upstream paths retained. -They cover the four slow state-test names the reference runner skips, including the two older Constantinople variants. -They are test data for the content-hash skip policy, not execution inputs to the Satin gate. -Keep their original bytes: formatting them changes the identities being tested. - -The upstream MIT license and Ethereum Foundation copyright notice are reproduced in [LICENSE](LICENSE). diff --git a/crates/mega-state-test/tests/input_limits.rs b/crates/mega-state-test/tests/input_limits.rs deleted file mode 100644 index d3c54dff1..000000000 --- a/crates/mega-state-test/tests/input_limits.rs +++ /dev/null @@ -1,148 +0,0 @@ -//! Input limits refuse whole fixtures rather than reporting a partial corpus or state as valid. - -use std::fs::File; - -use state_test::{ - blockchain, - input::{find_json_files, MAX_BLOCKCHAIN_FIXTURE_BYTES, MAX_FIXTURE_BYTES, MAX_FIXTURE_DEPTH}, - runner, Fork, Mode, -}; - -#[test] -fn test_both_runners_refuse_oversized_files_before_parsing() { - let root = tempfile::tempdir().unwrap(); - let path = root.path().join("oversized.json"); - File::create(&path).unwrap().set_len(MAX_FIXTURE_BYTES + 1).unwrap(); - - let failure = runner::run_file( - &path, - runner::Config { - mode: Mode::Equivalence, - fork: Fork::Osaka, - threads: 1, - json_outcome: false, - trace: false, - digest: None, - witness: None, - limits: None, - deviations: &[], - }, - ) - .unwrap_err(); - assert_eq!(failure.kind, runner::FailureKind::Fixture); - assert!(failure.detail.contains("exceeds 67108864 bytes"), "{failure:?}"); - File::create(&path).unwrap().set_len(MAX_BLOCKCHAIN_FIXTURE_BYTES + 1).unwrap(); - let failure = blockchain::run_file( - &path, - blockchain::Config { threads: 1, json_outcome: false, witness: None, deviations: &[] }, - ) - .unwrap_err(); - assert_eq!(failure.kind, blockchain::FailureKind::Fixture); - assert!(failure.detail.contains("exceeds 268435456 bytes"), "{failure:?}"); -} - -#[test] -fn test_discovery_refuses_excessive_depth_even_without_json_below_it() { - let root = tempfile::tempdir().unwrap(); - std::fs::write(root.path().join("visible.json"), "{}").unwrap(); - let mut nested = root.path().to_path_buf(); - for _ in 0..MAX_FIXTURE_DEPTH { - nested.push("d"); - } - std::fs::create_dir_all(&nested).unwrap(); - assert_eq!(find_json_files(root.path()).unwrap().len(), 1); - std::fs::create_dir(nested.join("one-too-deep")).unwrap(); - let error = find_json_files(root.path()).unwrap_err(); - assert!(error.to_string().contains("depth exceeds 64"), "{error}"); -} - -/// A compact but over-wide state stays below the byte limit; cardinality must reject it. -fn oversized_state() -> String { - let mut state = String::from("{"); - for index in 0..=state_test::input::MAX_STATE_ACCOUNTS { - if index != 0 { - state.push(','); - } - state.push_str(&format!( - "\"0x{index:040x}\":{{\"balance\":\"0x0\",\"code\":\"0x\",\"nonce\":\"0x0\",\"storage\":{{}}}}" - )); - } - state.push('}'); - assert!(state.len() < MAX_FIXTURE_BYTES as usize); - state -} - -#[test] -fn test_state_runner_rejects_wide_prestate_before_materializing_or_hashing_it() { - let root = tempfile::tempdir().unwrap(); - let path = root.path().join("wide.json"); - let fixture = format!( - r#"{{"wide":{{ - "env":{{"currentCoinbase":"0x0000000000000000000000000000000000000000", - "currentGasLimit":"0x1000000","currentNumber":"0x1","currentTimestamp":"0x1", - "currentBaseFee":"0x7","currentRandom":"0x0000000000000000000000000000000000000000000000000000000000000000", - "currentExcessBlobGas":"0x0"}}, - "pre":{}, - "transaction":{{"data":["0x"],"gasLimit":["0x5208"],"gasPrice":"0xa", - "nonce":"0x0","secretKey":"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to":"0x0000000000000000000000000000000000000001","value":["0x0"]}}, - "post":{{"Osaka":[{{"indexes":{{"data":0,"gas":0,"value":0}}, - "hash":"0x0000000000000000000000000000000000000000000000000000000000000000", - "logs":"0x0000000000000000000000000000000000000000000000000000000000000000"}}]}} - }}}}"#, - oversized_state() - ); - std::fs::write(&path, fixture).unwrap(); - let results = runner::run_file( - &path, - runner::Config { - mode: Mode::Equivalence, - fork: Fork::Osaka, - threads: 1, - json_outcome: false, - trace: false, - digest: None, - witness: None, - limits: None, - deviations: &[], - }, - ) - .unwrap(); - let [result] = &results[..] else { panic!("expected one result") }; - let runner::Outcome::Failed(failure) = &result.outcome else { - panic!("oversized pre-state was accepted: {:?}", result.outcome) - }; - assert_eq!(failure.kind, runner::FailureKind::Fixture); - assert!(failure.detail.contains("pre-state: state account count exceeds"), "{failure:?}"); -} - -#[test] -fn test_blockchain_runner_rejects_wide_pre_and_post_states_before_hashing() { - let root = tempfile::tempdir().unwrap(); - let path = root.path().join("wide.json"); - let state = oversized_state(); - for (pre, post, label) in [(&*state, "{}", "pre-state"), ("{}", &*state, "post-state")] { - let fixture = format!( - r#"{{"wide":{{"network":"Osaka","genesisRLP":"0x","blocks":[], - "pre":{pre},"postState":{post}, - "lastblockhash":"0x0000000000000000000000000000000000000000000000000000000000000000", - "config":{{"chainid":"0x1","blobSchedule":{{"Osaka":{{"baseFeeUpdateFraction":"0x1"}}}}}} - }}}}"# - ); - std::fs::write(&path, fixture).unwrap(); - let results = blockchain::run_file( - &path, - blockchain::Config { threads: 1, json_outcome: false, witness: None, deviations: &[] }, - ) - .unwrap(); - let [result] = &results[..] else { panic!("expected one result") }; - let blockchain::Outcome::Failed(failure) = &result.outcome else { - panic!("oversized {label} was accepted: {:?}", result.outcome) - }; - assert_eq!(failure.kind, blockchain::FailureKind::Fixture); - assert!( - failure.detail.contains(&format!("{label}: state account count exceeds")), - "{failure:?}" - ); - } -} diff --git a/crates/mega-state-test/tests/runner.rs b/crates/mega-state-test/tests/runner.rs index 6d1bf8382..2c2c6e3e8 100644 --- a/crates/mega-state-test/tests/runner.rs +++ b/crates/mega-state-test/tests/runner.rs @@ -271,7 +271,7 @@ fn test_what_is_counted_and_what_is_skipped() { json!("TransactionException.INTRINSIC_GAS_TOO_LOW"); let others = write( dir.path(), - "o.json", + "loopMul.json", json!({ "a_both": both, "b_expected_invalid": expected_invalid, @@ -331,62 +331,6 @@ fn test_explicit_blob_and_authorization_creates_are_rejected_for_the_named_reaso } } -/// The inferred forms keep the same expected-invalid handling as their explicit counterparts. -#[test] -fn test_inferred_blob_and_authorization_creates_keep_their_expected_invalid_skips() { - let dir = tempfile::tempdir().unwrap(); - for (fields, exception) in [ - (json!({ "maxFeePerBlobGas": "0x01", "to": "" }), "TYPE_3_TX_CONTRACT_CREATION"), - (json!({ "authorizationList": [], "to": "" }), "TYPE_4_TX_CONTRACT_CREATION"), - ] { - let mut expected = unit(&[Fork::Osaka], fields); - expected["post"]["Osaka"][0]["expectException"] = - json!(format!("TransactionException.{exception}")); - let path = write(dir.path(), "inferred.json", json!({ "invalid": expected })); - let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); - assert_eq!( - outcomes(&report), - [&Outcome::Skipped { reason: SkipReason::UnbuildableInvalidTransaction }] - ); - } -} - -/// Reject the wide public fixture value before `block_env` attempts its panicking conversion, -/// even when the transaction itself is expected to be invalid. -#[test] -fn test_excess_blob_gas_overflow_is_a_fixture_failure_instead_of_a_panic() { - let dir = tempfile::tempdir().unwrap(); - let mut wide = unit(&[Fork::Osaka], json!({})); - wide["env"]["currentExcessBlobGas"] = json!("0x10000000000000000"); - wide["post"]["Osaka"][0]["expectException"] = - json!("TransactionException.INVALID_SIGNATURE_VRS"); - let path = write(dir.path(), "wide.json", json!({ "wide": wide })); - let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); - let Outcome::Failed(failure) = &report.results[0].outcome else { - panic!("must reject fixture") - }; - assert_eq!(failure.kind, FailureKind::Fixture); - assert!(failure.detail.contains("currentExcessBlobGas")); - assert!(failure.detail.contains("u64")); -} - -/// A borrowed slow-test basename does not exempt unrelated fixture content from execution. -#[test] -fn test_slow_test_names_do_not_skip_replacement_content() { - let dir = tempfile::tempdir().unwrap(); - let fixture = fill_from_ethereum(unit(&[Fork::Osaka], json!({}))); - for name in [ - "Call50000_sha256.json", - "static_Call50000_sha256.json", - "loopMul.json", - "CALLBlake2f_MaxRounds.json", - ] { - let path = write(dir.path(), name, json!({ "replacement": fixture })); - let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); - assert_eq!(outcomes(&report), [&Outcome::Passed], "{name}"); - } -} - /// A test name that appears twice in a file fails the file, rather than the second test silently /// replacing the first. #[test] @@ -405,17 +349,22 @@ fn test_a_duplicate_test_name_fails_the_file() { ); } -/// A file that cannot be parsed is a failure of the run, not a set of skipped tests. +/// A malformed or oversized file fails the gate instead of becoming a set of skipped tests. #[test] fn test_an_unreadable_file_fails_the_gate() { let dir = tempfile::tempdir().unwrap(); - let path = write(dir.path(), "broken.json", json!({ "t": { "env": {} } })); - let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); - assert!(report.results.is_empty()); - assert_eq!(report.file_failures.len(), 1); - let summary = report.summary(); - assert_eq!((summary.file_failures, summary.defined), (1, 0)); - assert_eq!(report.gate(None, None, false), ["1 fixture files could not be read"]); + let broken = write(dir.path(), "broken.json", json!({ "t": { "env": {} } })); + let oversized = dir.path().join("oversized.json"); + std::fs::File::create(&oversized).unwrap().set_len(64 * 1024 * 1024 + 1).unwrap(); + for (path, detail) in [(broken, "parse:"), (oversized, "exceeds 67108864 bytes")] { + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + assert!(report.results.is_empty()); + assert_eq!(report.file_failures.len(), 1); + assert!(report.file_failures[0].1.detail.contains(detail), "{:?}", report.file_failures); + let summary = report.summary(); + assert_eq!((summary.file_failures, summary.defined), (1, 0)); + assert_eq!(report.gate(None, None, false), ["1 fixture files could not be read"]); + } } /// The base-fee vault Satin credits is taken back only when the fee routing made it: a vault the @@ -431,25 +380,58 @@ fn test_the_fee_vault_is_taken_back_only_when_the_routing_made_it() { assert_eq!(failure_kind(outcomes(&report)[0]), Some(FailureKind::StateRootMismatch)); } -/// A chain id that does not fit a `u64`, and a fixture value the transaction builder cannot take, -/// fail the test they belong to and nothing else. +/// Chain-id and blob-gas values wider than `u64`, and a value the transaction builder cannot +/// take, fail only the test they belong to. #[test] fn test_bad_fixture_values_fail_their_own_test() { let dir = tempfile::tempdir().unwrap(); let good = fill_from_ethereum(unit(&[Fork::Osaka], json!({}))); let mut chain = good.clone(); chain["env"]["currentChainID"] = json!("0x010000000000000000"); + let mut blob = good.clone(); + blob["env"]["currentExcessBlobGas"] = json!("0x010000000000000000"); + blob["post"]["Osaka"][0]["expectException"] = + json!("TransactionException.INVALID_SIGNATURE_VRS"); let fee = unit( &[Fork::Osaka], // One more than `u128::MAX`, which the fixture types' transaction builder refuses with a // panic rather than an error. json!({ "maxFeePerGas": "0x0a", "maxPriorityFeePerGas": "0x0100000000000000000000000000000000" }), ); - let path = - write(dir.path(), "a.json", json!({ "a_chain": chain, "b_fee": fee, "c_good": good })); + let path = write( + dir.path(), + "a.json", + json!({ + "a_chain": chain, "b_blob": blob, "c_fee": fee, "d_good": good, + }), + ); let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); let kinds: Vec<_> = outcomes(&report).into_iter().map(failure_kind).collect(); - assert_eq!(kinds, [Some(FailureKind::Fixture), Some(FailureKind::Panic), None]); + assert_eq!( + kinds, + [Some(FailureKind::Fixture), Some(FailureKind::Fixture), Some(FailureKind::Panic), None] + ); + let Outcome::Failed(blob) = &report.results[1].outcome else { panic!("must reject blob gas") }; + assert!(blob.detail.contains("currentExcessBlobGas")); +} + +/// A compact state can fit the input-byte bound and still exceed the account bound. It must +/// fail before the runner copies it into a database or computes a state root from it. +#[test] +fn test_wide_prestate_is_rejected_before_materializing_it() { + let dir = tempfile::tempdir().unwrap(); + let mut wide = unit(&[Fork::Osaka], json!({})); + let account = json!({ "balance": "0x0", "code": "0x", "nonce": "0x0", "storage": {} }); + wide["pre"] = Value::Object( + (0..=100_000).map(|index| (format!("0x{index:040x}"), account.clone())).collect(), + ); + let path = write(dir.path(), "wide.json", json!({ "wide": wide })); + assert!(std::fs::metadata(&path).unwrap().len() < 64 * 1024 * 1024); + let report = run(&[path], config(Mode::Equivalence, Fork::Osaka)); + let [result] = &report.results[..] else { panic!("must exercise one fixture entry") }; + let Outcome::Failed(failure) = &result.outcome else { panic!("must reject oversized state") }; + assert_eq!(failure.kind, FailureKind::Fixture); + assert!(failure.detail.contains("pre-state: state account count exceeds"), "{failure:?}"); } /// A registry of one Osaka deviation listing every failure of `report`, in the file at `path` diff --git a/crates/mega-state-test/tests/witness.rs b/crates/mega-state-test/tests/witness.rs index 6cd3f19ca..45028143d 100644 --- a/crates/mega-state-test/tests/witness.rs +++ b/crates/mega-state-test/tests/witness.rs @@ -140,7 +140,7 @@ fn test_a_sample_of_the_fixtures_replays_from_its_witness() { let (mut both, mut record_only, mut skipped, mut failed) = (0, 0, 0, Vec::new()); for path in &sampled { - let json = state_test::input::read_fixture(path).expect("a readable fixture"); + let json = std::fs::read_to_string(path).expect("a readable fixture"); let suite: TestSuite = match serde_json::from_str(&json) { Ok(suite) => suite, Err(error) => { diff --git a/crates/state-test/tests/cli.rs b/crates/state-test/tests/cli.rs index a979e0271..6f4f93eb7 100644 --- a/crates/state-test/tests/cli.rs +++ b/crates/state-test/tests/cli.rs @@ -527,3 +527,35 @@ fn test_btest_bad_arguments_exit_non_zero() { std::fs::write(dir.path().join("broken.json"), "{").unwrap(); assert_eq!(btest(&[], dir.path()).status.code(), Some(1), "an unreadable fixture"); } + +fn check_discovery_depth(args: &[&str]) { + let root = tempfile::tempdir().unwrap(); + std::fs::write(root.path().join("visible.json"), "{}").unwrap(); + let mut nested = root.path().to_path_buf(); + for _ in 0..63 { + nested.push("d"); + } + std::fs::create_dir_all(&nested).unwrap(); + std::fs::write(nested.join("boundary.json"), "{}").unwrap(); + let run = || state_test(args, root.path()); + let boundary = run(); + assert!(boundary.status.success(), "{}", String::from_utf8_lossy(&boundary.stderr)); + assert!(String::from_utf8_lossy(&boundary.stdout).contains("2 files")); + + nested.push("one-too-deep"); + std::fs::create_dir(&nested).unwrap(); + std::fs::write(nested.join("hidden.json"), "{}").unwrap(); + let output = run(); + assert!(!output.status.success(), "deep fixture tree was accepted"); + assert!(String::from_utf8_lossy(&output.stderr).contains("depth exceeds 64")); +} + +#[test] +fn test_state_cli_refuses_excessive_fixture_depth() { + check_discovery_depth(&["--fork", "Osaka"]); +} + +#[test] +fn test_blockchain_cli_refuses_excessive_fixture_depth() { + check_discovery_depth(&["btest"]); +} diff --git a/crates/state-test/tests/input_discovery.rs b/crates/state-test/tests/input_discovery.rs deleted file mode 100644 index 6169c3281..000000000 --- a/crates/state-test/tests/input_discovery.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Discovery limits must fail the CLI rather than execute an incomplete collection. - -use std::process::Command; - -fn check_discovery_depth(args: &[&str]) { - let root = tempfile::tempdir().unwrap(); - std::fs::write(root.path().join("visible.json"), "{}").unwrap(); - let mut nested = root.path().to_path_buf(); - for _ in 0..63 { - nested.push("d"); - } - std::fs::create_dir_all(&nested).unwrap(); - std::fs::write(nested.join("boundary.json"), "{}").unwrap(); - let run = || { - Command::new(env!("CARGO_BIN_EXE_state-test")).args(args).arg(root.path()).output().unwrap() - }; - let boundary = run(); - assert!(boundary.status.success(), "{}", String::from_utf8_lossy(&boundary.stderr)); - assert!(String::from_utf8_lossy(&boundary.stdout).contains("2 files")); - - nested.push("one-too-deep"); - std::fs::create_dir(&nested).unwrap(); - std::fs::write(nested.join("hidden.json"), "{}").unwrap(); - let output = run(); - assert!(!output.status.success(), "deep fixture tree was accepted"); - assert!(String::from_utf8_lossy(&output.stderr).contains("depth exceeds 64")); -} - -#[test] -fn test_state_cli_refuses_excessive_fixture_depth() { - check_discovery_depth(&["--fork", "Osaka"]); -} - -#[test] -fn test_blockchain_cli_refuses_excessive_fixture_depth() { - check_discovery_depth(&["btest"]); -} From d761e1482374a11dfe3adf9eaf006ea599c82804 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:05:47 +0800 Subject: [PATCH 05/12] fix(evme): redact scheme-less and encoded RPC URL echoes in error payloads --- bin/mega-evme/src/common/provider/mod.rs | 184 +++++++++++++++++- .../src/common/provider/transport.rs | 42 ++-- bin/mega-evme/tests/provider.rs | 96 +++++++++ .../configuration/state-management.md | 2 +- docs/mega-evme/overview.md | 6 +- 5 files changed, 304 insertions(+), 26 deletions(-) diff --git a/bin/mega-evme/src/common/provider/mod.rs b/bin/mega-evme/src/common/provider/mod.rs index 6ec6bd142..3cb01f653 100644 --- a/bin/mega-evme/src/common/provider/mod.rs +++ b/bin/mega-evme/src/common/provider/mod.rs @@ -18,6 +18,7 @@ mod transport; use std::{ fs, path::{Path, PathBuf}, + sync::Arc, }; use alloy_provider::{ @@ -394,8 +395,8 @@ impl RpcArgs { } /// Build an `RpcClient` over an arbitrary transport, wired with the configured - /// retry layer (or bare when `max_retries == 0`). `url` is used only to detect - /// whether the endpoint is local. + /// retry layer (or bare when `max_retries == 0`). `url` is used to detect whether + /// the endpoint is local and to redact configured URL components from server errors. fn build_client( &self, transport: T, @@ -404,6 +405,7 @@ impl RpcArgs { let is_local = url.host_str().is_some_and(|h| h == "localhost" || h == "127.0.0.1" || h == "::1"); let max_retries = self.max_retries; + let secrets = Arc::new(EndpointSecrets::from_url(url)); if self.max_retries > 0 { let policy = RateLimitRetryPolicy::default().or(|err: &TransportError| { matches!(err, RpcError::Transport(TransportErrorKind::Custom(_))) @@ -416,13 +418,13 @@ impl RpcArgs { ); ClientBuilder::default() .layer(tower::layer::layer_fn(move |inner| { - RedactedTransport::new(inner, max_retries) + RedactedTransport::new(inner, max_retries, Arc::clone(&secrets)) })) .layer(retry) .transport(transport, is_local) } else { ClientBuilder::default() - .transport(RedactedTransport::new(transport, max_retries), is_local) + .transport(RedactedTransport::new(transport, max_retries, secrets), is_local) } } @@ -502,20 +504,186 @@ pub(crate) fn display_rpc_url(raw: &str) -> String { .map_or_else(|| "".to_string(), |url| url.origin().ascii_serialization()) } +/// Credential-bearing components of the configured RPC endpoint URL (raw and percent-decoded). +/// +/// Used by [`RedactedTransport`] to detect when a server JSON-RPC error echoes the endpoint's +/// userinfo, non-root path, query, or fragment without a full `scheme://` URL. +#[derive(Debug, Clone)] +pub(super) struct EndpointSecrets { + needles: Vec, +} + +impl EndpointSecrets { + fn from_url(url: &alloy_transport_http::reqwest::Url) -> Self { + let mut needles = Vec::new(); + let mut push = |raw: &str, decode_plus: bool| { + let push_one = |list: &mut Vec, candidate: String| { + if !candidate.is_empty() && candidate != "/" && !list.contains(&candidate) { + list.push(candidate); + } + }; + push_one(&mut needles, raw.to_string()); + push_one(&mut needles, percent_decode_lossy(raw, decode_plus)); + }; + + push(url.username(), false); + if let Some(password) = url.password() { + push(password, false); + } + let path = url.path(); + if !path.is_empty() && path != "/" { + push(path, false); + let trimmed_end = path.trim_end_matches('/'); + if trimmed_end != path { + push(trimmed_end, false); + } + let trimmed_start = trimmed_end.trim_start_matches('/'); + if trimmed_start != trimmed_end { + push(trimmed_start, false); + } + } + if let Some(query) = url.query() { + push(query, true); + for pair in query.split('&') { + push(pair, true); + } + } + if let Some(fragment) = url.fragment() { + push(fragment, false); + } + Self { needles } + } + + fn matches(&self, text: &str) -> bool { + if self.needles.is_empty() { + return false; + } + let unescaped = unescape_json_ascii_escapes(text); + let decoded = percent_decode_lossy(text, false); + let decoded_plus = text.contains('+').then(|| percent_decode_lossy(text, true)); + let unescaped_decoded = percent_decode_lossy(&unescaped, false); + self.needles.iter().any(|needle| { + text.contains(needle) || + unescaped.contains(needle) || + decoded.contains(needle) || + decoded_plus.as_deref().is_some_and(|s| s.contains(needle)) || + unescaped_decoded.contains(needle) + }) + } +} + +/// Percent-decodes `%XX` sequences in `input` (and `+` to space when `decode_plus` is true). +/// Malformed `%` sequences are kept verbatim; non-UTF-8 byte sequences are decoded lossily. +fn percent_decode_lossy(input: &str, decode_plus: bool) -> String { + let bytes = input.as_bytes(); + let mut out = Vec::with_capacity(bytes.len()); + let mut i = 0; + while i < bytes.len() { + if bytes[i] == b'%' && i + 2 < bytes.len() { + if let (Some(hi), Some(lo)) = (hex_nibble(bytes[i + 1]), hex_nibble(bytes[i + 2])) { + out.push((hi << 4) | lo); + i += 3; + continue; + } + } else if decode_plus && bytes[i] == b'+' { + out.push(b' '); + i += 1; + continue; + } + out.push(bytes[i]); + i += 1; + } + String::from_utf8_lossy(&out).into_owned() +} + +fn hex_nibble(byte: u8) -> Option { + match byte { + b'0'..=b'9' => Some(byte - b'0'), + b'a'..=b'f' => Some(byte - b'a' + 10), + b'A'..=b'F' => Some(byte - b'A' + 10), + _ => None, + } +} + +/// Unescapes JSON-style `\/` (including repeated backslashes before `/`) and ASCII `\u00XX` +/// escapes so serialized URLs or paths embedded in a server error string are matched against +/// configured endpoint components. +fn unescape_json_ascii_escapes(input: &str) -> String { + let bytes = input.as_bytes(); + let mut out = Vec::with_capacity(bytes.len()); + let mut i = 0; + while i < bytes.len() { + if bytes[i] == b'\\' && i + 1 < bytes.len() { + let mut end = i; + while end < bytes.len() && bytes[end] == b'\\' { + end += 1; + } + if end < bytes.len() && bytes[end] == b'/' { + out.push(b'/'); + i = end + 1; + continue; + } + if bytes[i + 1] == b'u' && + i + 5 < bytes.len() && + bytes[i + 2] == b'0' && + bytes[i + 3] == b'0' + { + if let (Some(hi), Some(lo)) = (hex_nibble(bytes[i + 4]), hex_nibble(bytes[i + 5])) { + let ch = (hi << 4) | lo; + if ch.is_ascii() { + out.push(ch); + i += 6; + continue; + } + } + } + } + out.push(bytes[i]); + i += 1; + } + String::from_utf8_lossy(&out).into_owned() +} + +/// Redacts server-provided JSON-RPC error messages. +/// +/// If the message echoes any secret-bearing component of the configured endpoint URL (even without +/// a scheme, percent-encoded, or JSON-escaped), the entire server message is replaced with a safe +/// placeholder while the JSON-RPC error code is preserved by the caller. Otherwise, any absolute +/// URLs embedded in the text are redacted. +pub(super) fn redact_rpc_error_message(text: &str, secrets: &EndpointSecrets) -> String { + if secrets.matches(text) { + return "".to_string(); + } + redact_rpc_urls_in_text(text) +} + +/// Finds the earliest `://`, JSON-escaped `:\/`, or percent-encoded `%3A%2F%2F` scheme separator. +fn find_scheme_separator(text: &str) -> Option<(usize, usize, bool)> { + let plain = text.find("://").map(|at| (at, 3, true)); + let escaped = text.find(r":\/\/").map(|at| (at, 5, false)); + let encoded = text.to_ascii_lowercase().find("%3a%2f%2f").map(|at| (at, 9, false)); + [plain, escaped, encoded].into_iter().flatten().min_by_key(|(at, _, _)| *at) +} + /// Redacts URLs echoed by RPC errors, without changing successful RPC results. fn redact_rpc_urls_in_text(text: &str) -> String { let mut out = String::with_capacity(text.len()); let mut rest = text; - while let Some(colon) = rest.find("://") { + while let Some((colon, sep_len, is_plain)) = find_scheme_separator(rest) { let start = rest[..colon] .rfind(|c: char| !c.is_ascii_alphanumeric() && !matches!(c, '+' | '-' | '.')) .map_or(0, |at| at + rest[at..].chars().next().expect("a character").len_utf8()); // Punctuation can be part of a credential-bearing path or query. Consume the whole // non-whitespace token, including surrounding punctuation if present, to fail closed. - let end = - rest[colon + 3..].find(char::is_whitespace).map_or(rest.len(), |at| colon + 3 + at); + let end = rest[colon + sep_len..] + .find(char::is_whitespace) + .map_or(rest.len(), |at| colon + sep_len + at); out.push_str(&rest[..start]); - out.push_str(&display_rpc_url(&rest[start..end])); + if is_plain { + out.push_str(&display_rpc_url(&rest[start..end])); + } else { + out.push_str(""); + } rest = &rest[end..]; } out.push_str(rest); diff --git a/bin/mega-evme/src/common/provider/transport.rs b/bin/mega-evme/src/common/provider/transport.rs index ca16415c8..7978c0a98 100644 --- a/bin/mega-evme/src/common/provider/transport.rs +++ b/bin/mega-evme/src/common/provider/transport.rs @@ -26,11 +26,12 @@ use crate::common::{EvmeError, Result}; pub(super) struct RedactedTransport { inner: T, max_retries: u32, + secrets: Arc, } impl RedactedTransport { - pub(super) fn new(inner: T, max_retries: u32) -> Self { - Self { inner, max_retries } + pub(super) fn new(inner: T, max_retries: u32, secrets: Arc) -> Self { + Self { inner, max_retries, secrets } } } @@ -43,7 +44,9 @@ impl tower::Service for Red &mut self, cx: &mut std::task::Context<'_>, ) -> std::task::Poll> { - self.inner.poll_ready(cx).map_err(|error| redact_transport_error(error, self.max_retries)) + self.inner + .poll_ready(cx) + .map_err(|error| redact_transport_error(error, self.max_retries, &self.secrets)) } fn call(&mut self, req: RequestPacket) -> Self::Future { @@ -52,40 +55,51 @@ impl tower::Service for Red let future = tracing::subscriber::with_default(NoSubscriber::default(), || self.inner.call(req)); let max_retries = self.max_retries; + let secrets = Arc::clone(&self.secrets); Box::pin(async move { let mut response = future .with_subscriber(NoSubscriber::default()) .await - .map_err(|error| redact_transport_error(error, max_retries))?; + .map_err(|error| redact_transport_error(error, max_retries, &secrets))?; match &mut response { - ResponsePacket::Single(response) => redact_error_response(response), - ResponsePacket::Batch(responses) => { - responses.iter_mut().for_each(redact_error_response) - } + ResponsePacket::Single(response) => redact_error_response(response, &secrets), + ResponsePacket::Batch(responses) => responses + .iter_mut() + .for_each(|response| redact_error_response(response, &secrets)), } Ok(response) }) } } -fn redact_error_payload(error: &mut alloy_json_rpc::ErrorPayload) { - error.message = super::redact_rpc_urls_in_text(&error.message).into(); +fn redact_error_payload( + error: &mut alloy_json_rpc::ErrorPayload, + secrets: &super::EndpointSecrets, +) { + error.message = super::redact_rpc_error_message(&error.message, secrets).into(); // Arbitrary error data need not be interpreted or re-serialized for a diagnostic. // Backoff hints have already been consumed by the inner retry layer. error.data = None; } -fn redact_error_response(response: &mut alloy_json_rpc::Response) { +fn redact_error_response( + response: &mut alloy_json_rpc::Response, + secrets: &super::EndpointSecrets, +) { if let alloy_json_rpc::ResponsePayload::Failure(error) = &mut response.payload { - redact_error_payload(error); + redact_error_payload(error, secrets); } } -fn redact_transport_error(error: TransportError, max_retries: u32) -> TransportError { +fn redact_transport_error( + error: TransportError, + max_retries: u32, + secrets: &super::EndpointSecrets, +) -> TransportError { use alloy_provider::transport::RpcError; match error { RpcError::ErrorResp(mut error) => { - redact_error_payload(&mut error); + redact_error_payload(&mut error, secrets); RpcError::ErrorResp(error) } RpcError::Transport(TransportErrorKind::Custom(error)) => { diff --git a/bin/mega-evme/tests/provider.rs b/bin/mega-evme/tests/provider.rs index c8a10c1db..6dd680d31 100644 --- a/bin/mega-evme/tests/provider.rs +++ b/bin/mega-evme/tests/provider.rs @@ -189,6 +189,102 @@ async fn test_chain_id_error_omits_rpc_credentials(#[case] status: u16, #[case] } } +/// JSON-RPC errors that echo configured endpoint components without a scheme, percent-encoded, +/// or with JSON-escaped separators must never leak those secrets while keeping the error code. +#[rstest] +#[case::schemeless_path("unauthorized request to /v2/path-secret")] +#[case::host_and_path("upstream {host}/v2/path-secret?key=query-secret refused")] +#[case::query_key("invalid query parameter key=query-secret")] +#[case::userinfo("authentication failed for alice:userinfo-secret")] +#[case::fragment("unexpected fragment fragment-secret")] +#[case::percent_encoded_url( + "bad upstream http%3A%2F%2F{host}%2Fv2%2Fpath-secret%3Fkey%3Dquery-secret" +)] +#[case::percent_encoded_path("unauthorized %2Fv2%2Fpath-secret")] +#[case::escaped_separator_configured( + r#"{"url":"http:\/\/alice:userinfo-secret@{host}\/v2\/path-secret?key=query-secret"}"# +)] +#[case::escaped_separator_other(r#"{"upstream":"https:\/\/other.example\/v2\/other-secret"}"#)] +#[tokio::test(flavor = "multi_thread")] +async fn test_chain_id_error_redacts_schemeless_and_encoded_echo(#[case] server_msg: &str) { + let server = MockServer::start().await; + let host = server.uri().strip_prefix("http://").unwrap().to_string(); + let url = format!( + "{}/v2/path-secret?key=query-secret#fragment-secret", + server.uri().replacen("http://", "http://alice:userinfo-secret@", 1) + ); + let rendered_msg = server_msg.replace("{host}", &host); + let body = serde_json::json!({ + "jsonrpc": "2.0", + "id": 0, + "error": { "code": -32000, "message": rendered_msg }, + }); + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(body)) + .mount(&server) + .await; + let error = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("request fails"); + assert_eq!(server.received_requests().await.unwrap().len(), 1); + let message = error.to_string(); + assert!(message.contains("Failed to fetch chain ID"), "{message}"); + assert!(message.contains("-32000"), "JSON-RPC error code must be preserved: {message}"); + for secret in [ + "alice", + "userinfo-secret", + "path-secret", + "query-secret", + "fragment-secret", + "other-secret", + ] { + assert!(!message.contains(secret), "secret {secret:?} leaked in: {message}"); + } +} + +/// Percent-decoded endpoint components (such as a path containing spaces) echoed by the server +/// are also redacted, while an ordinary unrelated error message is preserved. +#[tokio::test(flavor = "multi_thread")] +async fn test_chain_id_error_redacts_percent_decoded_echo_and_keeps_safe_message() { + let server = MockServer::start().await; + let host = server.uri().strip_prefix("http://").unwrap().to_string(); + let url = format!("{}/v2/my%20key-secret?x=tail-secret", server.uri()); + + // Echoing the space-decoded path leaks `key-secret` and `tail-secret` if URL scanning stops + // at whitespace or only checks raw percent-encoded components. + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "jsonrpc": "2.0", + "id": 0, + "error": { + "code": -32001, + "message": format!("bad upstream http://{host}/v2/my key-secret?x=tail-secret"), + }, + }))) + .up_to_n_times(1) + .with_priority(1) + .mount(&server) + .await; + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "jsonrpc": "2.0", + "id": 0, + "error": { "code": -32601, "message": "method not found" }, + }))) + .with_priority(2) + .mount(&server) + .await; + + let leaked = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("echo fails"); + let leaked_msg = leaked.to_string(); + assert!(leaked_msg.contains("-32001"), "{leaked_msg}"); + for secret in ["key-secret", "tail-secret"] { + assert!(!leaked_msg.contains(secret), "secret {secret:?} leaked in: {leaked_msg}"); + } + + let safe = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("safe error fails"); + let safe_msg = safe.to_string(); + assert!(safe_msg.contains("-32601") && safe_msg.contains("method not found"), "{safe_msg}"); +} + // ─── Chain-id resolution ───────────────────────────────────────────────────── /// `build_provider` must call `eth_chainId` against the endpoint, name the diff --git a/docs/mega-evme/configuration/state-management.md b/docs/mega-evme/configuration/state-management.md index a69b568fa..1ba534312 100644 --- a/docs/mega-evme/configuration/state-management.md +++ b/docs/mega-evme/configuration/state-management.md @@ -227,7 +227,7 @@ When using fork mode, `mega-evme` caches RPC responses to avoid redundant networ These options take effect only when an RPC endpoint is actually contacted: on `run` and `tx` that requires `--fork` (without `--fork` they are accepted but silently ignored); on `replay` they apply to its `--rpc` fetches (an offline `--rpc.replay-file` run contacts no endpoint and does not use them). -On Satin, RPC URL diagnostics show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs echoed in HTTP errors. +On Satin, RPC URL diagnostics show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs (plain, percent-encoded, or escaped) and scheme-less echoes of the configured URL's components in HTTP and JSON-RPC error messages (preserving the JSON-RPC error code). This applies to verbose logs and log files as well as stderr. ### Per-Endpoint Cache Files diff --git a/docs/mega-evme/overview.md b/docs/mega-evme/overview.md index 05b52fedc..c93d74e65 100644 --- a/docs/mega-evme/overview.md +++ b/docs/mega-evme/overview.md @@ -110,10 +110,10 @@ Text a person reads on a terminal is filtered: escape sequences, control charact This covers error lines and a transaction's revert reason. `--json` output is not filtered: a JSON string carries the same characters, escaped. -The URL given to `--rpc` is written to no log line, error or cache file name with its userinfo (`user:password@`). -The userinfo is the part of the authority before its last `@`, and it is removed from a URL written without its scheme too. -A credential anywhere else in the URL, such as an API key in the path or the query, is not recognised and is printed with the URL. +On Satin, `--rpc` diagnostics (logs, errors, and `--log.file`) show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs or configured endpoint components echoed in server error messages. +Per-endpoint cache file names hash the URL with userinfo removed so endpoints with different paths or queries stay separate without placing the URL in the file name. The URL has to start with `http://` or `https://`. +On the legacy 1.7.1 engine, only userinfo is stripped from cache names and `--rpc` diagnostics are unchanged from 1.7.1. ## Read more From c4983b93a38c68719301de2d181f4818cb032682 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:05:48 +0800 Subject: [PATCH 06/12] fix(evme): bind Satin replay pre-state reads to verified canonical parent hash --- bin/mega-evme/AGENTS.md | 4 +- bin/mega-evme/src/common/state.rs | 16 +++- bin/mega-evme/src/replay/cmd.rs | 19 +++- bin/mega-evme/tests/replay_paths.rs | 137 +++++++++++++++++++++++++++- docs/mega-evme/commands/replay.md | 5 +- 5 files changed, 166 insertions(+), 15 deletions(-) diff --git a/bin/mega-evme/AGENTS.md b/bin/mega-evme/AGENTS.md index b4cccbbc9..b62577e48 100644 --- a/bin/mega-evme/AGENTS.md +++ b/bin/mega-evme/AGENTS.md @@ -24,12 +24,12 @@ Two engines: the in-tree sources run Satin; a spec from `Equivalence` to `Rex6` - Logging is structured via tracing macros, with explicit progress milestones. - RPC diagnostics use `display_rpc_url`, which hides userinfo, path, query and fragment; cache identity uses `redact_rpc_url` and keeps the path and query. Keep the two separate, and remove reqwest's URL before an HTTP error reaches a diagnostic. - `RedactedTransport` wraps the retry layer: the dependency classifies the original errors and consumes backoff hints before final diagnostics are redacted. + `RedactedTransport` wraps the retry layer: the dependency classifies the original errors and consumes backoff hints before final diagnostics are redacted, including scheme-less, percent-encoded, and escaped echoes of the configured URL's secret-bearing components. - Output paths keep both human-readable summaries and optional machine artifacts (trace/state dump). - The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. A transaction replay's engine is decided at the timestamp of its mined block, the one whose schedule it runs under: keep a new site to the same pair. - Satin transaction replay refuses pending and genesis transactions and checks the fetched parent's number and hash before using its state. + Satin transaction replay refuses pending and genesis transactions, checks the fetched parent's number and hash, and forks pre-state at that verified parent hash via EIP-1898 (`requireCanonical: true`). - Output on Satin is additive to the legacy output: every legacy field keeps its name and meaning, and what only Satin counts goes in the `satin` object (`tests/integration.rs` checks it on every fixture pair). ## ANTI-PATTERNS diff --git a/bin/mega-evme/src/common/state.rs b/bin/mega-evme/src/common/state.rs index cf2f88035..525ab0991 100644 --- a/bin/mega-evme/src/common/state.rs +++ b/bin/mega-evme/src/common/state.rs @@ -2,6 +2,7 @@ use std::{collections::BTreeMap, path::PathBuf, str::FromStr}; +use alloy_eips::BlockId; use alloy_network::Network; use alloy_primitives::{Address, BlockNumber, Bytes, B256, U256}; use alloy_provider::Provider; @@ -820,8 +821,19 @@ where BlockNumber::from(latest_block) }; - // Create AlloyDB with the provider and block number - let alloy_db = AlloyDB::new(provider, block_num.into()); + Self::new_forked_at(provider, block_num.into(), prestate, block_hashes) + } + + /// Create a new forked state bound to an explicit EIP-1898 [`BlockId`] (number or hash), + /// with optional prestate overrides and block hash overrides. + pub fn new_forked_at( + provider: P, + block_id: BlockId, + prestate: EvmState, + block_hashes: HashMap, + ) -> Result { + // Create AlloyDB with the provider and block selector + let alloy_db = AlloyDB::new(provider, block_id); // Wrap the AlloyDB for synchronous access with the runtime let wrapped_db = diff --git a/bin/mega-evme/src/replay/cmd.rs b/bin/mega-evme/src/replay/cmd.rs index fb2c88a59..d71300adb 100644 --- a/bin/mega-evme/src/replay/cmd.rs +++ b/bin/mega-evme/src/replay/cmd.rs @@ -1,6 +1,7 @@ use std::time::Instant; use alloy_consensus::{BlockHeader, Transaction as _}; +use alloy_eips::BlockId; use alloy_primitives::{B256, U256}; use alloy_provider::Provider; use alloy_rpc_types_eth::Block; @@ -432,14 +433,22 @@ impl Cmd { self.limits_override.as_ref().map(|limits| satin_limits(Some(limits))).transpose()?; debug!(chain_id = ctx.chain_id, spec = %MegaSpecId::SATIN, "Chain configuration"); - info!(fork_block = ctx.parent_block.header.number(), "Forking state from parent block",); - let mut database = EvmeState::new_forked( + // Bind pre-state reads to the verified parent hash with `requireCanonical: true` + // (EIP-1898) rather than its height: if a reorg occurs or a load-balanced endpoint serves + // a different fork after the headers were verified, the node refuses the stale hash + // instead of silently returning another parent's state. + let parent_block_id = BlockId::hash_canonical(ctx.parent_block.hash()); + info!( + fork_block = ctx.parent_block.header.number(), + fork_block_hash = %ctx.parent_block.hash(), + "Forking state from verified parent block", + ); + let mut database = EvmeState::new_forked_at( provider.clone(), - Some(ctx.parent_block.header.number()), + parent_block_id, Default::default(), Default::default(), - ) - .await?; + )?; let block_env = retrieve_block_env(&ctx.block)?; trace!(?block_env, "Block environment built"); diff --git a/bin/mega-evme/tests/replay_paths.rs b/bin/mega-evme/tests/replay_paths.rs index 37d98158a..22269745e 100644 --- a/bin/mega-evme/tests/replay_paths.rs +++ b/bin/mega-evme/tests/replay_paths.rs @@ -67,7 +67,17 @@ impl Recording { fn result(&self, method: &str, params: &[Value]) -> Result { let block_arg = |i: usize| params.get(i).and_then(Value::as_str).unwrap_or_default(); - let at_parent = |i: usize| block_arg(i) == format!("0x{:x}", BLOCK - 1); + let at_parent_number = |i: usize| block_arg(i) == format!("0x{:x}", BLOCK - 1); + let at_parent_hash = |i: usize| { + params.get(i) == + Some(&json!({ + "blockHash": self.block.block["parentHash"], + "requireCanonical": true, + })) + }; + // The legacy 1.7.1 engine queries state by parent number; Satin binds state to the + // verified canonical parent hash (EIP-1898). + let at_parent_state = |i: usize| at_parent_number(i) || at_parent_hash(i); let address = || -> Result { serde_json::from_value(params[0].clone()).map_err(|e| e.to_string()) }; @@ -102,8 +112,8 @@ impl Recording { } Ok(block) } - "eth_getBlockByNumber" if at_parent(0) => Ok(self.parent()), - "eth_getBalance" | "eth_getTransactionCount" | "eth_getCode" if at_parent(1) => { + "eth_getBlockByNumber" if at_parent_number(0) => Ok(self.parent()), + "eth_getBalance" | "eth_getTransactionCount" | "eth_getCode" if at_parent_state(1) => { let account = self.account(address()?).ok_or("account not recorded")?; Ok(match method { "eth_getBalance" => json!(account.balance), @@ -118,7 +128,7 @@ impl Recording { .unwrap_or_else(|| "0x".to_string())), }) } - "eth_getStorageAt" if at_parent(2) => { + "eth_getStorageAt" if at_parent_state(2) => { let account = self.account(address()?).ok_or("account not recorded")?; let slot: U256 = serde_json::from_value(params[1].clone()).map_err(|e| e.to_string())?; @@ -768,3 +778,122 @@ async fn test_a_replay_dump_carries_the_code_of_a_predecessors_account() { "{summary}" ); } + +/// Replay binds pre-state reads to the verified parent block hash (EIP-1898 with +/// `requireCanonical: true`) rather than its height, so a reorg or inconsistent load-balanced +/// endpoint serving different state at the parent number cannot silently feed the wrong pre-state. +#[tokio::test(flavor = "multi_thread")] +async fn test_replay_reads_prestate_at_parent_hash() { + // PUSH0 SLOAD PUSH0 MSTORE PUSH1 0x20 PUSH0 RETURN: returns storage slot 0. + let reader = address!("0x8888888888888888888888888888888888888888"); + let code = vec![0x5f, 0x54, 0x5f, 0x52, 0x60, 0x20, 0x5f, 0xf3]; + let hash_value = U256::from(0xbeefu64); + let height_value = U256::from(0xdeadu64); + + let mut recorded = read_block(fixtures(), BLOCK); + recorded + .prestate + .accounts + .insert(PAYER, PreAccount { balance: U256::from(10u128.pow(18)), ..PreAccount::default() }); + let code_hash = alloy_primitives::keccak256(&code); + let codes = HashMap::from_iter([(code_hash, code)]); + recorded.prestate.accounts.insert( + reader, + PreAccount { + code_hash: Some(code_hash), + storage: BTreeMap::from([(B256::ZERO, hash_value)]), + ..Default::default() + }, + ); + let target = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + recorded.block["transactions"] = json!([{ + "type": "0x2", + "chainId": "0x10e6", + "nonce": "0x0", + "gas": "0x4c4b40", + "maxFeePerGas": "0xf4240", + "maxPriorityFeePerGas": "0x0", + "to": reader, + "value": "0x0", + "accessList": [], + "input": "0x", + "r": "0x64c0524917585101b7ffb2286d4de676ca987554b33c6f9a37e7ad7508bfbb84", + "s": "0xe5199cacc6e07c6a9f8c74d0b06f964ce36dd362199b1c19d866f1a6f52d510", + "yParity": "0x1", + "v": "0x1", + "hash": target, + "blockHash": recorded.block["hash"], + "blockNumber": recorded.block["number"], + "transactionIndex": "0x0", + "from": PAYER, + "gasPrice": "0xf4240", + }]); + + let parent_hash = recorded.block["parentHash"].clone(); + let expected_selector = json!({ + "blockHash": parent_hash, + "requireCanonical": true, + }); + let parent_height = format!("0x{:x}", BLOCK - 1); + let server = Server::with_codes(recorded, None, codes).await; + + // Serve different storage at the parent height (simulating a reorg / split-view RPC). + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getStorageAt", + "params": [reader, U256::ZERO, parent_height], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": B256::from(height_value), + })) + }) + .with_priority(1) + .mount(&server.0) + .await; + + let run = run_evme(&[ + "replay", + target, + "--rpc", + &server.0.uri(), + "--rpc.no-cache-file", + "--rpc.max-retries", + "0", + "--override.spec", + "Satin", + "--json", + ]); + assert_eq!(run.code, 0, "{}{}", run.stderr, run.stdout); + let summary: Value = serde_json::from_str(&run.stdout).unwrap(); + assert_eq!(summary["success"], true, "{summary}"); + assert_eq!( + summary["output"], + json!(B256::from(hash_value)), + "replay must observe the state bound to the verified parent hash, not the parent height" + ); + + let requests = server.0.received_requests().await.unwrap(); + let mut state_reads = 0usize; + for request in &requests { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + let block_param = match body["method"].as_str() { + Some("eth_getBalance" | "eth_getTransactionCount" | "eth_getCode") => { + Some(&body["params"][1]) + } + Some("eth_getStorageAt") => Some(&body["params"][2]), + _ => None, + }; + if let Some(selector) = block_param { + state_reads += 1; + assert_eq!( + selector, &expected_selector, + "state read {} must pass EIP-1898 canonical parent hash, got {selector}", + body["method"] + ); + } + } + assert!(state_reads > 0, "expected at least one state RPC read"); +} diff --git a/docs/mega-evme/commands/replay.md b/docs/mega-evme/commands/replay.md index 6c82028e0..f063c556a 100644 --- a/docs/mega-evme/commands/replay.md +++ b/docs/mega-evme/commands/replay.md @@ -10,8 +10,9 @@ In offline mode (`--rpc.replay-file`), all data is served from a local fixture c A Satin transaction replay requires a mined transaction in a block after genesis. Pending transactions have no canonical block context and are refused. -Before reading the parent state, replay checks that the fetched parent has the preceding block number and the hash named by the transaction's block. -A mismatch aborts the replay; retry with a consistent RPC endpoint or recording. +Before reading the parent state, replay checks that the fetched parent has the preceding block number and the hash named by the transaction's block, and then issues pre-state reads (`eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount`) against that verified parent hash using EIP-1898 (`{"blockHash": ..., "requireCanonical": true}`) rather than by block number. +A header mismatch or non-canonical parent aborts the replay; retry with a consistent RPC endpoint or recording. +Because Satin pre-state reads are keyed by the EIP-1898 parent block hash instead of block number, per-endpoint cache entries (`--rpc.cache-dir`) and `--rpc.capture-file` / `--rpc.replay-file` keys differ from height-keyed captures; Satin replay files captured before this change must be re-captured. With `--block`, `replay` re-executes whole blocks instead and compares every receipt with the chain's; see [Replaying Whole Blocks](#replaying-whole-blocks). From b1d218cc4602e6efb92dc6b0c3031ed8dab6a7f1 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:05:48 +0800 Subject: [PATCH 07/12] fix(state-test): reject non-regular fixture inputs and follow symlinked directories --- crates/mega-state-test/README.md | 2 + crates/mega-state-test/src/input.rs | 137 +++++++++++++++++++++++++++- 2 files changed, 134 insertions(+), 5 deletions(-) diff --git a/crates/mega-state-test/README.md b/crates/mega-state-test/README.md index ef3757d79..53adb4a93 100644 --- a/crates/mega-state-test/README.md +++ b/crates/mega-state-test/README.md @@ -63,6 +63,8 @@ cargo run --release -p state-test -- --mode satin --fork Osaka
/state_test ## Fixture input limits Discovery accepts at most 100,000 fixture files across all input paths and entries at most 64 levels below each input directory. +Discovery follows symlinks so symlinked fixture subdirectories are included under the same depth and count limits, while broken links and symlink loops fail discovery. +Only regular files (after following links) are admitted: a non-regular input or `*.json` entry (such as a FIFO, socket, device, or directory) fails discovery with an error naming the path before any file is opened. A traversal error or an exceeded limit fails the run; neither a deep subtree nor excess files are silently omitted. The state-test runner accepts fixture files up to 64 MiB; the blockchain-test runner accepts up to 256 MiB because a file bundles many block sequences, and the pinned execution-spec fixtures include files around 160 MiB. Both reject oversized files before reading their contents and cap the read itself in case a file grows. diff --git a/crates/mega-state-test/src/input.rs b/crates/mega-state-test/src/input.rs index 0a1988cc6..1c98adc1b 100644 --- a/crates/mega-state-test/src/input.rs +++ b/crates/mega-state-test/src/input.rs @@ -21,18 +21,38 @@ const MAX_STATE_ACCOUNTS: usize = 100_000; /// The largest state a fixture may materialize, in storage slots across all accounts. const MAX_STATE_SLOTS: usize = 1_000_000; -/// Reads a UTF-8 fixture, refusing an oversized file before allocating its contents. +/// Reads a UTF-8 fixture, refusing non-regular and oversized files before allocating contents. pub(crate) fn read_fixture(path: &Path) -> io::Result { - read_with_limit(File::open(path)?, MAX_FIXTURE_BYTES) + read_file_with_limit(path, MAX_FIXTURE_BYTES) } /// Reads a blockchain fixture under its larger bound, using the same guarded reader. pub(crate) fn read_blockchain_fixture(path: &Path) -> io::Result { - read_with_limit(File::open(path)?, MAX_BLOCKCHAIN_FIXTURE_BYTES) + read_file_with_limit(path, MAX_BLOCKCHAIN_FIXTURE_BYTES) +} + +fn read_file_with_limit(path: &Path, limit: u64) -> io::Result { + let metadata = path + .metadata() + .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display())))?; + if !metadata.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file: {}", path.display()), + )); + } + read_with_limit(File::open(path)?, limit) } fn read_with_limit(file: File, limit: u64) -> io::Result { - if file.metadata()?.len() > limit { + let metadata = file.metadata()?; + if !metadata.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "fixture input is not a regular file", + )); + } + if metadata.len() > limit { return Err(io::Error::new( io::ErrorKind::InvalidData, format!("fixture exceeds {limit} bytes"), @@ -87,7 +107,15 @@ fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) - if metadata.is_file() { return add_file(path.to_path_buf(), files, limit); } - for entry in WalkDir::new(path) { + if !metadata.is_dir() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file or directory: {}", path.display()), + )); + } + // Follow symlinks so symlinked fixture directories are traversed rather than silently dropped; + // WalkDir reports symlink loops and broken links as errors, which propagate via `?`. + for entry in WalkDir::new(path).follow_links(true) { let entry = entry?; // WalkDir::max_depth would silently omit descendants, so inspect the first excess entry. if entry.depth() > depth { @@ -97,6 +125,15 @@ fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) - )); } if entry.path().extension().is_some_and(|ext| ext == "json") { + let entry_meta = entry.path().metadata().map_err(|error| { + io::Error::new(error.kind(), format!("{}: {error}", entry.path().display())) + })?; + if !entry_meta.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file: {}", entry.path().display()), + )); + } add_file(entry.into_path(), files, limit)?; } } @@ -195,4 +232,94 @@ mod tests { assert!(check_state_size([MAX_STATE_SLOTS, 1]).unwrap_err().contains("total slots")); assert!(check_state_size([1, usize::MAX]).is_err()); } + + #[cfg(unix)] + #[test] + fn test_discovery_rejects_fifo_and_non_regular_json_without_hanging() { + use std::{process::Command, sync::mpsc, time::Duration}; + + let root = tempfile::tempdir().unwrap(); + std::fs::write(root.path().join("valid.json"), "{}").unwrap(); + let fifo = root.path().join("p.json"); + let status = Command::new("mkfifo").arg(&fifo).status().expect("mkfifo runs"); + assert!(status.success(), "mkfifo failed"); + + // Discovery of a directory containing a FIFO named `*.json` fails explicitly without + // hanging. + let err = find_json_files(root.path()).expect_err("FIFO named *.json must fail discovery"); + assert!(err.to_string().contains(&fifo.display().to_string()), "{err}"); + let err = find_json_files_in_paths(&[root.path().to_path_buf()]) + .expect_err("multi-path discovery must also reject FIFO named *.json"); + assert!(err.to_string().contains(&fifo.display().to_string()), "{err}"); + + // Passing the FIFO directly also fails discovery explicitly. + let err = find_json_files(&fifo).expect_err("direct FIFO input must fail discovery"); + assert!(err.to_string().contains(&fifo.display().to_string()), "{err}"); + + // Even a direct `read_fixture` call refuses the FIFO without blocking in `File::open`. + let fifo_clone = fifo.clone(); + let (tx, rx) = mpsc::channel(); + std::thread::spawn(move || { + let _ = tx.send(read_fixture(&fifo_clone)); + }); + let read_res = rx + .recv_timeout(Duration::from_secs(2)) + .expect("read_fixture must reject FIFO without blocking"); + assert!(read_res.is_err(), "FIFO must not be read as a fixture"); + + // A directory whose name ends in `.json` is also a non-regular entry and fails discovery. + let dir_root = tempfile::tempdir().unwrap(); + let json_dir = dir_root.path().join("nested.json"); + std::fs::create_dir(&json_dir).unwrap(); + std::fs::write(json_dir.join("real.json"), "{}").unwrap(); + let err = find_json_files(dir_root.path()) + .expect_err("directory named *.json must fail discovery"); + assert!(err.to_string().contains(&json_dir.display().to_string()), "{err}"); + } + + #[cfg(unix)] + #[test] + fn test_discovery_follows_symlink_dir_and_rejects_symlink_loop() { + use std::os::unix::fs::symlink; + + let root = tempfile::tempdir().unwrap(); + let real = root.path().join("real"); + std::fs::create_dir(&real).unwrap(); + std::fs::write(real.join("a.json"), "{}").unwrap(); + + let top = root.path().join("top"); + std::fs::create_dir(&top).unwrap(); + std::fs::write(top.join("b.json"), "{}").unwrap(); + symlink(&real, top.join("link")).unwrap(); + + // Symlinked subdirectory's fixture is discovered, not silently dropped. + let files = find_json_files(&top).expect("symlinked directory is followed"); + assert_eq!(files.len(), 2, "{files:?}"); + assert!(files.iter().any(|p| p.ends_with("b.json")), "{files:?}"); + assert!(files.iter().any(|p| p.ends_with("a.json")), "{files:?}"); + + // Existing depth limit still applies to entries reached through a symlinked directory. + let err = discover(&top, &mut Vec::new(), 1, 10) + .expect_err("depth limit must apply through symlinked directory"); + assert!(err.to_string().contains("depth exceeds 1"), "{err}"); + + // A symlink loop yields an error rather than hanging or silently dropping entries. + let loop_root = tempfile::tempdir().unwrap(); + let sub = loop_root.path().join("sub"); + std::fs::create_dir(&sub).unwrap(); + symlink(loop_root.path(), sub.join("back")).unwrap(); + assert!(find_json_files(loop_root.path()).is_err(), "symlink loop must fail discovery"); + + // A symlink to a non-regular file (FIFO) named `*.json` fails discovery explicitly. + let fifo_target = root.path().join("pipe"); + let status = + std::process::Command::new("mkfifo").arg(&fifo_target).status().expect("mkfifo runs"); + assert!(status.success(), "mkfifo failed"); + let link_root = tempfile::tempdir().unwrap(); + let fifo_link = link_root.path().join("linked.json"); + symlink(&fifo_target, &fifo_link).unwrap(); + let err = find_json_files(link_root.path()) + .expect_err("symlink to FIFO named *.json must fail discovery"); + assert!(err.to_string().contains(&fifo_link.display().to_string()), "{err}"); + } } From c0beb18daa1bc325f38216c7db4d9413ba53ce6f Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:43:19 +0800 Subject: [PATCH 08/12] fix(evme): replace JSON-RPC server error messages with local diagnostics --- bin/mega-evme/AGENTS.md | 2 +- bin/mega-evme/src/common/provider/mod.rs | 212 +----------------- .../src/common/provider/transport.rs | 46 ++-- bin/mega-evme/tests/integration.rs | 76 +++++++ bin/mega-evme/tests/provider.rs | 97 +++++++- bin/mega-evme/tests/replay_paths.rs | 4 +- .../configuration/state-management.md | 3 +- docs/mega-evme/overview.md | 4 +- 8 files changed, 194 insertions(+), 250 deletions(-) diff --git a/bin/mega-evme/AGENTS.md b/bin/mega-evme/AGENTS.md index b62577e48..1797bf1ab 100644 --- a/bin/mega-evme/AGENTS.md +++ b/bin/mega-evme/AGENTS.md @@ -24,7 +24,7 @@ Two engines: the in-tree sources run Satin; a spec from `Equivalence` to `Rex6` - Logging is structured via tracing macros, with explicit progress milestones. - RPC diagnostics use `display_rpc_url`, which hides userinfo, path, query and fragment; cache identity uses `redact_rpc_url` and keeps the path and query. Keep the two separate, and remove reqwest's URL before an HTTP error reaches a diagnostic. - `RedactedTransport` wraps the retry layer: the dependency classifies the original errors and consumes backoff hints before final diagnostics are redacted, including scheme-less, percent-encoded, and escaped echoes of the configured URL's secret-bearing components. + `RedactedTransport` wraps the retry layer: the dependency classifies the original errors and consumes backoff hints before final diagnostics replace every JSON-RPC error message and `data` with a fixed local diagnostic (`server error message omitted`) while preserving the numeric error code. - Output paths keep both human-readable summaries and optional machine artifacts (trace/state dump). - The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. diff --git a/bin/mega-evme/src/common/provider/mod.rs b/bin/mega-evme/src/common/provider/mod.rs index 3cb01f653..c60fd635a 100644 --- a/bin/mega-evme/src/common/provider/mod.rs +++ b/bin/mega-evme/src/common/provider/mod.rs @@ -18,7 +18,6 @@ mod transport; use std::{ fs, path::{Path, PathBuf}, - sync::Arc, }; use alloy_provider::{ @@ -396,7 +395,8 @@ impl RpcArgs { /// Build an `RpcClient` over an arbitrary transport, wired with the configured /// retry layer (or bare when `max_retries == 0`). `url` is used to detect whether - /// the endpoint is local and to redact configured URL components from server errors. + /// the endpoint is local; [`RedactedTransport`] wraps the outermost layer so the + /// retry policy sees original server errors before final diagnostics replace them. fn build_client( &self, transport: T, @@ -405,7 +405,6 @@ impl RpcArgs { let is_local = url.host_str().is_some_and(|h| h == "localhost" || h == "127.0.0.1" || h == "::1"); let max_retries = self.max_retries; - let secrets = Arc::new(EndpointSecrets::from_url(url)); if self.max_retries > 0 { let policy = RateLimitRetryPolicy::default().or(|err: &TransportError| { matches!(err, RpcError::Transport(TransportErrorKind::Custom(_))) @@ -418,13 +417,13 @@ impl RpcArgs { ); ClientBuilder::default() .layer(tower::layer::layer_fn(move |inner| { - RedactedTransport::new(inner, max_retries, Arc::clone(&secrets)) + RedactedTransport::new(inner, max_retries) })) .layer(retry) .transport(transport, is_local) } else { ClientBuilder::default() - .transport(RedactedTransport::new(transport, max_retries, secrets), is_local) + .transport(RedactedTransport::new(transport, max_retries), is_local) } } @@ -504,192 +503,6 @@ pub(crate) fn display_rpc_url(raw: &str) -> String { .map_or_else(|| "".to_string(), |url| url.origin().ascii_serialization()) } -/// Credential-bearing components of the configured RPC endpoint URL (raw and percent-decoded). -/// -/// Used by [`RedactedTransport`] to detect when a server JSON-RPC error echoes the endpoint's -/// userinfo, non-root path, query, or fragment without a full `scheme://` URL. -#[derive(Debug, Clone)] -pub(super) struct EndpointSecrets { - needles: Vec, -} - -impl EndpointSecrets { - fn from_url(url: &alloy_transport_http::reqwest::Url) -> Self { - let mut needles = Vec::new(); - let mut push = |raw: &str, decode_plus: bool| { - let push_one = |list: &mut Vec, candidate: String| { - if !candidate.is_empty() && candidate != "/" && !list.contains(&candidate) { - list.push(candidate); - } - }; - push_one(&mut needles, raw.to_string()); - push_one(&mut needles, percent_decode_lossy(raw, decode_plus)); - }; - - push(url.username(), false); - if let Some(password) = url.password() { - push(password, false); - } - let path = url.path(); - if !path.is_empty() && path != "/" { - push(path, false); - let trimmed_end = path.trim_end_matches('/'); - if trimmed_end != path { - push(trimmed_end, false); - } - let trimmed_start = trimmed_end.trim_start_matches('/'); - if trimmed_start != trimmed_end { - push(trimmed_start, false); - } - } - if let Some(query) = url.query() { - push(query, true); - for pair in query.split('&') { - push(pair, true); - } - } - if let Some(fragment) = url.fragment() { - push(fragment, false); - } - Self { needles } - } - - fn matches(&self, text: &str) -> bool { - if self.needles.is_empty() { - return false; - } - let unescaped = unescape_json_ascii_escapes(text); - let decoded = percent_decode_lossy(text, false); - let decoded_plus = text.contains('+').then(|| percent_decode_lossy(text, true)); - let unescaped_decoded = percent_decode_lossy(&unescaped, false); - self.needles.iter().any(|needle| { - text.contains(needle) || - unescaped.contains(needle) || - decoded.contains(needle) || - decoded_plus.as_deref().is_some_and(|s| s.contains(needle)) || - unescaped_decoded.contains(needle) - }) - } -} - -/// Percent-decodes `%XX` sequences in `input` (and `+` to space when `decode_plus` is true). -/// Malformed `%` sequences are kept verbatim; non-UTF-8 byte sequences are decoded lossily. -fn percent_decode_lossy(input: &str, decode_plus: bool) -> String { - let bytes = input.as_bytes(); - let mut out = Vec::with_capacity(bytes.len()); - let mut i = 0; - while i < bytes.len() { - if bytes[i] == b'%' && i + 2 < bytes.len() { - if let (Some(hi), Some(lo)) = (hex_nibble(bytes[i + 1]), hex_nibble(bytes[i + 2])) { - out.push((hi << 4) | lo); - i += 3; - continue; - } - } else if decode_plus && bytes[i] == b'+' { - out.push(b' '); - i += 1; - continue; - } - out.push(bytes[i]); - i += 1; - } - String::from_utf8_lossy(&out).into_owned() -} - -fn hex_nibble(byte: u8) -> Option { - match byte { - b'0'..=b'9' => Some(byte - b'0'), - b'a'..=b'f' => Some(byte - b'a' + 10), - b'A'..=b'F' => Some(byte - b'A' + 10), - _ => None, - } -} - -/// Unescapes JSON-style `\/` (including repeated backslashes before `/`) and ASCII `\u00XX` -/// escapes so serialized URLs or paths embedded in a server error string are matched against -/// configured endpoint components. -fn unescape_json_ascii_escapes(input: &str) -> String { - let bytes = input.as_bytes(); - let mut out = Vec::with_capacity(bytes.len()); - let mut i = 0; - while i < bytes.len() { - if bytes[i] == b'\\' && i + 1 < bytes.len() { - let mut end = i; - while end < bytes.len() && bytes[end] == b'\\' { - end += 1; - } - if end < bytes.len() && bytes[end] == b'/' { - out.push(b'/'); - i = end + 1; - continue; - } - if bytes[i + 1] == b'u' && - i + 5 < bytes.len() && - bytes[i + 2] == b'0' && - bytes[i + 3] == b'0' - { - if let (Some(hi), Some(lo)) = (hex_nibble(bytes[i + 4]), hex_nibble(bytes[i + 5])) { - let ch = (hi << 4) | lo; - if ch.is_ascii() { - out.push(ch); - i += 6; - continue; - } - } - } - } - out.push(bytes[i]); - i += 1; - } - String::from_utf8_lossy(&out).into_owned() -} - -/// Redacts server-provided JSON-RPC error messages. -/// -/// If the message echoes any secret-bearing component of the configured endpoint URL (even without -/// a scheme, percent-encoded, or JSON-escaped), the entire server message is replaced with a safe -/// placeholder while the JSON-RPC error code is preserved by the caller. Otherwise, any absolute -/// URLs embedded in the text are redacted. -pub(super) fn redact_rpc_error_message(text: &str, secrets: &EndpointSecrets) -> String { - if secrets.matches(text) { - return "".to_string(); - } - redact_rpc_urls_in_text(text) -} - -/// Finds the earliest `://`, JSON-escaped `:\/`, or percent-encoded `%3A%2F%2F` scheme separator. -fn find_scheme_separator(text: &str) -> Option<(usize, usize, bool)> { - let plain = text.find("://").map(|at| (at, 3, true)); - let escaped = text.find(r":\/\/").map(|at| (at, 5, false)); - let encoded = text.to_ascii_lowercase().find("%3a%2f%2f").map(|at| (at, 9, false)); - [plain, escaped, encoded].into_iter().flatten().min_by_key(|(at, _, _)| *at) -} - -/// Redacts URLs echoed by RPC errors, without changing successful RPC results. -fn redact_rpc_urls_in_text(text: &str) -> String { - let mut out = String::with_capacity(text.len()); - let mut rest = text; - while let Some((colon, sep_len, is_plain)) = find_scheme_separator(rest) { - let start = rest[..colon] - .rfind(|c: char| !c.is_ascii_alphanumeric() && !matches!(c, '+' | '-' | '.')) - .map_or(0, |at| at + rest[at..].chars().next().expect("a character").len_utf8()); - // Punctuation can be part of a credential-bearing path or query. Consume the whole - // non-whitespace token, including surrounding punctuation if present, to fail closed. - let end = rest[colon + sep_len..] - .find(char::is_whitespace) - .map_or(rest.len(), |at| colon + sep_len + at); - out.push_str(&rest[..start]); - if is_plain { - out.push_str(&display_rpc_url(&rest[start..end])); - } else { - out.push_str(""); - } - rest = &rest[end..]; - } - out.push_str(rest); - out -} - /// Parses `--rpc`. The transport speaks HTTP, so any other scheme is refused here, before the URL /// reaches a library whose error text would repeat it whole. fn parse_rpc_url(raw: &str) -> Result { @@ -774,23 +587,6 @@ mod tests { } } - #[test] - fn test_urls_echoed_in_error_text_are_redacted_through_punctuation() { - for text in [ - "request failed for https://rpc.example/v2/(secret-key)", - "request failed for https://rpc.example/v2/key'with'apostrophes?key=secret-key", - "request failed for https://rpc.example/v2/%28secret-key%29?key=secret-key", - "{\"url\":\"https://rpc.example/v2/secret-key\"}", - ] { - let safe = redact_rpc_urls_in_text(text); - assert!(!safe.contains("secret-key"), "{safe}"); - assert!( - safe.starts_with("request failed for ") || safe.starts_with("{\"url\":\""), - "{safe}" - ); - } - } - /// Explicit `--rpc.cache-dir` is used verbatim. The file names the chain and a hash of the /// endpoint, and the hash does not change when only the userinfo does. #[test] diff --git a/bin/mega-evme/src/common/provider/transport.rs b/bin/mega-evme/src/common/provider/transport.rs index 7978c0a98..7a41032b3 100644 --- a/bin/mega-evme/src/common/provider/transport.rs +++ b/bin/mega-evme/src/common/provider/transport.rs @@ -20,18 +20,21 @@ use serde::{Deserialize, Serialize}; use crate::common::{EvmeError, Result}; +/// Fixed local diagnostic replacing every server-supplied JSON-RPC error message so server error +/// payloads can never disclose endpoint credentials or other server-echoed text. +const LOCAL_RPC_ERROR_MESSAGE: &str = "server error message omitted"; + /// Hides transport diagnostics only after the dependency has applied its retry policy. /// The inner future runs without tracing because dependency spans can contain the endpoint URL. #[derive(Clone)] pub(super) struct RedactedTransport { inner: T, max_retries: u32, - secrets: Arc, } impl RedactedTransport { - pub(super) fn new(inner: T, max_retries: u32, secrets: Arc) -> Self { - Self { inner, max_retries, secrets } + pub(super) fn new(inner: T, max_retries: u32) -> Self { + Self { inner, max_retries } } } @@ -44,9 +47,7 @@ impl tower::Service for Red &mut self, cx: &mut std::task::Context<'_>, ) -> std::task::Poll> { - self.inner - .poll_ready(cx) - .map_err(|error| redact_transport_error(error, self.max_retries, &self.secrets)) + self.inner.poll_ready(cx).map_err(|error| redact_transport_error(error, self.max_retries)) } fn call(&mut self, req: RequestPacket) -> Self::Future { @@ -55,51 +56,40 @@ impl tower::Service for Red let future = tracing::subscriber::with_default(NoSubscriber::default(), || self.inner.call(req)); let max_retries = self.max_retries; - let secrets = Arc::clone(&self.secrets); Box::pin(async move { let mut response = future .with_subscriber(NoSubscriber::default()) .await - .map_err(|error| redact_transport_error(error, max_retries, &secrets))?; + .map_err(|error| redact_transport_error(error, max_retries))?; match &mut response { - ResponsePacket::Single(response) => redact_error_response(response, &secrets), - ResponsePacket::Batch(responses) => responses - .iter_mut() - .for_each(|response| redact_error_response(response, &secrets)), + ResponsePacket::Single(response) => redact_error_response(response), + ResponsePacket::Batch(responses) => { + responses.iter_mut().for_each(redact_error_response) + } } Ok(response) }) } } -fn redact_error_payload( - error: &mut alloy_json_rpc::ErrorPayload, - secrets: &super::EndpointSecrets, -) { - error.message = super::redact_rpc_error_message(&error.message, secrets).into(); +fn redact_error_payload(error: &mut alloy_json_rpc::ErrorPayload) { + error.message = LOCAL_RPC_ERROR_MESSAGE.into(); // Arbitrary error data need not be interpreted or re-serialized for a diagnostic. // Backoff hints have already been consumed by the inner retry layer. error.data = None; } -fn redact_error_response( - response: &mut alloy_json_rpc::Response, - secrets: &super::EndpointSecrets, -) { +fn redact_error_response(response: &mut alloy_json_rpc::Response) { if let alloy_json_rpc::ResponsePayload::Failure(error) = &mut response.payload { - redact_error_payload(error, secrets); + redact_error_payload(error); } } -fn redact_transport_error( - error: TransportError, - max_retries: u32, - secrets: &super::EndpointSecrets, -) -> TransportError { +fn redact_transport_error(error: TransportError, max_retries: u32) -> TransportError { use alloy_provider::transport::RpcError; match error { RpcError::ErrorResp(mut error) => { - redact_error_payload(&mut error, secrets); + redact_error_payload(&mut error); RpcError::ErrorResp(error) } RpcError::Transport(TransportErrorKind::Custom(error)) => { diff --git a/bin/mega-evme/tests/integration.rs b/bin/mega-evme/tests/integration.rs index 5d8e9c98b..166a115f6 100644 --- a/bin/mega-evme/tests/integration.rs +++ b/bin/mega-evme/tests/integration.rs @@ -443,6 +443,82 @@ async fn test_rpc_response_errors_hide_credentials_in_stderr_and_log_files() { } } +/// CLI stderr and `--log.file` must report the JSON-RPC error code with a local diagnostic and +/// never echo server error text (key value alone, path segment alone, or benign `/rpc` messages). +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_rpc_json_error_stderr_and_log_never_echo_server_message() { + let cases = [ + ( + "/v2/path-secret?key=query-secret", + -32000i64, + "invalid API key query-secret", + &["query-secret", "path-secret", "invalid API key"][..], + ), + ( + "/v2/path-secret?key=query-secret", + -32001i64, + "unknown project path-secret", + &["path-secret", "query-secret", "unknown project"][..], + ), + ("/rpc", -32601i64, "header not found", &["header not found"][..]), + ]; + + let dir = tempfile::tempdir().unwrap(); + for (idx, (suffix, code, server_msg, forbidden)) in cases.into_iter().enumerate() { + let server = MockServer::start().await; + let url = format!("{}{suffix}", server.uri()); + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "jsonrpc": "2.0", + "id": 0, + "error": { "code": code, "message": server_msg, "data": { "raw": server_msg } }, + }))) + .mount(&server) + .await; + + for to_file in [false, true] { + let log_path = dir.path().join(format!("rpc-{idx}-{to_file}.log")); + let mut cmd = Command::new(env!("CARGO_BIN_EXE_mega-evme")); + cmd.env("RUST_LOG", "mega_evme=debug,alloy_transport_http=trace,alloy_transport=trace") + .args([ + "--log.no-color", + "replay", + &format!("0x{}", "11".repeat(32)), + "--override.spec", + "Satin", + "--rpc", + &url, + "--rpc.max-retries", + "0", + "--rpc.no-cache-file", + "-vvvv", + ]); + if to_file { + cmd.arg("--log.file").arg(&log_path); + } + let output = tokio::task::spawn_blocking(move || cmd.output()).await.unwrap().unwrap(); + assert_eq!(output.status.code(), Some(1)); + let mut text = format!( + "{}{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + if to_file { + text.push_str(&std::fs::read_to_string(&log_path).unwrap()); + } + assert!( + text.contains(&code.to_string()) && + text.contains("server returned an error response") && + text.contains("server error message omitted"), + "expected error code and local diagnostic in: {text}" + ); + for item in forbidden { + assert!(!text.contains(item), "server text {item:?} leaked in: {text}"); + } + } + } +} + const ZERO_HASH: &str = "0x0000000000000000000000000000000000000000000000000000000000000000"; const SENDER: &str = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; const RECEIVER: &str = "0x0000000000000000000000000000000000000001"; diff --git a/bin/mega-evme/tests/provider.rs b/bin/mega-evme/tests/provider.rs index 6dd680d31..a4eb00bc4 100644 --- a/bin/mega-evme/tests/provider.rs +++ b/bin/mega-evme/tests/provider.rs @@ -240,16 +240,14 @@ async fn test_chain_id_error_redacts_schemeless_and_encoded_echo(#[case] server_ } } -/// Percent-decoded endpoint components (such as a path containing spaces) echoed by the server -/// are also redacted, while an ordinary unrelated error message is preserved. +/// Percent-decoded endpoint components and ordinary server errors alike are replaced with a +/// local diagnostic that preserves only the JSON-RPC error code. #[tokio::test(flavor = "multi_thread")] -async fn test_chain_id_error_redacts_percent_decoded_echo_and_keeps_safe_message() { +async fn test_chain_id_error_redacts_percent_decoded_echo_and_omits_server_message() { let server = MockServer::start().await; let host = server.uri().strip_prefix("http://").unwrap().to_string(); let url = format!("{}/v2/my%20key-secret?x=tail-secret", server.uri()); - // Echoing the space-decoded path leaks `key-secret` and `tail-secret` if URL scanning stops - // at whitespace or only checks raw percent-encoded components. Mock::given(matchers::method("POST")) .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ "jsonrpc": "2.0", @@ -275,14 +273,95 @@ async fn test_chain_id_error_redacts_percent_decoded_echo_and_keeps_safe_message let leaked = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("echo fails"); let leaked_msg = leaked.to_string(); - assert!(leaked_msg.contains("-32001"), "{leaked_msg}"); - for secret in ["key-secret", "tail-secret"] { - assert!(!leaked_msg.contains(secret), "secret {secret:?} leaked in: {leaked_msg}"); + assert!( + leaked_msg.contains("-32001") && leaked_msg.contains("server error message omitted"), + "{leaked_msg}" + ); + for secret in ["key-secret", "tail-secret", "bad upstream"] { + assert!(!leaked_msg.contains(secret), "server text {secret:?} leaked in: {leaked_msg}"); } let safe = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("safe error fails"); let safe_msg = safe.to_string(); - assert!(safe_msg.contains("-32601") && safe_msg.contains("method not found"), "{safe_msg}"); + assert!( + safe_msg.contains("-32601") && safe_msg.contains("server error message omitted"), + "{safe_msg}" + ); + assert!(!safe_msg.contains("method not found"), "{safe_msg}"); +} + +/// JSON-RPC server error messages and data are never forwarded: every JSON-RPC error response is +/// replaced with a local diagnostic that preserves the numeric error code and omits all server +/// text (whether it echoes a single key value, a single path segment, or a benign message under a +/// short public path such as `/rpc`). +#[rstest] +#[case::key_value_alone( + "/v2/path-secret?key=query-secret", + -32000, + "invalid API key query-secret", + Some(serde_json::json!({"detail": "secret-data"})), + &["query-secret", "path-secret", "invalid API key", "secret-data"][..] +)] +#[case::path_segment_alone( + "/v2/path-secret?key=query-secret", + -32001, + "unknown project path-secret", + Some(serde_json::json!("secret-data")), + &["path-secret", "query-secret", "unknown project", "secret-data"][..] +)] +#[case::benign_under_short_public_path( + "/rpc", + -32005, + "invalid jsonrpc request: rate limit exceeded", + None, + &["invalid jsonrpc", "rate limit exceeded"][..] +)] +#[case::benign_not_found_under_rpc( + "/rpc", + -32601, + "header not found", + Some(serde_json::json!({"hint": "server-hint"})), + &["header not found", "server-hint"][..] +)] +#[tokio::test(flavor = "multi_thread")] +async fn test_rpc_error_uses_local_diagnostic_and_never_echoes_server_message( + #[case] suffix: &str, + #[case] code: i64, + #[case] server_msg: &str, + #[case] server_data: Option, + #[case] forbidden: &[&str], +) { + let server = MockServer::start().await; + let url = format!("{}{suffix}", server.uri()); + let mut err_obj = serde_json::json!({ "code": code, "message": server_msg }); + if let Some(data) = server_data { + err_obj["data"] = data; + } + Mock::given(matchers::method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "jsonrpc": "2.0", + "id": 0, + "error": err_obj, + }))) + .mount(&server) + .await; + + let error = test_rpc_args(&url, Some(0)).build_provider().await.expect_err("request fails"); + assert_eq!(server.received_requests().await.unwrap().len(), 1); + let message = error.to_string(); + assert!(message.contains("Failed to fetch chain ID"), "{message}"); + assert!( + message.contains(&code.to_string()), + "JSON-RPC error code {code} must be preserved: {message}" + ); + assert!( + message.contains("server returned an error response") && + message.contains("server error message omitted"), + "expected local diagnostic in: {message}" + ); + for text in forbidden { + assert!(!message.contains(text), "server text {text:?} leaked in: {message}"); + } } // ─── Chain-id resolution ───────────────────────────────────────────────────── diff --git a/bin/mega-evme/tests/replay_paths.rs b/bin/mega-evme/tests/replay_paths.rs index 22269745e..10302c609 100644 --- a/bin/mega-evme/tests/replay_paths.rs +++ b/bin/mega-evme/tests/replay_paths.rs @@ -634,7 +634,9 @@ async fn test_a_replay_stops_when_a_predecessor_account_cannot_be_read() { assert_ne!(run.code, 0, "a failed predecessor read is not skipped: {}", run.stdout); let output = format!("{}{}", run.stdout, run.stderr); assert!(output.contains("Block execution error"), "{output}"); - assert!(output.contains("account not recorded"), "{output}"); + assert!(output.contains(&MISSING.to_string()), "{output}"); + assert!(output.contains("-32000") && output.contains("server error message omitted"), "{output}"); + assert!(!output.contains("account not recorded"), "{output}"); } /// A block of calls from one payer to contracts the test adds to the recorded block's parent diff --git a/docs/mega-evme/configuration/state-management.md b/docs/mega-evme/configuration/state-management.md index 1ba534312..dc9950b42 100644 --- a/docs/mega-evme/configuration/state-management.md +++ b/docs/mega-evme/configuration/state-management.md @@ -227,7 +227,8 @@ When using fork mode, `mega-evme` caches RPC responses to avoid redundant networ These options take effect only when an RPC endpoint is actually contacted: on `run` and `tx` that requires `--fork` (without `--fork` they are accepted but silently ignored); on `replay` they apply to its `--rpc` fetches (an offline `--rpc.replay-file` run contacts no endpoint and does not use them). -On Satin, RPC URL diagnostics show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs (plain, percent-encoded, or escaped) and scheme-less echoes of the configured URL's components in HTTP and JSON-RPC error messages (preserving the JSON-RPC error code). +On Satin, RPC URL diagnostics show only the scheme, host and port: userinfo, path, query and fragment are hidden. +Every JSON-RPC error response replaces the server's error message and `data` with a fixed local diagnostic (`server error message omitted`) while keeping the JSON-RPC error code, so server error text is never forwarded. This applies to verbose logs and log files as well as stderr. ### Per-Endpoint Cache Files diff --git a/docs/mega-evme/overview.md b/docs/mega-evme/overview.md index c93d74e65..18a65ed19 100644 --- a/docs/mega-evme/overview.md +++ b/docs/mega-evme/overview.md @@ -110,10 +110,10 @@ Text a person reads on a terminal is filtered: escape sequences, control charact This covers error lines and a transaction's revert reason. `--json` output is not filtered: a JSON string carries the same characters, escaped. -On Satin, `--rpc` diagnostics (logs, errors, and `--log.file`) show only the scheme, host and port: userinfo, path, query and fragment are hidden, including URLs or configured endpoint components echoed in server error messages. +On Satin, `--rpc` diagnostics (logs, errors, and `--log.file`) show only the scheme, host and port: userinfo, path, query and fragment are hidden, and every JSON-RPC error response replaces the server's message and `data` with a fixed local diagnostic while preserving the numeric error code. Per-endpoint cache file names hash the URL with userinfo removed so endpoints with different paths or queries stay separate without placing the URL in the file name. The URL has to start with `http://` or `https://`. -On the legacy 1.7.1 engine, only userinfo is stripped from cache names and `--rpc` diagnostics are unchanged from 1.7.1. +On the legacy 1.7.1 engine, cache files are named `rpc-cache-{chain_id}.json` (without an endpoint component) and `--rpc` diagnostics are unchanged from 1.7.1. ## Read more From d9dc7b1b8c2c0ce725ae9059283a8917f318777a Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:46:56 +0800 Subject: [PATCH 09/12] fix(evme): resolve Satin replay BLOCKHASH ancestors by verified parentHash chain --- bin/mega-evme/AGENTS.md | 2 +- bin/mega-evme/src/replay/cmd.rs | 167 +++++++++++++- bin/mega-evme/tests/replay_paths.rs | 332 ++++++++++++++++++++++++++++ docs/mega-evme/commands/replay.md | 5 +- 4 files changed, 497 insertions(+), 9 deletions(-) diff --git a/bin/mega-evme/AGENTS.md b/bin/mega-evme/AGENTS.md index 1797bf1ab..8a9ce7c10 100644 --- a/bin/mega-evme/AGENTS.md +++ b/bin/mega-evme/AGENTS.md @@ -29,7 +29,7 @@ Two engines: the in-tree sources run Satin; a spec from `Equivalence` to `Rex6` - The engine is decided where a command needs it (`cmd.rs` for `run`/`tx`, `replay::Cmd::engine` for a transaction replay, `block/cmd.rs` per block), always through `Engine` (`of_spec`, `of_block`, `of_chain`), and a Satin run's schedule through `common::satin_schedule`; both read the chain's activation table, so they agree. A transaction replay's engine is decided at the timestamp of its mined block, the one whose schedule it runs under: keep a new site to the same pair. - Satin transaction replay refuses pending and genesis transactions, checks the fetched parent's number and hash, and forks pre-state at that verified parent hash via EIP-1898 (`requireCanonical: true`). + Satin transaction replay refuses pending and genesis transactions, checks the fetched parent's number and hash, forks pre-state at that verified parent hash via EIP-1898 (`requireCanonical: true`), and resolves `BLOCKHASH` ancestors on demand by walking `parentHash` via `eth_getBlockByHash` (verifying each ancestor's hash and number). - Output on Satin is additive to the legacy output: every legacy field keeps its name and meaning, and what only Satin counts goes in the `satin` object (`tests/integration.rs` checks it on every fixture pair). ## ANTI-PATTERNS diff --git a/bin/mega-evme/src/replay/cmd.rs b/bin/mega-evme/src/replay/cmd.rs index d71300adb..428fa3eab 100644 --- a/bin/mega-evme/src/replay/cmd.rs +++ b/bin/mega-evme/src/replay/cmd.rs @@ -1,4 +1,4 @@ -use std::time::Instant; +use std::{collections::HashMap, future::IntoFuture, sync::Mutex, time::Instant}; use alloy_consensus::{BlockHeader, Transaction as _}; use alloy_eips::BlockId; @@ -18,7 +18,8 @@ use mega_evm::{ inspector::JournalExt, interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, primitives::{eip4844, Address, Log}, - DatabaseRef, Inspector, + state::{AccountInfo, Bytecode}, + Database, DatabaseRef, Inspector, }, BlockLimits, MegaBlockExecutionCtx, MegaBlockExecutor, MegaEvmFactory, MegaHardforks, MegaSpecId, @@ -434,21 +435,21 @@ impl Cmd { debug!(chain_id = ctx.chain_id, spec = %MegaSpecId::SATIN, "Chain configuration"); // Bind pre-state reads to the verified parent hash with `requireCanonical: true` - // (EIP-1898) rather than its height: if a reorg occurs or a load-balanced endpoint serves - // a different fork after the headers were verified, the node refuses the stale hash - // instead of silently returning another parent's state. + // (EIP-1898) rather than its height, and resolve `BLOCKHASH` queries by walking + // `parentHash` links from that verified parent instead of querying `eth_getBlockByNumber`. let parent_block_id = BlockId::hash_canonical(ctx.parent_block.hash()); info!( fork_block = ctx.parent_block.header.number(), fork_block_hash = %ctx.parent_block.hash(), "Forking state from verified parent block", ); - let mut database = EvmeState::new_forked_at( + let state_db = EvmeState::new_forked_at( provider.clone(), parent_block_id, Default::default(), Default::default(), )?; + let mut database = VerifiedReplayDb::new(state_db, provider.clone(), &ctx.parent_block); let block_env = retrieve_block_env(&ctx.block)?; trace!(?block_env, "Block environment built"); @@ -666,6 +667,160 @@ impl Cmd { } } +/// Forked replay database whose `BLOCKHASH` reads are bound to the verified parent block's +/// `parentHash` chain rather than fetched by block number from `AlloyDB`. +#[derive(Debug)] +struct VerifiedReplayDb

+where + P: Provider, +{ + state: EvmeState, + ancestors: Mutex>, +} + +impl

VerifiedReplayDb

+where + P: Provider, +{ + fn new( + state: EvmeState, + provider: P, + parent_block: &Block, + ) -> Self { + Self { state, ancestors: Mutex::new(VerifiedAncestorChain::new(provider, parent_block)) } + } +} + +impl

Database for VerifiedReplayDb

+where + P: Provider + std::fmt::Debug, +{ + type Error = crate::common::EvmeError; + + fn basic(&mut self, address: Address) -> std::result::Result, Self::Error> { + self.state.basic(address) + } + + fn code_by_hash(&mut self, code_hash: B256) -> std::result::Result { + self.state.code_by_hash(code_hash) + } + + fn storage(&mut self, address: Address, index: U256) -> std::result::Result { + self.state.storage(address, index) + } + + fn block_hash(&mut self, number: u64) -> std::result::Result { + self.ancestors.lock().expect("ancestor chain lock poisoned").resolve(number) + } +} + +impl

DatabaseRef for VerifiedReplayDb

+where + P: Provider + std::fmt::Debug, +{ + type Error = crate::common::EvmeError; + + fn basic_ref(&self, address: Address) -> std::result::Result, Self::Error> { + self.state.basic_ref(address) + } + + fn code_by_hash_ref(&self, code_hash: B256) -> std::result::Result { + self.state.code_by_hash_ref(code_hash) + } + + fn storage_ref( + &self, + address: Address, + index: U256, + ) -> std::result::Result { + self.state.storage_ref(address, index) + } + + fn block_hash_ref(&self, number: u64) -> std::result::Result { + self.ancestors.lock().expect("ancestor chain lock poisoned").resolve(number) + } +} + +/// Lazily walks `parentHash` links from the verified parent block via `eth_getBlockByHash`, +/// checking each fetched header's hash and number so `BLOCKHASH` can never mix forks. +#[derive(Debug)] +struct VerifiedAncestorChain

{ + provider: P, + runtime: tokio::runtime::Handle, + parent_number: u64, + frontier_number: u64, + frontier_parent_hash: B256, + verified: HashMap, +} + +impl

VerifiedAncestorChain

+where + P: Provider, +{ + fn new(provider: P, parent_block: &Block) -> Self { + let parent_number = parent_block.number(); + let parent_hash = parent_block.hash(); + let mut verified = HashMap::new(); + verified.insert(parent_number, parent_hash); + Self { + provider, + runtime: tokio::runtime::Handle::current(), + parent_number, + frontier_number: parent_number, + frontier_parent_hash: parent_block.header.parent_hash(), + verified, + } + } + + fn resolve(&mut self, number: u64) -> crate::common::Result { + if let Some(&hash) = self.verified.get(&number) { + return Ok(hash); + } + if number > self.parent_number { + return Err(crate::common::EvmeError::RpcError(format!( + "Ancestor block height {number} is not before verified parent {}", + self.parent_number, + ))); + } + if self.parent_number - number >= 256 { + return Err(crate::common::EvmeError::RpcError(format!( + "Ancestor block height {number} is outside the 256-block BLOCKHASH window of \ + parent {}", + self.parent_number, + ))); + } + while self.frontier_number > number { + let expected_number = self.frontier_number - 1; + let expected_hash = self.frontier_parent_hash; + let fetched = tokio::task::block_in_place(|| { + self.runtime.block_on(self.provider.get_block_by_hash(expected_hash).into_future()) + }) + .map_err(|e| { + crate::common::EvmeError::RpcError(format!( + "Failed to fetch ancestor block {expected_number} ({expected_hash}): {e}" + )) + })? + .ok_or_else(|| { + crate::common::EvmeError::RpcError(format!( + "Ancestor block {expected_number} ({expected_hash}) not found" + )) + })?; + if fetched.number() != expected_number || fetched.hash() != expected_hash { + return Err(crate::common::EvmeError::RpcError(format!( + "Ancestor block mismatch at height {expected_number}: expected \ + {expected_number} ({expected_hash}), fetched {} ({})", + fetched.number(), + fetched.hash(), + ))); + } + self.verified.insert(expected_number, expected_hash); + self.frontier_number = expected_number; + self.frontier_parent_hash = fetched.header.parent_hash(); + } + Ok(*self.verified.get(&number).expect("verified chain reached target height")) + } +} + /// What the preceding-transaction loop does with an execution error. #[derive(Debug)] enum PredecessorError { diff --git a/bin/mega-evme/tests/replay_paths.rs b/bin/mega-evme/tests/replay_paths.rs index 10302c609..b31b5e6af 100644 --- a/bin/mega-evme/tests/replay_paths.rs +++ b/bin/mega-evme/tests/replay_paths.rs @@ -899,3 +899,335 @@ async fn test_replay_reads_prestate_at_parent_hash() { } assert!(state_reads > 0, "expected at least one state RPC read"); } + +/// Bytecode that returns `BLOCKHASH(NUMBER - 1) || BLOCKHASH(NUMBER - 2)` (64 bytes). +fn blockhash_ancestors_code() -> Vec { + vec![ + 0x60, 0x01, // PUSH1 1 + 0x43, // NUMBER + 0x03, // SUB -> N - 1 + 0x40, // BLOCKHASH + 0x5f, // PUSH0 + 0x52, // MSTORE -> mem[0x00..0x20] = BLOCKHASH(N - 1) + 0x60, 0x02, // PUSH1 2 + 0x43, // NUMBER + 0x03, // SUB -> N - 2 + 0x40, // BLOCKHASH + 0x60, 0x20, // PUSH1 0x20 + 0x52, // MSTORE -> mem[0x20..0x40] = BLOCKHASH(N - 2) + 0x60, 0x40, // PUSH1 0x40 + 0x5f, // PUSH0 + 0xf3, // RETURN + ] +} + +/// Satin transaction replay resolves `BLOCKHASH` ancestors by walking `parentHash` links from the +/// verified parent block (fetching earlier headers by hash and checking their hash and number), +/// never by calling `eth_getBlockByNumber` for ancestor heights. +#[tokio::test(flavor = "multi_thread")] +async fn test_replay_blockhash_walks_verified_ancestors_by_hash() { + let reader = address!("0x9999999999999999999999999999999999999999"); + let code = blockhash_ancestors_code(); + + let mut recorded = read_block(fixtures(), BLOCK); + recorded + .prestate + .accounts + .insert(PAYER, PreAccount { balance: U256::from(10u128.pow(18)), ..PreAccount::default() }); + let code_hash = alloy_primitives::keccak256(&code); + let codes = HashMap::from_iter([(code_hash, code)]); + recorded + .prestate + .accounts + .insert(reader, PreAccount { code_hash: Some(code_hash), ..Default::default() }); + let target = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01"; + recorded.block["transactions"] = json!([{ + "type": "0x2", + "chainId": "0x10e6", + "nonce": "0x0", + "gas": "0x4c4b40", + "maxFeePerGas": "0xf4240", + "maxPriorityFeePerGas": "0x0", + "to": reader, + "value": "0x0", + "accessList": [], + "input": "0x", + "r": "0x64c0524917585101b7ffb2286d4de676ca987554b33c6f9a37e7ad7508bfbb84", + "s": "0xe5199cacc6e07c6a9f8c74d0b06f964ce36dd362199b1c19d866f1a6f52d510", + "yParity": "0x1", + "v": "0x1", + "hash": target, + "blockHash": recorded.block["hash"], + "blockNumber": recorded.block["number"], + "transactionIndex": "0x0", + "from": PAYER, + "gasPrice": "0xf4240", + }]); + + let parent_hash: B256 = serde_json::from_value(recorded.block["parentHash"].clone()).unwrap(); + let grandparent_hash = B256::repeat_byte(0x22); + let great_grandparent_hash = B256::repeat_byte(0x33); + let fork_parent_hash = B256::repeat_byte(0xcc); + let fork_grandparent_hash = B256::repeat_byte(0xdd); + + let mut verified_parent = recorded.block.clone(); + verified_parent["number"] = json!(format!("0x{:x}", BLOCK - 1)); + verified_parent["hash"] = json!(parent_hash); + verified_parent["parentHash"] = json!(grandparent_hash); + verified_parent["transactions"] = json!([]); + + let mut fork_parent = verified_parent.clone(); + fork_parent["hash"] = json!(fork_parent_hash); + + let mut verified_grandparent = recorded.block.clone(); + verified_grandparent["number"] = json!(format!("0x{:x}", BLOCK - 2)); + verified_grandparent["hash"] = json!(grandparent_hash); + verified_grandparent["parentHash"] = json!(great_grandparent_hash); + verified_grandparent["transactions"] = json!([]); + + let mut fork_grandparent = verified_grandparent.clone(); + fork_grandparent["hash"] = json!(fork_grandparent_hash); + + let server = Server::with_codes(recorded, None, codes).await; + + // First `eth_getBlockByNumber(N-1)` serves the verified parent for header validation; any + // subsequent by-number lookup of N-1 serves a conflicting fork header. + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByNumber", + "params": [format!("0x{:x}", BLOCK - 1), false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": verified_parent, + })) + }) + .up_to_n_times(1) + .with_priority(1) + .mount(&server.0) + .await; + + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByNumber", + "params": [format!("0x{:x}", BLOCK - 1), false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": fork_parent, + })) + }) + .with_priority(2) + .mount(&server.0) + .await; + + // `eth_getBlockByNumber(N-2)` serves a different fork header than the hash-walked ancestor. + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByNumber", + "params": [format!("0x{:x}", BLOCK - 2), false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": fork_grandparent, + })) + }) + .with_priority(1) + .mount(&server.0) + .await; + + // `eth_getBlockByHash(grandparent_hash)` serves the verified ancestor reachable via parentHash. + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByHash", + "params": [grandparent_hash, false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": verified_grandparent, + })) + }) + .with_priority(1) + .mount(&server.0) + .await; + + let run = run_evme(&[ + "replay", + target, + "--rpc", + &server.0.uri(), + "--rpc.no-cache-file", + "--rpc.max-retries", + "0", + "--override.spec", + "Satin", + "--json", + ]); + assert_eq!(run.code, 0, "{}{}", run.stderr, run.stdout); + let summary: Value = serde_json::from_str(&run.stdout).unwrap(); + assert_eq!(summary["success"], true, "{summary}"); + + let mut expected_output = Vec::with_capacity(64); + expected_output.extend_from_slice(parent_hash.as_slice()); + expected_output.extend_from_slice(grandparent_hash.as_slice()); + assert_eq!( + summary["output"], + json!(alloy_primitives::hex::encode_prefixed(&expected_output)), + "BLOCKHASH(N-1) and BLOCKHASH(N-2) must observe hash-walked ancestors, not by-number headers" + ); + + let requests = server.0.received_requests().await.unwrap(); + let grandparent_num_hex = format!("0x{:x}", BLOCK - 2); + let parent_num_hex = format!("0x{:x}", BLOCK - 1); + let mut parent_by_number_calls = 0usize; + let mut grandparent_by_hash_calls = 0usize; + for request in &requests { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + match body["method"].as_str() { + Some("eth_getBlockByNumber") if body["params"][0] == grandparent_num_hex => { + panic!("replay must never query ancestor N-2 by block number: {body}"); + } + Some("eth_getBlockByNumber") if body["params"][0] == parent_num_hex => { + parent_by_number_calls += 1; + } + Some("eth_getBlockByHash") if body["params"][0] == json!(grandparent_hash) => { + grandparent_by_hash_calls += 1; + } + _ => {} + } + } + assert_eq!( + parent_by_number_calls, 1, + "N-1 should be fetched by number only once during header verification" + ); + assert_eq!( + grandparent_by_hash_calls, 1, + "N-2 must be fetched once by hash along the parentHash chain" + ); +} + +/// If walking `parentHash` encounters a missing ancestor or a header whose hash or number does +/// not match the expected link, Satin replay must fail explicitly. +#[tokio::test(flavor = "multi_thread")] +async fn test_replay_blockhash_fails_on_broken_ancestor_link() { + let reader = address!("0x9999999999999999999999999999999999999999"); + let code = blockhash_ancestors_code(); + let grandparent_hash = B256::repeat_byte(0x22); + + for (label, bad_grandparent) in [ + ("wrong_hash", Some((BLOCK - 2, B256::repeat_byte(0xee)))), + ("wrong_number", Some((BLOCK - 3, grandparent_hash))), + ("missing", None), + ] { + let mut recorded = read_block(fixtures(), BLOCK); + recorded.prestate.accounts.insert( + PAYER, + PreAccount { balance: U256::from(10u128.pow(18)), ..PreAccount::default() }, + ); + let code_hash = alloy_primitives::keccak256(&code); + let codes = HashMap::from_iter([(code_hash, code.clone())]); + recorded + .prestate + .accounts + .insert(reader, PreAccount { code_hash: Some(code_hash), ..Default::default() }); + let target = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02"; + recorded.block["transactions"] = json!([{ + "type": "0x2", + "chainId": "0x10e6", + "nonce": "0x0", + "gas": "0x4c4b40", + "maxFeePerGas": "0xf4240", + "maxPriorityFeePerGas": "0x0", + "to": reader, + "value": "0x0", + "accessList": [], + "input": "0x", + "r": "0x64c0524917585101b7ffb2286d4de676ca987554b33c6f9a37e7ad7508bfbb84", + "s": "0xe5199cacc6e07c6a9f8c74d0b06f964ce36dd362199b1c19d866f1a6f52d510", + "yParity": "0x1", + "v": "0x1", + "hash": target, + "blockHash": recorded.block["hash"], + "blockNumber": recorded.block["number"], + "transactionIndex": "0x0", + "from": PAYER, + "gasPrice": "0xf4240", + }]); + + let mut verified_parent = recorded.block.clone(); + verified_parent["number"] = json!(format!("0x{:x}", BLOCK - 1)); + verified_parent["hash"] = recorded.block["parentHash"].clone(); + verified_parent["parentHash"] = json!(grandparent_hash); + verified_parent["transactions"] = json!([]); + + let bad_result = bad_grandparent.map(|(num, hash)| { + let mut b = recorded.block.clone(); + b["number"] = json!(format!("0x{num:x}")); + b["hash"] = json!(hash); + b["parentHash"] = json!(B256::repeat_byte(0x33)); + b["transactions"] = json!([]); + b + }); + + let server = Server::with_codes(recorded, None, codes).await; + + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByNumber", + "params": [format!("0x{:x}", BLOCK - 1), false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": verified_parent, + })) + }) + .with_priority(1) + .mount(&server.0) + .await; + + Mock::given(matchers::body_partial_json(json!({ + "method": "eth_getBlockByHash", + "params": [grandparent_hash, false], + }))) + .respond_with(move |request: &wiremock::Request| { + let body: Value = serde_json::from_slice(&request.body).unwrap(); + let result = bad_result.clone().unwrap_or(Value::Null); + ResponseTemplate::new(200).set_body_json(json!({ + "jsonrpc": "2.0", + "id": body["id"], + "result": result, + })) + }) + .with_priority(1) + .mount(&server.0) + .await; + + let run = run_evme(&[ + "replay", + target, + "--rpc", + &server.0.uri(), + "--rpc.no-cache-file", + "--rpc.max-retries", + "0", + "--override.spec", + "Satin", + ]); + assert_ne!(run.code, 0, "{label}: broken ancestor link must fail replay: {}", run.stdout); + assert!( + run.stderr.contains("Ancestor block"), + "{label}: expected ancestor diagnostic in stderr: {}", + run.stderr + ); + } +} diff --git a/docs/mega-evme/commands/replay.md b/docs/mega-evme/commands/replay.md index f063c556a..9225211d7 100644 --- a/docs/mega-evme/commands/replay.md +++ b/docs/mega-evme/commands/replay.md @@ -11,8 +11,9 @@ In offline mode (`--rpc.replay-file`), all data is served from a local fixture c A Satin transaction replay requires a mined transaction in a block after genesis. Pending transactions have no canonical block context and are refused. Before reading the parent state, replay checks that the fetched parent has the preceding block number and the hash named by the transaction's block, and then issues pre-state reads (`eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount`) against that verified parent hash using EIP-1898 (`{"blockHash": ..., "requireCanonical": true}`) rather than by block number. -A header mismatch or non-canonical parent aborts the replay; retry with a consistent RPC endpoint or recording. -Because Satin pre-state reads are keyed by the EIP-1898 parent block hash instead of block number, per-endpoint cache entries (`--rpc.cache-dir`) and `--rpc.capture-file` / `--rpc.replay-file` keys differ from height-keyed captures; Satin replay files captured before this change must be re-captured. +`BLOCKHASH` queries resolve the parent directly from that verified header and walk earlier ancestors on demand by `parentHash` (`eth_getBlockByHash`, checking each header's hash and number across the 256-block window) instead of fetching ancestors by block number. +A header mismatch, broken ancestor link, or non-canonical parent response from the RPC server aborts the replay (cached hash-keyed hits and offline replay serve their recorded hash-bound entries); retry with a consistent RPC endpoint or recording. +Because Satin pre-state reads are keyed by the EIP-1898 parent block hash and `BLOCKHASH` ancestors are fetched via `eth_getBlockByHash` instead of block number, per-endpoint cache entries (`--rpc.cache-dir`) and `--rpc.capture-file` / `--rpc.replay-file` keys differ from height-keyed captures; Satin replay files captured before this change must be re-captured. With `--block`, `replay` re-executes whole blocks instead and compares every receipt with the chain's; see [Replaying Whole Blocks](#replaying-whole-blocks). From f7c6e2db7076aac9d4c5001e92f951549b5cf4c5 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:49:30 +0800 Subject: [PATCH 10/12] fix(state-test): reject symlinked directories and open fixture files non-blocking on Unix --- crates/mega-state-test/README.md | 5 +- crates/mega-state-test/src/input.rs | 271 +++++++++++++++++++++++----- 2 files changed, 229 insertions(+), 47 deletions(-) diff --git a/crates/mega-state-test/README.md b/crates/mega-state-test/README.md index 53adb4a93..2dd386cf1 100644 --- a/crates/mega-state-test/README.md +++ b/crates/mega-state-test/README.md @@ -63,8 +63,9 @@ cargo run --release -p state-test -- --mode satin --fork Osaka

/state_test ## Fixture input limits Discovery accepts at most 100,000 fixture files across all input paths and entries at most 64 levels below each input directory. -Discovery follows symlinks so symlinked fixture subdirectories are included under the same depth and count limits, while broken links and symlink loops fail discovery. -Only regular files (after following links) are admitted: a non-regular input or `*.json` entry (such as a FIFO, socket, device, or directory) fails discovery with an error naming the path before any file is opened. +Discovery does not follow directory symlinks: a symlinked directory (given as a root or encountered beneath one) fails discovery with an error naming the path rather than being silently dropped or traversed through aliases, and broken symlinks fail discovery as well. +Only regular files (including symlinks to regular `*.json` files) are admitted: a non-regular input or `*.json` entry (such as a FIFO, socket, device, or directory) fails discovery with an error naming the path before any file is opened. +The bounded reader opens files non-blocking on Unix (`O_NONBLOCK`) and validates the opened descriptor's file type before reading, so a path swapped to a FIFO after discovery cannot hang the runner. A traversal error or an exceeded limit fails the run; neither a deep subtree nor excess files are silently omitted. The state-test runner accepts fixture files up to 64 MiB; the blockchain-test runner accepts up to 256 MiB because a file bundles many block sequences, and the pinned execution-spec fixtures include files around 160 MiB. Both reject oversized files before reading their contents and cap the read itself in case a file grows. diff --git a/crates/mega-state-test/src/input.rs b/crates/mega-state-test/src/input.rs index 1c98adc1b..3e87f9adf 100644 --- a/crates/mega-state-test/src/input.rs +++ b/crates/mega-state-test/src/input.rs @@ -31,17 +31,104 @@ pub(crate) fn read_blockchain_fixture(path: &Path) -> io::Result { read_file_with_limit(path, MAX_BLOCKCHAIN_FIXTURE_BYTES) } -fn read_file_with_limit(path: &Path, limit: u64) -> io::Result { - let metadata = path - .metadata() - .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display())))?; - if !metadata.is_file() { - return Err(io::Error::new( - io::ErrorKind::InvalidInput, - format!("fixture input is not a regular file: {}", path.display()), - )); +#[cfg(unix)] +fn unix_o_nonblock() -> Option { + #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "dragonfly", + ))] + { + Some(0x0004) + } + #[cfg(all( + any(target_os = "linux", target_os = "android"), + any(target_arch = "mips", target_arch = "mips64"), + ))] + { + Some(0x0080) + } + #[cfg(all( + any(target_os = "linux", target_os = "android"), + any(target_arch = "sparc", target_arch = "sparc64"), + ))] + { + Some(0x4000) + } + #[cfg(all( + any(target_os = "linux", target_os = "android"), + not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "sparc", + target_arch = "sparc64", + )), + ))] + { + Some(0x0800) + } + #[cfg(not(any( + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "linux", + target_os = "android", + )))] + { + None } - read_with_limit(File::open(path)?, limit) +} + +/// Opens `path` read-only without blocking on Unix FIFOs (`O_NONBLOCK`), so descriptor validation +/// via `fstat` (`File::metadata`) rejects non-regular files even if the path is swapped between +/// discovery and open. +fn open_nonblocking(path: &Path) -> io::Result { + let mut options = std::fs::OpenOptions::new(); + options.read(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + if let Some(flag) = unix_o_nonblock() { + options.custom_flags(flag); + } else { + let metadata = path.metadata().map_err(|error| { + io::Error::new(error.kind(), format!("{}: {error}", path.display())) + })?; + if !metadata.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file: {}", path.display()), + )); + } + } + } + #[cfg(not(unix))] + { + let metadata = path.metadata().map_err(|error| { + io::Error::new(error.kind(), format!("{}: {error}", path.display())) + })?; + if !metadata.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file: {}", path.display()), + )); + } + } + options + .open(path) + .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display()))) +} + +fn read_file_with_limit(path: &Path, limit: u64) -> io::Result { + let file = open_nonblocking(path)?; + read_with_limit(file, limit) + .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display()))) } fn read_with_limit(file: File, limit: u64) -> io::Result { @@ -101,21 +188,43 @@ pub fn find_json_files_in_paths(paths: &[PathBuf]) -> io::Result> { } fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) -> io::Result<()> { - let metadata = path - .metadata() + // Strip any trailing separator so Unix `lstat` inspects a symlinked root directory itself + // rather than following it through the trailing slash. + let probe: PathBuf = path.components().collect(); + let symlink_meta = std::fs::symlink_metadata(&probe) .map_err(|error| io::Error::new(error.kind(), format!("{}: {error}", path.display())))?; - if metadata.is_file() { + if symlink_meta.file_type().is_symlink() { + let target_meta = path.metadata().map_err(|error| { + io::Error::new(error.kind(), format!("{}: {error}", path.display())) + })?; + if target_meta.is_dir() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("symlinked fixture directory is not allowed: {}", path.display()), + )); + } + if target_meta.is_file() { + return add_file(path.to_path_buf(), files, limit); + } + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file or directory: {}", path.display()), + )); + } + if symlink_meta.is_file() { return add_file(path.to_path_buf(), files, limit); } - if !metadata.is_dir() { + if !symlink_meta.is_dir() { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("fixture input is not a regular file or directory: {}", path.display()), )); } - // Follow symlinks so symlinked fixture directories are traversed rather than silently dropped; - // WalkDir reports symlink loops and broken links as errors, which propagate via `?`. - for entry in WalkDir::new(path).follow_links(true) { + // Do not follow directory symlinks: a symlinked directory fails discovery explicitly so + // aliased subtrees can neither execute fixtures twice nor cause exponential walks. Symlinks + // to regular `*.json` files are permitted; broken links and links to non-regular `*.json` + // targets fail explicitly. + for entry in WalkDir::new(path) { let entry = entry?; // WalkDir::max_depth would silently omit descendants, so inspect the first excess entry. if entry.depth() > depth { @@ -124,11 +233,32 @@ fn discover(path: &Path, files: &mut Vec, depth: usize, limit: usize) - format!("fixture directory depth exceeds {depth}: {}", entry.path().display()), )); } - if entry.path().extension().is_some_and(|ext| ext == "json") { - let entry_meta = entry.path().metadata().map_err(|error| { + if entry.file_type().is_symlink() { + let target_meta = entry.path().metadata().map_err(|error| { io::Error::new(error.kind(), format!("{}: {error}", entry.path().display())) })?; - if !entry_meta.is_file() { + if target_meta.is_dir() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!( + "symlinked fixture directory is not allowed: {}", + entry.path().display() + ), + )); + } + if entry.path().extension().is_some_and(|ext| ext == "json") { + if !target_meta.is_file() { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("fixture input is not a regular file: {}", entry.path().display()), + )); + } + add_file(entry.into_path(), files, limit)?; + } + continue; + } + if entry.path().extension().is_some_and(|ext| ext == "json") { + if !entry.file_type().is_file() { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("fixture input is not a regular file: {}", entry.path().display()), @@ -256,7 +386,8 @@ mod tests { let err = find_json_files(&fifo).expect_err("direct FIFO input must fail discovery"); assert!(err.to_string().contains(&fifo.display().to_string()), "{err}"); - // Even a direct `read_fixture` call refuses the FIFO without blocking in `File::open`. + // Even a direct `read_fixture` call refuses the FIFO without blocking, because the Unix + // reader opens with `O_NONBLOCK` and validates the opened descriptor's file type. let fifo_clone = fifo.clone(); let (tx, rx) = mpsc::channel(); std::thread::spawn(move || { @@ -265,7 +396,23 @@ mod tests { let read_res = rx .recv_timeout(Duration::from_secs(2)) .expect("read_fixture must reject FIFO without blocking"); - assert!(read_res.is_err(), "FIFO must not be read as a fixture"); + let read_err = read_res.expect_err("FIFO must not be read as a fixture"); + assert_eq!(read_err.kind(), io::ErrorKind::InvalidInput, "{read_err}"); + assert!(read_err.to_string().contains(&fifo.display().to_string()), "{read_err}"); + + // Exercise `open_nonblocking` directly on the FIFO (no pre-open metadata check) to prove + // the `O_NONBLOCK` open itself returns immediately and `read_with_limit` rejects the fd. + let fifo_clone2 = fifo.clone(); + let (tx2, rx2) = mpsc::channel(); + std::thread::spawn(move || { + let res = open_nonblocking(&fifo_clone2).and_then(|file| read_with_limit(file, 64)); + let _ = tx2.send(res); + }); + let direct_err = rx2 + .recv_timeout(Duration::from_secs(2)) + .expect("O_NONBLOCK open on FIFO must not block") + .expect_err("descriptor validation must reject opened FIFO"); + assert_eq!(direct_err.kind(), io::ErrorKind::InvalidInput, "{direct_err}"); // A directory whose name ends in `.json` is also a non-regular entry and fails discovery. let dir_root = tempfile::tempdir().unwrap(); @@ -279,47 +426,81 @@ mod tests { #[cfg(unix)] #[test] - fn test_discovery_follows_symlink_dir_and_rejects_symlink_loop() { + fn test_discovery_rejects_symlinked_directories_and_allows_regular_file_symlinks() { use std::os::unix::fs::symlink; let root = tempfile::tempdir().unwrap(); let real = root.path().join("real"); std::fs::create_dir(&real).unwrap(); - std::fs::write(real.join("a.json"), "{}").unwrap(); + let real_file = real.join("a.json"); + std::fs::write(&real_file, "{}").unwrap(); + // 1. Symlinked subdirectory fails discovery explicitly with InvalidInput naming the path. let top = root.path().join("top"); std::fs::create_dir(&top).unwrap(); std::fs::write(top.join("b.json"), "{}").unwrap(); - symlink(&real, top.join("link")).unwrap(); - - // Symlinked subdirectory's fixture is discovered, not silently dropped. - let files = find_json_files(&top).expect("symlinked directory is followed"); - assert_eq!(files.len(), 2, "{files:?}"); - assert!(files.iter().any(|p| p.ends_with("b.json")), "{files:?}"); - assert!(files.iter().any(|p| p.ends_with("a.json")), "{files:?}"); - - // Existing depth limit still applies to entries reached through a symlinked directory. - let err = discover(&top, &mut Vec::new(), 1, 10) - .expect_err("depth limit must apply through symlinked directory"); - assert!(err.to_string().contains("depth exceeds 1"), "{err}"); - - // A symlink loop yields an error rather than hanging or silently dropping entries. + let sub_link = top.join("link"); + symlink(&real, &sub_link).unwrap(); + let err = find_json_files(&top).expect_err("symlinked subdirectory must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); + assert!(err.to_string().contains(&sub_link.display().to_string()), "{err}"); + + // 2. Symlinked root directory (with or without trailing slash) fails discovery explicitly. + let root_link = root.path().join("root_link"); + symlink(&real, &root_link).unwrap(); + let err = + find_json_files(&root_link).expect_err("symlinked root directory must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); + assert!(err.to_string().contains(&root_link.display().to_string()), "{err}"); + + let root_link_slash = PathBuf::from(format!("{}/", root_link.display())); + let err = find_json_files(&root_link_slash) + .expect_err("symlinked root directory with trailing slash must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); + + // 3. Two links to one directory cannot cause duplicate execution (discovery fails). + let dup_root = root.path().join("dup"); + std::fs::create_dir(&dup_root).unwrap(); + symlink(&real, dup_root.join("first")).unwrap(); + symlink(&real, dup_root.join("second")).unwrap(); + let err = find_json_files(&dup_root) + .expect_err("multiple directory symlinks must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); + + // 4. Symlink loop fails discovery explicitly. let loop_root = tempfile::tempdir().unwrap(); let sub = loop_root.path().join("sub"); std::fs::create_dir(&sub).unwrap(); - symlink(loop_root.path(), sub.join("back")).unwrap(); - assert!(find_json_files(loop_root.path()).is_err(), "symlink loop must fail discovery"); - - // A symlink to a non-regular file (FIFO) named `*.json` fails discovery explicitly. + let back = sub.join("back"); + symlink(loop_root.path(), &back).unwrap(); + let err = find_json_files(loop_root.path()).expect_err("symlink loop must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); + assert!(err.to_string().contains(&back.display().to_string()), "{err}"); + + // 5. Symlink to a regular `*.json` file is permitted (both inside a directory and as root). + let file_link_root = root.path().join("file_links"); + std::fs::create_dir(&file_link_root).unwrap(); + let file_link = file_link_root.join("linked.json"); + symlink(&real_file, &file_link).unwrap(); + let files = find_json_files(&file_link_root).expect("regular file symlink is allowed"); + assert_eq!(files, vec![file_link.clone()]); + assert_eq!( + find_json_files(&file_link).expect("direct file symlink root"), + vec![file_link.clone()] + ); + assert_eq!(read_fixture(&file_link).expect("read regular file symlink"), "{}"); + + // 6. Symlink to a non-regular file (FIFO) named `*.json` fails discovery explicitly. let fifo_target = root.path().join("pipe"); let status = std::process::Command::new("mkfifo").arg(&fifo_target).status().expect("mkfifo runs"); assert!(status.success(), "mkfifo failed"); - let link_root = tempfile::tempdir().unwrap(); - let fifo_link = link_root.path().join("linked.json"); + let fifo_link_root = tempfile::tempdir().unwrap(); + let fifo_link = fifo_link_root.path().join("linked.json"); symlink(&fifo_target, &fifo_link).unwrap(); - let err = find_json_files(link_root.path()) + let err = find_json_files(fifo_link_root.path()) .expect_err("symlink to FIFO named *.json must fail discovery"); + assert_eq!(err.kind(), io::ErrorKind::InvalidInput, "{err}"); assert!(err.to_string().contains(&fifo_link.display().to_string()), "{err}"); } } From f8497bc1a2d4ea905fc866859f55ac4e865fa062 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 18:49:53 +0800 Subject: [PATCH 11/12] style(evme): format round-3 replay changes --- bin/mega-evme/src/replay/cmd.rs | 6 +----- bin/mega-evme/tests/replay_paths.rs | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/mega-evme/src/replay/cmd.rs b/bin/mega-evme/src/replay/cmd.rs index 428fa3eab..70c565ea3 100644 --- a/bin/mega-evme/src/replay/cmd.rs +++ b/bin/mega-evme/src/replay/cmd.rs @@ -728,11 +728,7 @@ where self.state.code_by_hash_ref(code_hash) } - fn storage_ref( - &self, - address: Address, - index: U256, - ) -> std::result::Result { + fn storage_ref(&self, address: Address, index: U256) -> std::result::Result { self.state.storage_ref(address, index) } diff --git a/bin/mega-evme/tests/replay_paths.rs b/bin/mega-evme/tests/replay_paths.rs index b31b5e6af..780dd9780 100644 --- a/bin/mega-evme/tests/replay_paths.rs +++ b/bin/mega-evme/tests/replay_paths.rs @@ -635,7 +635,10 @@ async fn test_a_replay_stops_when_a_predecessor_account_cannot_be_read() { let output = format!("{}{}", run.stdout, run.stderr); assert!(output.contains("Block execution error"), "{output}"); assert!(output.contains(&MISSING.to_string()), "{output}"); - assert!(output.contains("-32000") && output.contains("server error message omitted"), "{output}"); + assert!( + output.contains("-32000") && output.contains("server error message omitted"), + "{output}" + ); assert!(!output.contains("account not recorded"), "{output}"); } From c1ff65b06dd1c84d4d109f524b57053a530e5be2 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Fri, 20 Nov 2026 00:38:45 +0800 Subject: [PATCH 12/12] fix(state-test): drop a redundant clone in the FIFO regression test --- crates/mega-state-test/src/input.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/mega-state-test/src/input.rs b/crates/mega-state-test/src/input.rs index 3e87f9adf..766f06ea5 100644 --- a/crates/mega-state-test/src/input.rs +++ b/crates/mega-state-test/src/input.rs @@ -402,10 +402,9 @@ mod tests { // Exercise `open_nonblocking` directly on the FIFO (no pre-open metadata check) to prove // the `O_NONBLOCK` open itself returns immediately and `read_with_limit` rejects the fd. - let fifo_clone2 = fifo.clone(); let (tx2, rx2) = mpsc::channel(); std::thread::spawn(move || { - let res = open_nonblocking(&fifo_clone2).and_then(|file| read_with_limit(file, 64)); + let res = open_nonblocking(&fifo).and_then(|file| read_with_limit(file, 64)); let _ = tx2.send(res); }); let direct_err = rx2