ElementsProject / ElementsProject/lightning
Channel-scoped error can be lost while channeld exits
- Dominant language
- C
- Stars
- 3.1k
- Forks
- 1k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 13
Description
On master `f80895bac`, `channeld` sent a warning through `peer_failed_warn_nodisconnect` and began exiting. `connectd` then decrypted the peer's channel-scoped `WIRE_ERROR` and queued it to that subdaemon after `lightningd` had begun killing it. `channeld` never received the error, so the channel remained open.
BOLT #1 requires a receiving node, upon receiving a channel-scoped `error`, to:
> _MUST fail the channel referred to by `channel_id`, if that channel is with the sending node._
[BOLT #1 requirements](https://github.com/lightning/bolts/blob/35e79db504560b9d3494a0ed07bf1e8379c3663a/01-messaging.md#L393-L403)
Forwarding `WIRE_ERROR` directly from `connectd` to `lightningd` when a matching subdaemon exists fixes the race. End-to-end regtest validation confirmed that `lightningd` failed the channel, and broadcasted the commitment:
```diff
diff --git a/connectd/multiplex.c b/connectd/multiplex.c
index 1051645f..696e9e1b 100644
--- a/connectd/multiplex.c
+++ b/connectd/multiplex.c
@@ -1493,6 +1493,15 @@ static struct io_plan *read_body_from_peer_done(struct io_conn *peer_conn,
/* If we don't find a subdaemon for this, create a new one. */
subd = find_subd(peer, &channel_id);
+ if (subd && type == WIRE_ERROR) {
+ daemon_conn_send(peer->daemon->master,
+ take(towire_connectd_peer_spoke(NULL, &peer->id,
+ peer->counter,
+ type,
+ &channel_id,
+ is_peer_error(tmpctx, decrypted))));
+ return next_read(peer_conn, peer);
+ }
if (!subd) {
enum peer_wire t = fromwire_peektype(decrypted);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.