Skip to content

feature: use eth_getBlockReceipts instead of fetching receipts individually#131

Open
luborepka wants to merge 3 commits intostreamingfast:developfrom
luborepka:feature/use-block-receipts
Open

feature: use eth_getBlockReceipts instead of fetching receipts individually#131
luborepka wants to merge 3 commits intostreamingfast:developfrom
luborepka:feature/use-block-receipts

Conversation

@luborepka
Copy link

@luborepka luborepka commented Mar 11, 2026

  • Use eth_getBlockReceipts to fetch all transaction receipts in a single RPC call instead of one call per transaction
  • Automatically falls back to individual eth_getTransactionReceipt calls if the node doesn't support the batch method
  • Requires eth-go PR - Merged

Closes: #130

@luborepka luborepka changed the title feature: use block receipts feature: use eth_getBlockReceipts instead of fetching receipts individually Mar 11, 2026
switch method {
case "eth_getBlockReceipts":
// Simulate unsupported method
w.Write([]byte(`{"jsonrpc":"2.0","id":"0x1","error":{"code":-32601,"message":"method not found"}}`))
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you validated against some providers? I have the feeling this might need to be adaptative. See other comment about conditional fallback.

Comment on lines +152 to +155
out, err = fetchBlockReceipts(ctx, block, client, allowEmptyReceiptsOnBlock0)
if err == nil {
return out, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like that we conditionally decide to fallback to individual fetch only on method not found errors. In all other cases, the error should be returned directly.

Ideally also, we would have a form of caching of the fact that this client don't support it and on next invocation would straight skip to individual. I'm fine with a FIXME for now and merge without this optional feature.

return nil, fmt.Errorf("fetching block receipts: %w", err)
}

out = make(map[string]*rpc.TransactionReceipt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pre-allocated the array since we know the size

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.

Use eth_getBlockReceipts instead of fetching transaction receipts individually in blockfetcher

2 participants