Skip to content

refactor: unify per-pool compact counting behind a pure contract - #2599

Merged
dorianvp merged 6 commits into
devfrom
unify_action_count
Jul 30, 2026
Merged

refactor: unify per-pool compact counting behind a pure contract#2599
dorianvp merged 6 commits into
devfrom
unify_action_count

Conversation

@zancas

@zancas zancas commented Jul 30, 2026

Copy link
Copy Markdown
Member

This change splits pepper-sync's 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 a 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, which retires a miscopied expect message on the orchard count. The counts are additionally exported behind the existing test-features gate as pepper_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 to MixnetPriceFetch from zingolib/src/lightclient/send.rs, gated items under non-nym features); this branch neither introduces nor fixes that failure.

🤖 Generated with Claude Code

zancas and others added 2 commits July 29, 2026 19:25
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>
zancas and others added 4 commits July 29, 2026 20:52
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
zancas marked this pull request as draft July 30, 2026 05:34
@zancas
zancas force-pushed the unify_action_count branch from 4045f36 to ea9f21b Compare July 30, 2026 17:47
@zancas
zancas marked this pull request as ready for review July 30, 2026 20:22
@zancas
zancas requested a review from dorianvp July 30, 2026 20:23
@dorianvp
dorianvp merged commit aa7e8e8 into dev Jul 30, 2026
51 of 53 checks passed
@dorianvp
dorianvp deleted the unify_action_count branch July 30, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants