From a23fb681c9cf30463ee02147c02377c977e0a9b8 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Wed, 3 Apr 2024 17:25:18 +0800 Subject: [PATCH 1/8] fix 2930 signature --- mock/src/transaction.rs | 60 ++++++++++++- .../util/common_gadget/tx_access_list.rs | 86 +++++++++++++++++++ 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/mock/src/transaction.rs b/mock/src/transaction.rs index d0ba3d7856..474bcd9d83 100644 --- a/mock/src/transaction.rs +++ b/mock/src/transaction.rs @@ -7,7 +7,7 @@ use eth_types::{ }; use ethers_core::{ rand::{CryptoRng, RngCore}, - types::{Eip1559TransactionRequest, OtherFields, TransactionRequest}, + types::{Eip1559TransactionRequest, Eip2930TransactionRequest, OtherFields, TransactionRequest}, }; use ethers_signers::{LocalWallet, Signer}; use rand::SeedableRng; @@ -333,6 +333,8 @@ impl MockTransaction { pub fn build(&mut self) -> Self { if self.transaction_type == U64::from(2) { return self.build_1559(); + }else if self.transaction_type == U64::from(1) { + return self.build_2930(); } // TODO: handle eip2930 type later when add eip2930 tests. @@ -384,7 +386,7 @@ impl MockTransaction { self.to_owned() } - /// build 1559 type tx + /// build eip 1559 type tx pub fn build_1559(&mut self) -> Self { let tx = Eip1559TransactionRequest::new() .from(self.from.address()) @@ -438,6 +440,60 @@ impl MockTransaction { self.to_owned() } + /// build eip 2930 type tx + pub fn build_2930(&mut self) -> Self { + let legacy_tx = TransactionRequest::new() + .from(self.from.address()) + .nonce(self.nonce) + .value(self.value) + .data(self.input.clone()) + .gas(self.gas) + .chain_id(self.chain_id); + + println!("hit 2930 type tx"); + let legacy_tx = if let Some(to_addr) = self.to.clone() { + legacy_tx.to(to_addr.address()) + } else { + legacy_tx + }; + + let tx = Eip2930TransactionRequest::new(legacy_tx, self.access_list.clone()); + + match (self.v, self.r, self.s) { + (None, None, None) => { + // Compute sig params and set them in case we have a wallet as `from` attr. + if self.from.is_wallet() && self.hash.is_none() { + let mut sig = self + .from + .as_wallet() + .with_chain_id(self.chain_id) + .sign_transaction_sync(&tx.into()) + .expect("sign mock eip 2930 tx"); + + // helper `sign_transaction_sync` in ethers-rs lib does not handle correctly + // about v for non legacy tx, here correct it for z930 type. + sig.v = Self::normalize_v(sig.v, self.chain_id); // convert v to [0, 1] + + self.sig_data((sig.v, sig.r, sig.s)); + } else { + #[cfg(feature = "scroll")] + panic!("2930 type tx must have signature data, otherwise will be treated as L1Msg type in trace.go of l2geth"); + } + } + _ => panic!("Either all or none of the SigData params have to be set"), + } + + // Compute tx hash in case is not already set + if self.hash.is_none() { + let tmp_tx = Transaction::from(self.to_owned()); + // FIXME: Note that tmp_tx does not have sigs if self.from.is_wallet() = false. + // This means tmp_tx.hash() is not correct. + self.hash(tmp_tx.hash()); + } + + self.to_owned() + } + // helper `sign_transaction_sync` in ethers-rs lib compute V using legacy tx pattern(V = // recover_id + 2 * chain_id + 35), this method converts above V value to origin recover_id. pub(crate) fn normalize_v(v: u64, chain_id: u64) -> u64 { diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index 5b686e0fe8..b953d31098 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -153,3 +153,89 @@ impl TxAccessListGadget { address_len + storage_key_len } } + + +// tests for eip2930 +#[cfg(test)] +mod test { + use crate::test_util::CircuitTestBuilder; + use eth_types::{Error, Word}; + use ethers_signers::Signer; + use mock::{eth, gwei, TestContext, MOCK_ACCOUNTS, MOCK_WALLETS}; + + #[test] + fn test_eip2930_tx_for_empty_access_list() { + let ctx = build_ctx(gwei(80_000), gwei(2), gwei(2)).unwrap(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } + + // TODO: need to enable for scroll feature after merging this PR + // . + #[cfg(not(feature = "scroll"))] + #[test] + fn test_eip1559_tx_for_less_balance() { + let res = build_ctx(gwei(79_999), gwei(2), gwei(2)); + + // Return a tracing error if insufficient sender balance. + if let Error::TracingError(err) = res.unwrap_err() { + assert_eq!(err, "Failed to run Trace, err: Failed to apply config.Transactions[0]: insufficient funds for gas * price + value: address 0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241 have 79999000000000 want 80000000000000"); + } else { + panic!("Must be a tracing error"); + } + } + + #[test] + fn test_eip1559_tx_for_more_balance() { + let ctx = build_ctx(gwei(80_001), gwei(2), gwei(2)).unwrap(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } + + #[test] + fn test_eip1559_tx_for_gas_fee_cap_gt_gas_tip_cap() { + // Should be successful if `max_fee_per_gas > max_priority_fee_per_gas`. + let ctx = build_ctx(gwei(80_000), gwei(2), gwei(1)).unwrap(); + + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } + + // TODO: need to enable for scroll feature after merging this PR + // . + #[cfg(not(feature = "scroll"))] + #[test] + fn test_eip1559_tx_for_gas_fee_cap_lt_gas_tip_cap() { + let res = build_ctx(gwei(80_000), gwei(1), gwei(2)); + + // Return a tracing error if `max_fee_per_gas < max_priority_fee_per_gas`. + if let Error::TracingError(err) = res.unwrap_err() { + assert_eq!(err, "Failed to run Trace, err: Failed to apply config.Transactions[0]: max priority fee per gas higher than max fee per gas: address 0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241, maxPriorityFeePerGas: 2000000000, maxFeePerGas: 1000000000"); + } else { + panic!("Must be a tracing error"); + } + } + + fn build_ctx( + sender_balance: Word, + max_fee_per_gas: Word, + max_priority_fee_per_gas: Word, + ) -> Result, Error> { + TestContext::new( + None, + |accs| { + accs[0] + .address(MOCK_WALLETS[0].address()) + .balance(sender_balance); + accs[1].address(MOCK_ACCOUNTS[0]).balance(eth(1)); + }, + |mut txs, _accs| { + txs[0] + .from(MOCK_WALLETS[0].clone()) + .to(MOCK_ACCOUNTS[0]) + .gas(30_000.into()) + .gas_price(30_000.into()) + .value(gwei(20_000)) + .transaction_type(1); // Set tx type to EIP-2930. + }, + |block, _tx| block.number(0xcafeu64), + ) + } +} From 469be333e4cffe245f7ffadd0d7659c66f806b73 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Sun, 7 Apr 2024 10:25:07 +0800 Subject: [PATCH 2/8] fix gsa price in build 2930 tx --- mock/src/transaction.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mock/src/transaction.rs b/mock/src/transaction.rs index 474bcd9d83..a05929e608 100644 --- a/mock/src/transaction.rs +++ b/mock/src/transaction.rs @@ -336,7 +336,6 @@ impl MockTransaction { }else if self.transaction_type == U64::from(1) { return self.build_2930(); } - // TODO: handle eip2930 type later when add eip2930 tests. let tx = TransactionRequest::new() .from(self.from.address()) @@ -451,6 +450,11 @@ impl MockTransaction { .chain_id(self.chain_id); println!("hit 2930 type tx"); + let legacy_tx = if let Some(gas_price) = self.gas_price { + legacy_tx.gas_price(gas_price) + } else { + legacy_tx + }; let legacy_tx = if let Some(to_addr) = self.to.clone() { legacy_tx.to(to_addr.address()) } else { From 527b949bf65c1f58465173f5a2cc8f5793b93e64 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Sun, 7 Apr 2024 15:27:57 +0800 Subject: [PATCH 3/8] add non empty access list test --- .../util/common_gadget/tx_access_list.rs | 68 +++++++------------ 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index b953d31098..30534d3ee1 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -159,64 +159,42 @@ impl TxAccessListGadget { #[cfg(test)] mod test { use crate::test_util::CircuitTestBuilder; - use eth_types::{Error, Word}; + use eth_types::{Error, Word, AccessList, AccessListItem, address, H256}; use ethers_signers::Signer; use mock::{eth, gwei, TestContext, MOCK_ACCOUNTS, MOCK_WALLETS}; #[test] fn test_eip2930_tx_for_empty_access_list() { - let ctx = build_ctx(gwei(80_000), gwei(2), gwei(2)).unwrap(); + let ctx = build_ctx(gwei(80_000), None).unwrap(); CircuitTestBuilder::new_from_test_ctx(ctx).run(); } - // TODO: need to enable for scroll feature after merging this PR - // . - #[cfg(not(feature = "scroll"))] #[test] - fn test_eip1559_tx_for_less_balance() { - let res = build_ctx(gwei(79_999), gwei(2), gwei(2)); - - // Return a tracing error if insufficient sender balance. - if let Error::TracingError(err) = res.unwrap_err() { - assert_eq!(err, "Failed to run Trace, err: Failed to apply config.Transactions[0]: insufficient funds for gas * price + value: address 0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241 have 79999000000000 want 80000000000000"); - } else { - panic!("Must be a tracing error"); - } - } - - #[test] - fn test_eip1559_tx_for_more_balance() { - let ctx = build_ctx(gwei(80_001), gwei(2), gwei(2)).unwrap(); - CircuitTestBuilder::new_from_test_ctx(ctx).run(); - } - - #[test] - fn test_eip1559_tx_for_gas_fee_cap_gt_gas_tip_cap() { - // Should be successful if `max_fee_per_gas > max_priority_fee_per_gas`. - let ctx = build_ctx(gwei(80_000), gwei(2), gwei(1)).unwrap(); + fn test_eip2930_non_empty_access_list() { + let test_access_list = AccessList(vec![ + AccessListItem { + address: address!("0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241"), + storage_keys: [10, 11].map(H256::from_low_u64_be).to_vec(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000001111"), + storage_keys: [10, 11].map(H256::from_low_u64_be).to_vec(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000002222"), + storage_keys: [20, 22].map(H256::from_low_u64_be).to_vec(), + }, + ]); + let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); CircuitTestBuilder::new_from_test_ctx(ctx).run(); } - // TODO: need to enable for scroll feature after merging this PR - // . - #[cfg(not(feature = "scroll"))] - #[test] - fn test_eip1559_tx_for_gas_fee_cap_lt_gas_tip_cap() { - let res = build_ctx(gwei(80_000), gwei(1), gwei(2)); - - // Return a tracing error if `max_fee_per_gas < max_priority_fee_per_gas`. - if let Error::TracingError(err) = res.unwrap_err() { - assert_eq!(err, "Failed to run Trace, err: Failed to apply config.Transactions[0]: max priority fee per gas higher than max fee per gas: address 0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241, maxPriorityFeePerGas: 2000000000, maxFeePerGas: 1000000000"); - } else { - panic!("Must be a tracing error"); - } - } + // TODO: check if other types' test required. fn build_ctx( sender_balance: Word, - max_fee_per_gas: Word, - max_priority_fee_per_gas: Word, + access_list: Option ) -> Result, Error> { TestContext::new( None, @@ -230,10 +208,14 @@ mod test { txs[0] .from(MOCK_WALLETS[0].clone()) .to(MOCK_ACCOUNTS[0]) - .gas(30_000.into()) + .gas(40_000.into()) .gas_price(30_000.into()) .value(gwei(20_000)) .transaction_type(1); // Set tx type to EIP-2930. + + if access_list.is_some(){ + txs[0].access_list(access_list.unwrap()); + } }, |block, _tx| block.number(0xcafeu64), ) From 5dda0a945478dfb7dc5c7ab94557b9f11f650488 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Mon, 8 Apr 2024 16:18:38 +0800 Subject: [PATCH 4/8] add non empty access list tests --- .../util/common_gadget/tx_access_list.rs | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index 30534d3ee1..c3e2e4f25f 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -154,7 +154,6 @@ impl TxAccessListGadget { } } - // tests for eip2930 #[cfg(test)] mod test { @@ -163,26 +162,40 @@ mod test { use ethers_signers::Signer; use mock::{eth, gwei, TestContext, MOCK_ACCOUNTS, MOCK_WALLETS}; + // test with empty access list. #[test] fn test_eip2930_tx_for_empty_access_list() { + // CASE1: tx not set access list, `access_list` field is none. let ctx = build_ctx(gwei(80_000), None).unwrap(); CircuitTestBuilder::new_from_test_ctx(ctx).run(); + + // CASE2: tx set empty (neither address nor storage keys at all) access list into `access_list` field. + // this field is not none. + let test_access_list: AccessList = AccessList(vec![ + ]); + + let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); } + // test with non empty access list(address + storage keys list) #[test] fn test_eip2930_non_empty_access_list() { - let test_access_list = AccessList(vec![ + let test_access_list: AccessList = AccessList(vec![ AccessListItem { address: address!("0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241"), - storage_keys: [10, 11].map(H256::from_low_u64_be).to_vec(), + // one storage key + storage_keys: [10].map(H256::from_low_u64_be).to_vec(), }, AccessListItem { address: address!("0x0000000000000000000000000000000000001111"), + // two storage keys storage_keys: [10, 11].map(H256::from_low_u64_be).to_vec(), }, AccessListItem { address: address!("0x0000000000000000000000000000000000002222"), - storage_keys: [20, 22].map(H256::from_low_u64_be).to_vec(), + // three storage keys + storage_keys: [20, 22, 50].map(H256::from_low_u64_be).to_vec(), }, ]); @@ -190,6 +203,26 @@ mod test { CircuitTestBuilder::new_from_test_ctx(ctx).run(); } + // test with non empty access list(only address list) + #[test] + fn test_eip2930_only_address_access_list() { + let test_access_list: AccessList = AccessList(vec![ + AccessListItem { + address: address!("0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241"), + // no storage keys + storage_keys: Vec::new(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000001111"), + // no storage keys + storage_keys: Vec::new(), + }, + ]); + + let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } + // TODO: check if other types' test required. fn build_ctx( From 311e7183b9a261aabb05e7af6c82921224444f26 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Tue, 9 Apr 2024 14:38:45 +0800 Subject: [PATCH 5/8] fix fmt --- mock/src/transaction.rs | 23 ++++---- .../util/common_gadget/tx_access_list.rs | 59 +++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/mock/src/transaction.rs b/mock/src/transaction.rs index a05929e608..e42c43b855 100644 --- a/mock/src/transaction.rs +++ b/mock/src/transaction.rs @@ -7,7 +7,9 @@ use eth_types::{ }; use ethers_core::{ rand::{CryptoRng, RngCore}, - types::{Eip1559TransactionRequest, Eip2930TransactionRequest, OtherFields, TransactionRequest}, + types::{ + Eip1559TransactionRequest, Eip2930TransactionRequest, OtherFields, TransactionRequest, + }, }; use ethers_signers::{LocalWallet, Signer}; use rand::SeedableRng; @@ -333,7 +335,7 @@ impl MockTransaction { pub fn build(&mut self) -> Self { if self.transaction_type == U64::from(2) { return self.build_1559(); - }else if self.transaction_type == U64::from(1) { + } else if self.transaction_type == U64::from(1) { return self.build_2930(); } @@ -442,14 +444,13 @@ impl MockTransaction { /// build eip 2930 type tx pub fn build_2930(&mut self) -> Self { let legacy_tx = TransactionRequest::new() - .from(self.from.address()) - .nonce(self.nonce) - .value(self.value) - .data(self.input.clone()) - .gas(self.gas) - .chain_id(self.chain_id); - - println!("hit 2930 type tx"); + .from(self.from.address()) + .nonce(self.nonce) + .value(self.value) + .data(self.input.clone()) + .gas(self.gas) + .chain_id(self.chain_id); + let legacy_tx = if let Some(gas_price) = self.gas_price { legacy_tx.gas_price(gas_price) } else { @@ -496,7 +497,7 @@ impl MockTransaction { } self.to_owned() - } + } // helper `sign_transaction_sync` in ethers-rs lib compute V using legacy tx pattern(V = // recover_id + 2 * chain_id + 35), this method converts above V value to origin recover_id. diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index c3e2e4f25f..be7bbf490a 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -158,7 +158,7 @@ impl TxAccessListGadget { #[cfg(test)] mod test { use crate::test_util::CircuitTestBuilder; - use eth_types::{Error, Word, AccessList, AccessListItem, address, H256}; + use eth_types::{address, AccessList, AccessListItem, Error, Word, H256}; use ethers_signers::Signer; use mock::{eth, gwei, TestContext, MOCK_ACCOUNTS, MOCK_WALLETS}; @@ -169,16 +169,15 @@ mod test { let ctx = build_ctx(gwei(80_000), None).unwrap(); CircuitTestBuilder::new_from_test_ctx(ctx).run(); - // CASE2: tx set empty (neither address nor storage keys at all) access list into `access_list` field. - // this field is not none. - let test_access_list: AccessList = AccessList(vec![ - ]); - + // CASE2: tx set empty (neither address nor storage keys at all) access list into + // `access_list` field. this field is not none. + let test_access_list: AccessList = AccessList(vec![]); + let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); - CircuitTestBuilder::new_from_test_ctx(ctx).run(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); } - // test with non empty access list(address + storage keys list) + // test with non empty access list(address + storage keys list) #[test] fn test_eip2930_non_empty_access_list() { let test_access_list: AccessList = AccessList(vec![ @@ -203,31 +202,31 @@ mod test { CircuitTestBuilder::new_from_test_ctx(ctx).run(); } - // test with non empty access list(only address list) - #[test] - fn test_eip2930_only_address_access_list() { - let test_access_list: AccessList = AccessList(vec![ - AccessListItem { - address: address!("0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241"), - // no storage keys - storage_keys: Vec::new(), - }, - AccessListItem { - address: address!("0x0000000000000000000000000000000000001111"), - // no storage keys - storage_keys: Vec::new(), - }, - ]); + // test with non empty access list(only address list) + #[test] + fn test_eip2930_only_address_access_list() { + let test_access_list: AccessList = AccessList(vec![ + AccessListItem { + address: address!("0xEeFca179F40D3B8b3D941E6A13e48835a3aF8241"), + // no storage keys + storage_keys: Vec::new(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000001111"), + // no storage keys + storage_keys: Vec::new(), + }, + ]); - let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); - CircuitTestBuilder::new_from_test_ctx(ctx).run(); - } + let ctx = build_ctx(gwei(80_000), Some(test_access_list)).unwrap(); + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } // TODO: check if other types' test required. fn build_ctx( sender_balance: Word, - access_list: Option + access_list: Option, ) -> Result, Error> { TestContext::new( None, @@ -245,10 +244,10 @@ mod test { .gas_price(30_000.into()) .value(gwei(20_000)) .transaction_type(1); // Set tx type to EIP-2930. - - if access_list.is_some(){ + + if access_list.is_some() { txs[0].access_list(access_list.unwrap()); - } + } }, |block, _tx| block.number(0xcafeu64), ) From c912c4048a5db9f10e7f98272823cadd109be75f Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Tue, 9 Apr 2024 14:48:09 +0800 Subject: [PATCH 6/8] update for clippy --- .../src/evm_circuit/util/common_gadget/tx_access_list.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index be7bbf490a..97c437cd06 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -245,8 +245,8 @@ mod test { .value(gwei(20_000)) .transaction_type(1); // Set tx type to EIP-2930. - if access_list.is_some() { - txs[0].access_list(access_list.unwrap()); + if let Some(acc_list) = access_list { + txs[0].access_list(acc_list); } }, |block, _tx| block.number(0xcafeu64), From f65370e72e4ff7da08b35d3cb9e6f76b20812d53 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Tue, 9 Apr 2024 15:42:47 +0800 Subject: [PATCH 7/8] fix copy circuit test --- zkevm-circuits/src/copy_circuit/test.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/copy_circuit/test.rs b/zkevm-circuits/src/copy_circuit/test.rs index 58d1c516db..2f6987e3f1 100644 --- a/zkevm-circuits/src/copy_circuit/test.rs +++ b/zkevm-circuits/src/copy_circuit/test.rs @@ -15,13 +15,14 @@ use bus_mapping::{ use eth_types::{ address, bytecode, geth_types::GethData, word, AccessList, AccessListItem, ToWord, Word, H256, }; +use ethers_signers::Signer; use halo2_proofs::{ dev::{MockProver, VerifyFailure}, halo2curves::bn256::Fr, }; use mock::{ eth, gwei, test_ctx::helpers::account_0_code_account_1_no_code, MockTransaction, TestContext, - MOCK_ACCOUNTS, + MOCK_ACCOUNTS, MOCK_WALLETS, }; const K: u32 = 20; @@ -282,12 +283,12 @@ fn gen_access_list_data() -> CircuitInputBuilder { let test_ctx = TestContext::<1, 1>::new( None, |accs| { - accs[0].address(MOCK_ACCOUNTS[0]).balance(eth(20)); + accs[0].address(MOCK_WALLETS[0].address()).balance(eth(20)); }, |mut txs, _accs| { txs[0] - .from(MOCK_ACCOUNTS[0]) - .to(MOCK_ACCOUNTS[1]) + .from(MOCK_WALLETS[0].clone()) + .to(MOCK_ACCOUNTS[0]) .gas_price(gwei(2)) .gas(Word::from(0x10000)) .value(eth(2)) From 7a2c331cec8cc509a2568233225a6865ba947eb0 Mon Sep 17 00:00:00 2001 From: Dream Wu Date: Wed, 10 Apr 2024 09:26:36 +0800 Subject: [PATCH 8/8] minor update --- mock/src/transaction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock/src/transaction.rs b/mock/src/transaction.rs index e42c43b855..d05701c9ca 100644 --- a/mock/src/transaction.rs +++ b/mock/src/transaction.rs @@ -476,7 +476,7 @@ impl MockTransaction { .expect("sign mock eip 2930 tx"); // helper `sign_transaction_sync` in ethers-rs lib does not handle correctly - // about v for non legacy tx, here correct it for z930 type. + // about v for non legacy tx, here correct it for 2930 type. sig.v = Self::normalize_v(sig.v, self.chain_id); // convert v to [0, 1] self.sig_data((sig.v, sig.r, sig.s));