Repository navigation
net: decode each parent once per block proposal check #961
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
Merged
reardencode
merged 2 commits into
reardencode:master
from
average-gary:net/proposal-parent-cache
Oct 8, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Changed | ||
|
|
||
| - **A block proposal decodes each confirmed parent once.** `getblocktemplate` | ||
| proposal mode resolves a fan-out parent's fk once and decodes its packed | ||
| outputs once per check, not once per spending input. |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] The previous note is not fixed.
Query::tx_fk_by_txidandget_tx_by_txidsharelookup_tx_fk→Store::get_fk_by_txid(TipThenAny, so an archive parent is not dropped), but that is not a head probe.resolve_txidcallsTxTable::get_all_by_txid, which on a body-txid hit callsTxTable::get(decode_packed_tx_with_spender_rels_secretmaterializes every output, thengetdiscards them).chain_tx_outputsthen callsget_tx_meta_and_outputsand decodes the same body again. The per-input cache is real (that second decode runs once per distinct parent, spentness is still checked before the map, a failed fill is not inserted because?runs beforeVacant::insert, a vout past the end isNone, and same-block parents still hitcreatedfirst), so this is two packed decodes per parent rather than two per input.sample_reset_tx_getsonly increments inStore::get_tx, which this path does not call, socheck_block_proposal_decodes_each_parent_oncestays green attx_gets == 0while the resolve decode still happens. Mining andassemble_block_to_scriptare outside the sample window; the hole is the counter, not the reset order. The fee assert matches the inputs (1000 * (1..=50)=1_275_000). The RAM note and the doc on this function ("one head resolve, one packed outs decode") describe the path that was intended, not the oneget_fk_by_txidimplements. Its own comment says "without full body decode"; the batch resolver (get_fk_by_txid_batch_mode→resolve_identity_core) is the one that stops attxid.bodyand still prefers a connected fk.Suggestion: Resolve the fk the way
get_fk_by_txid_batch_mode(..., TipThenAny)already does (probe +txid.body+ height fence, noTxTable::get). Do not switch toprobe_body_match_fkalone; that returns the newest hit and can miss the connected row TipThenAny keeps. Point the journey at a counter that includes that decode, or thetx_gets == 0assert will keep passing while the parent is still decoded twice.