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

storage trie type should by Trie[Bytes32, U256] and not Trie[Bytes, U256] #1070

Closed
enitrat opened this issue Jan 6, 2025 · 1 comment
Closed
Labels
A-spec Area: specification C-bug Category: this is a bug, deviation, or other problem.

Comments

@enitrat
Copy link
Contributor

enitrat commented Jan 6, 2025

Metadata

  • Hardfork: hardfork-name

What was wrong?

The type used for the storage trie is Trie[Bytes, U256]. However the yellow paper specifies that

storageRoot: A 256-bit hash of the root node of a
Merkle Patricia tree that encodes the storage contents of the account (a mapping between 256-bit
integer values), encoded into the trie as a mapping
from the Keccak 256-bit hash of the 256-bit integer
keys to the RLP-encoded 256-bit integer values.
The hash is formally denoted σ[a]s.

The storage content is implemented as "(a mapping between 256-bit integer values)" - which means the proper key type should be Bytes32, and not Bytes, as the bit-length of the keys is always 256.

When popping the key from the stack in sload, we convert it to a byte32.

key = pop(evm.stack).to_be_bytes32()

Sources

Yellow Paper, page 4

@enitrat enitrat added A-spec Area: specification C-bug Category: this is a bug, deviation, or other problem. labels Jan 6, 2025
SamWilsn added a commit to SamWilsn/eth1.0-specs that referenced this issue Jan 25, 2025
SamWilsn added a commit to SamWilsn/eth1.0-specs that referenced this issue Jan 27, 2025
gurukamath added a commit that referenced this issue Jan 29, 2025
@gurukamath
Copy link
Collaborator

Closed with #1071 and #1096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-spec Area: specification C-bug Category: this is a bug, deviation, or other problem.
Projects
None yet
Development

No branches or pull requests

2 participants