lnpeer: add comment to on_channel_reestablish re blocking
In particular, lnd sends both chan_reest and then an error ("sync error").
It is critical we process the chan_reest and transition to WE_ARE_TOXIC before
processing the error (which would trigger us to force-close).
see spec 8a64c6a1ce/02-peer-protocol.md (L1504-L1506) :
> - upon reconnection:
> [...]
> - MUST transmit channel_reestablish for each channel.
> - MUST wait to receive the other node's channel_reestablish message before sending any other messages for that channel.
This commit is contained in:
@@ -1148,6 +1148,10 @@ class Peer(Logger):
|
||||
f"but close option is not allowed. {chan.get_state()=!r}")
|
||||
|
||||
def on_channel_reestablish(self, chan: Channel, msg):
|
||||
# Note: it is critical for this message handler to block processing of further messages,
|
||||
# until this msg is processed. If we are behind (lost state), and send chan_reest to the remote,
|
||||
# when the remote realizes we are behind, they might send an "error" message - but the spec mandates
|
||||
# they send chan_reest first. If we processed the error first, we might force-close and lose money!
|
||||
their_next_local_ctn = msg["next_commitment_number"]
|
||||
their_oldest_unrevoked_remote_ctn = msg["next_revocation_number"]
|
||||
their_local_pcp = msg.get("my_current_per_commitment_point")
|
||||
|
||||
Reference in New Issue
Block a user