[anchor commitment] Make the anchor commitment type spec compliant#4558
Conversation
cfromknecht
left a comment
There was a problem hiding this comment.
first pass looks good
There was a problem hiding this comment.
possible underflow, here and below
There was a problem hiding this comment.
Pre-existing, but I think it is safe to add the extra check: ca22db6
There was a problem hiding this comment.
can be simplified with +=
There was a problem hiding this comment.
maybe coopCloseFee + commitFee + anchorValue can be extracted to prevent a future bug where only one is updated
There was a problem hiding this comment.
preexisting: help message is a little misleading. it will work with watchtowers, but state updates for anchor channels won't be backed up. this should change before 0.12 though with anchor tower support in the works
joostjager
left a comment
There was a problem hiding this comment.
LGTM. Tested on regtest and inspected coop close tx. Anchor value is indeed added back to the initiator balance. Two questions:
- Did you (manually) test coop closing an old-format anchor channel?
- Is the itest coop closing with anchors anywhere?
There was a problem hiding this comment.
maybe coopCloseFee + commitFee + anchorValue can be extracted to prevent a future bug where only one is updated
Do you mean one node running the updated code, one node running the old code? If yes, then I tried this in one of the integration tests, and closing expectedly failed.
Yes, most tests using anchors are closing the channel at the end, most notably the |
|
@halseth looks good, can squash now |
There was a problem hiding this comment.
Make clear in a comment that this is a sanity check and not supposed to be hit?
|
Squashed and rebased. Removed the commit making anchors non-experimental as discussed, such that they are still behind a build tag. |
|
@halseth appears related to newly added underflow check |
Fixed! |
|
|
@cfromknecht Should be good now. |
To be spec compliant, we require the initiator to not pay the anchor values into fees on coop close. We extract the balance calculation into commitment.go, and add back the value of the anchors to the initiator's balance.
Also modify the test to check for this condition.
1ea3da2 to
bf18929
Compare
This PR makes the necessary changes to the anchor commitment type to make it compliant with the final spec version as defined in lightning/bolts#688
There are two changes needed:
20/21. This means that we now require this bit to be advertised to signal anchor support. The old bit will be ignored by new nodes.NOTE: Watchtowers are still not supported for anchor commitment types, and anchor support is not advertised by default but must be enabled through the
--protocol.anchorsoption.