Skip to content

Contract code reset in verkle tree #31559

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

Open
rjl493456442 opened this issue Apr 4, 2025 · 1 comment
Open

Contract code reset in verkle tree #31559

rjl493456442 opened this issue Apr 4, 2025 · 1 comment

Comments

@rjl493456442
Copy link
Member

Before EIP-7702, contract code could not be reset and could only be deleted when the account was destructed. This behavior has changed with EIP-7702.

In a Merkle tree, contract code is not stored directly in the trie; instead, only the code hash is maintained in the account object. As a result, resetting contract code does not cause any issues.

In a Verkle tree, however, the contract code itself is stored directly within the trie, making the semantics less clear:

  • If the contract code is unset, all leftover code chunks should be removed;
  • If new contract code is added, the corresponding code chunk should be inserted;
  • If contract code were to be updated with a different size (currently not possible),
    • part of the code should be overwritten;
    • part of the code should be removed;
@gballet
Copy link
Member

gballet commented Apr 10, 2025

There are indeed some issues with this, owing to the fact deletions are hard to do with verkle trees.

There are two ways to solve this problem that I can see:

  1. overwrite the code with 0s, as happens with deletions
  2. leave it as-is, since the code size will be set to 0 and the code hash to empty.

They both have the drawback, however, that the chunked code (or zeros) needs to be kept in the tree for future updates (i.e. we can't optimize by saying "well, the code is read-only so once it's committed to in the group's commitment, we can drop the code chunks from the db").

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

No branches or pull requests

2 participants