Skip to content

Commit 3fcc150

Browse files
AlexRamRamHalosGhost
authored andcommitted
Fix in contract deployment
In evm_host::create(), the evmc::result return object must have the create_address member set to the new contract address (the VM does not set it) If left as 0x0, deployment of contracts by another contract (i.e. at depth>0) is likely to fail such as in UniswapV3Factory.createPool() Signed-off-by: Alexander Jung <[email protected]>
1 parent b69ab77 commit 3fcc150

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/3pc/agent/runners/evm/address.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ namespace cbdc::threepc::agent::runner {
3434
const evmc::bytes32& salt,
3535
const cbdc::hash_t& bytecode_hash)
3636
-> evmc::address {
37+
// Specs: https://eips.ethereum.org/EIPS/eip-1014
38+
3739
auto new_addr = evmc::address();
3840
auto buf = cbdc::buffer();
3941
static constexpr uint8_t contract_address2_preimage_prefix = 0xFF;

src/3pc/agent/runners/evm/host.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ namespace cbdc::threepc::agent::runner {
257257
auto res = execute(call_msg, msg.input_data, msg.input_size);
258258

259259
if(res.status_code == EVMC_SUCCESS) {
260+
// The VM does not populate res.create_address, and it must
261+
// set to the address of the new contract.
262+
// If left as 0x0, deployment of contracts by another contract
263+
// (i.e. depth>0) is likely to fail (e.g.
264+
// UniswapV3Factory.createPool())
265+
res.create_address = new_addr;
266+
260267
auto maybe_acc = get_account(new_addr, !m_is_readonly_run);
261268
if(!maybe_acc.has_value()) {
262269
maybe_acc = evm_account();

0 commit comments

Comments
 (0)