Skip to content

feat: add CLOSE_GROUP_SIZE and CLOSE_GROUP_MAJORITY constants#44

Merged
mickvandijke merged 3 commits intomainfrom
feat/close-group-constants
Mar 25, 2026
Merged

feat: add CLOSE_GROUP_SIZE and CLOSE_GROUP_MAJORITY constants#44
mickvandijke merged 3 commits intomainfrom
feat/close-group-constants

Conversation

@mickvandijke
Copy link
Collaborator

Summary

  • Adds CLOSE_GROUP_SIZE (5) and CLOSE_GROUP_MAJORITY (3) constants to ant_protocol
  • Re-exports both from the crate root so downstream consumers can use ant_node::CLOSE_GROUP_SIZE
  • Replaces the local REQUIRED_QUOTES constant in the payment module with the canonical CLOSE_GROUP_SIZE

Test plan

  • cargo build passes
  • cargo test --no-run compiles all tests
  • cargo fmt and cargo clippy clean

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 25, 2026 15:36
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_SIZE and CLOSE_GROUP_MAJORITY constants to src/ant_protocol/mod.rs.
  • Re-exported these constants from src/lib.rs so consumers can use ant_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.

Comment on lines 1042 to 1044
// Build 5 quotes with distinct peer IDs (required by CLOSE_GROUP_SIZE enforcement)
let mut peer_quotes = Vec::new();
for _ in 0..5 {
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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 {

Copilot uses AI. Check for mistakes.
…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>
@mickvandijke mickvandijke merged commit d9e542b into main Mar 25, 2026
21 checks passed
@mickvandijke mickvandijke deleted the feat/close-group-constants branch March 25, 2026 15:59
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.

3 participants