diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index e9632f261a..f68ede75ea 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -536,7 +536,9 @@ impl RlpCircuitConfig { }, ); - // if (tx_id' == tx_id and format' != format) or (tx_id' != tx_id and tx_id' != 0) + // These two cases are not the very last non-padding RLP instance. + // 1. (tx_id' == tx_id and format' != format) + // 2. (tx_id' != tx_id and tx_id' != 0) cb.condition( sum::expr([ // case 1 @@ -572,6 +574,23 @@ impl RlpCircuitConfig { }, ); + // For the very last non-padding RLP instance, we have + // tx_id' != tx_id && tx_id' == 0 + cb.condition( + and::expr([ + is_padding_in_dt.expr(Rotation::next())(meta), + not::expr(tx_id_check_in_dt.is_equal_expression.expr()), + ]), + |cb| { + // byte_rev_idx == 1 + cb.require_equal( + "byte_rev_idx is 1 at the last index", + meta.query_advice(data_table.byte_rev_idx, Rotation::cur()), + 1.expr(), + ); + }, + ); + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); @@ -1122,6 +1141,7 @@ impl RlpCircuitConfig { cb.condition(tidx_eq_tlen, |cb| { // assertions emit_rlp_tag!(meta, cb, tag_expr(meta), false); + constrain_eq!(meta, cb, rlp_table.tag_value, tag_value_acc_expr(meta)); // state transitions. update_state!(meta, cb, tag, tag_next_expr(meta));