mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
EVMHost: mark precompiles as existing accounts in the constructor
This commit is contained in:
parent
578d69983d
commit
2a62425f0a
@ -86,6 +86,20 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
|
||||
assertThrow(false, Exception, "Berlin is not supported yet.");
|
||||
else //if (_evmVersion == langutil::EVMVersion::petersburg())
|
||||
m_evmRevision = EVMC_PETERSBURG;
|
||||
|
||||
// Mark all precompiled contracts as existing. Existing here means to have a balance (as per EIP-161).
|
||||
// NOTE: keep this in sync with `EVMHost::call` below.
|
||||
//
|
||||
// A lot of precompile addresses had a balance before they became valid addresses for precompiles.
|
||||
// For example all the precompile addresses allocated in Byzantium had a 1 wei balance sent to them
|
||||
// roughly 22 days before the update went live.
|
||||
for (unsigned precompiledAddress = 1; precompiledAddress <= 8; precompiledAddress++)
|
||||
{
|
||||
evmc::address address{};
|
||||
address.bytes[19] = precompiledAddress;
|
||||
// 1wei
|
||||
m_state.accounts[address].balance.bytes[31] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
evmc_storage_status EVMHost::set_storage(const evmc::address& _addr, const evmc::bytes32& _key, const evmc::bytes32& _value) noexcept
|
||||
|
@ -70,10 +70,6 @@ public:
|
||||
|
||||
Account* account(evmc::address const& _address)
|
||||
{
|
||||
// Make all precompiled contracts exist.
|
||||
// Be future-proof and consider everything below 1024 as precompiled contract.
|
||||
if (u160(convertFromEVMC(_address)) < 1024)
|
||||
m_state.accounts[_address];
|
||||
auto it = m_state.accounts.find(_address);
|
||||
return it == m_state.accounts.end() ? nullptr : &it->second;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user