Skip to content
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

Closed
vbuterin opened this issue Aug 11, 2017 · 6 comments
Closed

Prevent overwriting contracts #684

vbuterin opened this issue Aug 11, 2017 · 6 comments
Labels

Comments

@vbuterin
Copy link
Contributor

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
Copy link
Member

axic commented Aug 11, 2017

Resolves #83.

@karalabe
Copy link
Member

karalabe commented Aug 25, 2017

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

@rtkaczyk
Copy link

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 mana-ethereum/mana that referenced this issue Aug 15, 2018
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 mana-ethereum/mana that referenced this issue Aug 15, 2018
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 pushed a commit to mana-ethereum/mana that referenced this issue Aug 16, 2018
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
@ytrezq
Copy link

ytrezq commented Oct 4, 2019

Does this proposal means that if a ᴄʀᴇᴀᴛᴇ2 operations fails with the a stupid error like out of gas (because the creator forgot to include enough gas) that even in that case (no contract deployed) it’s impossible to rerun the same ᴄʀᴇᴀᴛᴇ2 operation (but with enough gas) ?

@github-actions
Copy link

github-actions bot commented Jan 2, 2022

There has been no activity on this issue for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the stale label Jan 2, 2022
@github-actions
Copy link

This issue was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@axic @karalabe @vbuterin @rtkaczyk @ytrezq and others