Skip to content

Fix: Rep Selection#39

Merged
sephynox merged 3 commits into
mainfrom
fix/rep-selection
Jul 25, 2026
Merged

Fix: Rep Selection#39
sephynox merged 3 commits into
mainfrom
fix/rep-selection

Conversation

@sephynox

@sephynox sephynox commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rust client improperly handled rep selection, so a lagging rep could return a stale/null head and blocks built on it were rejected out-of-order. This PR uses the highest weighted rep first deferring more complex selection for later.

Changes

  • Reads now go to the highest-scored rep. Failures decay it and retries pick the next-best
  • Added e2e tests reproducing stale-head and abandoned-vote conflicts
  • Release script: crates.io User-Agent + publish checks

Note

Medium Risk
Changes how all read paths (head, balance, builder context) choose representatives, which can alter which node is trusted for chain tip data; behavior is more deterministic but shifts load and failure modes compared to random Po2C.

Overview
Rep selection for ledger reads no longer uses power-of-two random choices. RepBook::pick() always returns the representative with the highest effective score (voting weight fraction × AIMD reliability). Failed reads still decay that rep’s score, so retries in dispatch_any naturally move to the next-best peer. The in-tree SmallRng, rng_counter, and rand_core dependency are removed.

Client stack patch releases: keetanetwork-client 0.5.1, keetanetwork-bindings 0.4.4, keetanetwork-client-wasi 0.6.1, keetanetwork-client-wasm 0.5.1 (workspace + lockfile).

E2e coverage adds cases for transmitting on a stale head after another staple lands, and for abandoned temporary votes conflicting with a reworked fee retry.

scripts/release.sh centralizes crates.io metadata fetch with a required User-Agent, fails publish checks on lookup errors, and tolerates cargo package when workspace deps are not yet on crates.io during batched releases.

Reviewed by Cursor Bugbot for commit b1e16a2. Bugbot is set up for automated code reviews on this repo. Configure here.

@sephynox
sephynox requested review from Srayman and rkeene July 25, 2026 00:16
@sephynox sephynox self-assigned this Jul 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

}

#[test]
fn pick_fails_over_when_the_leader_reliability_decays() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this necessary for now? If a highest weight rep is unreliable doesn't seem like the network will be able to accomplish much.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What if in the future highest weight is ~20% and second is ~19%? I think we can leave it for now and figure out something better later.

@sephynox
sephynox merged commit e29761f into main Jul 25, 2026
9 checks passed
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.

2 participants