mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement create2 for evmhost.
This commit is contained in:
parent
0e3a2fec66
commit
679f729f2f
@ -172,6 +172,28 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
||||
message.destination = convertToEVMC(createAddress);
|
||||
code = evmc::bytes(message.input_data, message.input_data + message.input_size);
|
||||
}
|
||||
else if (message.kind == EVMC_CREATE2)
|
||||
{
|
||||
Address createAddress(keccak256(
|
||||
bytes(1, 0xff) +
|
||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
||||
keccak256(bytes(message.input_data, message.input_data + message.input_size)).asBytes()
|
||||
));
|
||||
message.destination = convertToEVMC(createAddress);
|
||||
if (accounts.count(message.destination) && (
|
||||
accounts[message.destination].nonce > 0 ||
|
||||
!accounts[message.destination].code.empty()
|
||||
))
|
||||
{
|
||||
evmc::result result({});
|
||||
result.status_code = EVMC_OUT_OF_GAS;
|
||||
accounts = stateBackup;
|
||||
return result;
|
||||
}
|
||||
|
||||
code = evmc::bytes(message.input_data, message.input_data + message.input_size);
|
||||
}
|
||||
else if (message.kind == EVMC_DELEGATECALL)
|
||||
{
|
||||
code = accounts[message.destination].code;
|
||||
@ -184,7 +206,6 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
||||
}
|
||||
else
|
||||
code = accounts[message.destination].code;
|
||||
//TODO CREATE2
|
||||
|
||||
auto& destination = accounts[message.destination];
|
||||
|
||||
@ -199,7 +220,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
||||
evmc::result result = m_vm.execute(*this, m_evmRevision, message, code.data(), code.size());
|
||||
m_currentAddress = currentAddress;
|
||||
|
||||
if (message.kind == EVMC_CREATE)
|
||||
if (message.kind == EVMC_CREATE || message.kind == EVMC_CREATE2)
|
||||
{
|
||||
result.gas_left -= evmasm::GasCosts::createDataGas * result.output_size;
|
||||
if (result.gas_left < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user