revm_handler_interface/
precompile_provider.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use interpreter::InterpreterResult;
use primitives::{Address, Bytes};

pub trait PrecompileProvider: Clone {
    type Context;
    type Error;

    /// Create a new precompile.
    fn new(context: &mut Self::Context) -> Self;

    /// Run the precompile.
    fn run(
        &mut self,
        context: &mut Self::Context,
        address: &Address,
        bytes: &Bytes,
        gas_limit: u64,
    ) -> Result<Option<InterpreterResult>, Self::Error>;

    /// Get the warm addresses.
    fn warm_addresses(&self) -> impl Iterator<Item = Address>;

    /// Check if the address is a precompile.
    fn contains(&self, address: &Address) -> bool;
}