Skip to content

Commit

Permalink
Fix calldata handling during creation in EVMHost.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekpyron committed Apr 18, 2023
1 parent 02e936a commit bb21d6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/EVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions test/libsolidity/semanticTests/various/create_calldata.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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;
}
}
// ----
// constructor(): 42 ->
// gas irOptimized: 147187
// gas legacy: 176782
// gas legacyOptimized: 139518
// s() -> 0x20, 0

0 comments on commit bb21d6c

Please sign in to comment.