diff --git a/src/executor/stack/mod.rs b/src/executor/stack/mod.rs index 3f824215f..2ede0a629 100644 --- a/src/executor/stack/mod.rs +++ b/src/executor/stack/mod.rs @@ -87,18 +87,28 @@ pub struct PrecompileOutput { pub logs: Vec, } +/// Precompiles function signature. Expected input arguments are: +/// * Address +/// * Input +/// * Context +/// * State +/// * Is static +type PrecompileFn = fn(H160, &[u8], Option, &Context, &mut S, bool) -> Option>; + /// Stack-based executor. pub struct StackExecutor<'config, S> { config: &'config Config, - precompile: fn(H160, &[u8], Option, &Context) -> Option>, + precompile: PrecompileFn, state: S, } -fn no_precompile( +fn no_precompile( _address: H160, _input: &[u8], _target_gas: Option, _context: &Context, + _state: &mut S, + _is_static: bool, ) -> Option> { None } @@ -123,7 +133,7 @@ impl<'config, S: StackState<'config>> StackExecutor<'config, S> { pub fn new_with_precompile( state: S, config: &'config Config, - precompile: fn(H160, &[u8], Option, &Context) -> Option>, + precompile: PrecompileFn, ) -> Self { Self { config, @@ -531,7 +541,7 @@ impl<'config, S: StackState<'config>> StackExecutor<'config, S> { } } - if let Some(ret) = (self.precompile)(code_address, &input, Some(gas_limit), &context) { + if let Some(ret) = (self.precompile)(code_address, &input, Some(gas_limit), &context, &mut self.state, is_static) { match ret { Ok(PrecompileOutput { exit_status , output, cost, logs }) => { for Log { address, topics, data} in logs {