Pass is_static to precompiles
@@ -87,10 +87,18 @@ pub struct PrecompileOutput {
pub logs: Vec<Log>,
}
+/// Precompiles function signature. Expected input arguments are:
+/// * Address
+/// * Input
+/// * Context
+/// * State
+/// * Is static
+type PrecompileFn<S> = fn(H160, &[u8], Option<u64>, &Context, &mut S, bool) -> Option<Result<PrecompileOutput, ExitError>>;
+
/// Stack-based executor.
pub struct StackExecutor<'config, S> {
config: &'config Config,
- precompile: fn(H160, &[u8], Option<u64>, &Context, &mut S) -> Option<Result<PrecompileOutput, ExitError>>,
+ precompile: PrecompileFn<S>,
state: S,
}
@@ -99,7 +107,8 @@ fn no_precompile<S>(
_input: &[u8],
_target_gas: Option<u64>,
_context: &Context,
- _state: &mut S
+ _state: &mut S,
+ _is_static: bool,
) -> Option<Result<PrecompileOutput, ExitError>> {
None
}
@@ -124,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<u64>, &Context, &mut S) -> Option<Result<PrecompileOutput, ExitError>>,
+ precompile: PrecompileFn<S>,
) -> Self {
Self {
config,
@@ -532,7 +541,7 @@ impl<'config, S: StackState<'config>> StackExecutor<'config, S> {
}
}
- if let Some(ret) = (self.precompile)(code_address, &input, Some(gas_limit), &context, &mut self.state) {
+ 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 {
