Skip to content

Commit

Permalink
fix: use correct chain id for l1 fee (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc authored Jun 7, 2024
1 parent 8cd233b commit 4f6d4ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion bus-mapping/src/circuit_input_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,14 @@ impl<'a> CircuitInputBuilder {
),
);

Transaction::new(call_id, &self.sdb, &mut self.code_db, eth_tx, is_success)
Transaction::new(
call_id,
self.block.chain_id(),
&self.sdb,
&mut self.code_db,
eth_tx,
is_success,
)
}

/// Iterate over all generated CallContext RwCounterEndOfReversion
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl Block {
self.relax_mode
}

/// ..
/// State root after all blocks in this chunk
pub fn end_state_root(&self) -> Word {
self.headers
.last_key_value()
Expand Down
8 changes: 6 additions & 2 deletions bus-mapping/src/circuit_input_builder/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,13 @@ impl Transaction {
/// Create a new Self.
pub fn new(
call_id: usize,
chain_id: u64,
sdb: &StateDB,
code_db: &mut CodeDB,
eth_tx: &eth_types::Transaction,
is_success: bool,
) -> Result<Self, Error> {
let chain_id = eth_tx.chain_id.unwrap_or_default().as_u64();
let tx_chain_id = eth_tx.chain_id.unwrap_or_default().as_u64();
let block_num = eth_tx.block_number.unwrap().as_u64();
let (found, _) = sdb.get_account(&eth_tx.from);
if !found {
Expand Down Expand Up @@ -354,6 +355,9 @@ impl Transaction {
let (l1_fee, l1_fee_committed) = if tx_type.is_l1_msg() {
Default::default()
} else {
// tx.chain_id can be zero for legacy tx.
// So we should not use that.
// We need to use "global" chain id.
(
TxL1Fee::get_current_values_from_state_db(sdb, chain_id, block_num),
TxL1Fee::get_committed_values_from_state_db(sdb, chain_id, block_num),
Expand All @@ -371,7 +375,7 @@ impl Transaction {
Ok(Self {
block_num,
hash: eth_tx.hash,
chain_id,
chain_id: tx_chain_id,
tx_type,
rlp_bytes: eth_tx.rlp().to_vec(),
rlp_unsigned_bytes: get_rlp_unsigned(eth_tx),
Expand Down

0 comments on commit 4f6d4ae

Please sign in to comment.