refactor: unify per-pool compact counting behind a pure contract - #2599
Merged
Conversation
Split pepper-sync utils into block and transaction modules, moving the noun out of the function names and into the module path. The transaction module gains shielded_output_count and shielded_input_count: pure, total functions from a compact transaction and shielded pool to the count of elements the transaction carries for that pool. The block module holds the same-named operations as compositions over vtx, beside the renamed compact-block getters. CompactTx carries no transaction version, so a version-aware error arm is unrepresentable on the wire type and the functions are total; an empty ironwood list is the truthful count for any pre-v6 transaction. The four inline counting sites in the scan loop, calculate_block_tree_bounds, and the batcher now share the contract, retiring a miscopied expect message on the orchard count. The counts are exported behind the existing test-features gate as pepper_sync::test_support, mirroring the block and transaction split, so integration tests auditing served blocks share the arithmetic the scanner uses. Unit tests pin the counts across every pool, both directions, and empty and multi-transaction shapes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Convert the block-height unwrap in block::get_compact_height to an expect naming its one real trigger: no valid chain height exceeds u32::MAX, so a u64 wire value above it can only come from a malicious or broken indexer, and sync dies loudly rather than trust it. The conversion's behavior is unchanged; only the panic message gains the diagnosis. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rebase the served_outputs_match_chain_metadata_deltas sweep onto pepper_sync::test_support::block::shielded_output_count, replacing its three inline per-pool sums. The sweep now audits the wire with the same arithmetic the scanner uses, and the helper's own unit tests are the independent pin on that arithmetic, so sharing it does not let a counting bug hide on both sides. The libtonode-tests manifest enables the test-features gate on its direct pepper-sync dependency instead of inheriting it by feature unification through zingolib's testutils. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Import the test_support block module and the ShieldedPool variants so each count reads as one line: block::shielded_output_count(&block, Ironwood). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zancas
marked this pull request as draft
July 30, 2026 05:34
zancas
force-pushed
the
unify_action_count
branch
from
July 30, 2026 17:47
4045f36 to
ea9f21b
Compare
zancas
marked this pull request as ready for review
July 30, 2026 20:22
dorianvp
approved these changes
Jul 30, 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.
This change splits pepper-sync's
utilsintoblockandtransactionmodules, moving the noun out of the function names and into the module path. Thetransactionmodule gainsshielded_output_countandshielded_input_count: pure, total functions from a compact transaction and a shielded pool to the count of elements the transaction carries for that pool. Theblockmodule holds the same-named operations as compositions overvtx, beside the renamed compact-block getters.CompactTxcarries no transaction version, so a version-aware error arm is unrepresentable on the wire type and the functions are total; an empty ironwood list is the truthful count for any pre-v6 transaction.The four inline counting sites in the scan loop,
calculate_block_tree_bounds, and the batcher now share the contract, which retires a miscopied expect message on the orchard count. The counts are additionally exported behind the existingtest-featuresgate aspepper_sync::test_support, mirroring the block and transaction split, so integration tests that audit served blocks (such as the sweep in #2598) can share the arithmetic the scanner uses. Unit tests pin the counts across every pool, both directions, and empty and multi-transaction shapes.Note for reviewers: the
cargo-checkmate (doc)job is red on dev itself at the merge base (a broken intra-doc link toMixnetPriceFetchfromzingolib/src/lightclient/send.rs, gated items under non-nym features); this branch neither introduces nor fixes that failure.🤖 Generated with Claude Code