11use crate :: { EvmDatabase , VerificationError } ;
22use sbv_kv:: KeyValueStoreGet ;
3- use sbv_precompile:: PrecompileProvider ;
43use sbv_primitives:: {
54 B256 , Bytes ,
65 chainspec:: ChainSpec ,
76 types:: {
8- evm:: precompiles:: PrecompilesMap ,
97 reth:: {
10- evm:: {
11- ConfigureEvm , Database , EthEvm , EthEvmConfig , EvmEnv , EvmFactory ,
12- eth:: EthEvmContext ,
13- execute:: Executor ,
14- revm:: {
15- Context , Inspector , MainBuilder , MainContext ,
16- context:: {
17- BlockEnv , CfgEnv , TxEnv ,
18- result:: { EVMError , HaltReason } ,
19- } ,
20- inspector:: NoOpInspector ,
21- } ,
22- } ,
8+ evm:: { ConfigureEvm , EthEvmConfig , execute:: Executor } ,
239 execution_types:: BlockExecutionOutput ,
2410 primitives:: { Block , Receipt , RecoveredBlock } ,
2511 } ,
26- revm:: { SpecId , database:: CacheDB , precompile :: PrecompileSpecId } ,
12+ revm:: database:: CacheDB ,
2713 } ,
2814} ;
2915use std:: sync:: Arc ;
3016
31- /// Ethereum-related EVM configuration with [`SbvEthEvmFactory`] as the factory.
32- pub type EvmConfig = EthEvmConfig < ChainSpec , SbvEthEvmFactory > ;
33-
3417/// EVM executor that handles the block.
3518#[ derive( Debug ) ]
3619pub struct EvmExecutor < ' a , CodeDb , BlockHashProvider > {
@@ -59,7 +42,7 @@ impl<CodeDb: KeyValueStoreGet<B256, Bytes>, BlockHashProvider: KeyValueStoreGet<
5942{
6043 /// Handle the block with the given witness
6144 pub fn execute ( self ) -> Result < BlockExecutionOutput < Receipt > , VerificationError > {
62- let provider = EvmConfig :: new_with_evm_factory ( self . chain_spec . clone ( ) , SbvEthEvmFactory ) ;
45+ let provider = EthEvmConfig :: new ( self . chain_spec . clone ( ) ) ;
6346
6447 let output = cycle_track ! (
6548 provider. executor( CacheDB :: new( self . db) ) . execute( self . block) ,
@@ -69,53 +52,3 @@ impl<CodeDb: KeyValueStoreGet<B256, Bytes>, BlockHashProvider: KeyValueStoreGet<
6952 Ok ( output)
7053 }
7154}
72-
73- /// Factory producing [`EthEvm`].
74- #[ derive( Debug , Default , Clone , Copy ) ]
75- #[ non_exhaustive]
76- pub struct SbvEthEvmFactory ;
77-
78- impl EvmFactory for SbvEthEvmFactory {
79- type Evm < DB : Database , I : Inspector < EthEvmContext < DB > > > = EthEvm < DB , I , Self :: Precompiles > ;
80- type Context < DB : Database > = Context < BlockEnv , TxEnv , CfgEnv , DB > ;
81- type Tx = TxEnv ;
82- type Error < DBError : core:: error:: Error + Send + Sync + ' static > = EVMError < DBError > ;
83- type HaltReason = HaltReason ;
84- type Spec = SpecId ;
85- type Precompiles = PrecompilesMap ;
86-
87- fn create_evm < DB : Database > ( & self , db : DB , input : EvmEnv ) -> Self :: Evm < DB , NoOpInspector > {
88- let spec_id = input. cfg_env . spec ;
89- EthEvm :: new (
90- Context :: mainnet ( )
91- . with_block ( input. block_env )
92- . with_cfg ( input. cfg_env )
93- . with_db ( db)
94- . build_mainnet_with_inspector ( NoOpInspector { } )
95- . with_precompiles ( PrecompileProvider :: with_spec (
96- PrecompileSpecId :: from_spec_id ( spec_id) ,
97- ) ) ,
98- false ,
99- )
100- }
101-
102- fn create_evm_with_inspector < DB : Database , I : Inspector < Self :: Context < DB > > > (
103- & self ,
104- db : DB ,
105- input : EvmEnv ,
106- inspector : I ,
107- ) -> Self :: Evm < DB , I > {
108- let spec_id = input. cfg_env . spec ;
109- EthEvm :: new (
110- Context :: mainnet ( )
111- . with_block ( input. block_env )
112- . with_cfg ( input. cfg_env )
113- . with_db ( db)
114- . build_mainnet_with_inspector ( inspector)
115- . with_precompiles ( PrecompileProvider :: with_spec (
116- PrecompileSpecId :: from_spec_id ( spec_id) ,
117- ) ) ,
118- true ,
119- )
120- }
121- }
0 commit comments