From 5699a5f051954a76a573840faea18344f9161a03 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Mon, 28 Jun 2021 11:51:35 +0300 Subject: [PATCH 1/5] Add London to recognized fork spec variants --- ethjson/src/spec/spec.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethjson/src/spec/spec.rs b/ethjson/src/spec/spec.rs index 182bf95..8862634 100644 --- a/ethjson/src/spec/spec.rs +++ b/ethjson/src/spec/spec.rs @@ -40,8 +40,10 @@ pub enum ForkSpec { ConstantinopleFix, /// Istanbul (#9,069,000, 2019-12-08) Istanbul, - /// Berlin (To be announced) + /// Berlin (#12,244,000, 2021-04-15) Berlin, + /// London (To be announced) + London, /// Byzantium transition test-net EIP158ToByzantiumAt5, /// Homestead transition test-net From ba83e81f4db5cfff4a5898d593f53fc25d6faa94 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Tue, 22 Jun 2021 21:33:19 +0300 Subject: [PATCH 2/5] Update ethtests to version 9.0.2 Test stChangedEIP150 is no longer present in the suite. Test stExample has added a post-Berlin transaction description and has to be ignored for the time being. --- jsontests/res/ethtests | 2 +- jsontests/tests/state.rs | 4 ++-- jsontests/tests/vm.rs | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jsontests/res/ethtests b/jsontests/res/ethtests index 63c2b72..5d65138 160000 --- a/jsontests/res/ethtests +++ b/jsontests/res/ethtests @@ -1 +1 @@ -Subproject commit 63c2b72ff9d81a07c03dac46977218156cd136bf +Subproject commit 5d651381daf9d12cc663a7326b3b16d7bb4c1aa0 diff --git a/jsontests/tests/state.rs b/jsontests/tests/state.rs index 1624400..d10f6e6 100644 --- a/jsontests/tests/state.rs +++ b/jsontests/tests/state.rs @@ -41,7 +41,6 @@ pub fn run(dir: &str) { #[test] fn st_call_delegate_codes_call_code_homestead() { run("res/ethtests/GeneralStateTests/stCallDelegateCodesCallCodeHomestead") } #[test] fn st_call_delegate_codes_homestead() { run("res/ethtests/GeneralStateTests/stCallDelegateCodesHomestead") } #[test] fn st_chain_id() { run("res/ethtests/GeneralStateTests/stChainId") } -#[test] fn st_changed_eip150() { run("res/ethtests/GeneralStateTests/stChangedEIP150") } #[test] fn st_code_copy() { run("res/ethtests/GeneralStateTests/stCodeCopyTest") } #[test] fn st_code_size_limit() { run("res/ethtests/GeneralStateTests/stCodeSizeLimit") } #[test] #[ignore] fn st_create2() { run("res/ethtests/GeneralStateTests/stCreate2") } @@ -50,7 +49,8 @@ pub fn run(dir: &str) { #[test] fn st_eip150_single_code_gas_prices() { run("res/ethtests/GeneralStateTests/stEIP150singleCodeGasPrices") } #[test] fn st_eip150_specific() { run("res/ethtests/GeneralStateTests/stEIP150Specific") } #[test] fn st_eip158_specific() { run("res/ethtests/GeneralStateTests/stEIP158Specific") } -#[test] fn st_example() { run("res/ethtests/GeneralStateTests/stExample") } +// post-Berlin transaction descriptions without gasPrice +#[test] #[ignore] fn st_example() { run("res/ethtests/GeneralStateTests/stExample") } #[test] fn st_ext_code_hash() { run("res/ethtests/GeneralStateTests/stExtCodeHash") } #[test] fn st_homestead_specific() { run("res/ethtests/GeneralStateTests/stHomesteadSpecific") } #[test] fn st_init_code() { run("res/ethtests/GeneralStateTests/stInitCodeTest") } diff --git a/jsontests/tests/vm.rs b/jsontests/tests/vm.rs index 9d5ff75..30808b0 100644 --- a/jsontests/tests/vm.rs +++ b/jsontests/tests/vm.rs @@ -26,15 +26,15 @@ pub fn run(dir: &str) { } } -#[test] fn vm_arithmetic() { run("res/ethtests/VMTests/vmArithmeticTest"); } -#[test] fn vm_bitwise_logic() { run("res/ethtests/VMTests/vmBitwiseLogicOperation"); } -#[test] fn vm_block_info() { run("res/ethtests/VMTests/vmBlockInfoTest"); } -#[test] fn vm_environmental_info() { run("res/ethtests/VMTests/vmEnvironmentalInfo"); } -#[test] fn vm_io_and_flow() { run("res/ethtests/VMTests/vmIOandFlowOperations"); } -#[test] fn vm_log() { run("res/ethtests/VMTests/vmLogTest"); } -#[test] #[ignore] fn vm_performance() { run("res/ethtests/VMTests/vmPerformance"); } -#[test] fn vm_push_dup_swap() { run("res/ethtests/VMTests/vmPushDupSwapTest"); } -#[test] fn vm_random() { run("res/ethtests/VMTests/vmRandomTest"); } -#[test] fn vm_sha3() { run("res/ethtests/VMTests/vmSha3Test"); } -#[test] fn vm_system() { run("res/ethtests/VMTests/vmSystemOperations"); } -#[test] fn vm_other() { run("res/ethtests/VMTests/vmTests"); } +#[test] fn vm_arithmetic() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmArithmeticTest"); } +#[test] fn vm_bitwise_logic() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmBitwiseLogicOperation"); } +#[test] fn vm_block_info() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmBlockInfoTest"); } +#[test] fn vm_environmental_info() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmEnvironmentalInfo"); } +#[test] fn vm_io_and_flow() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmIOandFlowOperations"); } +#[test] fn vm_log() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmLogTest"); } +#[test] #[ignore] fn vm_performance() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmPerformance"); } +#[test] fn vm_push_dup_swap() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmPushDupSwapTest"); } +#[test] fn vm_random() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmRandomTest"); } +#[test] fn vm_sha3() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmSha3Test"); } +#[test] fn vm_system() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmSystemOperations"); } +#[test] fn vm_other() { run("res/ethtests/LegacyTests/Constantinople/VMTests/vmTests"); } From 946573980049898dea3c3d99e890ae99c3644c07 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Mon, 28 Jun 2021 12:48:18 +0300 Subject: [PATCH 3/5] Add new state test cases to the tests All GeneralStateTests/st* cases from the 9.0.2 release of the Ethereum now have their associated Rust test cases. Some of the new tests have to be ignored for now due to the new transaction data format. Also, test Constantinople/GeneralStateTests/stTimeConsuming is tagged with #[ignore] since it is, indeed, time-consuming. --- jsontests/tests/state.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jsontests/tests/state.rs b/jsontests/tests/state.rs index d10f6e6..4787256 100644 --- a/jsontests/tests/state.rs +++ b/jsontests/tests/state.rs @@ -50,6 +50,10 @@ pub fn run(dir: &str) { #[test] fn st_eip150_specific() { run("res/ethtests/GeneralStateTests/stEIP150Specific") } #[test] fn st_eip158_specific() { run("res/ethtests/GeneralStateTests/stEIP158Specific") } // post-Berlin transaction descriptions without gasPrice +#[test] #[ignore] fn st_eip1559() { run("res/ethtests/GeneralStateTests/stEIP1559") } +// post-Berlin transaction descriptions without gasPrice +#[test] #[ignore] fn st_eip2930() { run("res/ethtests/GeneralStateTests/stEIP2930") } +// post-Berlin transaction descriptions without gasPrice #[test] #[ignore] fn st_example() { run("res/ethtests/GeneralStateTests/stExample") } #[test] fn st_ext_code_hash() { run("res/ethtests/GeneralStateTests/stExtCodeHash") } #[test] fn st_homestead_specific() { run("res/ethtests/GeneralStateTests/stHomesteadSpecific") } @@ -79,7 +83,9 @@ pub fn run(dir: &str) { #[test] #[ignore] fn st_sstore() { run("res/ethtests/GeneralStateTests/stSStoreTest") } #[test] fn st_stack() { run("res/ethtests/GeneralStateTests/stStackTests") } #[test] #[ignore] fn st_static_call() { run("res/ethtests/GeneralStateTests/stStaticCall") } +#[test] fn st_static_flag_enabled() { run("res/ethtests/GeneralStateTests/stStaticFlagEnabled") } #[test] fn st_system_operations() { run("res/ethtests/GeneralStateTests/stSystemOperationsTest") } +#[test] #[ignore] fn st_time_consuming() { run("res/ethtests/GeneralStateTests/stTimeConsuming") } #[test] fn st_transaction() { run("res/ethtests/GeneralStateTests/stTransactionTest") } #[test] fn st_transition() { run("res/ethtests/GeneralStateTests/stTransitionTest") } #[test] fn st_wallet() { run("res/ethtests/GeneralStateTests/stWalletTest") } From ae963a21084490b1897dea0147115c2e153101b0 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Mon, 28 Jun 2021 13:10:34 +0300 Subject: [PATCH 4/5] Added GeneralStateTests/VMTests The currently maintained subset of old VM tests is now under the state tests and the test cases shall be invoked using that format. --- jsontests/tests/state.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jsontests/tests/state.rs b/jsontests/tests/state.rs index 4787256..39279de 100644 --- a/jsontests/tests/state.rs +++ b/jsontests/tests/state.rs @@ -93,3 +93,14 @@ pub fn run(dir: &str) { #[test] fn st_zero_calls() { run("res/ethtests/GeneralStateTests/stZeroCallsTest") } #[test] fn st_zero_knowledge() { run("res/ethtests/GeneralStateTests/stZeroKnowledge") } #[test] fn st_zero_knowledge2() { run("res/ethtests/GeneralStateTests/stZeroKnowledge2") } + +mod vm { + use super::*; + + #[test] fn vm_arithmetic() { run("res/ethtests/GeneralStateTests/VMTests/vmArithmeticTest"); } + #[test] fn vm_bitwise_logic() { run("res/ethtests/GeneralStateTests/VMTests/vmBitwiseLogicOperation"); } + #[test] fn vm_io_and_flow() { run("res/ethtests/GeneralStateTests/VMTests/vmIOandFlowOperations"); } + #[test] fn vm_log() { run("res/ethtests/GeneralStateTests/VMTests/vmLogTest"); } + #[test] #[ignore] fn vm_performance() { run("res/ethtests/GeneralStateTests/VMTests/vmPerformance"); } + #[test] fn vm_other() { run("res/ethtests/GeneralStateTests/VMTests/vmTests"); } +} From 884df62c6fb2daee7a0169f14082d5352c89459b Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Wed, 30 Jun 2021 11:28:50 +0300 Subject: [PATCH 5/5] Parse and ignore transactions without gasPrice Some newer state tests use EIP-1559 transactions with maxPriorityFeePerGas and maxFeePerGas fields replacing the gasPrice field in the transaction JSON structure. As evm has no way to deal with these currently, make sure such transaction descriptions can be parsed, but skip tests containing them. --- ethjson/src/test_helpers/state.rs | 4 ++-- jsontests/src/state.rs | 9 +++++++-- jsontests/tests/state.rs | 9 +++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ethjson/src/test_helpers/state.rs b/ethjson/src/test_helpers/state.rs index 170366e..651645f 100644 --- a/ethjson/src/test_helpers/state.rs +++ b/ethjson/src/test_helpers/state.rs @@ -55,7 +55,7 @@ pub struct MultiTransaction { /// Gas limit set. pub gas_limit: Vec, /// Gas price. - pub gas_price: Uint, + pub gas_price: Option, /// Nonce. pub nonce: Uint, /// Secret key. @@ -73,7 +73,7 @@ impl MultiTransaction { Transaction { data: self.data[indexes.data as usize].clone(), gas_limit: self.gas_limit[indexes.gas as usize], - gas_price: self.gas_price, + gas_price: self.gas_price.expect("transaction formats without gasPrice are not supported yet"), nonce: self.nonce, to: self.to.clone(), value: self.value[indexes.value as usize], diff --git a/jsontests/src/state.rs b/jsontests/src/state.rs index 58c5eca..c758a68 100644 --- a/jsontests/src/state.rs +++ b/jsontests/src/state.rs @@ -27,7 +27,7 @@ impl Test { pub fn unwrap_to_vicinity(&self) -> MemoryVicinity { MemoryVicinity { - gas_price: self.0.transaction.gas_price.clone().into(), + gas_price: self.0.transaction.gas_price.as_ref().unwrap().clone().into(), origin: self.unwrap_caller(), block_hashes: Vec::new(), block_number: self.0.env.number.clone().into(), @@ -95,11 +95,16 @@ pub fn test(name: &str, test: Test) { } pub fn test_run(name: &str, test: Test) { + if test.0.transaction.gas_price.is_none() { + println!("Skip {}: transaction without gasPrice", name); + return; + } + for (spec, states) in &test.0.post_states { let (gasometer_config, precompile, delete_empty) = match spec { ethjson::spec::ForkSpec::Istanbul => (Config::istanbul(), istanbul_precompile, true), spec => { - println!("Skip spec {:?}", spec); + println!("Skip {}:{:?}", name, spec); continue }, }; diff --git a/jsontests/tests/state.rs b/jsontests/tests/state.rs index 39279de..25d2e3f 100644 --- a/jsontests/tests/state.rs +++ b/jsontests/tests/state.rs @@ -49,12 +49,9 @@ pub fn run(dir: &str) { #[test] fn st_eip150_single_code_gas_prices() { run("res/ethtests/GeneralStateTests/stEIP150singleCodeGasPrices") } #[test] fn st_eip150_specific() { run("res/ethtests/GeneralStateTests/stEIP150Specific") } #[test] fn st_eip158_specific() { run("res/ethtests/GeneralStateTests/stEIP158Specific") } -// post-Berlin transaction descriptions without gasPrice -#[test] #[ignore] fn st_eip1559() { run("res/ethtests/GeneralStateTests/stEIP1559") } -// post-Berlin transaction descriptions without gasPrice -#[test] #[ignore] fn st_eip2930() { run("res/ethtests/GeneralStateTests/stEIP2930") } -// post-Berlin transaction descriptions without gasPrice -#[test] #[ignore] fn st_example() { run("res/ethtests/GeneralStateTests/stExample") } +#[test] fn st_eip1559() { run("res/ethtests/GeneralStateTests/stEIP1559") } +#[test] fn st_eip2930() { run("res/ethtests/GeneralStateTests/stEIP2930") } +#[test] fn st_example() { run("res/ethtests/GeneralStateTests/stExample") } #[test] fn st_ext_code_hash() { run("res/ethtests/GeneralStateTests/stExtCodeHash") } #[test] fn st_homestead_specific() { run("res/ethtests/GeneralStateTests/stHomesteadSpecific") } #[test] fn st_init_code() { run("res/ethtests/GeneralStateTests/stInitCodeTest") }