@@ -7,7 +7,7 @@ use revm_database::{
77 TransitionAccount , TransitionState ,
88 states:: { CacheAccount , bundle_state:: BundleRetention , plain_account:: PlainStorage } ,
99} ;
10- use revm_primitives:: { Address , B256 , HashMap , U256 } ;
10+ use revm_primitives:: { Address , B256 , U256 } ;
1111use revm_state:: { Account , AccountInfo , Bytecode , EvmState } ;
1212use std:: { fmt:: Formatter , time:: Instant , vec:: Vec } ;
1313
@@ -152,39 +152,6 @@ impl CacheAccountInfo {
152152 }
153153 }
154154
155- /// Account got touched and before EIP161 state clear this account is considered created.
156- pub fn touch_create_pre_eip161 (
157- & mut self ,
158- storage : StorageWithOriginalValues ,
159- ) -> ( Option < TransitionAccount > , PlainStorage ) {
160- let previous_status = self . status . clone ( ) ;
161-
162- let had_no_info = self . account . as_ref ( ) . map ( |info| info. is_empty ( ) ) . unwrap_or_default ( ) ;
163- match self . status . on_touched_created_pre_eip161 ( had_no_info) {
164- None => return ( None , PlainStorage :: default ( ) ) ,
165- Some ( new_status) => {
166- self . status = new_status;
167- }
168- }
169-
170- let plain_storage = storage. iter ( ) . map ( |( k, v) | ( * k, v. present_value ) ) . collect ( ) ;
171- let previous_info = self . account . take ( ) ;
172-
173- self . account = Some ( AccountInfo :: default ( ) ) ;
174-
175- (
176- Some ( TransitionAccount {
177- info : Some ( AccountInfo :: default ( ) ) ,
178- status : self . status . clone ( ) ,
179- previous_info,
180- previous_status,
181- storage,
182- storage_was_destroyed : false ,
183- } ) ,
184- plain_storage,
185- )
186- }
187-
188155 pub fn change (
189156 & mut self ,
190157 new : AccountInfo ,
@@ -219,38 +186,25 @@ impl CacheAccountInfo {
219186/// It loads all accounts from database and applies revm output to it.
220187///
221188/// It generates transitions that is used to build BundleState.
222- #[ derive( Clone , Debug ) ]
189+ #[ derive( Clone , Debug , Default ) ]
223190pub struct ParallelCacheState {
224191 /// Cached accounts
225192 pub accounts : DashMap < Address , CacheAccountInfo > ,
226193 /// Cached storage slots
227194 pub storage : DashMap < Address , DashMap < U256 , U256 > > ,
228195 /// Cache contracts
229196 pub contracts : DashMap < B256 , Bytecode > ,
230- /// Has EIP-161 state clear enabled (Spurious Dragon hardfork).
231- pub has_state_clear : bool ,
232- }
233-
234- impl Default for ParallelCacheState {
235- fn default ( ) -> Self {
236- Self :: new ( true )
237- }
238197}
239198
240199impl ParallelCacheState {
241200 /// New default state.
242- pub fn new ( has_state_clear : bool ) -> Self {
243- Self {
244- accounts : Default :: default ( ) ,
245- storage : Default :: default ( ) ,
246- contracts : Default :: default ( ) ,
247- has_state_clear,
248- }
201+ pub fn new ( ) -> Self {
202+ Self :: default ( )
249203 }
250204
251205 /// Copy the cached data and convert to CacheState
252206 pub fn as_cache_state ( & self ) -> CacheState {
253- let mut state = CacheState :: new ( self . has_state_clear ) ;
207+ let mut state = CacheState :: new ( ) ;
254208 for kv in self . accounts . iter ( ) {
255209 let info = kv. value ( ) ;
256210 state. accounts . insert (
@@ -283,11 +237,6 @@ impl ParallelCacheState {
283237 state
284238 }
285239
286- /// Set state clear flag. EIP-161.
287- pub fn set_state_clear_flag ( & mut self , has_state_clear : bool ) {
288- self . has_state_clear = has_state_clear;
289- }
290-
291240 /// Insert not existing account.
292241 pub fn insert_not_existing ( & self , address : Address ) {
293242 self . accounts
@@ -376,19 +325,12 @@ impl ParallelCacheState {
376325 // Account is touched, but not selfdestructed or newly created.
377326 // Account can be touched and not changed.
378327 // And when empty account is touched it needs to be removed from database.
379- // EIP-161 state clear
328+ // EIP-161 state clear (revm v40+ dropped pre-EIP161 support; Spurious Dragon
329+ // is always assumed active).
380330 else if is_empty {
381331 self . storage . remove ( & address) ;
382- if self . has_state_clear {
383- // touch empty account.
384- ( self . get_account_mut ( address) . touch_empty_eip161 ( ) , None )
385- } else {
386- // if account is empty and state clear is not enabled we should save
387- // empty account.
388- let ( transition, changed_slots) =
389- self . get_account_mut ( address) . touch_create_pre_eip161 ( changed_storage) ;
390- ( transition, Some ( changed_slots) )
391- }
332+ drop ( changed_storage) ;
333+ ( self . get_account_mut ( address) . touch_empty_eip161 ( ) , None )
392334 } else {
393335 let ( transition, changed_slots) =
394336 self . get_account_mut ( address) . change ( account. info , changed_storage) ;
@@ -591,9 +533,10 @@ impl<DB: DatabaseRef> ParallelState<DB> {
591533 }
592534
593535 /// State clear EIP-161 is enabled in Spurious Dragon hardfork.
594- pub fn set_state_clear_flag ( & mut self , has_state_clear : bool ) {
595- self . cache . set_state_clear_flag ( has_state_clear) ;
596- }
536+ ///
537+ /// revm v40+ dropped pre-EIP161 support and always assumes Spurious Dragon is active;
538+ /// this setter is kept as a no-op for API compatibility with older callers.
539+ pub fn set_state_clear_flag ( & mut self , _has_state_clear : bool ) { }
597540
598541 /// Insert non-existent account
599542 pub fn insert_not_existing ( & self , address : Address ) {
@@ -795,7 +738,7 @@ impl<DB: DatabaseRef> DatabaseRef for ParallelState<DB> {
795738}
796739
797740impl < DB : DatabaseRef > DatabaseCommit for ParallelState < DB > {
798- fn commit ( & mut self , evm_state : HashMap < Address , Account > ) {
741+ fn commit ( & mut self , evm_state : revm_primitives :: AddressMap < Account > ) {
799742 let transitions = self . cache . apply_evm_state ( evm_state) ;
800743 self . apply_transition ( transitions) ;
801744 }
0 commit comments