From 8d90b53af0d470597dbae7ebed971cb7d842b7d2 Mon Sep 17 00:00:00 2001 From: lightsing Date: Sun, 28 Apr 2024 14:32:40 +0800 Subject: [PATCH 1/4] add curie suite --- testool/Config.toml | 40 ++++++++++++++++++++++++++++------ testool/src/config.rs | 4 ++-- testool/src/main.rs | 6 ++++- testool/src/statetest/suite.rs | 8 ++++++- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/testool/Config.toml b/testool/Config.toml index e959148547..87b87034d7 100644 --- a/testool/Config.toml +++ b/testool/Config.toml @@ -1,6 +1,8 @@ [[suite]] id="default" -path="tests/src/GeneralStateTestsFiller/**/*" +paths = [ + "tests/src/GeneralStateTestsFiller/**/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [ @@ -11,21 +13,27 @@ ignore_tests = [ [[suite]] id="EIP1153" -path = "tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*" +paths = [ + "tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [] [[suite]] id="EIP2930" -path="tests/src/GeneralStateTestsFiller/stEIP2930/*" +paths = [ + "tests/src/GeneralStateTestsFiller/stEIP2930/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [] [[suite]] id="EIP1559" -path="tests/src/GeneralStateTestsFiller/stEIP1559/**/*" +paths = [ + "tests/src/GeneralStateTestsFiller/stEIP1559/**/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [] @@ -33,25 +41,43 @@ ignore_tests = [] [[suite]] id="precompile" -path="tests/src/GeneralStateTestsFiller/stPreCompiledContracts/*" +paths = [ + "tests/src/GeneralStateTestsFiller/stPreCompiledContracts/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [] [[suite]] id="precompile2" -path="tests/src/GeneralStateTestsFiller/stPreCompiledContracts2/*" +paths = [ + "tests/src/GeneralStateTestsFiller/stPreCompiledContracts2/*" +] max_gas = 500000 max_steps = 1000 ignore_tests = [] [[suite]] id="nightly" -path="tests/src/GeneralStateTestsFiller/**/*" +paths = [ + "tests/src/GeneralStateTestsFiller/**/*" +] max_gas = 0 max_steps = 100000 ignore_tests=[] +[[suite]] +id="curie" +paths = [ + "tests/src/GeneralStateTestsFiller/stEIP1559/*", + "tests/src/GeneralStateTestsFiller/stEIP2930/*", + "tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*", + "tests/src/GeneralStateTestsFiller/Cancun/stEIP5656-MCOPY/*" +] +max_gas = 0 +max_steps = 100000 +ignore_tests = [] + [[set]] id = "sigkill" desc = "tests that sigkill" diff --git a/testool/src/config.rs b/testool/src/config.rs index 0dd85066f8..6ac56959e7 100644 --- a/testool/src/config.rs +++ b/testool/src/config.rs @@ -16,7 +16,7 @@ pub struct Config { #[derive(Debug, Clone, Deserialize)] pub struct TestSuite { pub id: String, - pub path: String, + pub paths: Vec, pub max_gas: u64, pub max_steps: u64, @@ -28,7 +28,7 @@ impl Default for TestSuite { fn default() -> Self { Self { id: "default".to_string(), - path: String::default(), + paths: vec![], max_gas: u64::MAX, max_steps: u64::MAX, ignore_tests: Some(Filter::any()), diff --git a/testool/src/main.rs b/testool/src/main.rs index aba2122b6a..e3119d2387 100644 --- a/testool/src/main.rs +++ b/testool/src/main.rs @@ -173,7 +173,11 @@ fn go() -> Result<()> { let compiler = Compiler::new(true, Some(PathBuf::from(CODEHASH_FILE)))?; let suite = config.suite(&args.suite)?.clone(); let mut state_tests = load_statetests_suite(&suite, config, compiler)?; - log::info!("{} tests collected in {}", state_tests.len(), suite.path); + log::info!( + "{} tests collected in {}", + state_tests.len(), + suite.paths.join(", ") + ); if args.ls { let mut list: Vec<_> = state_tests.into_iter().map(|t| t.id).collect(); diff --git a/testool/src/statetest/suite.rs b/testool/src/statetest/suite.rs index 8a5d65db83..6a6006829d 100644 --- a/testool/src/statetest/suite.rs +++ b/testool/src/statetest/suite.rs @@ -22,8 +22,14 @@ pub fn load_statetests_suite( let skip_paths: Vec<&String> = config.skip_paths.iter().flat_map(|t| &t.paths).collect(); let skip_tests: Vec<&String> = config.skip_tests.iter().flat_map(|t| &t.tests).collect(); - let tcs = glob::glob(&suite.path) + let tcs = suite + .paths + .iter() + .map(|p| glob::glob(p)) + .collect::, glob::PatternError>>() .context("failed to read glob")? + .into_iter() + .flatten() .filter_map(|v| v.ok()) .filter(|f| { !skip_paths From 932be11c8e7af3026473b66a78ff53e1f25f47eb Mon Sep 17 00:00:00 2001 From: lightsing Date: Sun, 28 Apr 2024 14:57:22 +0800 Subject: [PATCH 2/4] enable normalize for stEIP1153-transientStorage --- testool/src/abi.rs | 7 +++++-- testool/src/statetest/yaml.rs | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/testool/src/abi.rs b/testool/src/abi.rs index 6b5545200e..5a95171d05 100644 --- a/testool/src/abi.rs +++ b/testool/src/abi.rs @@ -1,6 +1,10 @@ use anyhow::Result; use eth_types::{Bytes, U256}; use sha3::Digest; +use std::sync::atomic::{AtomicBool, Ordering}; + +/// dirty hack to enable normalization +pub static ENABLE_NORMALIZE: AtomicBool = AtomicBool::new(false); /// encodes an abi call (e.g. "f(uint) 1") pub fn encode_funccall(spec: &str) -> Result { @@ -76,8 +80,7 @@ pub fn encode_funccall(spec: &str) -> Result { }; // Shoule be false for stEIP1153-transientStorage, // due to this bughttps://github.com/ethereum/tests/issues/1369 - let enable_normalize = true; - let bytes: Vec = if !enable_normalize { + let bytes: Vec = if !ENABLE_NORMALIZE.load(Ordering::SeqCst) { 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(); diff --git a/testool/src/statetest/yaml.rs b/testool/src/statetest/yaml.rs index 7fee98a928..92f0269a61 100644 --- a/testool/src/statetest/yaml.rs +++ b/testool/src/statetest/yaml.rs @@ -2,7 +2,7 @@ use super::{ parse, spec::{AccountMatch, Env, StateTest, DEFAULT_BASE_FEE}, }; -use crate::{utils::MainnetFork, Compiler}; +use crate::{abi, utils::MainnetFork, Compiler}; use anyhow::{anyhow, bail, Context, Result}; use eth_types::{geth_types::Account, Address, Bytes, H256, U256}; use ethers_core::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; @@ -10,6 +10,7 @@ use std::{ collections::{BTreeMap, HashMap, HashSet}, convert::TryInto, str::FromStr, + sync::atomic::Ordering, }; use yaml_rust::Yaml; @@ -50,6 +51,11 @@ impl<'a> YamlStateTestBuilder<'a> { /// generates `StateTest` vectors from a ethereum yaml test specification pub fn load_yaml(&mut self, path: &str, source: &str) -> Result> { + if path.contains("stEIP1153-transientStorage") { + abi::ENABLE_NORMALIZE.store(true, Ordering::SeqCst); + } else { + abi::ENABLE_NORMALIZE.store(false, Ordering::SeqCst); + } //log::trace!("load_yaml {path}"); // get the yaml root element let doc = yaml_rust::YamlLoader::load_from_str(source) From fdea754df62c3717f57bd0ad56082034fe62a0d6 Mon Sep 17 00:00:00 2001 From: lightsing Date: Sun, 28 Apr 2024 15:09:22 +0800 Subject: [PATCH 3/4] fix --- testool/src/abi.rs | 10 ++++++---- testool/src/statetest/yaml.rs | 5 ++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/testool/src/abi.rs b/testool/src/abi.rs index 5a95171d05..41b39427ff 100644 --- a/testool/src/abi.rs +++ b/testool/src/abi.rs @@ -1,10 +1,12 @@ use anyhow::Result; use eth_types::{Bytes, U256}; use sha3::Digest; -use std::sync::atomic::{AtomicBool, Ordering}; +use std::cell::RefCell; -/// dirty hack to enable normalization -pub static ENABLE_NORMALIZE: AtomicBool = AtomicBool::new(false); +thread_local! { + /// dirty hack to enable normalization + pub static ENABLE_NORMALIZE: RefCell = RefCell::new(true); +} /// encodes an abi call (e.g. "f(uint) 1") pub fn encode_funccall(spec: &str) -> Result { @@ -80,7 +82,7 @@ pub fn encode_funccall(spec: &str) -> Result { }; // Shoule be false for stEIP1153-transientStorage, // due to this bughttps://github.com/ethereum/tests/issues/1369 - let bytes: Vec = if !ENABLE_NORMALIZE.load(Ordering::SeqCst) { + let bytes: Vec = if ENABLE_NORMALIZE.with_borrow(|b| *b) { 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(); diff --git a/testool/src/statetest/yaml.rs b/testool/src/statetest/yaml.rs index 92f0269a61..ab6760c1fb 100644 --- a/testool/src/statetest/yaml.rs +++ b/testool/src/statetest/yaml.rs @@ -10,7 +10,6 @@ use std::{ collections::{BTreeMap, HashMap, HashSet}, convert::TryInto, str::FromStr, - sync::atomic::Ordering, }; use yaml_rust::Yaml; @@ -52,9 +51,9 @@ impl<'a> YamlStateTestBuilder<'a> { /// generates `StateTest` vectors from a ethereum yaml test specification pub fn load_yaml(&mut self, path: &str, source: &str) -> Result> { if path.contains("stEIP1153-transientStorage") { - abi::ENABLE_NORMALIZE.store(true, Ordering::SeqCst); + abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = false) } else { - abi::ENABLE_NORMALIZE.store(false, Ordering::SeqCst); + abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = true) } //log::trace!("load_yaml {path}"); // get the yaml root element From f30120023e91579acd3333129493a5c8266019b5 Mon Sep 17 00:00:00 2001 From: lightsing Date: Sun, 28 Apr 2024 15:13:07 +0800 Subject: [PATCH 4/4] fix cond, move comment --- testool/src/abi.rs | 4 +--- testool/src/statetest/yaml.rs | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testool/src/abi.rs b/testool/src/abi.rs index 41b39427ff..525b2486f7 100644 --- a/testool/src/abi.rs +++ b/testool/src/abi.rs @@ -80,9 +80,7 @@ pub fn encode_funccall(spec: &str) -> Result { state_mutability: StateMutability::Payable, constant: Some(false), }; - // Shoule be false for stEIP1153-transientStorage, - // due to this bughttps://github.com/ethereum/tests/issues/1369 - let bytes: Vec = if ENABLE_NORMALIZE.with_borrow(|b| *b) { + let bytes: Vec = if !ENABLE_NORMALIZE.with_borrow(|b| *b) { 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(); diff --git a/testool/src/statetest/yaml.rs b/testool/src/statetest/yaml.rs index ab6760c1fb..5ec4576ce7 100644 --- a/testool/src/statetest/yaml.rs +++ b/testool/src/statetest/yaml.rs @@ -50,6 +50,8 @@ impl<'a> YamlStateTestBuilder<'a> { /// generates `StateTest` vectors from a ethereum yaml test specification pub fn load_yaml(&mut self, path: &str, source: &str) -> Result> { + // Shoule be false for stEIP1153-transientStorage, + // due to this bug https://github.com/ethereum/tests/issues/1369 if path.contains("stEIP1153-transientStorage") { abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = false) } else {