Skip to content

refactor(registry): honest getRegisteredNodes with on-chain active[], drop bootstrap N+1 - #1613

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/bootstrap-registry-isactive-0c8181
Aug 5, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/bootstrap-registry-isactive-0c8181

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

CapacityBond.getActiveNodes was misnamed: it returned the unfiltered _registeredAddrs page, so every caller had to re-derive activeness with a per-entry isActive call. The node registry bootstrap paid that N+1 on every 15-minute resync (#1565).

What

Rename to getRegisteredNodes / getRegisteredNodeCount and compute isActive on-chain per entry, returned as a parallel bool[] active alongside the page. One paginated read now derives both projections with zero per-entry round-trips.

function getRegisteredNodes(uint256 offset, uint256 limit)
    external view returns (NodeInfo[] memory page, bool[] memory active); // active[i] = isActive(page[i])
  • 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. Behavior change: stale-active (e.g. mid-unbonding) nodes are now dropped up front rather than only at probe time.
  • ABI binding, doc comments, ADRs 003/012/016/019/022 + appendix-observability.

Tests (TDD, written test-first)

  • Solidity — an unbonding operator is present in page but active[i] == false (the payable-but-inactive invariant).
  • Rust — the client excludes a stale-active node whose isActive is false.

Verification

  • forge test: 868 pass (129 CapacityBond) · CI build --deny warnings · .gas-snapshot regenerated (only CapacityBond + full-protocol-deploy suites shift; pure suites untouched)
  • cargo nextest node/incentive/client-pull: 1328 pass · clippy --workspace clean · cargo fmt --check clean · anvil-e2e compile gate pass
  • aderyn/slither: no new findings on the added code

#1565

🤖 Generated with Claude Code

… 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]>
Copilot AI lite review requested due to automatic review settings August 5, 2026 14:20
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: e355dfd4-572c-4309-9159-e856b272cbe4

📥 Commits

Reviewing files that changed from the base of the PR and between 6421881 and 9aab44f.

📒 Files selected for processing (19)
  • adr/003-payments.md
  • adr/012-client.md
  • adr/016-contract-interactions.md
  • adr/019-node-onboarding.md
  • adr/022-content-discovery.md
  • adr/appendix-observability.md
  • contracts/.gas-snapshot
  • contracts/src/CapacityBond.sol
  • contracts/test/CapacityBond.t.sol
  • crates/cli/src/commands/node.rs
  • crates/client-pull/src/discovery.rs
  • crates/client-pull/src/lib.rs
  • crates/common/src/cli/node.rs
  • crates/incentive/src/capacity_bond.rs
  • crates/node/src/dht/capacity_bond_registry.rs
  • crates/node/src/dht/chain_staker_set.rs
  • crates/node/src/dht/node_address.rs
  • crates/node/src/dht/staker_set.rs
  • crates/node/src/runtime/mod.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 90.07% (2629/2919 lines)
▲ +0.32pp vs base (89.75% → 90.07%)
Run: 31015421467

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.31% (was 80.32%, ▼ 0.01%) — 57100/71103 lines

File Coverage Lines Δ
crates/cli/src/commands/node.rs 76.40% 1117/1462 ● 0.00%
crates/client-pull/src/discovery.rs 96.18% 755/785 ▼ 0.20%
crates/client-pull/src/lib.rs 90.21% 1429/1584 ▲ +0.06%
crates/common/src/cli/node.rs 100.00% 5/5 ● 0.00%
crates/node/src/dht/capacity_bond_registry.rs 72.80% 364/500 ▲ +0.29%
crates/node/src/dht/chain_staker_set.rs 84.03% 100/119 ● 0.00%
crates/node/src/dht/node_address.rs 81.58% 93/114 ● 0.00%
crates/node/src/dht/staker_set.rs 94.00% 47/50 ● 0.00%
crates/node/src/runtime/mod.rs 46.61% 1094/2347 ● 0.00%
History
Commit Total Δ vs base
300d087 80.32% ● 0.00%
9aab44f (HEAD) 80.31% ▼ 0.01%

Copilot AI 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.

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/getActiveNodeCount with getRegisteredNodes/getRegisteredNodeCount, where getRegisteredNodes returns (page, active[]).
  • Updates node bootstrap + client discovery to zip page with active[] instead of per-entry isActive calls, and tightens discovery filtering to the strict isActive.
  • 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.

Comment thread crates/client-pull/src/discovery.rs Resolved
…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]>
@alpergundogdu
alpergundogdu merged commit 0f1be9c into main Aug 5, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/bootstrap-registry-isactive-0c8181 branch August 5, 2026 14:36
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