New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent overwriting contracts #684

Open
vbuterin opened this Issue Aug 11, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@vbuterin
Collaborator

vbuterin commented Aug 11, 2017

Specification

If a contract creation is attempted, due to either a creation transaction or the CREATE (or future CREATE2) opcode, and the destination address already has either nonzero nonce, or nonempty code, then the creation throws immediately, with exactly the same behavior as would arise if the first byte in the init code were an invalid opcode. This applies retroactively starting from genesis.

Rationale

This is the most correct approach for handling the case where a contract is created in a slot where a contract already exists, as the current behavior of overwriting contract code is highly unintuitive and dangerous.

Currently this is not an issue because there is no way to create a contract with the same address twice without spending >2^80 computational effort to find an address collision, but with #86 this will change. Hence it is important to have correct behavior for this situation in the long term. This can be safely applied retroactively for simplicity, because currently creating a contract with the same address twice is computationally infeasible.

@axic

This comment has been minimized.

Show comment
Hide comment
@axic

axic Aug 11, 2017

Member

Resolves #83.

Member

axic commented Aug 11, 2017

Resolves #83.

@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Aug 25, 2017

Member

Possible corner case and request for discussion ethereum/pm#21 (comment). Bug in my code, disregard.

Member

karalabe commented Aug 25, 2017

Possible corner case and request for discussion ethereum/pm#21 (comment). Bug in my code, disregard.

@rtkaczyk

This comment has been minimized.

Show comment
Hide comment
@rtkaczyk

rtkaczyk Oct 9, 2017

Perhaps it is not a question of great practical importance, but how does this relate to EIP-161? I.e. what if under the newly created address there exists an empty account (according to EIP-161 rules). Should it still result in an error, or should the empty account be considered inexistent (hence no conflict) and contract creation should proceed normally?

destination address already has either nonzero nonce, or nonempty code

Nevermind, this wording actually answers my question

rtkaczyk commented Oct 9, 2017

Perhaps it is not a question of great practical importance, but how does this relate to EIP-161? I.e. what if under the newly created address there exists an empty account (according to EIP-161 rules). Should it still result in an error, or should the empty account be considered inexistent (hence no conflict) and contract creation should proceed normally?

destination address already has either nonzero nonce, or nonempty code

Nevermind, this wording actually answers my question

germsvel added a commit to poanetwork/mana that referenced this issue Aug 15, 2018

Prevent collisions on account creation
There was an issue with contract creation that would overwrite
contracts. The solution is to check for a positive nonce or nonempty
code hash in an account. If that's the case, the contract creation needs
to fail instead of overwriting the account.

For more information see ethereum/EIPs#684

germsvel added a commit to poanetwork/mana that referenced this issue Aug 15, 2018

Prevent collisions on account creation
There was an issue with contract creation that could overwrite
contracts. The solution is to check for a positive nonce or nonempty
code hash in the account that is about to be created. If that's the
case, the contract creation needs to fail instead of overwriting the
account.

For more information see ethereum/EIPs#684

ayrat555 added a commit to poanetwork/mana that referenced this issue Aug 16, 2018

Prevent collisions on account creation (#358)
There was an issue with contract creation that could overwrite
contracts. The solution is to check for a positive nonce or nonempty
code hash in the account that is about to be created. If that's the
case, the contract creation needs to fail instead of overwriting the
account.

For more information see ethereum/EIPs#684

@holiman holiman referenced this issue Sep 5, 2018

Merged

Update ethereum/tests fixtures #1224

3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment