Skip to content

Commit

Permalink
Fix tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Oct 10, 2024
1 parent a4be51e commit 7c8e0b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions test/state/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ struct Account
/// The account has been created in the current transaction.
bool just_created = false;

// This account's code changed due to setting EIP-7702 delegation.
bool code_changed = false;

evmc_access_status access_status = EVMC_ACCESS_COLD;

[[nodiscard]] bool is_empty() const noexcept
Expand Down
11 changes: 8 additions & 3 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ StateDiff State::build_diff(evmc_revision rev) const

// Output only the new code.
// TODO: Output also the code hash. It will be needed for DB update and MPT hash.
if (m.just_created && !m.code.empty())
if ((m.just_created && !m.code.empty()) || m.code_changed)
a.code = m.code;

for (const auto& [k, v] : m.storage)
Expand Down Expand Up @@ -454,6 +454,8 @@ std::variant<TransactionReceipt, std::error_code> transition(const StateView& st
{
State state{state_view};
auto* sender_ptr = state.find(tx.sender);
// TODO hack to load full code into sender_ptr account
state.get_code(tx.sender);

// Validate transaction. The validation needs the sender account, so in case
// it doesn't exist provide an empty one. The account isn't created in the state
Expand Down Expand Up @@ -490,7 +492,8 @@ std::variant<TransactionReceipt, std::error_code> transition(const StateView& st
authority_ptr->access_status = EVMC_ACCESS_WARM;

// Skip if authority has non-delegated code.
if (!authority_ptr->code.empty() && !is_code_delegated(authority_ptr->code))
if (authority_ptr->code_hash != Account::EMPTY_CODE_HASH &&
!is_code_delegated(state.get_code(*auth.signer)))
continue;

Check warning on line 497 in test/state/state.cpp

View check run for this annotation

Codecov / codecov/patch

test/state/state.cpp#L496-L497

Added lines #L496 - L497 were not covered by tests

// Skip if authorization nonce is incorrect.
Expand All @@ -517,6 +520,8 @@ std::variant<TransactionReceipt, std::error_code> transition(const StateView& st
authority_ptr->code.reserve(std::size(DELEGATION_MAGIC) + std::size(auth.addr.bytes));
authority_ptr->code = DELEGATION_MAGIC;
authority_ptr->code += auth.addr;
// TODO set only if code is changed to another delegation
authority_ptr->code_changed = true;

++authority_ptr->nonce;
}
Expand Down Expand Up @@ -563,7 +568,7 @@ std::variant<TransactionReceipt, std::error_code> transition(const StateView& st
if (tx.to.has_value())
{
const auto* to_ptr = state.find(*tx.to);
if (to_ptr != nullptr && is_code_delegated(to_ptr->code))
if (to_ptr != nullptr && is_code_delegated(state.get_code(*tx.to)))
{
assert(rev >= EVMC_PRAGUE);
assert(to_ptr->code.size() ==
Expand Down

0 comments on commit 7c8e0b8

Please sign in to comment.