Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
fix(testool): add fix from scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
curryrasul committed May 9, 2024
1 parent 9a13854 commit 5bf7ffa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions testool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions testool/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
15 changes: 14 additions & 1 deletion testool/src/abi.rs
Original file line number Diff line number Diff line change
@@ -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<Bytes> {
Expand Down Expand Up @@ -67,7 +68,19 @@ pub fn encode_funccall(spec: &str) -> Result<Bytes> {
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<u8> = if !enable_normalize {
let encoded_params = ethers_core::abi::encode(&args);
let short_signature: Vec<u8> = sha3::Keccak256::digest(tokens[0])[0..4].to_vec();
let bytes: Vec<u8> = short_signature.into_iter().chain(encoded_params).collect();
bytes
} else {
func.encode_input(&args)?
};

Ok(Bytes::from(bytes))
}

#[cfg(test)]
Expand Down
19 changes: 12 additions & 7 deletions testool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand All @@ -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(());
}

Expand Down Expand Up @@ -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(());
};

Expand Down

0 comments on commit 5bf7ffa

Please sign in to comment.