Skip to content

fix(contracts)!: register a signer's capability at the larger value of each field - #2994

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/issue-2839-fix-d3f37b
Nov 25, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/issue-2839-fix-d3f37b

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #2839.

Problem

Capability registration was write-once. A pool owner could sign a wide capability and a narrow one (1 µUSDC, or near-expiry) for the same signer, open streams on the wide one, and land the narrow one first with a capability-only redeemMany. Every stream served under the wide capability then redeemed for about nothing.

Fix

  • Contract: _registerCapability keeps max(cap) and max(expiry) over every owner-signed capability landed for a signer. A capability that raises neither field is a no-op and is not verified. A zero-cap or already-expired capability is still never recorded. The node's first redemption carries its own capability, so the registration rises to the terms it served under and its vouchers redeem in full. The node needs no chain watching.
  • Per field, not "larger on both": two capabilities like [low cap, long expiry] and [high cap, short expiry] are not comparable, so a both-fields rule would keep the race.
  • Node: the admission clamp to the on-chain registration (from fix(node): clamp a presented capability to the signer's on-chain registration #2265) is deleted. It marked the lane registered, which stopped the redeemer landing the node's own capability. Admission refusal of an expired or spent registered signer is unchanged: a client that presents a capability on a spent signer is refused, the owner's own doing.
  • ADR 003/005: state the max rule and delete the "two capabilities for an unregistered signer" residual.

The issue's payee-gate and CapabilityRegistered event checkboxes are not needed with this rule. sponsord is unaffected: it rotates signer keys and never raises terms.

Registration costs about 400 gas more (the conditional writes). .gas-snapshot is regenerated.

Tests

  • Forge: a narrow registration raised by a wider capability that then pays in full; crossed capabilities merge to the max of each field; an expired capability raises nothing; a raise with a bad owner signature reverts; a capability that raises neither field is a no-op.
  • e2e presented_capability_raises_a_narrower_registration replaces the clamp e2e test: the owner lands narrow A, the delegate fetches the whole blob under wide B, every accepted payment redeems, and the registration ends at B's terms. This drops that test's drained-signer "new signer key" tail; the remedy wording stays covered by the CLI unit tests.
  • forge test (642), slither, cargo clippy --all-features, cargo doc with warnings denied, cargo nextest for node/incentive/cli/client (4405 pass), and the delegated anvil e2e all pass locally.

🤖 Generated with Claude Code

…f each field

`_registerCapability` keeps max(cap) and max(expiry) over every
owner-signed capability landed for a signer, instead of the first one.
A pool owner can no longer land a narrow capability ahead of the wide one
a node serves under: the node's first redemption carries its own
capability and raises the registration, so its vouchers redeem in full.

The node's admission clamp to the on-chain registration is removed; it
would mark the lane registered and stop the node landing its capability.
ADR 003 drops the "two capabilities for an unregistered signer" residual.

Closes #2839

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 9f37ed6 claude/issue-2839-fi... b0f4f70 +/-
78% 78% 0%
View coverage of the 6 most impacted files.
File main 9f37ed6 claude/issue-2839-fi... b0f4f70 +/-
crates/client/s...undle/engine.rs 51% 51% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/incentive/src/lane.rs 96% 96% 0%
crates/node/src...s/client/mod.rs 88% 89% +1%
crates/node/src...nt/admission.rs 97% 98% +1%
crates/protocol/src/framing.rs 92% 93% +1%

Solidity / code-coverage/forge

main 9f37ed6 claude/issue-2839-fi... b0f4f70 +/-
93% 93% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 25, 2026 14:49 UTC

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@alpergundogdu
alpergundogdu merged commit 3dcff0c into main Nov 25, 2026
36 checks passed
@alpergundogdu
alpergundogdu deleted the claude/issue-2839-fix-d3f37b branch November 25, 2026 15:02
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.

PaymentPool/node: any EOA can land a signer registration with no event, and a live lane is never clamped to it

1 participant