Merge pull request #14138 from ethereum/evmHostCalldataFix

Fix calldata handling during creation in EVMHost.
This commit is contained in:
Daniel 2023-04-18 13:47:07 +02:00 committed by GitHub
commit 3f04f00bdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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