diff --git a/bus-mapping/src/circuit_input_builder/input_state_ref.rs b/bus-mapping/src/circuit_input_builder/input_state_ref.rs index 216d42d182..04d61a5824 100644 --- a/bus-mapping/src/circuit_input_builder/input_state_ref.rs +++ b/bus-mapping/src/circuit_input_builder/input_state_ref.rs @@ -1131,19 +1131,34 @@ impl<'a> CircuitInputStateRef<'a> { /// Handle a restore and a return step caused by any opcode that causes a return to the /// previous call context. - /// `caller_ctx.return_data` should be updated **before** this method. + /// `caller_ctx.return_data` should be updated **before** this method (except error cases). pub fn handle_return( &mut self, exec_step: &mut ExecStep, geth_steps: &[GethExecStep], need_restore: bool, ) -> Result<(), Error> { + let step = &geth_steps[0]; + + // For these 6 opcodes, the return data should be handled in opcodes respectively. + // For other opcodes/states, return data must be empty. + if !matches!( + step.op, + OpcodeId::RETURN + | OpcodeId::REVERT + | OpcodeId::CALL + | OpcodeId::CALLCODE + | OpcodeId::DELEGATECALL + | OpcodeId::STATICCALL + ) { + if let Ok(caller) = self.caller_ctx_mut() { + caller.return_data.clear(); + } + } if need_restore { self.handle_restore_context(exec_step, geth_steps)?; } - let step = &geth_steps[0]; - let call = self.call()?.clone(); let call_ctx = self.call_ctx()?; let callee_memory = call_ctx.memory.clone(); diff --git a/bus-mapping/src/evm/opcodes/returndatasize.rs b/bus-mapping/src/evm/opcodes/returndatasize.rs index 3693e7d5eb..0f0db170e9 100644 --- a/bus-mapping/src/evm/opcodes/returndatasize.rs +++ b/bus-mapping/src/evm/opcodes/returndatasize.rs @@ -28,7 +28,8 @@ impl Opcode for Returndatasize { // TODO: fix error in deposit_ether.json... let real_return_data_len = value.as_usize(); - let local_return_data_len = state.call_ctx()?.return_data.len(); + let call_ctx = state.call_ctx()?; + let local_return_data_len = call_ctx.return_data.len(); if real_return_data_len != local_return_data_len { log::error!( "return_data.len() != RETURNDATASIZE value, {} != {}, step: {:?}", diff --git a/bus-mapping/src/evm/opcodes/stackonlyop.rs b/bus-mapping/src/evm/opcodes/stackonlyop.rs index 0aea31eb30..f0549e5b4a 100644 --- a/bus-mapping/src/evm/opcodes/stackonlyop.rs +++ b/bus-mapping/src/evm/opcodes/stackonlyop.rs @@ -49,7 +49,6 @@ impl Opcode let next_step = geth_steps.get(1); let err = state.get_step_err(geth_step, next_step); exec_step.error = err.unwrap(); - state.handle_return(&mut exec_step, geth_steps, true)?; } diff --git a/testool/src/compiler.rs b/testool/src/compiler.rs index 6e4638c395..1b1e010d29 100644 --- a/testool/src/compiler.rs +++ b/testool/src/compiler.rs @@ -89,7 +89,7 @@ struct CompilerSettings { output_selection: HashMap>>, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Default)] #[serde(rename_all = "camelCase")] struct Optimizer { enabled: bool, @@ -132,12 +132,6 @@ impl CompilerSettings { } } -impl Default for Optimizer { - fn default() -> Self { - Optimizer { enabled: false } - } -} - #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct CompilationResult { diff --git a/testool/src/statetest/results.rs b/testool/src/statetest/results.rs index 903423278e..79b95289e0 100644 --- a/testool/src/statetest/results.rs +++ b/testool/src/statetest/results.rs @@ -394,7 +394,7 @@ impl Results { .create(true) .append(true) .open(path)?; - for (_, result) in &self.tests { + for result in self.tests.values() { let entry = format!( "{:?};{};{};{}\n", result.level, diff --git a/testool/tests b/testool/tests index e4fc8f6cab..747a4828f3 160000 --- a/testool/tests +++ b/testool/tests @@ -1 +1 @@ -Subproject commit e4fc8f6cabec7cab0a7a92f8ba3a00a450b2b90b +Subproject commit 747a4828f36c5fc8ab4f288d1cf4f1fe6662f3d6