Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions bus-mapping/src/circuit_input_builder/input_state_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion bus-mapping/src/evm/opcodes/returndatasize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {:?}",
Expand Down
1 change: 0 additions & 1 deletion bus-mapping/src/evm/opcodes/stackonlyop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ impl<const N_POP: usize, const N_PUSH: usize, const IS_ERR: bool> 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)?;
}

Expand Down
8 changes: 1 addition & 7 deletions testool/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct CompilerSettings {
output_selection: HashMap<String, HashMap<String, Vec<String>>>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
struct Optimizer {
enabled: bool,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion testool/src/statetest/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion testool/tests
Submodule tests updated from e4fc8f to 747a48