Skip to content

Commit

Permalink
Don't use InvokerControl for precompile (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas authored Nov 23, 2023
1 parent 1fa8518 commit 3b9e87c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
9 changes: 3 additions & 6 deletions precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ pub use crate::simple::{ECRecover, Identity, Ripemd160, Sha256};

use alloc::vec::Vec;
use evm::standard::{CodeResolver, Config, Precompile, ResolvedCode};
use evm::{
ExitError, ExitException, ExitResult, GasedMachine, InvokerControl, RuntimeBackend,
RuntimeState, StaticGasometer,
};
use evm::{ExitError, ExitException, ExitResult, RuntimeBackend, RuntimeState, StaticGasometer};

use primitive_types::H160;

Expand Down Expand Up @@ -62,7 +59,7 @@ impl<S: AsRef<RuntimeState>, G: StaticGasometer, H> Precompile<S, G, H> for Stan
state: S,
mut gasometer: G,
_handler: &mut H,
) -> InvokerControl<GasedMachine<S, G>, (ExitResult, (S, G, Vec<u8>))> {
) -> (ExitResult, (S, G, Vec<u8>)) {
let (exit, retval) = match self {
Self::ECRecover => ECRecover.execute(input, state.as_ref(), &mut gasometer),
Self::Sha256 => Sha256.execute(input, state.as_ref(), &mut gasometer),
Expand All @@ -75,7 +72,7 @@ impl<S: AsRef<RuntimeState>, G: StaticGasometer, H> Precompile<S, G, H> for Stan
Self::Blake2F => Blake2F.execute(input, state.as_ref(), &mut gasometer),
};

InvokerControl::DirectExit((exit, (state, gasometer, retval)))
(exit, (state, gasometer, retval))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/standard/invoker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub trait Precompile<S, G, H> {
state: S,
gasometer: G,
handler: &mut H,
) -> InvokerControl<GasedMachine<S, G>, (ExitResult, (S, G, Vec<u8>))>;
) -> (ExitResult, (S, G, Vec<u8>));
}

impl<S, G, H> Precompile<S, G, H> for Infallible {
Expand All @@ -122,7 +122,7 @@ impl<S, G, H> Precompile<S, G, H> for Infallible {
_state: S,
_gasometer: G,
_handler: &mut H,
) -> InvokerControl<GasedMachine<S, G>, (ExitResult, (S, G, Vec<u8>))> {
) -> (ExitResult, (S, G, Vec<u8>)) {
match *self {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/standard/invoker/routines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ where
is_static,
}))
}
ResolvedCode::Precompile(precompile) => {
Ok(precompile.execute(&input, state, gasometer, handler))
}
ResolvedCode::Precompile(precompile) => Ok(InvokerControl::DirectExit(
precompile.execute(&input, state, gasometer, handler),
)),
}
}

Expand Down

0 comments on commit 3b9e87c

Please sign in to comment.