Skip to content

Conversation

omerfirmak
Copy link
Contributor

Towards #26974

Best reviewed commit by commit.

From my benchmarks, it seems that the dominant cost is still the DB reads. Sender derivation seems to be negligible.
Currently for a single receipt to be served we need to do multiple DB reads. If we are so concerned about the performance of this RPC, we should make the receipts self-contained so they don't need data from multiple queries to be stitched together to make a full receipt. This comes at the expense of slight increase in storage requirements but it might be acceptable given that EIP-4444 is in the works.

@omerfirmak omerfirmak force-pushed the get-receipt-by-hash branch from a25ac66 to 92ac972 Compare June 12, 2025 18:08
@rjl493456442 rjl493456442 self-assigned this Jun 13, 2025
@omerfirmak omerfirmak force-pushed the get-receipt-by-hash branch from 92ac972 to b6270a5 Compare June 13, 2025 07:48
@omerfirmak omerfirmak force-pushed the get-receipt-by-hash branch 3 times, most recently from e83328c to 5970887 Compare June 16, 2025 07:59
@omerfirmak
Copy link
Contributor Author

all done @fjl

rjl493456442
rjl493456442 previously approved these changes Jun 18, 2025
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.

SGTM

@omerfirmak
Copy link
Contributor Author

@rjl493456442, here are the benchmark numbers you asked for

GetTransactionReceipt                    GetTransaction=5.307098ms   HeaderByHash=1.130133ms  GetReceipts=6.795809ms  deriveAndMarshal="89.181µs"  HowOld=1,024,002
GetTransactionReceipt                    GetTransaction=3.39098ms    HeaderByHash=2.639094ms  GetReceipts=5.865259ms  deriveAndMarshal="96.673µs"  HowOld=1,034,242
GetTransactionReceipt                    GetTransaction=5.362379ms   HeaderByHash=5.684053ms  GetReceipts=8.684312ms  deriveAndMarshal="137.879µs" HowOld=1,044,482
GetTransactionReceipt                    GetTransaction=6.830262ms   HeaderByHash=1.291873ms  GetReceipts=5.993433ms  deriveAndMarshal="108.209µs" HowOld=1,054,722
GetTransactionReceipt                    GetTransaction=5.230193ms   HeaderByHash=3.07685ms   GetReceipts=5.278652ms  deriveAndMarshal="81.733µs"  HowOld=1,064,962
GetTransactionReceipt                    GetTransaction=7.390969ms   HeaderByHash=2.135011ms  GetReceipts=10.148381ms deriveAndMarshal="130.712µs" HowOld=1,075,202
GetTransactionReceipt                    GetTransaction=4.207496ms   HeaderByHash=2.921562ms  GetReceipts=8.163861ms  deriveAndMarshal="338.306µs" HowOld=1,085,442
GetTransactionReceipt                    GetTransaction=7.251558ms   HeaderByHash=1.318247ms  GetReceipts=11.235391ms deriveAndMarshal="101.144µs" HowOld=1,095,682
GetTransactionReceipt                    GetTransaction=8.71241ms    HeaderByHash=2.41199ms   GetReceipts=7.142382ms  deriveAndMarshal="97.244µs"  HowOld=1,105,922
GetTransactionReceipt                    GetTransaction=4.027002ms   HeaderByHash=1.706223ms  GetReceipts=7.321775ms  deriveAndMarshal="171.774µs" HowOld=1,116,162
GetTransactionReceipt                    GetTransaction=4.559297ms   HeaderByHash=2.330645ms  GetReceipts=8.024197ms  deriveAndMarshal="86.753µs"  HowOld=1,126,402
GetTransactionReceipt                    GetTransaction=3.925892ms   HeaderByHash=1.314483ms  GetReceipts=10.06001ms  deriveAndMarshal="182.867µs" HowOld=1,136,642
GetTransactionReceipt                    GetTransaction=11.206626ms  HeaderByHash=6.299174ms  GetReceipts=5.497019ms  deriveAndMarshal="84.116µs"  HowOld=1,146,882
GetTransactionReceipt                    GetTransaction=3.082548ms   HeaderByHash=1.013447ms  GetReceipts=7.851637ms  deriveAndMarshal="109.408µs" HowOld=1,157,122
GetTransactionReceipt                    GetTransaction=5.416056ms   HeaderByHash=2.209813ms  GetReceipts=8.388604ms  deriveAndMarshal="99.979µs"  HowOld=1,167,362

@omerfirmak omerfirmak force-pushed the get-receipt-by-hash branch 2 times, most recently from 9cab99c to 977bcf4 Compare June 19, 2025 14:27
@omerfirmak
Copy link
Contributor Author

squashed everything so I can rebase another PR on top of this.

this is an attempt at reducing wasted effort in GetReceiptByHash by
not decoding or deriving unrelated receipts
rjl493456442
rjl493456442 previously approved these changes Jun 23, 2025
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.

LGTM

@rjl493456442 rjl493456442 added this to the 1.15.12 milestone Jun 23, 2025
@rjl493456442
Copy link
Member

Btw, I just realized that our RPC (e.g. eth_getTransactionReceipt) doesn't serve receipt on side chain.

It's aligned with the old implementation though, not sure if we should fix it or now.

for indx, receipt := range receipts {
receiptByLookup, err := chain.GetCanonicalReceipt(body.Transactions[indx], receipt.BlockHash,
receipt.BlockNumber.Uint64(), uint64(indx))
assert.NoError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

removing this would get rid of the new assert dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not an entirely new dependency since it is being used by other packages, so I thought it would be fine. But we could remove if its not something we want.

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

LGTM

@omerfirmak
Copy link
Contributor Author

omerfirmak commented Jun 24, 2025

Compared to the latest release, this PR achieves around 1.5x speed up.
For the same 400 RPC requests with empty caches v1.15.11 took 10.943084651s while this PR took 7.04103658s

@fjl fjl modified the milestones: 1.16.0, 1.16.1 Jun 24, 2025
@fjl fjl removed the status:triage label Jun 24, 2025
@rjl493456442 rjl493456442 merged commit f70aaa8 into ethereum:master Jul 1, 2025
3 of 4 checks passed
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 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.

4 participants