audit: reaudit low fixes (tx.head RAM gate, in-flight bytes, pending FIFO, cut-through batch, tapscript weight) - #303
Merged
Merged
Conversation
BDZ peel scratch + keys + g at the default 2^25 seal peaks around 1 GiB per worker, but the free-RAM gate still used 750 MiB. Two workers on a 1.5 GiB-free host would oversubscribe. Match the gate (and owner docs) to the actual peak. Co-authored-by: Cursor <cursoragent@cursor.com>
Same-txid overwrite saturating-added another 40-byte creates listing while the HashMap still held one slot, so iflight= could exceed live Arc bytes until the older pack pruned. Charge creates occupancy on vacant insert only, and subtract only when remove_keys actually drops the map entry (or the CreatePin). Co-authored-by: Cursor <cursoragent@cursor.com>
stash_pending_block dropped pending.keys().next() — HashMap iteration order — so a burst could evict the body on the current header path. Track insert order and pop the oldest hash, matching Q-60's pending FIFO. Re-stash of the same hash keeps its place. Co-authored-by: Cursor <cursoragent@cursor.com>
Core EvalChecksigTapscript subtracts VALIDATION_WEIGHT_PER_SIGOP for a non-empty sig, then rejects an empty pubkey. We rejected empty pubkey first, so a CHECKSIG that was also over the weight budget reported \"empty pubkey\" instead of \"validation weight\". Same reject either way; match Core's error class. Co-authored-by: Cursor <cursoragent@cursor.com>
Cake historicalMode=false walked spent.idx + spent.body once per eligible tx (up to 16384 serial reads). One spent_range_batch plus one spent-body walk per create, matching serial unspent_create_vouts. Co-authored-by: Cursor <cursoragent@cursor.com>
PendingBlocks::insert and len were only reached from tests, so -D warnings failed the non-test lib build. Tip-follow now inserts through the wrapper; the cap pin uses keys().len(). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Five findings from the 2026-08-28 reaudit, one commit each:
tx.headrebuild workers sized at 1 GiB peak. The free-RAM gate still used 750 MiB while BDZ peel scratch + keys + g at the default 2²⁵ seal peaks around 1 GiB. Two workers on a 1.5 GiB-free host would oversubscribe. Gate and owner docs now match the peak (1.5 GiB → 1 worker; 2 GiB → 2).creates/outsoccupancy. Same-txid overwrite saturating-added another 40-byte creates listing while the HashMap still held one slot, soiflight=could exceed live Arc bytes until the older pack pruned. Charge creates occupancy on vacant insert only; subtract only whenremove_keysactually drops the map entry or the CreatePin.stash_pending_blockdroppedpending.keys().next()(HashMap iteration order), so a burst could evict the body on the current header path. Insert order is tracked; the oldest hash is popped. Re-stash of the same hash keeps its place. Matches Q-60's pending FIFO.spent.idxbatch per wave. CakehistoricalMode=falsewalked idx + body once per eligible tx (up to 16384 serial reads on the serve thread).unspent_create_vouts_batchdoes onespent_range_batchplus one spent-body walk per create;get_output_spender_metas_atis that walk (not one 8-byte pread per vout). Serialunspent_create_voutsresults unchanged.EvalChecksigTapscriptsubtractsVALIDATION_WEIGHT_PER_SIGOPfor a non-empty sig, then rejects an empty pubkey. We rejected empty pubkey first, so a CHECKSIG that was also over the weight budget reported"empty pubkey"instead of"validation weight". Same reject either way; match Core's error class.Tests
parse_rebuild_workers_and_1gib_cap/workers_for_free_ram_1gib_head_is_not_sh_1_5gib(store)same_txid_overwrite_does_not_double_count_creates_bytes(query)pending_blocks_insert_evicts_at_cap(net)unspent_create_vouts_batch_matches_serial/get_output_spender_metas_at_one_walk(store);load_thin_cut_through_drops_spent_p2tr(query)tapscript_empty_pubkey_reports_weight_when_budget_exhausted(consensus)Each failed red before its fix. Targeted crate tests green locally;
cargo fmtclean.Made with Cursor