peer_control: Make close wait for complete closure, with timeout. - #1355
Conversation
|
This closely mirrors my https://github.com/rustyrussell/lightning/tree/guilt/remove-dev-fail branch which I obviously forgot to put a PR in for! But yours is better anyway... I avoided putting in a timeout for simplicity, but OTOH you return more information from close, which is nice but makes the timeout a necessity. You're clearly not from Australia though, because 2 seconds is grossly insufficient as a default :) You also force a connection initiation to the peer, which is nice. And wrote the man page! Can I ask you to cherry-pick commits or steal stuff as appropriate from my branch? |
I am also obviously not an embedded semi-independent agent in an AI agent network sharing computational and network resources with other competing and cooperating knowledge agents, especially since 2 seconds would also be grossly insufficient as a default in that situation. What would be a plausible default for a human being in Australia?
Okay, I shall check. There are no useful tests for the new closing functionality in particular, so if I see any tests I will steal them. |
|
30 seconds seems to be the modern default. |
49e5829 to
2e77181
Compare
|
Rebased, changed timeout to 30 seconds, added some code from @rustyrussell , please review again. |
451112d to
31850c3
Compare
cdecker
left a comment
There was a problem hiding this comment.
Just some minor things that are a bit off.
| Normally the peer needs to be live and connected in order to negotiate | ||
| a bilateral close. | ||
| Forcing a unilateral close can be used if you suspect you can no longer | ||
| access the peer. |
| On success, an object with fields 'tx' and 'txid' containing the | ||
| closing transaction are returned. | ||
| It will also have a field 'type' which is either the JSON string | ||
| 'bilateral' or the JSON string 'unilateral'. |
There was a problem hiding this comment.
I usually use collaborative close to describe the bilateral close, which is a bit nicer. The spec talks about a "mutual close" or "cooperative close" which is also slightly nicer than bilateral (and you use cooperative in the code later).
There was a problem hiding this comment.
Hmm. Grepping lightning-rfc:
- cooperative: 1 time, in 00-introduction.md
- bilateral: 0 times, ha
- mutual: many times, in 00-introduction.md, 02-peer-protocol.md, 05-onchain.md
Perhaps we should go with 'mutual' instead, as that seems to be the preferred term in the RFC. Note that the BOLT spec uses 'mutual' and 'unilateral'.
| #include <wire/gen_onion_wire.h> | ||
|
|
||
| struct close_command { | ||
| /* Off struct lightningd close_commands. */ |
| cc->channel = NULL; | ||
| command_fail(cc->cmd, "Channel forgotten before proper close."); | ||
| } | ||
| /* Destroy the close command structure. */ |
There was a problem hiding this comment.
Nit: one empty line between functions.
|
|
||
| # Close the channel to forget the peer | ||
| l1.rpc.close(l2.info['id']) | ||
| self.assertRaisesRegex(ValueError, |
There was a problem hiding this comment.
I don't understand why now all of these closes fail in the integration tests. Aren't these supposed to be collaborative closes? The 0 timeout everywhere is a bit excessive IMHO
There was a problem hiding this comment.
The tests assume that close does not wait for the close to complete. This PR makes close wait either for the timeout or the close to complete; to emulate the old behavior we set timeout to 0 and let the command fail due to timeout. Otherwise I would have to check each instance of .rpc.close to see if I can remove the wait_for_logs afterwards or if they scan for something more substantial than bilateral close. Being lazy. I shall see if they will still work properly if I make them wait.
There was a problem hiding this comment.
Well, ok, we should slowly make these closes normal again though (noting this for my cleanup queue).
There was a problem hiding this comment.
Yes, you should have put a FIXME above each of these!
| struct short_channel_id *scid; | ||
|
|
||
| /* Closing txid, for reporting to JSON */ | ||
| struct bitcoin_txid *closing_txid; |
There was a problem hiding this comment.
This field will not be repopulated when restarting / loading from DB, could that lead us into an inconsistent behavior? Before restart we show the closing_txid after the restart we lose that. If we broadcast the transaction we'll have it in the transactions table btw.
ff7c19b to
602bee5
Compare
|
Rebased, fixed nits. Removed |
|
Thanks @ZmnSCPxj, I oversaw the removal of dev-fail by @rustyrussell, which I think is a bit eager. Forced closes do have the side effect of potentially sending close messages to the peer, which might not be desired in the test cases, so maybe we should keep dev-fail for integration tests? |
|
Okay, I will remove that commit that removes |
Also report tx and txid, and whether we closed unilaterally or bilaterally, if we could close the channel. Also make a manpage. Fixes: ElementsProject#1207 Fixes: ElementsProject#714 Fixes: ElementsProject#622
It should, indeed, close once they reconnect. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
d3b03a1 to
28868b8
Compare
|
Just kicked Travis, let's see if the failure was a flake. Edit: I'm afraid it failed again, did something change with that test? It seems to get hung up on |
|
Well, I notice that the retry system does not seem to work well with this particular test, sigh. |
|
Can you teach me how to remove the rerunfailures? I tried, to run without rerunfailures, as I suspect that an earlier run will show the root cause, and rerunfailures does not completely clear the test environment, so that reruns will fail for spurious reason once the first run fails for the real reason. I tried removing the rerunfailures here: ZmnSCPxj@b8925ff but the CI still runs it with rerun. Hmm.... |
|
Increasing the timeouts for closing in the |
|
That's good news, any reason for it being 72? We can probably just overshoot and say 100 seconds, just to be safe. |
|
And to answer your question: rerunfailures is enabled automagically on Travis using the following lines in the Makefile: Lines 43 to 47 in 774af5f So if you set |
|
I also missed this comment:
We are now storing all transactions that we broadcast or that we watched in the |
|
We already store |
|
|
||
| # Close the channel to forget the peer | ||
| l1.rpc.close(l2.info['id']) | ||
| self.assertRaisesRegex(ValueError, |
There was a problem hiding this comment.
Yes, you should have put a FIXME above each of these!
Also report tx and txid, and whether we closed unilaterally or
bilaterally, if we could close the channel.
Also make a manpage.
Fixes: #1207
Fixes: #714
Fixes: #622