From ee3a8af754e994362f8159103221a339fd727e50 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:41:33 +0800 Subject: [PATCH] fix(stages): clear pre-eip161 accounts (#1747) --- crates/executor/src/executor.rs | 4 ++-- crates/storage/provider/src/execution_result.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/executor/src/executor.rs b/crates/executor/src/executor.rs index 22cc7c391d..e6a7bef842 100644 --- a/crates/executor/src/executor.rs +++ b/crates/executor/src/executor.rs @@ -185,7 +185,7 @@ where new: to_reth_acc(&account.info), } } else { - AccountInfoChangeSet::NoChange + AccountInfoChangeSet::NoChange { is_empty: account.is_empty() } }; entry.info = account.info.clone(); (account_changeset, entry) @@ -709,7 +709,7 @@ mod tests { assert_eq!( changesets.changeset.get(&account1).unwrap().account, - AccountInfoChangeSet::NoChange, + AccountInfoChangeSet::NoChange { is_empty: false }, "No change to account" ); assert_eq!( diff --git a/crates/storage/provider/src/execution_result.rs b/crates/storage/provider/src/execution_result.rs index 747f08eabc..3c0fcc18dd 100644 --- a/crates/storage/provider/src/execution_result.rs +++ b/crates/storage/provider/src/execution_result.rs @@ -53,7 +53,10 @@ pub enum AccountInfoChangeSet { old: Account, }, /// Nothing was changed for the account (nonce/balance). - NoChange, + NoChange { + /// Useful to clear existing empty accounts pre-EIP-161. + is_empty: bool, + }, } impl AccountInfoChangeSet { @@ -94,8 +97,10 @@ impl AccountInfoChangeSet { AccountBeforeTx { address, info: Some(old) }, )?; } - AccountInfoChangeSet::NoChange => { - // do nothing storage account didn't change + AccountInfoChangeSet::NoChange { is_empty } => { + if has_state_clear_eip && is_empty { + tx.delete::(address, None)?; + } } } Ok(())