revmc_examples_runner/
lib.rs1#![no_std]
4
5extern crate alloc;
6
7use revmc_builtins as _;
10
11use revm::{
12 context::{BlockEnv, CfgEnv, Context, Journal, TxEnv},
13 database_interface::Database,
14 handler::MainBuilder,
15 primitives::{hardfork::SpecId, hex, B256},
16 MainnetEvm,
17};
18use revmc_context::EvmCompilerFn;
19
20include!("./common.rs");
21
22revmc_context::extern_revmc! {
24 fn fibonacci;
25}
26
27#[derive(Clone, Default)]
29pub struct ExternalContext;
30
31impl ExternalContext {
32 pub fn new() -> Self {
34 Self
35 }
36
37 pub fn get_function(&self, bytecode_hash: B256) -> Option<EvmCompilerFn> {
39 if bytecode_hash == B256::from(FIBONACCI_HASH) {
41 return Some(EvmCompilerFn::new(fibonacci));
42 }
43 None
44 }
45}
46
47pub type MainnetContext<DB> = Context<BlockEnv, TxEnv, CfgEnv, DB, Journal<DB>, ()>;
49
50pub fn build_evm<DB: Database>(db: DB) -> MainnetEvm<MainnetContext<DB>> {
57 Context::<BlockEnv, TxEnv, CfgEnv, DB, Journal<DB>, ()>::new(db, SpecId::CANCUN).build_mainnet()
58}