From d04a971c2b0039954f89a49ca058501ce19eedd8 Mon Sep 17 00:00:00 2001 From: "sm.wu" Date: Thu, 29 Feb 2024 17:45:55 +0800 Subject: [PATCH] unimplemented when chunk right after invalid_tx --- bus-mapping/src/circuit_input_builder.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bus-mapping/src/circuit_input_builder.rs b/bus-mapping/src/circuit_input_builder.rs index 26cb003798..7cd93c0900 100644 --- a/bus-mapping/src/circuit_input_builder.rs +++ b/bus-mapping/src/circuit_input_builder.rs @@ -341,17 +341,17 @@ impl<'a, C: CircuitsParams> CircuitInputBuilder { tx_ctx: TransactionContext, next_geth_step: Option<(usize, &GethExecStep)>, last_call: Option, - ) -> Result<(), Error> { + ) -> Result { // we dont chunk if // 1. on last chunk // 2. still got some buffer room before max_rws let Some(max_rws) = self.circuits_params.max_rws() else { // terminiate earlier due to no max_rws - return Ok(()); + return Ok(false); }; if self.chunk_ctx.is_last_chunk() || self.chunk_rws() + RW_BUFFER_SIZE < max_rws { - return Ok(()); + return Ok(false); }; // Optain the first op of the next GethExecStep, for fixed case also lookahead @@ -377,7 +377,7 @@ impl<'a, C: CircuitsParams> CircuitInputBuilder { self.commit_chunk_ctx(true, tx.id as usize, last_copy, last_call); self.set_begin_chunk(&next_ops, Some(&tx)); - Ok(()) + Ok(true) } /// Handle a transaction with its corresponding execution trace to generate @@ -451,14 +451,23 @@ impl<'a, C: CircuitsParams> CircuitInputBuilder { tx.steps_mut().push(end_tx_step.clone()); (end_tx_step, last_call) } else if self.feature_config.invalid_tx { - // chunk before hands to avoid chunk between [InvalidTx, BeginTx) - self.check_and_chunk(geth_trace, tx.clone(), tx_ctx.clone(), None, None)?; // Generate InvalidTx step let invalid_tx_step = gen_associated_steps( &mut self.state_ref(&mut tx, &mut tx_ctx), ExecState::InvalidTx, )?; tx.steps_mut().push(invalid_tx_step.clone()); + // Peek the end_tx_step + let is_chunk = + self.check_and_chunk(geth_trace, tx.clone(), tx_ctx.clone(), None, None)?; + if is_chunk { + // TODO we dont support chunk after invalid_tx + // becasuse begin_chunk will constraints what next step execution state. + // And for next step either begin_tx or invalid_tx will both failed because + // begin_tx/invalid_tx define new execution state. + unimplemented!("dont support invalid_tx with multiple chunks") + } + (invalid_tx_step, None) } else { panic!("invalid tx support not enabled")