Skip to content

fix(tempo): coordinate parallel sponsor fee exposure - #699

Merged
brendanjryan merged 2 commits into
mainfrom
feat/atomic-sponsor-budget
Jul 23, 2026
Merged

fix(tempo): coordinate parallel sponsor fee exposure#699
brendanjryan merged 2 commits into
mainfrom
feat/atomic-sponsor-budget

Conversation

@gakonst

@gakonst gakonst commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What changed

  • replace sender-level serialization with a sponsor-wide atomic fee budget
  • key the budget by the recovered on-chain sponsor address, independent of replay-store prefixes
  • persist the final sponsor-signed transaction hash and an owner-fenced lifecycle (preparedbroadcastingpending)
  • keep broadcast/pending exposure reserved until a receipt is observed or the expiring nonce reaches validBefore
  • reconcile receipts lazily before admitting more work; stale workers cannot release replacement reservations
  • bound both aggregate declared fee exposure and reservation count
  • wait for capacity until the payment challenge deadline rather than rejecting parallel expiring-nonce submissions

Why

Tempo expiring nonces are designed for independent transactions to be submitted in parallel. A sender mutex defeats that property, while releasing budget immediately after an optimistic RPC response fails to bound transactions that are still pending or whose response was lost.

This keeps the aggregate sponsor bound without coupling independent senders or same-sender expiring-nonce transactions. The final signed hash and owner token provide the useful lifecycle/reconciliation pieces discussed in #690; this PR intentionally does not take #690’s sender lock or add a manual recovery API. It supersedes #690 for this behavior.

Tempo references:

Policy

tempo.charge({ feePayerPolicy }) accepts:

  • maxInFlightTotalFee: aggregate declared worst-case fee exposure; defaults to maxTotalFee * 10
  • maxInFlightReservations: count bound protecting the budget from zero/low-fee request amplification; defaults to 100

Per-transaction fee validation remains in the shared fee-payer policy. The aggregate settings are charge-broadcast policy and do not leak into session fee-payer configuration. A single transaction larger than the aggregate budget is rejected immediately instead of waiting until expiry.

Capacity waiters perform atomic no-op reads while full. A challenge expiry stops a waiter from beginning new work, but an already broadcast reservation remains counted through the transaction’s later validBefore boundary.

Validation

  • reproduced the previous same-sender rejection on pristine main
  • verified concurrent same-sender expiring-nonce transactions succeed
  • verified different senders sharing one sponsor coordinate against the same atomic budget
  • verified capacity waits and proceeds after terminal receipt reconciliation
  • verified optimistic sponsored broadcasts remain persisted as pending
  • verified owner fencing rejects stale transitions/releases
  • verified reservation-count limiting and oversized-transaction rejection
  • local Tempo node: 180 focused fee-payer/charge/budget tests passed
  • pnpm check:ci
  • pnpm exec tsgo -b
  • pnpm build

Both commits are SSH-signed for GitHub verification.

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/mppx@699

commit: a034bbe

Comment thread src/tempo/server/Charge.ts Outdated
@parvahuja

Copy link
Copy Markdown
Contributor

outside of the edge case above, i think 👍

Comment thread src/tempo/server/Charge.test.ts
Comment thread src/tempo/server/Charge.ts Outdated
Comment thread src/tempo/server/Charge.ts Outdated
Comment thread src/tempo/server/Charge.ts Outdated
@gakonst
gakonst force-pushed the feat/atomic-sponsor-budget branch from 303b1d7 to 6ed7056 Compare July 23, 2026 19:10
@gakonst gakonst changed the title fix: coordinate sponsored transactions with atomic fee budgets fix(tempo): coordinate parallel sponsor fee exposure Jul 23, 2026
@gakonst
gakonst force-pushed the feat/atomic-sponsor-budget branch from 6ed7056 to a034bbe Compare July 23, 2026 19:12
@brendanjryan
brendanjryan merged commit a8e73b7 into main Jul 23, 2026
15 of 16 checks passed
@brendanjryan
brendanjryan deleted the feat/atomic-sponsor-budget branch July 23, 2026 19:55
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.

3 participants