forked from privacy-scaling-explorations/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix sig issue for 1559/2930 in tx circuit (#1269)
* fix sig issue for 1559 * add supercircuit test for 1559 * refactor 1559&2930 test helper to single mod * update tests * fmt align * change pub(crate) mod * use wallet_a as from addr * restore serial_test_super_circuit_1tx_2max_tx * increase max_rlp_rows * add access list para in test helper test_block_2930_trace * refactor 2930 test with/no access list * remove debug info * fmt align * add empty storage_keys into access list * disable test serial_test_super_circuit_eip_2930_tx_accesslist for rlp issue
- Loading branch information
1 parent
e6cfd7b
commit 2f252a3
Showing
4 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
//! Helper functions for super circuit tests of EIP-1559 | ||
|
||
use super::CircuitsParams; | ||
use eth_types::{address, l2_types::BlockTrace, AccessList, AccessListItem, H256}; | ||
use ethers_signers::{LocalWallet, Signer}; | ||
use mock::{eth, gwei, TestContext, MOCK_CHAIN_ID}; | ||
use rand::SeedableRng; | ||
use rand_chacha::ChaCha20Rng; | ||
|
||
pub(crate) fn test_block_1559_trace() -> BlockTrace { | ||
let mut rng = ChaCha20Rng::seed_from_u64(2); | ||
let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID); | ||
|
||
let addr_a = wallet_a.address(); | ||
let addr_b = address!("0x0000000000000000000000000000000000001559"); | ||
|
||
TestContext::<2, 1>::new( | ||
None, | ||
|accs| { | ||
accs[0].address(addr_b).balance(eth(1)); | ||
accs[1].address(addr_a).balance(gwei(80_000)); | ||
}, | ||
|mut txs, _accs| { | ||
txs[0] | ||
.from(wallet_a) | ||
.to(addr_b) | ||
.gas_price(gwei(2)) | ||
.gas(30_000.into()) | ||
.value(gwei(20_000)) | ||
.max_fee_per_gas(gwei(2)) | ||
.max_priority_fee_per_gas(gwei(2)) | ||
.transaction_type(2); // Set tx type to EIP-1559. | ||
}, | ||
|block, _tx| block.number(0xcafe_u64), | ||
) | ||
.unwrap() | ||
.l2_trace() | ||
.clone() | ||
} | ||
|
||
pub(crate) fn test_circuits_params(max_txs: usize, max_calldata: usize) -> CircuitsParams { | ||
CircuitsParams { | ||
max_txs, | ||
max_calldata, | ||
max_rws: 256, | ||
max_copy_rows: 256, | ||
max_exp_steps: 256, | ||
max_bytecode: 512, | ||
max_mpt_rows: 2049, | ||
max_poseidon_rows: 512, | ||
max_evm_rows: 0, | ||
max_keccak_rows: 0, | ||
max_inner_blocks: 1, | ||
max_rlp_rows: 1000, | ||
..Default::default() | ||
} | ||
} | ||
|
||
/// Helper functions for super circuit tests of EIP-2930 | ||
/// param `has_access_list` indicates targeting tx has access list data or not. | ||
pub(crate) fn test_block_2930_trace(has_access_list: bool) -> BlockTrace { | ||
let mut rng = ChaCha20Rng::seed_from_u64(2); | ||
let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID); | ||
|
||
let addr_a = wallet_a.address(); | ||
let addr_b = address!("0x0000000000000000000000000000000000002930"); | ||
|
||
let test_access_list = AccessList(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(), | ||
}, | ||
AccessListItem { | ||
address: address!("0x0000000000000000000000000000000000003333"), | ||
storage_keys: [30, 33].map(H256::from_low_u64_be).to_vec(), | ||
}, | ||
// empty storage_keys | ||
AccessListItem { | ||
address: address!("0x0000000000000000000000000000000000004444"), | ||
storage_keys: Vec::new(), | ||
}, | ||
]); | ||
|
||
TestContext::<2, 1>::new( | ||
None, | ||
|accs| { | ||
accs[0].address(addr_b).balance(eth(20)); | ||
accs[1].address(addr_a).balance(eth(20)); | ||
}, | ||
|mut txs, _accs| { | ||
txs[0] | ||
.from(wallet_a) | ||
.to(addr_b) | ||
.gas_price(gwei(2)) | ||
.gas(1_000_000.into()) | ||
.value(eth(2)) | ||
.transaction_type(1); // Set tx type to EIP-2930. | ||
|
||
if has_access_list { | ||
txs[0].access_list(test_access_list); | ||
} | ||
}, | ||
|block, _tx| block.number(0xcafe_u64), | ||
) | ||
.unwrap() | ||
.l2_trace() | ||
.clone() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters