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

Update EIP-7702: Prohibit nonce-changing opcodes #8538

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Amxx
Copy link
Contributor

@Amxx Amxx commented May 8, 2024

Rational for this change is explained in the PR, but might deserve some discussion. All these are a transposition of a discussion that already happened on EIP-5806 (alghouth without all the attention/participation that EIP-7702 is getting today)

Restricting nonce-changing operation

  • Lets say Alice has an EOA, and gave a signature so that Bob (or anyone) can temporarily place code at Alice's EOA's address.
  • Lets say Alice submits a "normal" transaction, with the correct nonce
  • Lets say before Alice transaction is mined, Bob (or anyone) uses Alice signature, invokes the code at under Alice's EOA's address, and execute any of these opcodes

Then Alice's nonce would increase, and the "normal" transaction would no longer be valid. This could DoS Alice's ability to use her EOA. It would also mess up with the mempool. Therefore, I strongly believe that these opcode MUST be restrited.

Restricting SSTORE

EDIT: The SSTORE part is the subject of #8539, no longer in this PR.

I understand people want to use SSTORE. I'm one of them, and I was very reluctant to add this restriction to EIP-5806. However, there is an invariant formulated somewhere (maybe @gballet can find the refenrence) that accounts without code SHOULD NOT have storage slot set. I believe this has to do with the transition to Verkle, or with safety assumption if permanent code is ever placed at this address. This restriction was recognised during the AA breakout session n°2.

I guess the proposed behavior is similar to what happens today if you use SSTORE in a contract that is selfdestructed within its construction transaction.

If you need persistent storage, you can use a third party contract that holds it for you

@Amxx Amxx requested a review from eth-bot as a code owner May 8, 2024 23:54
@github-actions github-actions bot added c-update Modifies an existing proposal s-draft This EIP is a Draft t-core labels May 8, 2024
@eth-bot
Copy link
Collaborator

eth-bot commented May 8, 2024

File EIPS/eip-7702.md

Requires 1 more reviewers from @adietrichs, @lightclient, @SamWilsn, @vbuterin

@eth-bot eth-bot added the a-review Waiting on author to review label May 8, 2024
@eth-bot eth-bot changed the title EIP-7702: Add opcode restrictions Update EIP-7702: Add opcode restrictions May 8, 2024
EIPS/eip-7702.md Outdated Show resolved Hide resolved
@@ -57,7 +57,7 @@ At the start of executing the transaction, for each `[contract_code, y_parity, r
2. Verify that the contract code of `signer` is empty.
3. Set the contract code of `signer` to `contract_code`.

At the end of the transaction, set the `contract_code` of each `signer` back to empty.
At the end of the transaction, set the `contract_code` of each `signer` back to empty. Any storage set for the `signer` must also be cleared.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say not cleared, but prevent SSTORE in the first place. Otherwise it might have unintended consequences to code that assumes the SSTORE was not implicitly a TSTORE. See my Safe example in the EM thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I originally proposed, both in EIP-5806 and here.

I see that #8539 is specifying that part, so I'll change this PR to be only about create/create2/selfdestruct

@Amxx Amxx changed the title Update EIP-7702: Add opcode restrictions Update EIP-7702: Prohibit nonce-changing opcodes May 9, 2024
@AmadiMichael
Copy link

Resharing my comment from the 7702 eip...

Not so sure about the invariant because a contract that sets storage at initialization but also returns 0 bytes at initialization has no bytecode but has > 0 storage slots set.

E.g

PUSH1 0x01
PUSH0
SSTORE

PUSH0
PUSH0
RETURN

Returns no runtime code but definitely has something at storage slot 0 which if read via an rpc returns 0x01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-review Waiting on author to review c-update Modifies an existing proposal s-draft This EIP is a Draft t-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants