-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
During close sometimes a node would broadcast the wrong transaction #3549
Comments
This |
I confirm that the following patch fixes this issue: --- i/lightningd/closing_control.c
+++ w/lightningd/closing_control.c
@@ -82,21 +89,16 @@ static bool better_closing_fee(struct lightningd *ld,
" for weight %"PRIu64" at feerate %u",
type_to_string(tmpctx, struct amount_sat, &fee),
weight, min_feerate);
return false;
}
- /* In case of a tie, prefer new over old: this covers the preference
+ /* Prefer new over old: this covers the preference
* for a mutual close over a unilateral one. */
- /* If we don't know the feerate, prefer higher fee. */
- if (feerate_unknown)
- return amount_sat_greater_eq(fee, last_fee);
-
- /* Otherwise prefer lower fee. */
- return amount_sat_less_eq(fee, last_fee);
+ return true;
}
static void peer_received_closing_signature(struct channel *channel,
const u8 *msg)
{
struct bitcoin_signature sig; Now both l1 and l2 successfully broadcast the same, identical, tx. I am not sure (yet) whether this would introduce other problems though. |
The patch looks good but the function now deserves a rename. |
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes ElementsProject#3549 Changelog-Fixed: Always broadcast the latest close tx at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial proposal.
Is Submitted the above patch + a polished test at #3556 |
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes ElementsProject#3549 Changelog-Fixed: Always broadcast the latest close tx at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial proposal.
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes ElementsProject#3549 Changelog-Fixed: Always broadcast the latest close tx at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial proposal.
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes ElementsProject#3549 Changelog-Fixed: Always broadcast the latest close tx at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial proposal.
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes ElementsProject#3549 Changelog-Fixed: Always broadcast the latest close transaction at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial closing proposal.
Ideally we'd use whatever is closer to our ideal fee. That helps if we restart negotiation. However, it's all an approximation anyway, so this is better than the prior behavior. |
Before this patch we would only update `channel->last_tx` with the newly proposed closure tx from the peer if the fee of the new one was lower. In negotiations where we are at the higher end and the peer starts lower, all peer's subsequent proposals will be higher than his initial proposal and in this case we would never update `channel->last_tx` and would wrongly broadcast his initial proposal at the end of the negotiation. Fixes #3549 Changelog-Fixed: Always broadcast the latest close transaction at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial closing proposal.
I think it now works "ideally". We have two cases:
|
Lets have two nodes l1 and l2 that go into channel closing negotiation:
This is a test case, run as
pytest tests/ -v -k test_closing_fee_negotiation_strategy -r P
:Sometimes it would print:
and sometimes:
This is because both l1 and l2 race in getting their tx broadcasted and included in bitcoind's mempool. If l1 succeeds then we get the first print, if l2 succeeds, then we get the second print. The too-late-to-broadcast node gets
txn-mempool-conflict (code 18)
from bitcoind.From the dumped l1 log (I added the trailing
(previous txid=%s)
to ensure it is the same tx):The previous transaction (
channel->last_tx
) that has fee of 2896 is never updated because all newer ones have higher fees: https://github.com/ElementsProject/lightning/blob/master/lightningd/closing_control.c#L115The text was updated successfully, but these errors were encountered: