diff --git a/Cargo.lock b/Cargo.lock index a99cb46ac0..a88a74fc90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4199,6 +4199,7 @@ dependencies = [ "regex", "serde", "serde_json", + "sha3 0.10.8", "strum 0.24.1", "strum_macros 0.24.3", "thiserror", diff --git a/testool/Cargo.toml b/testool/Cargo.toml index cb09bf1444..6f74b5e2ba 100644 --- a/testool/Cargo.toml +++ b/testool/Cargo.toml @@ -34,6 +34,7 @@ rand_chacha = "0.3" rand = "0.8" halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v0.3.0" } urlencoding = "2.1.2" +sha3 = "0.10" [features] diff --git a/testool/Config.toml b/testool/Config.toml index 07943c9243..c9190c1e89 100644 --- a/testool/Config.toml +++ b/testool/Config.toml @@ -10,6 +10,13 @@ path="tests/src/GeneralStateTestsFiller/**/*" max_gas = 0 max_steps = 100000 +[[suite]] +id="EIP1153" +path = "tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*" +max_gas = 500000 +max_steps = 1000 +ignore_tests = [] + [[skip_paths]] desc = "unimplemented" paths = [ diff --git a/testool/src/abi.rs b/testool/src/abi.rs index 34e1699253..22f16c232a 100644 --- a/testool/src/abi.rs +++ b/testool/src/abi.rs @@ -1,5 +1,6 @@ use anyhow::Result; use eth_types::{Bytes, U256}; +use sha3::Digest; /// encodes an abi call (e.g. "f(uint) 1") pub fn encode_funccall(spec: &str) -> Result { @@ -67,7 +68,19 @@ pub fn encode_funccall(spec: &str) -> Result { constant: Some(false), }; - Ok(Bytes::from(func.encode_input(&args)?)) + // Shoule be false for stEIP1153-transientStorage, + // due to this bug https://github.com/ethereum/tests/issues/1369 + let enable_normalize = true; + let bytes: Vec = if !enable_normalize { + let encoded_params = ethers_core::abi::encode(&args); + let short_signature: Vec = sha3::Keccak256::digest(tokens[0])[0..4].to_vec(); + let bytes: Vec = short_signature.into_iter().chain(encoded_params).collect(); + bytes + } else { + func.encode_input(&args)? + }; + + Ok(Bytes::from(bytes)) } #[cfg(test)] diff --git a/testool/src/main.rs b/testool/src/main.rs index 1687af80fb..a2274a3490 100644 --- a/testool/src/main.rs +++ b/testool/src/main.rs @@ -76,14 +76,15 @@ struct Args { v: bool, } -fn run_single_test(test: StateTest, circuits_config: CircuitsConfig) -> Result<()> { +fn run_single_test( + test: StateTest, + suite: TestSuite, + circuits_config: CircuitsConfig, +) -> Result<()> { log::info!("{}", &test); let trace = geth_trace(test.clone())?; crate::utils::print_trace(trace)?; - log::info!( - "result={:?}", - run_test(test, TestSuite::default(), circuits_config) - ); + log::info!("result={:?}", run_test(test, suite, circuits_config)); Ok(()) } @@ -100,7 +101,7 @@ fn go() -> Result<()> { if let Some(oneliner) = &args.oneliner { let test = StateTest::parse_oneline_spec(oneliner)?; - run_single_test(test, circuits_config)?; + run_single_test(test, Default::default(), circuits_config)?; return Ok(()); } @@ -137,7 +138,11 @@ fn go() -> Result<()> { } bail!("test '{}' not found", test_id); } - run_single_test(state_tests_filtered.remove(0).clone(), circuits_config)?; + run_single_test( + state_tests_filtered.remove(0).clone(), + suite, + circuits_config, + )?; return Ok(()); }; diff --git a/testool/tests b/testool/tests index 747a4828f3..faf33b4714 160000 --- a/testool/tests +++ b/testool/tests @@ -1 +1 @@ -Subproject commit 747a4828f36c5fc8ab4f288d1cf4f1fe6662f3d6 +Subproject commit faf33b471465d3c6cdc3d04fbd690895f78d33f2