Skip to content

Drop LoadHint from NodeAnnounce; trustless tie-break only - #620

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/jovial-napier-a346fc
May 20, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/jovial-napier-a346fc

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #616.

LoadHint advertised a node's active_streams and bandwidth_utilization in every gossip announce and fed tier 1 of the selection tie-breaker. The honesty story was "reputation penalizes nodes whose observed delivery contradicts the advertised load" — but that cross-check was never built: reputation updates from delivery outcomes (latency, errors), not from any advertised-vs-observed load comparison. The publisher emitted zeros on every announce since the gossip crate landed, so tier 1 has been comparing zero to zero in production.

A trustless network doesn't carry unenforceable self-claims on the wire. Saturation handling flows entirely through the closed loop already in place: slower nodes get worse RTT → worse RTT lifts the selection score → reputation drops on observed slow deliveries. Tie-break shrinks from four tiers to three: geo diversity → stake → random.

What's touched

Code (10 files):

  • crates/protocol/src/gossip.rs — drop LoadHint struct, drop load field from NodeAnnounceBody
  • crates/protocol/src/lib.rs — drop re-export
  • crates/gossip/src/{service,validation,peer_table}.rs — drop usage from publisher + test fixtures
  • crates/node/src/selection.rs — drop Candidate.load, compare_load, tier-1 block in pick_best_in_group; tests rewritten to exercise geo + stake + random with stake-based determinism
  • crates/node/src/admin.rs — drop from RawPeer and the PeerEntry → PeerView mapping
  • crates/common/src/admin.rs — drop PeerView.load and doc references
  • crates/cli/src/commands/node.rs — drop LOAD column from decdn node peers table output
  • crates/cli/tests/admin_peers.rs — drop fixture field

ADRs (6 files):

  • adr/001-network.md — drop struct, drop the advisory paragraph, drop tie-break bullet
  • adr/005-protocol.md — drop "and load hint" from metadata description
  • adr/008-reputation.md — drop tier 1, renumber tie-break tiers
  • adr/012-client.md — drop advisory mention from trust model
  • adr/013-schema-evolution.md — drop from both `NodeAnnounceBody` examples and the signed-fields table row
  • adr/019-node-onboarding.md — drop from onboarding's first announce example

Verification

  • `cargo build` clean
  • `cargo clippy --workspace --all-targets` clean
  • `cargo fmt --all -- --check` clean
  • `cargo test` clean across affected crates (decdn-protocol, decdn-gossip, decdn-common, decdn-node, decdn-cli — 542 tests pass). Two pre-existing flakes on this machine (case-insensitive FS in `bundle_create`, SIGHUP timing in `sighup_signal`) reproduce on `main` and are not related.
  • Pre-commit hooks all passed: fmt, clippy, doc, deny, markdownlint, ADR reference hygiene

Comment thread crates/protocol/src/gossip.rs Outdated

/// Current `GossipEnvelope::version` emitted by this protocol version.
pub const GOSSIP_VERSION: u8 = 1;
///

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No need for this at all, drop it please.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request removes the LoadHint field from NodeAnnounce messages and eliminates the load-based tie-breaking tier from the node selection algorithm, reducing it to a three-tier process (geographic diversity, stake, and randomness). These changes are reflected across several ADR documents, the protocol definition—which includes a bump of GOSSIP_VERSION to 2—and the CLI's peer table output. A review comment suggests renaming a test in crates/node/src/selection.rs to more accurately reflect its behavior regarding the interaction between geographic diversity and stake tiers.

Comment thread crates/node/src/selection.rs Outdated
// Different load → stake doesn't matter, lower load wins.
let busy_rich = with_stake(
with_region(with_load(make_candidate(1, 100, 10, 1.0), 0, 90), "US"),
fn stake_tier_only_runs_when_geo_tied() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The test name stake_tier_only_runs_when_geo_tied is a bit misleading. The test setup uses candidates from different regions ('US' and 'DE'), so the geo diversity is not tied. The test actually demonstrates that when both regions are 'unseen', the geo tier doesn't filter the candidates, and the decision falls through to the stake tier. A more descriptive name could prevent future confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — the regions are different, not tied. The actual behavior being pinned is that geo tier 1 is a no-op when no region has been emitted yet (start of a fresh tie group), so stake tier 2 decides. Renamed to higher_stake_wins_when_all_regions_unseen in c162b58 and rewrote the leading comment to explain what's actually happening.

@alpergundogdu
alpergundogdu force-pushed the claude/jovial-napier-a346fc branch 2 times, most recently from 8b98161 to 63069cc Compare May 20, 2026 16:51
…only

LoadHint advertised a node's `active_streams` and `bandwidth_utilization`
in every gossip announce and fed tier 1 of the selection tie-breaker.
The honesty story was "reputation penalizes nodes whose observed delivery
contradicts the advertised load" — but that cross-check was never built:
reputation updates from delivery outcomes (latency, errors), not from any
advertised-vs-observed load comparison. A lying node looks slow, same as
an honest slow node, so the incentive was rhetorical. The publisher
emitted zeros on every announce since the gossip crate landed, the tier-1
tie-break compared zero to zero, and the closed-loop RTT+reputation
signal already de-selects saturated nodes within seconds.

A trustless network doesn't carry unenforceable self-claims on the wire.
Saturation handling now flows entirely through the existing closed loop:
slower nodes get worse RTT, worse RTT lifts the selection score, and
reputation drops on observed slow deliveries. Tie-break shrinks from
four tiers to three: geo diversity → stake → random.

Touched:
- crates/protocol/src/gossip.rs — drop struct, drop signed-body field
- crates/protocol/src/lib.rs — drop re-export
- crates/gossip/{service,validation,peer_table}.rs — drop usage
- crates/node/src/selection.rs — drop `Candidate.load`, `compare_load`,
  tier-1 block in `pick_best_in_group`; tests rewritten to exercise
  geo+stake+random over stake-based determinism
- crates/node/src/admin.rs — drop from RawPeer/PeerView mapping
- crates/common/src/admin.rs — drop PeerView.load + doc references
- crates/cli/src/commands/node.rs — drop LOAD column from `node peers`
  table output
- crates/cli/tests/admin_peers.rs — drop fixture field
- adr/{001,005,008,012,013,019}.md — drop struct definitions, drop
  tier-1 from tie-break, drop advisory/trust-model references, drop
  signed-fields-table row

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the claude/jovial-napier-a346fc branch from 63069cc to c162b58 Compare May 20, 2026 16:54
@alpergundogdu
alpergundogdu merged commit 5b67c41 into main May 20, 2026
3 checks passed
@alpergundogdu
alpergundogdu deleted the claude/jovial-napier-a346fc branch May 20, 2026 16:56
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 89.90% (was 89.90%, ● 0.00%) — 16524/18381 lines

File Coverage Lines Δ
crates/cli/src/commands/node.rs 79.15% 463/585 ▼ 0.08%
crates/common/src/admin.rs 69.57% 16/23 ● 0.00%
crates/gossip/src/peer_table.rs 96.20% 152/158 ▼ 0.09%
crates/gossip/src/service.rs 31.48% 85/270 ▲ +0.46%
crates/gossip/src/validation.rs 100.00% 240/240 ● 0.00%
crates/node/src/admin.rs 95.80% 616/643 ▼ 0.04%
crates/node/src/selection.rs 97.77% 525/537 ▲ +0.02%
crates/protocol/src/gossip.rs 100.00% 65/65 ● 0.00%
History
Commit Total Δ vs base
c162b58 (HEAD) 89.90% ● 0.00%

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.

Discussion: keep or remove LoadHint from NodeAnnounce

1 participant