Merge pull request #11435 from ethereum/reset-warm-access

Clears EIP-2929 account and storage access indicator on new blocks.
This commit is contained in:
chriseth 2021-05-25 16:31:04 +02:00 committed by GitHub
commit e1ef16251e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -168,6 +168,16 @@ void EVMHost::reset()
}
}
void EVMHost::resetWarmAccess()
{
// Clear EIP-2929 account access indicator
recorded_account_accesses.clear();
// Clear EIP-2929 storage access indicator
for (auto& [address, account]: accounts)
for (auto& [slot, value]: account.storage)
value.access_status = EVMC_ACCESS_COLD;
}
void EVMHost::transfer(evmc::MockedAccount& _sender, evmc::MockedAccount& _recipient, u256 const& _value) noexcept
{
assertThrow(u256(convertFromEVMC(_sender.balance)) >= _value, Exception, "Insufficient balance for transfer");

View File

@ -56,11 +56,14 @@ public:
explicit EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm);
void reset();
/// Clears EIP-2929 account and storage access indicator
void resetWarmAccess();
void newBlock()
{
tx_context.block_number++;
tx_context.block_timestamp += 15;
recorded_logs.clear();
resetWarmAccess();
}
/// @returns contents of storage at @param _addr.