Skip to content

Commit

Permalink
fix last frame result
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Jan 26, 2025
1 parent 0b51ebb commit 72c6acf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 31 deletions.
6 changes: 0 additions & 6 deletions crates/handler/interface/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ pub trait Frame: Sized {
frame_input: Self::FrameInit,
) -> Result<FrameOrResult<Self>, Self::Error>;

fn final_return(
context: &mut Self::Context,
frame_context: &mut Self::FrameContext,
result: &mut Self::FrameResult,
) -> Result<(), Self::Error>;

fn init(
&self,
context: &mut Self::Context,
Expand Down
8 changes: 0 additions & 8 deletions crates/handler/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,6 @@ where
Self::init_with_context(0, frame_input, memory, context, frame_context)
}

fn final_return(
_context: &mut Self::Context,
_frame_context: &mut Self::FrameContext,
_result: &mut Self::FrameResult,
) -> Result<(), Self::Error> {
Ok(())
}

fn init(
&self,
context: &mut CTX,
Expand Down
12 changes: 1 addition & 11 deletions crates/handler/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,6 @@ pub trait EthHandler {
Self::Frame::return_result(frame, context, frame_context, result)
}

fn frame_final_return(
context: &mut Self::Context,
frame_context: &mut <Self::Frame as Frame>::FrameContext,
result: &mut <Self::Frame as Frame>::FrameResult,
) -> Result<(), Self::Error> {
Self::Frame::final_return(context, frame_context, result)?;
Ok(())
}

fn run_exec_loop(
&mut self,
context: &mut Self::Context,
Expand All @@ -229,7 +220,7 @@ pub trait EthHandler {
let frame = frame_stack.last_mut().unwrap();
let call_or_result = self.frame_call(frame, context, frame_context)?;

let mut result = match call_or_result {
let result = match call_or_result {
ItemOrResult::Item(init) => {
match self.frame_init(frame, context, frame_context, init)? {
ItemOrResult::Item(new_frame) => {
Expand All @@ -248,7 +239,6 @@ pub trait EthHandler {
};

let Some(frame) = frame_stack.last_mut() else {
Self::Frame::final_return(context, frame_context, &mut result)?;
return Ok(result);
};
self.frame_return_result(frame, context, frame_context, result)?;
Expand Down
12 changes: 7 additions & 5 deletions crates/inspector/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,14 @@ where
.frame_return_result(frame, context, frame_context, result)
}

fn frame_final_return(
fn last_frame_result(
&self,
context: &mut Self::Context,
_frame_context: &mut <<Self as EthHandler>::Frame as Frame>::FrameContext,
result: &mut <<Self as EthHandler>::Frame as Frame>::FrameResult,
frame_context: &mut <Self::Frame as Frame>::FrameContext,
frame_result: &mut <Self::Frame as Frame>::FrameResult,
) -> Result<(), Self::Error> {
context.frame_end(result);
Ok(())
context.frame_end(frame_result);
self.handler
.last_frame_result(context, frame_context, frame_result)
}
}
5 changes: 4 additions & 1 deletion crates/inspector/src/inspector_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ where
fn frame_end(&mut self, frame_output: &mut FrameResult) {
let insp = self.inspector.get_inspector();
let context = &mut self.inner;
let frame_input = self.frame_input_stack.pop().expect("Frame pushed");
let Some(frame_input) = self.frame_input_stack.pop() else {
// case where call returns immediately will not push to call stack.
return;
};
match frame_output {
FrameResult::Call(outcome) => {
let FrameInput::Call(i) = frame_input else {
Expand Down

0 comments on commit 72c6acf

Please sign in to comment.