feat: add CLOSE_GROUP_SIZE and CLOSE_GROUP_MAJORITY constants#44
feat: add CLOSE_GROUP_SIZE and CLOSE_GROUP_MAJORITY constants#44mickvandijke merged 3 commits intomainfrom
Conversation
Define close group constants in ant_protocol and re-export from crate root so downstream consumers can reference them. Replaces the local REQUIRED_QUOTES constant in the payment module with the canonical CLOSE_GROUP_SIZE. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR centralizes the network “close group” sizing into ant_protocol by introducing CLOSE_GROUP_SIZE (5) and CLOSE_GROUP_MAJORITY (3), then updates payment logic to use the canonical constant and re-exports the constants from the crate root for downstream use.
Changes:
- Added
CLOSE_GROUP_SIZEandCLOSE_GROUP_MAJORITYconstants tosrc/ant_protocol/mod.rs. - Re-exported these constants from
src/lib.rsso consumers can useant_node::CLOSE_GROUP_SIZE. - Replaced the payment module’s local quote-count constant usage with
CLOSE_GROUP_SIZE.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/payment/verifier.rs |
Uses CLOSE_GROUP_SIZE for quote-count validation and updates related test comment. |
src/payment/single_node.rs |
Removes the local required-quote constant and switches fixed-size arrays/validations to CLOSE_GROUP_SIZE. |
src/lib.rs |
Re-exports CLOSE_GROUP_SIZE / CLOSE_GROUP_MAJORITY from the crate root. |
src/ant_protocol/mod.rs |
Defines and documents the close-group sizing constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Build 5 quotes with distinct peer IDs (required by CLOSE_GROUP_SIZE enforcement) | ||
| let mut peer_quotes = Vec::new(); | ||
| for _ in 0..5 { |
There was a problem hiding this comment.
This test constructs 5 quotes using a hard-coded loop bound (0..5) while the enforcement now uses CLOSE_GROUP_SIZE. Use CLOSE_GROUP_SIZE (and consider updating the other similar loops in this test module) so the test stays consistent if the constant changes.
| // Build 5 quotes with distinct peer IDs (required by CLOSE_GROUP_SIZE enforcement) | |
| let mut peer_quotes = Vec::new(); | |
| for _ in 0..5 { | |
| // Build CLOSE_GROUP_SIZE quotes with distinct peer IDs (required by CLOSE_GROUP_SIZE enforcement) | |
| let mut peer_quotes = Vec::new(); | |
| for _ in 0..CLOSE_GROUP_SIZE { |
…eplace hard-coded loops - MEDIAN_INDEX is now CLOSE_GROUP_SIZE / 2 instead of a magic number - All test loops use CLOSE_GROUP_SIZE instead of hard-coded 0..5 - Updated doc comments to reference the constant Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete the Section 18 test matrix with the remaining scenarios: - #3: Fresh replication stores chunk + updates PaidForList on remote nodes - #9: Fetch retry rotates to alternate source - #10: Fetch retry exhaustion with single source - #11: Repeated ApplicationFailure events decrease peer trust score - #12: Bootstrap node discovers keys stored on multiple peers - #14: Hint construction covers all locally stored keys - #15: Data and PaidForList survive node shutdown (partition) - #17: Neighbor sync request returns valid response (admission test) - #21: Paid-list majority confirmed from multiple peers via verification - #24: PaidNotify propagates paid-list entries after fresh replication - #25: Paid-list convergence verified via majority peer queries - #44: PaidForList persists across restart (cold-start recovery) - #45: PaidForList lost in fresh directory (unrecoverable scenario) All 56 Section 18 scenarios now have test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Complete the Section 18 test matrix with the remaining scenarios: - #3: Fresh replication stores chunk + updates PaidForList on remote nodes - #9: Fetch retry rotates to alternate source - #10: Fetch retry exhaustion with single source - #11: Repeated ApplicationFailure events decrease peer trust score - #12: Bootstrap node discovers keys stored on multiple peers - #14: Hint construction covers all locally stored keys - #15: Data and PaidForList survive node shutdown (partition) - #17: Neighbor sync request returns valid response (admission test) - #21: Paid-list majority confirmed from multiple peers via verification - #24: PaidNotify propagates paid-list entries after fresh replication - #25: Paid-list convergence verified via majority peer queries - #44: PaidForList persists across restart (cold-start recovery) - #45: PaidForList lost in fresh directory (unrecoverable scenario) All 56 Section 18 scenarios now have test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
CLOSE_GROUP_SIZE(5) andCLOSE_GROUP_MAJORITY(3) constants toant_protocolant_node::CLOSE_GROUP_SIZEREQUIRED_QUOTESconstant in the payment module with the canonicalCLOSE_GROUP_SIZETest plan
cargo buildpassescargo test --no-runcompiles all testscargo fmtandcargo clippyclean🤖 Generated with Claude Code