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.
src/payment/verifier.rs
Outdated
| // 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>
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