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

ethclient: Fix eth_getBlockReceipts call when using block numbers or labels #28358

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

ajsutton
Copy link
Contributor

The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.

The incorrect encoding was introduced in #28087 when switching from the working but non-standard object encoding (e.g. {"blockNumber":"0x7fffffffffffffff"}) that comes from JSON serialising BlockNumberOrHash to using String() to return a single value. With this implementation of String() it matches the execution-apis spec for block hash, block number and block labels.

…labels

The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

Thank you!

rpc/types_test.go Outdated Show resolved Hide resolved
rpc/types_test.go Outdated Show resolved Hide resolved
rpc/types_test.go Outdated Show resolved Hide resolved
rpc/types_test.go Outdated Show resolved Hide resolved
rpc/types_test.go Outdated Show resolved Hide resolved
@ajsutton
Copy link
Contributor Author

Happy to apply those changes to the test once the run of morning meetings is over, but worth noting that I just copied the test above it so it currently matches the style of testing used through that file. Do you want to make these style changes to all tests in the file while I'm at it?

@ajsutton
Copy link
Contributor Author

@holiman Updated just the new test for now as suggested and left the others. Happy to rework them to the same style if you'd like though but feels out of scope of this PR.

@ajsutton
Copy link
Contributor Author

Looks like CI failed because the VisualStudio run hit the 60 minute time out.

@ajsutton ajsutton requested a review from holiman October 18, 2023 21:57
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Thanks @ajsutton, LGTM!

@holiman holiman added this to the 1.13.5 milestone Oct 25, 2023
@holiman holiman merged commit d8c6ae0 into ethereum:master Oct 25, 2023
1 of 2 checks passed
@ajsutton ajsutton deleted the getBlockReceipts branch October 26, 2023 04:16
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
…thereum#28358)

The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
sduchesneau pushed a commit to streamingfast/go-ethereum that referenced this pull request Dec 19, 2023
…thereum#28358)

Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
marun added a commit to ava-labs/coreth that referenced this pull request Dec 19, 2023
darioush pushed a commit to ava-labs/coreth that referenced this pull request Dec 20, 2023
* Copy ethereum/go-ethereum#27702

* Fix TestRPCGetBlockReceipts

* Get ethclient compiling

* Copy ethereum/go-ethereum#28087

* Copy ethereum/go-ethereum#28358
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this pull request Jan 31, 2024
…thereum#28358)

The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
This pull request was closed.
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.

4 participants