Repository navigation
Conversation
Payers currently sign one EIP-712 voucher per delivery interval: ~2,500
signatures for a 10 GB transfer at the 4 MiB cadence, 10,000 at the 1 MB
wire default. That is CPU-bound on secp256k1 and FS-bound on the
fsync-before-continue rule, and it forces a coarse interval — which is
exactly the amount a payer can withhold.
PayWord is not a new object. There is one voucher whose cumulative
`amount` is the settlement anchor, and the hash chain is an optional,
signature-free way to advance that anchor between signatures.
Redemption is one formula:
claimed = voucher.amount + chain_index * chunk_price
`chain_index = 0` settles exactly `amount` and walks nothing — the same
shape as today's voucher. Above 0 the node exhibits a preimage proving
the chunks it streamed past the last signature, and the contract walks
at most MAX_CHAIN_LENGTH hashes. Signatures become O(1) per transfer
(one, or two on a cooperative close, plus one per rollover), never one
per chunk. The contract gains no storage slot and no second settlement
object.
Two resolutions, deliberately kept separate: a preimage settles whole
chunks for one hash, and a voucher `amount` settles any residual exact
to one USDC base unit. A partial trailing chunk or a sub-chunk transfer
closes with a zero-root amount-voucher, not a preimage. The chain is the
unilateral fallback; the amount-voucher is the cooperative close.
A sealed voucher sets `chain_root = 0` and redeems at index 0 with a
zero preimage. Those zeros satisfy the ordinary check, and keccak
preimage resistance makes any higher index infeasible — so the voucher
is cryptographically sealed at its `amount` with no optional field and
no contract branch.
chunk_bytes is fixed at 1 MiB. USDC's 6 decimals are the binding
constraint: a chunk must price to at least one base unit, so the earlier
draft's 64 KiB is unpayable. 1 MiB prices to ~10 base units at the
$0.01/GB target and stays payable down to the governance floor. Because
CHUNK_BYTES == BYTES_PER_MB, chunk_price is the advertised rate_per_mb
and the payability floor is the existing deliveryFloor — no second
price constant.
MAX_CHAIN_LENGTH is 255, not the 1024 the issue names. The wire sets
this bound, not gas: a preimage travels as `preimage || index`, 33 bytes
flat, and 255 is the largest chain whose releasable indices fit one byte
directly. Index 0 is the redeem-side settlement case and never travels,
so releasable indices are 1..=255 and the byte IS the index — no offset
tag, no +1 on receipt, nowhere for an off-by-one to live. The trade is
~4x more signatures (255 MiB per chain) for a fixed-width message and a
walk capped at 255 hashes.
Schema slimming: chain_length and chunk_bytes are protocol constants
outside the signed voucher (~20% less redeem calldata). chain_root and
chunk_price stay signed — an unsigned root lets a payer disown a chain
it authorized, and an unsigned price settles at whatever governance rate
holds at redeem time.
One chain per lane is a payer-side MUST. A preimage is a bearer proof
with no payee of its own, so a shared chain_root would let preimages
released to one node be spent against another's voucher. No node can
detect it and the contract never sees two vouchers together, hence the
new Cross-lane preimage spend attack vector.
Cross-ADR consistency: 005 gains the unsigned 33-byte ChunkPreimage
message and BadPreimage/ChainExhausted reject reasons, and loses
voucher_interval_mb negotiation; 016 updates the redeem signature; 013
renumbers the ClientMessage tail (pre-launch, no shim); glossary and
architecture track the new vocabulary.
Deliberately out of scope, owned by their own issues: async voucher
persistence (#1672) and the credit-window rewrite (#1669). ADR 003 now
leads the code — PaymentPool.sol and crates/{incentive,protocol,
client-pull} still implement the pre-PayWord model, tracked separately.
Closes #1670
Co-Authored-By: Claude Opus 5 (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.
Closes #1670.
What this is
PayWord alone, in ADR 003 where the payment model lives — not a new ADR. PR #1652 bundled it with async voucher persistence and edited ~17 ADRs; this touches 10, all docs.
The model: amount-anchored, chain is an optional extension
PayWord is not a new object. One voucher, whose cumulative
amountis the settlement anchor. The chain is an optional, signature-free way to advance that anchor between signatures. Redemption is one formula:chain_index = 0→ settles exactlyamount, no walk. Identical in shape to today's voucher.chain_index > 0→ the node exhibits a preimage proving chunks streamed past the last signature; the contract walks ≤MAX_CHAIN_LENGTHhashes.Signatures are O(1) per transfer (one, or two on a cooperative close, plus one per rollover), never one per chunk. The contract gains no storage slot —
Lane {amount, bytesDelivered}is unchanged, becauseclaimed − paidis idempotent over whatever proof the node presents.Two resolutions, kept separate
chunk_bytes(1 MiB)amountA sub-chunk remainder closes with a zero-root amount-voucher, not a preimage. 1.5 MB = one preimage + a closing voucher for exactly 15 base units. The chain is the unilateral fallback; the amount-voucher is the cooperative close.
Sealed voucher, no contract branch
chain_root = 0redeemed at index 0 with a zero preimage satisfies the ordinarykeccak^k(preimage) == chain_rootcheck with zeros. At any higher index it would need a preimage hashing to 0 — infeasible. So the voucher is cryptographically sealed at itsamount, with a fixed schema, no optional field, and nothing in the contract testingchainRoot == 0.Two decisions worth reviewing
chunk_bytes= 1 MiB, fixed. USDC's 6 decimals are the binding constraint — a chunk must price to ≥1 base unit, so the earlier draft's 64 KiB is unpayable at the floor rate. 1 MiB prices to ~10 units at the $0.01/GB target and stays payable down to the governance floor. BecauseCHUNK_BYTES == BYTES_PER_MB,chunk_priceis the advertisedrate_per_mband the payability floor is the existingdeliveryFloor— no second price constant, no new governance knob.MAX_CHAIN_LENGTH= 255, not the 1024 in the issue body. This is a deliberate deviation, not a transcription error. The wire sets the bound, not gas: a preimage travels aspreimage ‖ index, 33 bytes flat. 1024 doesn't fit a byte, and 256 would fit only via anindex − 1offset. 255 designs the off-by-one out entirely — index 0 is the redeem-side settlement case and never travels, so releasable indices are1..=255and the byte is the index. The trade: ~4× more signatures (255 MiB per chain) for a fixed-width message and a walk capped at 255 hashes (~16k gas at full depth, zero on the cooperative path).Schema slimming
Out of the signed voucher as protocol constants (~20% less redeem calldata):
chain_length→ alwaysMAX_CHAIN_LENGTH;chunk_bytes→ fixed. Kept signed:chain_root(an unsigned root lets a payer disown a chain it authorized) andchunk_price(an unsigned price settles at whatever governance rate holds at redeem time — a repudiation surface).Signed voucher:
{pool_id, signer, provider, amount, bytes_delivered, chain_root, chunk_price}.One chain per lane — a payer-side MUST
A preimage is a bearer proof with no payee of its own. A shared
chain_rootacross two providers would let every preimage released to A extend B's voucher, so B claims chunks it never delivered and the signer pays twice per tick. No node can detect it (each sees only its own lane) and the contract never sees two vouchers together. Carried forward from a review finding on #1652 — no split-out issue covers it — with a new Cross-lane preimage spend attack vector.Out of scope, by design
(last_amount, last_bytes_delivered, chain_root, highest_index), and a node that restarts without the root and index silently forfeits every chunk metered since the last signature.Cross-ADR consistency
005 gains the unsigned 33-byte
ChunkPreimagemessage andBadPreimage/ChainExhaustedreject reasons, and losesvoucher_interval_mbnegotiation entirely; 016 updates theredeemsignature and class diagram; 013 renumbers theClientMessagetail (pre-launch, no shim per CLAUDE.md); 012/014/038/039, glossary, and architecture track the new vocabulary. Glossary gains Chain root / preimage and Payment chunk — the latter because "chunk" already means the 1024-byte BLAKE3 leaf in this repo.ADR 003 now leads the code
Deliberate.
PaymentPool.solandcrates/{incentive,protocol,client-pull}still implement the pre-PayWord model; no hash-chain code exists yet. Implementation follow-ups are filed separately.Verification
make -C adr check-refs— 1703 anchors resolve, no bare refs, no numeric §Nmake -C adr check-book-list— in sync (24 ADRs + 11 appendices)markdownlint— clean on all 10 filesmmdc. The fullmake -C adr bookfails on028-slashing-appeals.md, which this branch does not touch — pre-existing on main.voucher_interval_mb,cumulative − paid, and every offset-encoding pattern (index − 1,index_tag,tag + 1) all return zero hits.🤖 Generated with Claude Code