Skip to content

Commit

Permalink
add eip155
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamWuGit committed Sep 19, 2024
1 parent 143d7ae commit 60280f3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
39 changes: 39 additions & 0 deletions zkevm-circuits/src/evm_circuit/tests/eip155.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// tests for eip155 tx
#[cfg(test)]
mod test {
use crate::test_util::CircuitTestBuilder;
use eth_types::{address, AccessList, AccessListItem, Error, Word, H256};
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() {
let ctx = build_ctx(gwei(80_000)).unwrap();
}

fn build_ctx(
sender_balance: Word,
) -> Result<TestContext<2, 1>, 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(40_000.into())
.gas_price(30_000.into())
.value(gwei(20_000))
// Set tx type to EIP-155.
.transaction_type(0);
},
|block, _tx| block.number(0xcafeu64),
)
}
}
11 changes: 0 additions & 11 deletions zkevm-circuits/src/evm_circuit/tests/pre-eip155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ mod test {
use ethers_core::{types::Bytes, utils::get_contract_address};
use mock::{eth, gwei, MockTransaction, TestContext, MOCK_ACCOUNTS};

fn gas(call_data: &[u8]) -> Word {
Word::from(
GasCost::TX.as_u64()
+ 2 * OpcodeId::PUSH32.constant_gas_cost().as_u64()
+ call_data
.iter()
.map(|&x| if x == 0 { 4 } else { 16 })
.sum::<u64>(),
)
}

// Note: all pre-eip155 txs here for testing have signature data. don't need to generate signature dynamically
// because ethers-rs lib's helper `sign_transaction_sync` doesn't support pre-eip155 type.
#[test]
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/evm_circuit/util/common_gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ use halo2_proofs::{
plonk::{Error, Expression},
};

mod tx_access_list;
mod tx_eip1559;
mod tx_eip2930;
mod tx_l1_fee;
mod tx_l1_msg;

pub(crate) use tx_access_list::TxAccessListGadget;
pub(crate) use tx_eip1559::TxEip1559Gadget;
pub(crate) use tx_eip2930::TxAccessListGadget;
pub(crate) use tx_l1_fee::TxL1FeeGadget;
pub(crate) use tx_l1_msg::TxL1MsgGadget;

Expand Down

0 comments on commit 60280f3

Please sign in to comment.