Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use InvokerControl for precompile #234

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
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
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
Loading