You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Geth version: Version: 1.8.17-stable
OS & Version: OSX
Expected behaviour
CREATE2 reverts tx if a contract is tried to be deployed twice at the same address
Actual behaviour
Does not revert. Uses more gas than in the initial creation. For some reason does not alter the storage even though there is a check to see if the storage is altered. Does return address 0x0 on the second create.
Steps to reproduce the behaviour
Deploy the TestMe contract
Call Deploy with any seed and set argument to any value.
Verify that the contract A is created at the address which can be found in Last (CurrVal should be same as argument)
Now redeploy TestMe: use the same seed but a different argument
The code now re-runs, does not revert. Last is now 0x0. The CurrVal in A does not change.
contractTestMe{
addresspublic Last;
uintpublic Argument;
function Deploy(uintseed, uintarg) publicreturns (address) {
Argument = arg;
// ctr is the actual runtime bytecode of contract A // compiled with 0.5.0-nightly.2018.10.9+commit.4ab2e03b.Emscripten.clang in remixbytesmemory ctr =hex'608060405234801561001057600080fd5b50600033905080600160a060020a0316631543b3136040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801561006b57600080fd5b505afa15801561007f573d6000803e3d6000fd5b505050506040513d602081101561009557600080fd5b5051600055506099806100a96000396000f3fe608060405260043610603e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f1aab64181146043575b600080fd5b348015604e57600080fd5b5060556067565b60408051918252519081900360200190f35b6000548156fea165627a7a723058205665d5eb639b7be5314a60862785a6b2285a4de4f2a382d6f5aa4ddf8917e9570029';
address a;
assembly{
let pointer := ctr
let len :=mload(pointer)
let start :=add(pointer, 0x20)
a :=create2(0, start, len, seed)
}
Last = a;
return (a);
}
}
contractA{
uintpublic CurrVal;
constructor() public {
TestMe target =TestMe(msg.sender);
CurrVal = target.Argument();
}
}
Note: you cannot pass "argument" in the constructor because this changes the init_code.
By EIP 1014 create2 at an address which has already code OR a nonce it should revert.
The text was updated successfully, but these errors were encountered:
Specifically, if nonce or code is nonzero, then the create-operation fails.
If a create-operation succeeds, the new address will be returned on the top of the stack. If you get a 0 on the top of the stack, the create has failed. Which seems to be exactly what happened: " Last is now 0x0."
System information
Geth version:
Version: 1.8.17-stable
OS & Version: OSX
Expected behaviour
CREATE2 reverts tx if a contract is tried to be deployed twice at the same address
Actual behaviour
Does not revert. Uses more gas than in the initial creation. For some reason does not alter the storage even though there is a check to see if the storage is altered. Does return address 0x0 on the second create.
Steps to reproduce the behaviour
Note: you cannot pass "argument" in the constructor because this changes the init_code.
By EIP 1014 create2 at an address which has already code OR a nonce it should revert.
The text was updated successfully, but these errors were encountered: