Repository navigation
Conversation
753acf6 to
b44be37
Compare
NishantBansal2003
left a comment
There was a problem hiding this comment.
I think this needs to be rebased on top of #162 to consume the affine type SentShutdown
morehouse
left a comment
There was a problem hiding this comment.
I think we want the affine type wired in for sure.
But that probably isn't enough -- we can't expect the target to send us a shutdown message until all HTLCs have been resolved as well. There's also probably a case where we could send two shutdown messages and the target may ignore any of them after the first one.
I think for the HTLCs we can't really implement that part until #111 is implemented, so we can just add a TODO for that.
For the duplicate shutdown case we could probably add a flag to the channel state that indicates whether the peer has already responded to the first shutdown, and if they have then any subsequent RecvShutdown message becomes a no-op (similar to RecvChannelReady).
b44be37 to
7c5f9fc
Compare
bc867ba to
77cf4f8
Compare
Added TODOs in 77cf4f8. I thought it would be useful to group all HTLC TODOs together with
We now check in 77cf4f8 if we expect a shutdown on any channel. Only then we wait for a shutdown response. We don't know on which channel we will receive a shutdown, but I could change TODO:
Mhh, I wonder if there's a conflict between this (#163 (comment)):
and this (#163 (review)):
In 77cf4f8, |
2a50e89 to
d083969
Compare
I forgot tests for |
f399f63 to
74b38b0
Compare
|
This is ready for review now. I'm working on a new PR with a |
|
This PR has grown a bit. @ekzyis would it be possible to split this into smaller PRs? Perhaps something like this:
|
74b38b0 to
fd0bbbb
Compare
|
fd0bbbb: rebased on master (dc2ef28) and only includes the new FYI, this question in #163 (comment) is still open for me:
But I think it's more relevant when we start consuming the output of |
fd0bbbb to
8d65b49
Compare
|
8d65b49: add |
| /// `shutdown` has been sent, so the counterparty's `shutdown` may now be | ||
| /// received. | ||
| SentShutdown, | ||
| SentShutdown(Shutdown), |
There was a problem hiding this comment.
This is the first affine variable to contain actual data, and I don't think we really need to do this.
We could make RecvShutdown like RecvChannelReady and record our shutdown script in the channel state when we send shutdown. Then no matter which shutdown we get a response for, we can look it's channel up in the channel state to get our script.
There was a problem hiding this comment.
The affine variable SentShutdown no longer contains any data in 677a7a6. We record the shutdown scripts we send and receive in our channel state now. RecvShutdown reads replies from there.
However, I did take this part less literally, though:
no matter which
shutdownwe get a response for, we can look its channel up in the channel state
I decided to include ChannelId as an input to RecvShutdown. If RecvShutdown doesn't know for which channel we want to receive shutdown and we expect shutdown on multiple channels, it wasn't clear to me which shutdown script RecvShutdown should return. That's the difference to RecvChannelReady: it has no output that depends on the channel.
I considered recording the timestamps of received shutdown messages to then always return the latest received shutdown script, but it seemed flawed compared to adding ChannelId to RecvShutdown. It would be more code to come up with some reasonable order for RecvShutdown and shutdown messages to deal with an issue in a less obvious way. WDYT?
|
@morehouse I'll get back to you on this once I've prepared my workshop for TABConf (TABConf/8.tabconf.com#10). Maybe I can include eclair nodes with the recently disclosed vulnerabilities to warnet. |
8d65b49 to
677a7a6
Compare
|
677a7a6: addressed feedback (see replies) and updated commit message + PR description |
677a7a6 to
20ac848
Compare
|
20ac848: revert changes to |
20ac848 to
6bdc2ea
Compare
|
6bdc2ea to
09799ed
Compare
|
RecvShutdown consumes the SentShutdown of a previous SendShutdown and waits for the target's `shutdown` on the given channel. It returns that channel's scriptpubkey, or empty bytes if no `shutdown` was received. The target can send `shutdown` at any time and on any channel, so a received one is recorded into its channel's state like `channel_ready`, and explicit receives skip past it instead of failing. SendShutdown records the script we sent, which is what makes a reply expected there, and RecvShutdown reads the reply from channel state, so one recorded before it ran is reported just the same. BOLT 2 lets the target warn about a non-standard scriptpubkey instead of replying, but every implementation except LDK disconnects afterwards and LDK acts as if the `shutdown` never came, so a warning just ends execution like any other unexpected message. A target that has not sent `channel_ready` may ignore our `shutdown`, so RecvShutdown is a no-op until it has. That gives up coverage of targets which do reply before then, in exchange for not spending a receive timeout on every target which doesn't.
09799ed to
ce9d13d
Compare
|
ce9d13d: rebased on master |
This implements the
RecvShutdownoperation for #98.