Skip to content

use uint256 for keys to disallow 0x empty #641

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

Closed
wants to merge 1 commit into from

Conversation

macfarla
Copy link
Contributor

@macfarla macfarla commented Mar 28, 2025

the type currently used for storage slot key and storage proof key bytesMax32 allows 0x empty values. uint256 seems a better option for keys since the empty 0x value should never be used.

Added some clarification to make this less confusing -

The current type used for storage slot key from the schema is:

bytesMax32:
  title: 32 hex encoded bytes
  type: string
  pattern: ^0x[0-9a-f]{0,64}$

From the existing types, this seemed like the one that matches the desired behaviour -

uint256:
  title: hex encoded 256 bit unsigned integer
  type: string
  pattern: ^0x(0|[1-9a-f][0-9a-f]{0,63})$

@macfarla macfarla marked this pull request as draft March 28, 2025 23:13
@macfarla
Copy link
Contributor Author

storage slot key

$ref: '#/components/schemas/bytesMax32'

there's a comment here which indicates some history that may add context "this used to require strict uint256, but usage of leading zero is commonplace, so we can't disallow it."

@jflo
Copy link

jflo commented Mar 31, 2025

This was discussed on RPC call #3 and no major objections were found. Will continue to solicit feedback.

@macfarla
Copy link
Contributor Author

macfarla commented Apr 3, 2025

Added some clarification in the description based on discussion in the RPC standards call. If a new type makes more sense than using the existing hex encoded uint256 definition that's also fine.

@macfarla
Copy link
Contributor Author

macfarla commented Apr 4, 2025

further investigation reveals that

  • 0x empty is used for the storage root, so it does have meaning in this context to have 0x as a key
  • usage of leading zeros is commonplace for storage slots

closing this PR.

however - maybe something of this context should be added to the spec itself for clarification
28e82b4

Note the slot parameter of eth_getStorageAt had to be relaxed to bytesMax32, since the
new uint256 pattern disallows leading zero, but usage of leading zero is commonplace
for storage slots.

@macfarla macfarla closed this Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants