From 5aff2f1146d3650f59fdd8e148143013b1ecd7c2 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Sun, 29 Oct 2023 06:03:12 -0700 Subject: [PATCH] chore(state): consistent selfdestruct status transition (#847) --- crates/revm/src/db/states/account_status.rs | 2 ++ crates/revm/src/db/states/cache_account.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/revm/src/db/states/account_status.rs b/crates/revm/src/db/states/account_status.rs index d077caf0d0..aaf0b5b48e 100644 --- a/crates/revm/src/db/states/account_status.rs +++ b/crates/revm/src/db/states/account_status.rs @@ -167,6 +167,8 @@ impl AccountStatus { /// Returns the next account status on selfdestruct. pub fn on_selfdestructed(&self) -> AccountStatus { match self { + // Non existing account can't be destroyed. + AccountStatus::LoadedNotExisting => AccountStatus::LoadedNotExisting, // If account is created and selfdestructed in the same block, mark it as destroyed again. // Note: there is no big difference between Destroyed and DestroyedAgain in this case, // but was added for clarity. diff --git a/crates/revm/src/db/states/cache_account.rs b/crates/revm/src/db/states/cache_account.rs index 2d6232766c..126ce2ffe7 100644 --- a/crates/revm/src/db/states/cache_account.rs +++ b/crates/revm/src/db/states/cache_account.rs @@ -179,8 +179,6 @@ impl CacheAccount { self.status = self.status.on_selfdestructed(); if previous_status == AccountStatus::LoadedNotExisting { - // transitions for account loaded as not existing. - self.status = AccountStatus::LoadedNotExisting; None } else { Some(TransitionAccount {