fix(staking): preserve validator UX on the train - #412
Conversation
The staking contract withdrew the unpaged validator reads the CLI was built on. `activeValidators()` is gone outright, and the balanced-tree walk lost both of its footholds: `validatorsRoot()` no longer exists and `validatorView()` no longer carries the left/right/parent links. None of this degrades gracefully -- the calls revert rather than truncating, so `genlayer staking active-validators` exits non-zero against a deployment carrying the change. Read the append-only joined registry instead, one page at a time: `validatorsJoinedCount()` bounds the walk and `getValidatorsJoined(start, pageSize)` returns each page. The count is read first so a set that grows underneath the walk cannot spin the loop, and a short page means it shrank instead -- stop there and let the next read see the settled set. Page size is 64, matching the convention the contract's own paged reads are written around; committee capacity is 1,543 seats, which is why the unpaged read had to go in the first place. `staking validators` loses its one-call answer for "in the current draw", so the active marker is now derived from what is still readable: joined, and neither banned nor quarantined.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The four SDK-side items under What this does NOT fix are now covered by
One correction worth carrying across: the paged reads are not train-only. |
Present the SDK's stored-state lifecycle in ordinary receipt output and reserve raw stored/projected/action data for an explicit advanced lifecycle command with optional timestamp evaluation. Keep manual finalization under advanced recovery and preserve full raw receipts behind --raw.\n\nValidation: full 75-file Vitest suite (814 tests); build; generated docs; diff check.
Depends-On: genlayerlabs/genlayer-consensus#1307
Depends-On: genlayerlabs/genlayer-node#1800
Depends-On: genlayerlabs/genlayer-js#212
Decision
The CLI targets the train contracts without deployment-version fallbacks. Ordinary commands use the SDK's stored, consumer-oriented lifecycle; projection and manual finalization live under advanced/recovery commands.
--wait-until decided|finalized, not raw protocol statuses.Changes
staking active-validatorsstrict and addsstaking joined-validators.ReadyToFinalize.--rawoutput.d9c564ebb3294f4472fcc69638b0ab0b7624cf50.Validation
npx tsc --noEmitnpm test -- --run: 813 passed across 75 files, including loopback wallet testsnpm run buildgit diff --checkLive composed behavior is qualified by genlayerlabs/genlayer-e2e#748; the 1,543-validator scenario remains gated.