Repository navigation
fix(node): clamp a presented capability to the signer's on-chain registration - #2266
Merged
Merged
Conversation
…lity (#2265) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stration (#2265) On-chain registration is write-once per (pool, signer), so a voucher past the registered cap or expiry redeems to nothing. Admission now keeps the registered terms from its existing getAuthorization read, refuses an expired registration, and clamps the lane to min(presented, registered). After a landed registration the redeemer persists the chain's registered expiry instead of the attached capability's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 9ffcd09 in the Show a line coverage summary of the most impacted files.
|
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.
Closes #2265.
Problem
On-chain registration is write-once per
(pool, signer). A node held the cap and expiry of the capability the client presented, not the registered terms. A pool owner could register signer S with a small capability A, then present a wider capability B for S at another node. That node served under B's terms, and every voucher past A's cap redeemed to 0.The new e2e test reproduces it on unmodified
main(first commit):Fix
getAuthorizationforcap − spentheadroom (fix(node): confirm signer cap headroom on-chain before admitting a serve #1958) but dropped the registered terms. ThePoolViewmethod is nowsigner_authorization, returningUnregisteredorRegistered { cap, expiry, spent }. Admission refuses a registered signer whose registration has expired, as well as one whosecap − spentcan't cover a floor. The refusal reason is stillSignerCapExhausted, so the wire is unchanged.min(presented, registered)forcapandexpiryand recordsregistered_until. The lane is recorded to the store under the per-lane lock (LaneState::clamp_to_registration,ClientHandler::clamp_lane_to_registration). This applies to new lanes and to existing lanes on their next stream. The voucher path then refuses past the registered cap (SpendingCapExhausted) or expiry (CapabilityExpired), and the mid-stream signer re-check reads the clampedheld_cap.cap/expiryare write-once and persist on the lane. Onlyspentgoes stale, and the existing 1-minute TTL covers that.cap/expiry/registered_untilfields.redeemManythat carriedCapabilityRegs, the node readsgetAuthorizationsonce for those lanes and persists the chain's registered expiry, not the attachedreg.expiry. If that read fails, nothing is persisted. The next sweep re-attaches the reg (an on-chain no-op) and reads again.held_capin the mid-stream re-check, and a new residual. ADR 005 updates the client guidance forSpendingCapExhaustedandCapabilityExpired: a registered signer needs a new key, not a fresh capability for the same key.Needs a maintainer decision
registered_untilonly gates whether the planner attaches aCapabilityReg, and that attach is a harmless no-op for an already-registered signer. The admission clamp is what stops the loss. Step 3 costs oneeth_callper landed chunk that carried registrations. Keep it, or drop it as surface?Tests
cli_fetch_delegated::presented_capability_is_clamped_to_the_signers_registered_terms: registers A via a capability-onlyredeemMany, fetches with B, and asserts the node accepted no more than A's cap and that every accepted voucher redeems. Fails onmain, passes here.clamp_to_registration(lower terms, zero-expiry mapping),SignerAuthorizationview and cache tests (including the expired registration), the handler live-lane clamp with store persistence, and the post-redeem expiry read (chain expiry wins; a failed read persists nothing).🤖 Generated with Claude Code