Repository navigation
db/snapshotsync/freezeblocks, rpc: hash eth_getLogs receipt txns by txNum in block files - #25283
Merged
Merged
Conversation
…xNum in block files TxnHashByIdxInBlock takes the txNum of the transaction. Block files use the canonical txNum as transaction id, so for a frozen block the transaction is read by txNum without decoding the block body, into a pooled buffer. txnRlpByID returns nil for an empty word (system transaction without data) instead of panicking.
AskAlexSharov
approved these changes
Oct 24, 2026
lupin012
marked this pull request as ready for review
October 24, 2026 21:00
lupin012
requested review from
mh0lt,
sudeepdino008 and
yperbasis
as code owners
October 24, 2026 21:00
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 25, 2026
…sh-txnum # Conflicts: # execution/blockreplay/memreader.go
lupin012
enabled auto-merge
October 25, 2026 21:09
lupin012
disabled auto-merge
October 25, 2026 21:46
lupin012
enabled auto-merge
October 25, 2026 21:46
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 25, 2026
AskAlexSharov
enabled auto-merge
October 26, 2026 04:26
Collaborator
|
Looks good. Ship. |
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a receipt is not in the receipt LRU,
eth_getLogsreads it withPersistedReceipt, which first computes the transaction hash withTxnHashByIdxInBlock(the stored receipt has no hash; it only fillstransactionHash). For a block in files this:BaseTxnID, once for every transaction of the block;Getterand a new buffer for the transaction RLP, then hashes it.With the default receipt cache and wide filters (many addresses, many logs per request)
TxnHashByIdxInBlockwas 39-41% of the process CPU and 34% of the bytes allocated by the node; the body part alone (BodyForTxnFromSnapshot) was 9.4% of the CPU.Change
TxnHashByIdxInBlocktakes thetxNumof the transaction (the only caller,PersistedReceipt, already has it).DumpBodieswritesbody.BaseTxnIDas the canonical txNum, seeblock_snapshots.go), so for a frozen block the transaction is read from the transactions file bytxNum, without reading the body. The read uses a pooled buffer.txNumis inside the id range of the transactions file; otherwise the previous code runs unchanged. Blocks still in the DB are not affected.txnRlpByIDreturns nil for an empty word instead of panicking: system transactions without data are stored as empty words, and the fast path no longer has the body check in front of it.Pure performance change, no behaviour change. TDD note: the existing frozen-blocks test now checks the hash of every block of a frozen segment and of the DB tail against the block's transaction (a mutation of
txNummakes it fail), and a new case covers the empty-word panic found during review (red before the guard, green after).Results
Mainnet node (
--prune.mode=minimal), default receipt cache,rpc_perfwithout HTTP compression, patterns of 20000 requests over the last 3000 blocks (100-block ranges), rounds base / opt / opt / base, median of the two rounds. 1200 sampled responses are byte-identical between base and this branch.At 1000 qps:
At 2000 qps the single-address pattern gets -21% CPU/req and -22..-24% p95/p99. CPU profile:
BodyForTxnFromSnapshot9.4% -> 0%; allocations:TxnHashByIdxInBlock34% -> 7% of the allocated bytes.The two rounds of each variant agree closely (e.g. 16 addresses: base 9.12 / 9.00 ms/req, opt 7.58 / 7.45 ms/req; p95 base 46.5 / 46.6 ms, opt 38.7 / 38.1 ms).