Repository navigation
refactor(registry): honest getRegisteredNodes with on-chain active[], drop bootstrap N+1 - #1613
Conversation
… drop bootstrap N+1 `CapacityBond.getActiveNodes` was misnamed: it returned the unfiltered `_registeredAddrs` page, so every caller re-derived activeness with a per-entry `isActive` call. The node registry bootstrap paid that N+1 on each 15-minute resync (#1565). Rename to `getRegisteredNodes` / `getRegisteredNodeCount` and compute `isActive` on-chain per entry, returned as a parallel `bool[] active` alongside the page. One paginated read now yields both projections with no per-entry round-trip: - `active[i]` is the full predicate (registered AND bond >= minBond AND no unbonding AND not ejected) — NOT the raw `NodeInfo.active` registration flag, which stays true mid-unbonding. - `page` stays unfiltered so the node->address payout bindings survive an operator that is inactive but still payable. Consumers: - node bootstrap: zip page/active, delete the per-entry isActive calls. - client discovery: filter on the real isActive (active[]) instead of the raw NodeInfo.active flag, so stale-active (e.g. mid-unbonding) nodes are dropped up front rather than only at probe time. - ABI binding, doc comments, ADRs 003/012/016/019/022 + observability. Tests (TDD): Solidity asserts an unbonding operator is present in `page` but `active[i] == false`; Rust asserts the client excludes a stale-active node whose isActive is false. Closes #1565 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (19)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Contracts coverageLine coverage: 90.07% (2629/2919 lines) |
Gas snapshotNo gas changes vs base. |
Coverage reportTotal: 80.31% (was 80.32%, ▼ 0.01%) — 57100/71103 lines
History
|
There was a problem hiding this comment.
Pull request overview
Refactors the CapacityBond registry enumeration API to eliminate bootstrap N+1 RPC calls by returning an unfiltered NodeInfo[] page plus an on-chain computed bool[] active (the full isActive predicate) from a single paginated view call, and updates all consumers/docs accordingly.
Changes:
- Replaces
getActiveNodes/getActiveNodeCountwithgetRegisteredNodes/getRegisteredNodeCount, wheregetRegisteredNodesreturns(page, active[]). - Updates node bootstrap + client discovery to zip
pagewithactive[]instead of per-entryisActivecalls, and tightens discovery filtering to the strictisActive. - Adds a Solidity regression test for the payable-but-inactive (mid-unbonding) invariant and refreshes ADR references / gas snapshot.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/runtime/mod.rs | Updates runtime commentary to reflect the new registry read name. |
| crates/node/src/dht/staker_set.rs | Updates staker-set docs to reference getRegisteredNodes. |
| crates/node/src/dht/node_address.rs | Updates node-address projection docs to reference the shared getRegisteredNodes enumeration. |
| crates/node/src/dht/chain_staker_set.rs | Updates module docs describing how the active set is seeded and maintained. |
| crates/node/src/dht/capacity_bond_registry.rs | Switches bootstrap enumeration to getRegisteredNodes and consumes on-chain active[]. |
| crates/incentive/src/capacity_bond.rs | Updates the generated binding surface/documentation to the new ABI. |
| crates/common/src/cli/node.rs | Updates CLI help text to reference getRegisteredNodes. |
| crates/client-pull/src/lib.rs | Updates module-level discovery docs to reference getRegisteredNodes. |
| crates/client-pull/src/discovery.rs | Changes discovery filtering to use the strict on-chain active[] predicate and updates tests. |
| crates/cli/src/commands/node.rs | Updates CLI docs to reference getRegisteredNodes. |
| contracts/test/CapacityBond.t.sol | Adds a test asserting unbonding operators remain in page while active[i] == false. |
| contracts/src/CapacityBond.sol | Implements getRegisteredNodes (returns (page, active[])) and getRegisteredNodeCount. |
| contracts/.gas-snapshot | Updates gas snapshot after contract/test changes. |
| adr/appendix-observability.md | Updates watcher documentation to reference getRegisteredNodes. |
| adr/022-content-discovery.md | Updates discovery ADR references to the new registry read. |
| adr/019-node-onboarding.md | Updates onboarding bootstrap step to reference getRegisteredNodes. |
| adr/016-contract-interactions.md | Updates contract interaction inventory and bootstrap pattern documentation. |
| adr/012-client.md | Updates client bootstrap documentation to reference getRegisteredNodes. |
| adr/003-payments.md | Updates interface excerpt + narrative references to the new registry read. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…h mismatch The two arrays are equal-length by construction (the contract fills both in one loop), so the consumers zip them. A divergence — ABI drift or a decoder fault — would make `zip` silently truncate, dropping stakers and bindings (node bootstrap) or candidates (client discovery) with no trace. Add an explicit length check at both zip sites, returning a clear error before zipping. Regression test on the client path asserts a mismatched page/active pair errors rather than returning fewer candidates. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Why
CapacityBond.getActiveNodeswas misnamed: it returned the unfiltered_registeredAddrspage, so every caller had to re-derive activeness with a per-entryisActivecall. The node registry bootstrap paid that N+1 on every 15-minute resync (#1565).What
Rename to
getRegisteredNodes/getRegisteredNodeCountand computeisActiveon-chain per entry, returned as a parallelbool[] activealongside the page. One paginated read now derives both projections with zero per-entry round-trips.active[i]is the full predicate (registered AND bond ≥ minBond AND no unbonding AND not ejected) — not the rawNodeInfo.activeregistration flag, which staystruemid-unbonding.pagestays unfiltered so the node→address payout bindings survive an operator that is inactive but still payable.Consumers
page/active, delete the per-entryisActivecalls.isActive(active[]) instead of the rawNodeInfo.activeflag. Behavior change: stale-active (e.g. mid-unbonding) nodes are now dropped up front rather than only at probe time.Tests (TDD, written test-first)
pagebutactive[i] == false(the payable-but-inactive invariant).isActiveis false.Verification
forge test: 868 pass (129 CapacityBond) · CI build--deny warnings·.gas-snapshotregenerated (only CapacityBond + full-protocol-deploy suites shift; pure suites untouched)cargo nextestnode/incentive/client-pull: 1328 pass · clippy--workspaceclean ·cargo fmt --checkclean · anvil-e2e compile gate pass#1565
🤖 Generated with Claude Code