Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.
Merged
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
28 changes: 15 additions & 13 deletions bus-mapping/src/evm/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ fn fn_gen_associated_ops(opcode_id: &OpcodeId) -> FnGenAssociatedOps {
}
}

fn fn_gen_error_state_associated_ops(error: &ExecError) -> FnGenAssociatedOps {
fn fn_gen_error_state_associated_ops(error: &ExecError) -> Option<FnGenAssociatedOps> {
match error {
ExecError::InvalidJump => ErrorInvalidJump::gen_associated_ops,
ExecError::OutOfGas(OogError::Call) => OOGCall::gen_associated_ops,
ExecError::InvalidJump => Some(ErrorInvalidJump::gen_associated_ops),
ExecError::OutOfGas(OogError::Call) => Some(OOGCall::gen_associated_ops),
// more future errors place here
_ => {
warn!("Using dummy gen_associated_ops for error state {:?}", error);
Dummy::gen_associated_ops
warn!("TODO: error state {:?} not implemented", error);
None
}
}
}
Expand Down Expand Up @@ -303,21 +303,23 @@ pub fn gen_associated_ops(
exec_step.error = Some(exec_error.clone());
// TODO: after more error state handled, refactor all error handling in
// fn_gen_error_state_associated_ops method
if exec_step.oog_or_stack_error() && !geth_step.op.is_call_or_create() {
state.gen_restore_context_ops(&mut exec_step, geth_steps)?;
// For exceptions that have been implemented
if let Some(fn_gen_error_ops) = fn_gen_error_state_associated_ops(&exec_error) {
return fn_gen_error_ops(state, geth_steps);
} else {
// For exceptions that already enter next call context, but fail immediately
// (e.g. Depth, InsufficientBalance), we still need to parse the call.
if geth_step.op.is_call_or_create() && !exec_step.oog_or_stack_error() {
let call = state.parse_call(geth_step)?;
// Switch to callee's call context
state.push_call(call);
// For exceptions that fail to enter next call context, we need
// to restore call context of current caller
} else {
let fn_gen_error_associated_ops = fn_gen_error_state_associated_ops(&exec_error);
return fn_gen_error_associated_ops(state, geth_steps);
state.gen_restore_context_ops(&mut exec_step, geth_steps)?;
}
state.handle_return(geth_step)?;
return Ok(vec![exec_step]);
}

state.handle_return(geth_step)?;
return Ok(vec![exec_step]);
}
// if no errors, continue as normal
fn_gen_associated_ops(state, geth_steps)
Expand Down