Skip to content

Commit

Permalink
chore: add sanity check to assert post-curie traces (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
roynalnaruto authored Sep 10, 2024
1 parent 6e6ee0e commit 0879801
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 42 deletions.
87 changes: 46 additions & 41 deletions bus-mapping/src/evm/opcodes/begin_end_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn gen_begin_tx_steps(state: &mut CircuitInputStateRef) -> Result<Vec<ExecSt
}
}
} else {
// else, add 3 ( or 6 after curie) RW read operations for transaction L1 fee.
// else, add 6 RW read operations for transaction L1 fee.
gen_tx_l1_fee_ops(state, &mut exec_step)?;
}

Expand Down Expand Up @@ -727,7 +727,7 @@ fn write_tx_receipt(
Ok(())
}

// Add 3(or 6 after curie) RW read operations for transaction L1 fee.
// Add 6 RW read operations for transaction L1 fee.
fn gen_tx_l1_fee_ops(
state: &mut CircuitInputStateRef,
exec_step: &mut ExecStep,
Expand Down Expand Up @@ -786,47 +786,52 @@ fn gen_tx_l1_fee_ops(
),
)?;

// curie operations
// Sanity check: we do not support pre-curie blocks as of <https://github.com/scroll-tech/zkevm-circuits/pull/1415>
//
// We expect a post-curie block.
let chain_id = state.block.chain_id;
let block_number = state.tx.block_num;
if is_curie_enabled(chain_id, block_number) {
state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::L1_BLOB_BASEFEE_SLOT,
l1_blob_basefee,
l1_blob_basefee,
tx_id,
l1_blob_basefee_committed,
),
)?;
state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::COMMIT_SCALAR_SLOT,
commit_scalar,
commit_scalar,
tx_id,
commit_scalar_committed,
),
)?;
state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::BLOB_SCALAR_SLOT,
blob_scalar,
blob_scalar,
tx_id,
blob_scalar_committed,
),
)?;
}
debug_assert!(
is_curie_enabled(chain_id, block_number),
"block {block_number} is pre-curie",
);

state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::L1_BLOB_BASEFEE_SLOT,
l1_blob_basefee,
l1_blob_basefee,
tx_id,
l1_blob_basefee_committed,
),
)?;
state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::COMMIT_SCALAR_SLOT,
commit_scalar,
commit_scalar,
tx_id,
commit_scalar_committed,
),
)?;
state.push_op(
exec_step,
RW::READ,
StorageOp::new(
*l1_gas_price_oracle::ADDRESS,
*l1_gas_price_oracle::BLOB_SCALAR_SLOT,
blob_scalar,
blob_scalar,
tx_id,
blob_scalar_committed,
),
)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/execution/begin_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
// if scroll:
// KeccakCodeHash
// else:
// 3 or 6 l1 fee rw
// 6 l1 fee rw
// RwCounterEndOfReversion
// IsPersistent
// IsSuccess
Expand Down

0 comments on commit 0879801

Please sign in to comment.