Skip to content

Commit

Permalink
fix(Inspector): frame_end called multiple times (#2037)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita authored Jan 28, 2025
1 parent 03f84f3 commit 249531c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions crates/handler/interface/src/item_or_result.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::Frame;

#[derive(Clone, Debug)]
pub enum ItemOrResult<ITEM, RES> {
Item(ITEM),
Result(RES),
Expand Down
23 changes: 7 additions & 16 deletions crates/inspector/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,9 @@ where
.handler
.frame_init_first(context, frame_context, frame_input);

match &mut ret {
Ok(ItemOrResult::Result(res)) => {
context.frame_end(res);
}
Ok(ItemOrResult::Item(frame)) => {
context.initialize_interp(frame.interpreter());
}
_ => (),
// only if new frame is created call initialize_interp hook.
if let Ok(ItemOrResult::Item(frame)) = &mut ret {
context.initialize_interp(frame.interpreter());
}
ret
}
Expand All @@ -297,14 +292,10 @@ where
let mut ret = self
.handler
.frame_init(frame, context, frame_context, frame_input);
match &mut ret {
Ok(ItemOrResult::Result(res)) => {
context.frame_end(res);
}
Ok(ItemOrResult::Item(frame)) => {
context.initialize_interp(frame.interpreter());
}
_ => (),

// only if new frame is created call initialize_interp hook.
if let Ok(ItemOrResult::Item(frame)) = &mut ret {
context.initialize_interp(frame.interpreter());
}
ret
}
Expand Down
2 changes: 1 addition & 1 deletion crates/precompile/src/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ mod tests {
.unwrap();

let res = run_add(&input, BYZANTIUM_ADD_GAS_COST, 499);
println!("{:?}", res);

assert!(matches!(
res,
Err(PrecompileErrors::Error(PrecompileError::OutOfGas))
Expand Down

0 comments on commit 249531c

Please sign in to comment.