Fix calldata handling during creation in EVMHost.

This commit is contained in:
Daniel Kirchner 2023-04-18 12:39:24 +02:00
parent 02e936ad82
commit 421738b50d
2 changed files with 19 additions and 0 deletions

View File

@ -366,6 +366,11 @@ evmc::Result EVMHost::call(evmc_message const& _message) noexcept
access_account(tx_context.block_coinbase);
}
if (message.kind == EVMC_CREATE || message.kind == EVMC_CREATE2)
{
message.input_data = nullptr;
message.input_size = 0;
}
evmc::Result result = m_vm.execute(*this, m_evmRevision, message, code.data(), code.size());
if (message.kind == EVMC_CREATE || message.kind == EVMC_CREATE2)

View File

@ -0,0 +1,14 @@
contract C {
bytes public s;
constructor(uint256 x) {
// Due to a bug in EVMHost, msg.data used to contain initcode and constructor arguments.
s = msg.data;
assert(msg.data.length == 0);
}
}
// ----
// constructor(): 42 ->
// gas irOptimized: 147541
// gas legacy: 177488
// gas legacyOptimized: 140089
// s() -> 0x20, 0