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

feat: implement eth_getBlockReceipts #423

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

eshaan7
Copy link
Contributor

@eshaan7 eshaan7 commented Nov 7, 2024

Partially Closes: #200.
Related: #200 (comment)

@@ -197,6 +197,7 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {

let tx_hashes = block.transactions.hashes();

// TODO: replace this with rpc.get_block_receipts?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ncitron; thoughts on this?

Using getBlockReceipts instead of getTransactionReceipt would significantly reduce the number of HTTP calls made to the RPC.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is getBlockReceipts widely supported (at least by most the major clients and rpc providers)? If so, we should be using it instead.

Copy link
Contributor Author

@eshaan7 eshaan7 Nov 10, 2024

Choose a reason for hiding this comment

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

ethereum/execution-apis#438

erigon, geth, nethermind, besu, nimbus, reth,

infura, quicknode, alchemy, chainstack

yep, seems to be widely supported.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah in that case lets do it. Thanks for finding this optimization!

Copy link
Contributor Author

@eshaan7 eshaan7 Nov 11, 2024

Choose a reason for hiding this comment

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

Ah. So there is one peculiar issue:

Some RPC providers return different response in eth_getTransactionReceipt vs eth_getBlockReceipts. This is primarily due to ethereum/execution-apis#295 not being finalized. For example, https://ethereum-rpc.publicnode.com includes the logs[].blockTimestamp field in eth_getBlockReceipts but not in eth_getTransactionReceipt. This makes the N::receipt_contains equality check break for such providers.

A way to curb this is by comparing encoded receipt which I've added as a fallback with a note in comment. LMK if you have a better approach.

@eshaan7
Copy link
Contributor Author

eshaan7 commented Nov 7, 2024

The rpc_equivalence tests are passing for me locally but failing in GitHub actions. Not sure why.

image

@ncitron
Copy link
Collaborator

ncitron commented Nov 8, 2024

Don't worry about those tests. They are failing in CI because CI runs triggered from forks don't have access to gh secrets (where we keep our alchemy api key) for security reasons.

@@ -337,6 +337,7 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {
.collect::<Result<HashSet<_>, _>>()?;

// Collect all (proven) tx receipts as a map of tx hash to receipt
// TODO: use get_block_receipts instead to reduce the number of RPC calls?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can significantly optimize verify_logs too. Will create a separate issue for it once this PR is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue: #438

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! Lets do the optimization on getLogs too when you get a chance.

@ncitron ncitron merged commit c34324c into a16z:master Nov 20, 2024
3 of 5 checks passed
@eshaan7 eshaan7 deleted the add-eth_getBlockReceipts branch November 20, 2024 12:16
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.

Missing RPC methods
2 participants