Skip to content

feat(gossip): implement epidemic broadcast fanout in run_gossip_loop (#82) - #84

Open
ZuLu0890 wants to merge 1 commit into
StellarConduit:mainfrom
ZuLu0890:feature/issue-82-epidemic-broadcast-fanout
Open

feat(gossip): implement epidemic broadcast fanout in run_gossip_loop (#82)#84
ZuLu0890 wants to merge 1 commit into
StellarConduit:mainfrom
ZuLu0890:feature/issue-82-epidemic-broadcast-fanout

Conversation

@ZuLu0890

Copy link
Copy Markdown
Contributor

Summary

Closes #82.

Implements the epidemic broadcast fanout logic in run_gossip_loop that was previously stubbed with a TODO.

Changes

src/gossip/protocol.rs

  • run_gossip_loop now accepts state: Arc<Mutex<GossipState>> as a parameter
  • Epidemic push fanout: on each round tick, drains buffered messages from the active queue, calculates fanout target via FanoutCalculator (logarithmic scaling, clamped to MIN/MAX), selects a random peer subset with select_random_peers, and sends each message to each selected peer
  • Also moves a paced recovery batch from the macro-merge backlog on each tick
  • Anti-entropy pull: on the 30-second tick, picks one random peer and sends a SyncRequest built from the current GossipState
  • Updated unit tests to pass the new GossipState argument

src/gossip/fanout.rs

  • Added FanoutCalculator::calculate_target(active) — simplified API delegating to calculate(active, None)
  • Added FanoutCalculator::select_random<T: Clone>(&self, items, f) — generic peer selection (used by integration tests)

src/gossip/bloom.rs

  • Added BloomFilter — a public two-window sliding bloom filter with a &[u8] API, matching the type expected by tests/gossip_test.rs

src/gossip/round.rs

  • Added RoundScheduler — a public wrapper around GossipScheduler with get_interval() and advance_time(delta) for integration test use

tests/message_format_validation_test.rs

  • Fixed pre-existing compile error: added missing topology_flags: vec![] to TopologyUpdate initializer

Tests

  • ✅ 9 gossip integration tests (cargo test --test gossip_test)
  • ✅ 33 gossip unit tests (cargo test --lib gossip)
  • Pre-existing failures in topology_test and relay_node_submission are unaffected by this PR (confirmed on main before changes)

…tellarConduit#82)

- Add GossipState parameter to run_gossip_loop so the loop has access
  to the active message queue and macro-merge backlog
- On each round tick: drain the active queue, calculate fanout target
  using FanoutCalculator (log-scale with min/max clamp), randomly
  select peer subset, and send each buffered message to selected peers
- Anti-entropy tick now picks one random peer and sends a SyncRequest
  generated from the current GossipState
- Add FanoutCalculator::calculate_target and select_random<T> methods
  (generic over any Clone type) to satisfy integration test surface
- Add BloomFilter public type wrapping a sliding two-window bloom filter
  with a &[u8] API and rotation on capacity
- Add RoundScheduler public wrapper around GossipScheduler exposing
  get_interval() and advance_time() for test-friendly virtual-clock use
- Fix pre-existing compile error in message_format_validation_test.rs
  (missing topology_flags field in TopologyUpdate initializer)

All 33 gossip unit tests and 9 gossip integration tests pass.
@Mrwicks00

Copy link
Copy Markdown
Contributor

@ZuLu0890 fix cicd error

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.

Implement Epidemic Broadcast Fanout in run_gossip_loop

2 participants