Repository navigation
docs(adr-016): surface off-chain read API for client/node bootstrap - #333
Merged
Merged
Conversation
ADR 016's cross-contract call table only covered contract-to-contract interactions, leaving the off-chain client/node read surface implicit. The view functions clients call at cold-start (`getActiveNodes`, `getActiveNodeCount`, `getFirstRegisteredAt`) are specified in ADRs 001 / 012 / 019 but were not cross-referenced here, which is why PR #237's StakingRegistry scaffolded without them. Add a dedicated "Off-Chain Read API" subsection that lists these functions, the bootstrap pagination pattern, the liveness caveat, and a pointer to #332 (settlement-weighted ranking discussion). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Expand the off-chain read API section with a concrete proposal for biasing cold-start peer discovery toward proven deliverers. Settlement events are already going on-chain via StablePaymentChannel; surfacing them as a queryable signal (lastSettlementAt) lets clients rank candidates without adding a separate liveness oracle. Includes the contract-surface sketch, forward-compat principles (return raw signals, keep region off-chain for now), and the cold-start operator handling. Discussion remains open at #332. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the contract interactions ADR to include a new section for the Off-Chain Read API, detailing the view functions in the StakingRegistry used for node discovery and reputation. The feedback suggests improving the documentation's technical accuracy by clarifying function parameters, adding missing ADR references, and correcting the terminology regarding the pagination pattern.
- Add `ethAddress` parameter name to the `getFirstRegisteredAt` signature with a parenthetical note clarifying it's the operator address. - Cite ADR 008 (reputation) and ADR 019 (onboarding) since they formalize the cold-start bonus window the function exists to feed. - Rename "pagination contract" → "pagination pattern" to avoid collision with the Solidity "contract" sense in this section. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alpergundogdu
force-pushed
the
docs/adr-016-external-read-api
branch
from
April 27, 2026 16:11
93cd00e to
426d9ae
Compare
Drop the "Proposed" framing and the discussion-issue pointer — the contract surface is settled and ships as part of this amendment. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
stakeMultiple is a derived staking value used for on-chain fee tiering at settlement time, not for off-chain peer selection. Including it in the cold-start tuple violates the "raw signals, not policy" principle and clutters the surface with data callers don't need for ranking. Callers that genuinely need it can fetch getStakeMultiple(operator) per-node on demand. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alpergundogdu
added a commit
that referenced
this pull request
Apr 28, 2026
Squashed baseline taken from the original PR #237 work (commits 084e53a..4017f1a). Same contract surface and tests; no content changes. Subsequent commits in this PR add the off-chain read API and settlement-weighted ranking signals from PR #333. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alpergundogdu
added a commit
that referenced
this pull request
Apr 28, 2026
…R 016/333) Adds the StakingRegistry surface ADR 016 §3 (post-#333) specifies for client/node cold-start bootstrap, and wires StablePaymentChannel to stamp settlement activity so off-chain clients can rank candidates by recent delivery. StakingRegistry: - struct NodeInfo { address operator; bytes32 nodeId; uint64 lastSettlementAt; } - getActiveNodeCount() / getActiveNodes(offset, limit) backed by an EnumerableSet.AddressSet maintained in registerNode/ejectNode. - getFirstRegisteredAt(ethAddress) — stable across re-registrations, feeds the reputation cold-start bonus window (ADR 008). - recordSettlement(operator) gated by SETTLEMENT_REPORTER_ROLE plus a per-operator lastSettlementAt mapping returned in NodeInfo. StablePaymentChannel: - settleChannel calls recordSettlement(provider) on any non-zero claim, stamping the registry. Zero-claim settlements are skipped (no liveness signal). Existing tests now grant the role in setUp; the deploy script grants it in production. Deploy.s.sol: - Atomic role-wiring step grants SETTLEMENT_REPORTER_ROLE to the StablePaymentChannel alongside BLACKLIST_ROLE/SLASH_ROLE. ADR 016: - Cross-contract call table records the recordSettlement edge. - Post-deployment initialization step + access control matrix include the new role. Tests (forge test: 142 passed, 0 failed, 0 skipped): - Eight new tests covering active-set enumeration, pagination, first-registered timestamp stability, role gating, the settlement stamp flowing into NodeInfo, and the no-stamp path on zero-claim settlements. Branch was rebased onto current main (the original PR was 18 commits behind); the contract scaffold from #237 is preserved as a single squashed baseline commit followed by this delta. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ADR 016's cross-contract call table only covered contract-to-contract interactions — the off-chain client/node read surface was left implicit. The view functions clients invoke at cold-start (
getActiveNodes,getActiveNodeCount,getFirstRegisteredAt) are specified in ADRs 001 / 012 / 019 but were never cross-referenced in ADR 016, which is why PR #237'sStakingRegistryscaffolded without them.This adds a dedicated Off-Chain Read API subsection covering:
Closes #332 (the discussion is now formalized in the ADR; team review on this PR is the place to land it).
Related: PR #237 (contract scaffold) and #327 (PoC-blocking Rust-side registry query) — both gated on the view functions surfaced here.
Why now
PR #237 (contract scaffold) is open. Without these view functions in StakingRegistry, our PoC-blocking #327 (Rust-side registry query) can't be implemented as ADR 012 specifies — clients would have to replay events from genesis or depend on a subgraph indexer.
Test plan
🤖 Generated with Claude Code