fix(stages): clear pre-eip161 accounts (#1747)

This commit is contained in:
joshieDo
2023-03-14 14:41:33 +08:00
committed by GitHub
parent 5b90cbc411
commit ee3a8af754
2 changed files with 10 additions and 5 deletions

View File

@@ -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!(

View File

@@ -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::<tables::PlainAccountState>(address, None)?;
}
}
}
Ok(())