Skip to content

Commit

Permalink
fix: fix tx circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
lastminutedev committed Dec 19, 2023
1 parent 4453825 commit 9ab71ab
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ impl<'a> CircuitInputBuilder {
let mut tx = self.new_tx(eth_tx, !geth_trace.failed)?;

// Sanity check for transaction L1 fee.
let tx_l1_fee = if tx.tx_type.is_l1_msg() {
let tx_l1_fee = if tx.tx_type.is_l1_msg() || tx.tx_type.is_l1_block_hashes() {
0
} else {
tx.l1_fee()
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl Transaction {
);

let tx_type = TxType::get_tx_type(eth_tx);
let (l1_fee, l1_fee_committed) = if tx_type.is_l1_msg() {
let (l1_fee, l1_fee_committed) = if tx_type.is_l1_msg() || tx_type.is_l1_block_hashes() {
Default::default()
} else {
(
Expand Down
5 changes: 1 addition & 4 deletions zkevm-circuits/src/evm_circuit/execution/begin_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
let tx_caller_address_is_zero = IsZeroGadget::construct(cb, tx_caller_address.expr());
cb.require_equal(
"CallerAddress != 0 (not a padding tx)",
and::expr([
not::expr(tx_l1_block_hashes.is_l1_block_hashes()),
tx_caller_address_is_zero.expr(),
]),
tx_caller_address_is_zero.expr(),
false.expr(),
);
let tx_callee_address_is_zero = IsZeroGadget::construct(cb, tx_callee_address.expr());
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/evm_circuit/execution/end_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<F: Field> ExecutionGadget<F> for EndTxGadget<F> {
let effective_fee = cb.query_word_rlc();

cb.condition(tx_l1_custom_tx.expr(), |cb| {
cb.require_zero("l1fee is 0 for l1msg", tx_l1_fee.expr());
cb.require_zero("l1fee is 0 for l1msg and l1 block hashesg", tx_l1_fee.expr());
});
cb.require_equal(
"tx_fee == l1_fee + l2_fee",
Expand Down Expand Up @@ -405,7 +405,7 @@ impl<F: Field> ExecutionGadget<F> for EndTxGadget<F> {
)?;

let tx_l1_fee = if tx.tx_type.is_l1_custom_tx() {
log::trace!("tx is l1msg and l1 fee is 0");
log::trace!("tx is l1msg or l1 block hashes and l1 fee is 0");
0
} else {
tx.l1_fee.tx_l1_fee(tx.tx_data_gas_cost).0
Expand Down
1 change: 0 additions & 1 deletion zkevm-circuits/src/super_circuit/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ fn test_super_circuit<
);

block.txs[0].tx_type = TxType::L1BlockHashes;
block.txs[0].caller_address = address!("0x0000000000000000000000000000000000000000");

let active_row_num =SuperCircuit::<
Fr,
Expand Down
8 changes: 4 additions & 4 deletions zkevm-circuits/src/tx_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,14 +1180,14 @@ impl<F: Field> SubCircuitConfig<F> for TxCircuitConfig<F> {
});

meta.lookup_any("l1 block hashes calldata in block table", |meta| {
let is_tag_block_num = meta.query_advice(is_tag_block_num, Rotation::cur());
let block_num = meta.query_advice(tx_table.value, Rotation::cur());
let calldata_rlc = meta.query_advice(calldata_rlc, Rotation::cur());
let is_tag_good = meta.query_advice(is_calldata, Rotation::cur());
let block_num = meta.query_advice(tx_table.value, Rotation(16));
let calldata_rlc = meta.query_advice(tx_table.value, Rotation::cur());

let input_expr = vec![L1BlockHashesCalldata.expr(), block_num, calldata_rlc];
let table_expr = block_table.table_exprs(meta);
let condition = and::expr([
is_tag_block_num,
is_tag_good,
meta.query_advice(is_l1_block_hashes, Rotation::cur()),
meta.query_fixed(q_enable, Rotation::cur()),
]);
Expand Down

0 comments on commit 9ab71ab

Please sign in to comment.