Skip to content

Commit

Permalink
Refunding for existing authority accounts via global refund counter
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Aug 28, 2024
1 parent 242ab62 commit f6762bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ std::variant<TransactionReceipt, std::error_code> transition(State& state, const
assert(sender_acc.nonce < Account::NonceMax); // checked in transaction validation
++sender_acc.nonce; // Bump sender nonce.

auto delegation_refund = 0;

for (const auto& auth : tx.authorization_list)
{
// Check if authority exists
Expand All @@ -501,7 +503,7 @@ std::variant<TransactionReceipt, std::error_code> transition(State& state, const

// Refund if authority account creation is not needed
static constexpr int64_t EXISTING_AUTHORITY_REFUND = 25000 - 2500;
sender_ptr->balance += EXISTING_AUTHORITY_REFUND;
delegation_refund += EXISTING_AUTHORITY_REFUND;
}
else
{
Expand Down Expand Up @@ -579,7 +581,7 @@ std::variant<TransactionReceipt, std::error_code> transition(State& state, const

const auto max_refund_quotient = rev >= EVMC_LONDON ? 5 : 2;
const auto refund_limit = gas_used / max_refund_quotient;
const auto refund = std::min(result.gas_refund, refund_limit);
const auto refund = std::min(delegation_refund + result.gas_refund, refund_limit);
gas_used -= refund;
assert(gas_used > 0);

Expand Down

0 comments on commit f6762bc

Please sign in to comment.