@@ -322,7 +322,21 @@ class MockedHost : public Host
322322 }
323323
324324 // / Record an account access.
325+ // /
326+ // / This method is required by EIP-2929 introduced in ::EVMC_BERLIN. It will record the account
327+ // / access in MockedHost::recorded_account_accesses and return previous access status.
328+ // / This methods returns ::EVMC_ACCESS_WARM for known addresses of precompiles.
329+ // / The EIP-2929 specifies that evmc_message::sender and evmc_message::destination are always
330+ // / ::EVMC_ACCESS_WARM. Therefore, you should init the MockedHost with:
331+ // /
332+ // / mocked_host.access_account(msg.sender);
333+ // / mocked_host.access_account(msg.destination);
334+ // /
335+ // / The same way you can mock transaction access list (EIP-2930) for account addresses.
336+ // /
325337 // / @param addr The address of the accessed account.
338+ // / @returns The ::EVMC_ACCESS_WARM if the account has been accessed before,
339+ // / the ::EVMC_ACCESS_COLD otherwise.
326340 evmc_access_status access_account (const address& addr) noexcept override
327341 {
328342 // Check if the address have been already accessed.
@@ -341,6 +355,18 @@ class MockedHost : public Host
341355 }
342356
343357 // / Access the account's storage value at the given key.
358+ // /
359+ // / This method is required by EIP-2929 introduced in ::EVMC_BERLIN. In records that the given
360+ // / account's storage key has been access and returns the previous access status.
361+ // / To mock storage access list (EIP-2930), you can pre-init account's storage values with
362+ // / the ::EVMC_ACCESS_WARM flag:
363+ // /
364+ // / mocked_host.accounts[msg.destination].storage[key] = {value, EVMC_ACCESS_WARM};
365+ // /
366+ // / @param addr The account address.
367+ // / @param key The account's storage key.
368+ // / @return The ::EVMC_ACCESS_WARM if the storage key has been accessed before,
369+ // / the ::EVMC_ACCESS_COLD otherwise.
344370 evmc_access_status access_storage (const address& addr, const bytes32& key) noexcept override
345371 {
346372 auto & value = accounts[addr].storage [key];
0 commit comments