diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index c620e2af62..ad8c6fbe51 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -102,6 +102,8 @@ pub struct TxCircuitConfig { tx_table: TxTable, tx_tag_bits: BinaryNumberConfig, + // A selector which is enabled at 2nd row + q_second: Column, tx_type: Column, tx_type_bits: BinaryNumberConfig, // The associated rlp tag to lookup in the RLP table @@ -194,7 +196,7 @@ impl SubCircuitConfig for TxCircuitConfig { }: Self::ConfigArgs, ) -> Self { let q_enable = tx_table.q_enable; - + let q_second = meta.fixed_column(); let q_calldata_first = meta.fixed_column(); let q_calldata_last = meta.fixed_column(); // tag, rlp_tag, tx_type, is_none @@ -314,6 +316,17 @@ impl SubCircuitConfig for TxCircuitConfig { ); // tx_id transition + meta.create_gate("tx_id starts with 1", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "tx_id == 1", + meta.query_advice(tx_table.tx_id, Rotation::cur()), + 1.expr(), + ); + + cb.gate(meta.query_fixed(q_second, Rotation::cur())) + }); meta.create_gate("tx_id transition", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -987,6 +1000,7 @@ impl SubCircuitConfig for TxCircuitConfig { tx_type_bits, rlp_tag, is_none, + q_second, u16_table, tx_id_is_zero, value_is_zero, @@ -1827,6 +1841,13 @@ impl TxCircuit { None, )?; + region.assign_fixed( + || "q_second", + config.q_second, + 1, + || Value::known(F::one()), + )?; + // Assign all tx fields except for call data for (i, sign_data) in sigs.iter().enumerate() { let tx = if i < self.txs.len() {