Skip to content

ADR 003 gap: no ChannelOpened event — clients cannot enumerate their own channels #426

Closed

Description

@alpergundogdu

Gap

ADR 003 §Events defines events for every channel state transition except opening:

  • ChannelCloseInitiated (indexed initiator)
  • ChannelDisputed (indexed disputor)
  • ChannelSettled (indexed provider)
  • ChannelToppedUp
  • ChannelExpiredReclaimed (indexed client)
  • ADR 010 ChannelForceClosedByTokenRemoval (indexed token, caller)

There is no ChannelOpened event. A channel that has been opened but never had any subsequent action (no closeChannel, no topUp, no dispute) is invisible to log scans.

Why this matters

A client (or provider) cannot enumerate their own open channels:

  • getChannel(channelId) works only if you already know the channelId.
  • clientChannelNonce[client] tells you how many channels the client opened in total, but not which (provider, token) pairs they paired with.
  • The ID formula keccak256(client, provider, [token,] channelNonce) is deterministic, but reconstructing channelIds requires knowing the (provider, token) inputs — not stored on-chain.
  • Log scans by client topic miss any channel that's never been touched after open.

The only enumeration path today: walk every `openChannel` transaction sent from the client's address via archive RPC, decode calldata, compute channelIds, cross-reference each against `getChannel(id)`. Heavy, requires full archive RPC, and breaks for clients using smart accounts where the `from` is the bundler/EntryPoint, not the channel client.

Affected use cases

  • Wallet UIs — "show me my open channels and their balances"
  • CLI tools — close-stuck-channel utilities, especially after a node fails (see #423 / #424 for the symmetric zero-voucher close that makes recovery operationally useful)
  • Off-chain accountants / dashboards — "how much USDC do I have locked in channels right now"
  • Indexers / subgraphs — would have to scan transaction calldata rather than logs, which is fundamentally heavier
  • Watchtower-class fraud detectors (appendix-fraud-detection.md) — third parties watching the chain to detect stale closes have no way to know about a channel until something happens to it

Proposed fix

Add a single event to the ADR 003 §Events table and to the contract spec:

```solidity
event ChannelOpened(
bytes32 indexed channelId,
address indexed client,
address indexed provider,
address token, // zero address = USDC in PoC; explicit for ADR 010 multi-token
uint256 deposit,
uint64 expiresAt
);
```

Three indexed fields — the EVM maximum — covers the natural query patterns:

  • `topics=[ChannelOpened, *, paddedClient]` → all channels for a client
  • `topics=[ChannelOpened, *, *, paddedProvider]` → all channels for a provider
  • `topics=[ChannelOpened, paddedChannelId]` → the specific channel (redundant with `getChannel` but useful in receipts)

Emitted at the end of `openChannel`, after `safeTransferFrom` and channel struct write.

Cost

One `LOG3` opcode per `openChannel`. EVM gas: `375 + 8 × len(non-indexed-data)`. Non-indexed data is (`address token, uint256 deposit, uint64 expiresAt`) ≈ 96 bytes → ~1,150 gas total. Negligible relative to the `SSTORE` and `safeTransferFrom` already in the function (~80k gas).

Alternatives

Option Verdict
Status quo: enumerate via tx-history archive scans Heavy; breaks under smart-account abstraction; relies on archive RPC
Status quo: subgraph parsing calldata Possible but fundamentally heavier than log-based; subgraph maintainer overhead
Add an enumerable mapping (mapping(address => EnumerableSet<bytes32>) clientChannels) Storage cost on every open + delete on every close; ~$0.05+ extra gas per call. Heavier than necessary when an event suffices
Add ChannelOpened event Trivial contract change; standard Ethereum pattern; ~1,150 gas per open

Refs

  • ADR 003 §Events
  • ADR 010 §forceCloseChannel — explicitly cites "callers (governance bots, channel parties) provide the channel ID" as the design preference, but assumes callers have the channelId from somewhere
  • ADR 016 §Off-Chain Read API — has bootstrap views for StakingRegistry but nothing for channel enumeration
  • #423 / #424 — symmetric zero-voucher close depends on clients being able to find their channels first

Origin

Surfaced while sketching a `decdn channel list` / `decdn channel close` CLI shape in service of operationalising #424.

Activity

  1. added
    design:missing-decision
    design:adr
    prio:medium
    on May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

design:adrdesign:missing-decisionprio:medium

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions