Skip to content

Commit

Permalink
Support delegation clearing in StateDiff API
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Nov 22, 2024
1 parent d487ec5 commit 5c8549e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ StateDiff State::build_diff(evmc_revision rev) const
// TODO: Output also the code hash. It will be needed for DB update and MPT hash.
if ((m.just_created && !m.code.empty()) || m.code_changed)
a.code = m.code;
if (m.code_changed && m.code.empty())
a.code_cleared = true;

for (const auto& [k, v] : m.storage)
{
Expand Down
3 changes: 3 additions & 0 deletions test/state/state_diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct StateDiff
/// New account code. If empty, it means the code has not changed.
bytes code;

/// If true, account code was emptied due to resetting EIP-7702 delegation.
bool code_cleared = false;

/// The list of the account's storage modifications: key => new value.
/// The value 0 means the storage entry is deleted.
std::vector<std::pair<bytes32, bytes32>> modified_storage;
Expand Down
2 changes: 2 additions & 0 deletions test/state/test_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void TestState::apply(const state::StateDiff& diff)
a.balance = m.balance;
if (!m.code.empty())
a.code = m.code; // TODO: Consider taking rvalue ref to avoid code copy.
if (m.code_cleared)
a.code.clear();
for (const auto& [k, v] : m.modified_storage)
{
if (v)
Expand Down

0 comments on commit 5c8549e

Please sign in to comment.