Repository navigation
docs(adr): add ChannelOpened event so wallets can enumerate channels - #427
Conversation
…426) A channel that has been opened but never had any subsequent on-chain action (no closeChannel, no topUp, no dispute) is invisible to log scans today — there's no ChannelOpened event in the spec. Wallets, CLI tools, and indexers cannot list a client's or provider's open channels without parsing the full transaction history of every candidate address. Add ChannelOpened with three indexed fields (channelId, client, provider — the EVM maximum) so: - Clients enumerate via eth_getLogs(topics=[ChannelOpened, *, paddedClient]) - Providers enumerate via the third topic - Indexers key on channelId for full history reconstruction Non-indexed payload carries `token, deposit, expiresAt`. The token field is USDC for the PoC and an arbitrary governance-approved ERC-20 in production (per ADR 010), so the same event signature carries through the multi-token migration without a wire-format break. Cost: one LOG3 per openChannel (~1,150 gas) — negligible relative to the SSTORE and safeTransferFrom already in the function (~80k gas). Three sites updated: - §Function table: openChannel description now mentions the emit - §Events table: ChannelOpened added as the chronologically-first row - New paragraph below the events table explaining the off-chain enumeration use case the event enables This unblocks operationally useful CLI tooling on top of the symmetric zero-voucher close (#424): `decdn channel list` enumerates open channels via log scan, `decdn channel close <id>` triggers recovery when a node has failed before any voucher boundary. Closes #426 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the adr/003-payments.md documentation to include the ChannelOpened event, which is emitted by the openChannel function. The event utilizes three indexed fields—channelId, client, and provider—to facilitate efficient off-chain channel enumeration via log filtering. Feedback was provided to refactor the description of this event to remove historical justification and focus strictly on the current design's capabilities, ensuring the ADR remains a concise record of the system's architecture.
| | `ChannelForceClosedByTokenRemoval(channelId, token, caller, …)` | `forceCloseChannel` (production `PaymentChannel` only — see [ADR 010](010-multi-token.md)) | `disputeDeadline` | | ||
| | `RateBoundsUpdated` | `setRateBounds` | `newDeliveryFloor, newDeliveryCeiling` | | ||
|
|
||
| `ChannelOpened` is the entry point for off-chain channel enumeration: a client lists their channels via `eth_getLogs(topics=[ChannelOpened, *, paddedClientAddress])`; a provider does the same with their address in the third topic; an indexer keys on `channelId`. Without this event, channels that have been opened but not yet acted on (no `topUp`, `closeChannel`, or `disputeChannel`) are invisible to log scans, forcing wallets to walk the client's entire transaction history to enumerate them. |
There was a problem hiding this comment.
This paragraph contains historical narrative and justification for the change ("Without this event..."). According to the general rules, such context should reside in issue discussions or merge commit messages to maintain a clean record of the current design in the canonical documentation. The ADR should focus on the current design and its capabilities.
| `ChannelOpened` is the entry point for off-chain channel enumeration: a client lists their channels via `eth_getLogs(topics=[ChannelOpened, *, paddedClientAddress])`; a provider does the same with their address in the third topic; an indexer keys on `channelId`. Without this event, channels that have been opened but not yet acted on (no `topUp`, `closeChannel`, or `disputeChannel`) are invisible to log scans, forcing wallets to walk the client's entire transaction history to enumerate them. | |
| ChannelOpened is the entry point for off-chain channel enumeration: a client lists their channels via eth_getLogs(topics=[ChannelOpened, *, paddedClientAddress]); a provider does the same with their address in the third topic; an indexer keys on channelId. This ensures channels are discoverable via log scans even if they have not yet had any subsequent on-chain activity (no topUp, closeChannel, or disputeChannel). |
References
- Avoid including historical narratives, iteration details, or information about dropped features in canonical documentation (e.g., ADRs). Such context should reside in issue discussions or merge commit messages to maintain a clean record of the current design.
Replace "Without this event, ... forcing wallets to walk the client's entire transaction history" with positive framing of current behavior, per gemini-code-assist review on #427.
Closes #426.
Adds
ChannelOpenedto ADR 003's events table so off-chain components can enumerate channels by log scan instead of by parsing full tx history.The gap (from #426)
Today, a channel that has been opened but never had any subsequent on-chain action (no
topUp,closeChannel, ordisputeChannel) is invisible to log scans. The spec has events for every other state transition — close, dispute, settle, topUp, expire, force-close — but not open.This breaks:
The only enumeration path today: walk every `openChannel` transaction sent from the client's address via archive RPC, decode calldata, compute channelIds. Heavy, requires full archive RPC, breaks under smart-account abstraction where `tx.origin` is the bundler, not the channel client.
What changes
Three indexed fields — the EVM maximum — covers the natural query patterns:
eth_getLogs(topics=[ChannelOpened, *, paddedClient])→ all channels for a clienteth_getLogs(topics=[ChannelOpened, *, *, paddedProvider])→ all channels for a providereth_getLogs(topics=[ChannelOpened, paddedChannelId])→ the specific channel (redundant withgetChannelbut useful in receipts and migration)Non-indexed payload (
token, deposit, expiresAt) — the token field is USDC for the PoC and an arbitrary governance-approved ERC-20 in production, so the same event signature survives the ADR 010 multi-token migration without a wire-format break.Three edit sites in ADR 003:
openChanneldescription now mentions "emitsChannelOpened"ChannelOpenedadded as the chronologically-first row, plus a sentence noting why it has three indexed fieldsCost
One
LOG3opcode inopenChannel. EVM gas:375 + 8 × 96(non-indexed bytes) ≈ 1,150 gas. Negligible relative to theSSTOREandsafeTransferFromalready in the function (~80k gas).Refs
tokenfield inChannelOpenedcarries throughTest plan
cargo buildcleanpre-commit run --files adr/003-payments.md— markdownlint + cargo deny passNote: independent of #422 (watchtower → fraud-detection) and #424 (symmetric zero-voucher close). All three touch ADR 003 in different sections; #422 and #424 will need a small textual rebase against this one but no structural conflict.
🤖 Generated with Claude Code