Skip to content

Commit

Permalink
fix(EOF): panic on empty input range, and continue exec after eofcrea…
Browse files Browse the repository at this point in the history
…te (#1477)

* reset instruction result

* switch extcall value order

* fix empty input

* revert value pop
  • Loading branch information
rakita authored Jun 7, 2024
1 parent 22e15d3 commit bdd1b8e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/interpreter/src/instructions/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ pub fn extcall_input(interpreter: &mut Interpreter) -> Option<Bytes> {

let return_memory_offset = resize_memory(interpreter, input_offset, input_size)?;

if return_memory_offset.is_empty() {
return Some(Bytes::new());
}

Some(Bytes::copy_from_slice(
interpreter
.shared_memory
Expand Down
1 change: 1 addition & 0 deletions crates/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl Interpreter {
}

pub fn insert_eofcreate_outcome(&mut self, create_outcome: EOFCreateOutcome) {
self.instruction_result = InstructionResult::Continue;
let instruction_result = create_outcome.instruction_result();

self.return_data_buffer = if *instruction_result == InstructionResult::Revert {
Expand Down
1 change: 0 additions & 1 deletion crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ impl<'a, EXT, DB: Database> Evm<'a, EXT, DB> {
}
InterpreterAction::None => unreachable!("InterpreterAction::None is not expected"),
};

// handle result
match frame_or_result {
FrameOrResult::Frame(frame) => {
Expand Down
2 changes: 2 additions & 0 deletions crates/revm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub enum Frame {
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug)]
pub enum FrameResult {
Call(CallOutcome),
Create(CreateOutcome),
Expand Down Expand Up @@ -135,6 +136,7 @@ impl FrameResult {

/// Contains either a frame or a result.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug)]
pub enum FrameOrResult {
/// Boxed call or create frame.
Frame(Frame),
Expand Down

0 comments on commit bdd1b8e

Please sign in to comment.