Skip to content

docs(adr-016): surface off-chain read API for client/node bootstrap - #333

Merged
alpergundogdu merged 6 commits into
mainfrom
docs/adr-016-external-read-api
Apr 28, 2026
Merged

alpergundogdu merged 6 commits into
mainfrom
docs/adr-016-external-read-api

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

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's StakingRegistry scaffolded without them.

This adds a dedicated Off-Chain Read API subsection covering:

  • The view functions clients depend on, with cross-references to the spec ADRs
  • The pagination pattern from ADR 012 §Bootstrap
  • The liveness caveat (registry is a seed list, not a liveness oracle)
  • A concrete proposal for settlement-weighted bootstrap ranking so clients bias cold-start toward proven deliverers

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

alpergundogdu and others added 2 commits April 27, 2026 08:30
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]>

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment thread adr/016-contract-interactions.md Resolved
Comment thread adr/016-contract-interactions.md Resolved
- 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
alpergundogdu force-pushed the docs/adr-016-external-read-api branch from 93cd00e to 426d9ae Compare April 27, 2026 16:11
alpergundogdu and others added 3 commits April 27, 2026 09:14
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]>
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
alpergundogdu merged commit 6715ee7 into main Apr 28, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the docs/adr-016-external-read-api branch April 28, 2026 10:35
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]>
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.

Discussion: bias bootstrap toward proven deliverers via on-chain settlement activity

1 participant