Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions crates/database/src/states/account_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ impl AccountStatus {
}

/// Returns the next account status on touched empty account post state clear EIP (EIP-161).
///
/// # Panics
///
/// If current status is [AccountStatus::Loaded] or [AccountStatus::Changed].
pub fn on_touched_empty_post_eip161(&self) -> Self {
match self {
// Account can be touched but not existing. The status should remain the same.
Expand All @@ -108,10 +104,8 @@ impl AccountStatus {
Self::InMemoryChange | Self::Destroyed | Self::LoadedEmptyEIP161 => Self::Destroyed,
// Transition to destroy the account.
Self::DestroyedAgain | Self::DestroyedChanged => Self::DestroyedAgain,
// Account statuses considered unreachable.
Self::Loaded | Self::Changed => {
unreachable!("Wrong state transition, touch empty is not possible from {self:?}");
}
// Account can become empty.
Self::Changed | Self::Loaded => Self::Destroyed,
}
}

Expand Down Expand Up @@ -319,6 +313,14 @@ mod test {
AccountStatus::DestroyedChanged.on_touched_empty_post_eip161(),
AccountStatus::DestroyedAgain
);
assert_eq!(
AccountStatus::Loaded.on_touched_empty_post_eip161(),
AccountStatus::Destroyed
);
assert_eq!(
AccountStatus::Changed.on_touched_empty_post_eip161(),
AccountStatus::Destroyed
);
}

#[test]
Expand Down
Loading