refactor(rpc): trace block reads - #3952
Conversation
Reviewing PR #3952
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3952 +/- ##
==========================================
- Coverage 74.75% 74.53% -0.22%
==========================================
Files 461 461
Lines 40928 40959 +31
==========================================
- Hits 30594 30528 -66
- Misses 8230 8324 +94
- Partials 2104 2107 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…pt handlers and iterators in v9/v10
5867d17 to
aecd3bd
Compare
|
Claude finished @EgeCaner's task in 10m 4s —— View job Review of PR #3952
The refactor itself is sound — pinning the block id to a header up front genuinely closes the Important
Nit
Checked and fine
|
| // it together with its index. Returns ErrTransactionNotFound when missing. | ||
| func (p *PreConfirmed) TransactionByHash(hash *felt.Felt) (core.Transaction, uint, error) { | ||
| func (p *PreConfirmed) TransactionByHash( | ||
| hash *felt.TransactionHash, |
There was a problem hiding this comment.
Thank you for detail attention and updating the types 🙏
|
Claude finished @EgeCaner's task in 5m 59s —— View job Re-review of PR #3952
All three findings from the previous round are addressed, and the accessor fix ended up better than the status quo on Previous findings — resolved
Nits (new)
Also checked, no issue
|
|
Claude finished @EgeCaner's task in 2m 54s —— View job Re-review of PR #3952
One new commit since the last round: Verified
The serializer is on the sole decode path for State of the earlier findings
Still open and non-blocking: the guard branch itself has no test in either version — a subtest where
|

What
Reworks the RPC trace path (v9 + v10) so tracing a finalised block reads only what it
actually needs, and so a
latest/l1_acceptedtag cannot resolve to two differentblocks within one call.
Receipts off the hot path
traceFinalisedBlockused to read the whole block — header, transactions andreceipts — then hand all of it to the VM path, which only ever uses the transactions.
Receipts are needed solely by the feeder-gateway branch, which exists for
Starknet ≤ 0.13.2 blocks and never runs on a modern chain. That branch is now its own
function (
fetchTracesFromFeederGateway) and is the only caller that reads receipts,via a new paired accessor:
core.GetTransactionsAndReceiptsByBlockNumber/Blockchain.TransactionsAndReceiptsByBlockNumber— both live under the same key, so the legacy path still pays one block read, not two.
TransactionsByBlockNumberand decodes no receipts at all.So the common case drops a full receipt-slice CBOR decode per traced block (plus the
header decode, since the header is now passed down rather than re-read).
Block ids pinned once
TraceBlockTransactionsresolves the block id to a header up front and passes thatheader down; every subsequent read goes by
header.Number. Previously the tag wasre-resolved per read, so a block stored between two reads could make one call mix data
from two different blocks. Same treatment for the pre-confirmed branch.
Cache moved up, keyed on
felt.FeltThe trace cache is now checked and populated in one place (
traceFinalisedBlock, rightafter the header read) instead of inside each branch. The
rpccore.TraceCacheKeywrapper struct is gone; the cache is keyed directly on
felt.Felt.Feeder-gateway blocks are cached with an empty (non-nil)
InitialReads, since thegateway never supplies them — an empty set is the final answer for those blocks, so a
later call that does pass the flag is still served from the cache.
Error classification
Failed reads on the trace path reported "not found" unconditionally, hiding real DB and
decode failures behind
ErrTxnHashNotFound/ErrBlockNotFound. Header, pre-confirmedchain, transaction, and parent-state reads now return not-found only for
db.ErrKeyNotFound(pluspending.ErrPreConfirmedNotFoundfor the pre-confirmedchain) and surface anything else as
ErrInternal, matching whatstateByBlockIDalready did.
Notes
felt.Feltcache key.x-execution-stepsis still absent on cache hits (pre-existing; noted separately).Call/SimulateTransactionsstill resolve the block id twice (state, then header)and can straddle a store — same class of race, left for a follow-up.