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

fixes #495: param and return types for eth_getStorageAt #513

Merged
merged 5 commits into from
Feb 13, 2025

Conversation

eshaan7
Copy link
Contributor

@eshaan7 eshaan7 commented Feb 13, 2025

Closes #495.

Changes

  • Change slot param type to be U256 instead of B256.
  • Change return value of eth_getStorageAt to be B256 instead of U256.

@eshaan7 eshaan7 changed the title fix: param and return types for eth_getStorageAt fixes #495: param and return types for eth_getStorageAt Feb 13, 2025
Copy link
Collaborator

@ncitron ncitron left a comment

Choose a reason for hiding this comment

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

I think it would probably be best to try and mirror the interface of alloy here, which is to make the keys and values both U256. By switching to U256 for the key this should resolve the issue, as U256 is not required to be padded to 32 bytes when deserialized.

As for the return type, alloy uses U256, but this does mean the rpc return type may not be padded with zeros and playing with alchemy it seems responses are usually padded, so maybe the B256 makes more sense, especially if the spec demands padding.

But definitely want to go from JsonStorageKey -> U256 at a minimum, as it is deserialized the same way (I think) and is the more commonly used type.

@eshaan7
Copy link
Contributor Author

eshaan7 commented Feb 13, 2025

As for the return type, alloy uses U256, but this does mean the rpc return type may not be padded with zeros and playing with alchemy it seems responses are usually padded, so maybe the B256 makes more sense, especially if the spec demands padding.

Yes, I tried with both Geth and Reth and they are padding the return value so that's why I went with B256.

But definitely want to go from JsonStorageKey -> U256 at a minimum, as it is deserialized the same way (I think) and is the more commonly used type.

That makes sense. Will do a lil more manual testing to verify the deserialization is as expected.

@eshaan7
Copy link
Contributor Author

eshaan7 commented Feb 13, 2025

image

@ncitron -- Made the slot param take U256. PTAL.

Copy link
Collaborator

@ncitron ncitron left a comment

Choose a reason for hiding this comment

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

LGTM!

@ncitron ncitron merged commit 98f85ae into a16z:master Feb 13, 2025
4 of 6 checks passed
@eshaan7 eshaan7 deleted the fix/gh-495 branch February 15, 2025 08:55
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.

fix: fetching storage slot with less than 32 byte length
2 participants