@@ -61,11 +61,11 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
6161 {
6262 let Environment { provider_factory, .. } = self . env . init :: < N > ( AccessRights :: RO ) ?;
6363
64- let provider = provider_factory. database_provider_ro ( ) ?;
6564 let components = components ( provider_factory. chain_spec ( ) ) ;
6665
6766 let min_block = self . from ;
68- let best_block = provider. best_block_number ( ) ?;
67+ let best_block = DatabaseProviderFactory :: database_provider_ro ( & provider_factory) ?
68+ . best_block_number ( ) ?;
6969 let mut max_block = best_block;
7070 if let Some ( to) = self . to {
7171 if to > best_block {
@@ -111,6 +111,9 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
111111 let stats_tx = stats_tx. clone ( ) ;
112112 tasks. spawn_blocking ( move || {
113113 let mut executor = evm_config. batch_executor ( db_at ( start_block - 1 ) ) ;
114+ let mut executor_created = Instant :: now ( ) ;
115+ let executor_lifetime = Duration :: from_secs ( 120 ) ;
116+
114117 for block in start_block..end_block {
115118 let block = provider_factory
116119 . recovered_block ( block. into ( ) , TransactionVariant :: NoHash ) ?
@@ -166,9 +169,12 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
166169 }
167170 let _ = stats_tx. send ( block. gas_used ( ) ) ;
168171
169- // Reset DB once in a while to avoid OOM
170- if executor. size_hint ( ) > 1_000_000 {
172+ // Reset DB once in a while to avoid OOM or read tx timeouts
173+ if executor. size_hint ( ) > 1_000_000 ||
174+ executor_created. elapsed ( ) > executor_lifetime
175+ {
171176 executor = evm_config. batch_executor ( db_at ( block. number ( ) ) ) ;
177+ executor_created = Instant :: now ( ) ;
172178 }
173179 }
174180
0 commit comments