Skip to content
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

Remove watch-confirmed with depth 0 in zero-conf #2310

Merged
merged 6 commits into from
Jun 13, 2022

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Jun 10, 2022

This is a PR on #2224, best reviewed commit-by-commit.

The first commit contains only some clean-up and nits.

The second commit removes the use a depth 0 watch-confirmed (which is quite hacky) and instead skips the WAIT_FOR_FUNDING_CONFIRMED state entirely, which fits better with our model, at the cost of duplication a few lines of code (which we could refactor to a dedicated function, but I'd rather have them explicitly in each event handlers as they vary slightly depending on the case).

The third commit contains a few small changes to Validation.scala. The most important change is that we lost a call to updateBalances in #2224 by moving the initialization of private channels in the handler of ShortChannelIdAssigned, which we restore in handleLocalChannelUpdate, otherwise path-finding would ignore all newly created channels.

@t-bast t-bast requested a review from pm47 June 10, 2022 08:53
@t-bast t-bast force-pushed the zeroconf-scid-alias-bast branch from dbfbd72 to 869175b Compare June 13, 2022 07:19
@t-bast
Copy link
Member Author

t-bast commented Jun 13, 2022

@pm47 rebased on the latest push of #2224

@t-bast
Copy link
Member Author

t-bast commented Jun 13, 2022

Some tests aren't passing, but they're actually broken on the #2224 branch (where the CI hasn't run, probably because of the noci flag in some commits). We should merge this to #2224 and then fix the tests in an additional commit.

@pm47 pm47 force-pushed the zeroconf-scid-alias branch from da46456 to c20f672 Compare June 13, 2022 11:51
@t-bast t-bast force-pushed the zeroconf-scid-alias-bast branch 2 times, most recently from a33b5a8 to de53949 Compare June 13, 2022 12:20
t-bast added 3 commits June 13, 2022 14:35
Instead of using a watch with minDepth=0, we can directly skip the
wait_for_funding_confirmed state when using 0-conf, which is less hacky.
* Small refactorings and typos.
* Remove a few redundant changes.
* Ensure that the balance is correctly initialized for new channels,
  otherwise they would be ignored during path-finding
@t-bast t-bast force-pushed the zeroconf-scid-alias-bast branch from de53949 to d9ec2b1 Compare June 13, 2022 12:35
Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change 👍

log.info(s"committing txid=${fundingTx.txid}")
goto(WAIT_FOR_FUNDING_CONFIRMED) using DATA_WAIT_FOR_FUNDING_CONFIRMED(commitments, Some(fundingTx), blockHeight, None, Left(fundingCreated)) storing() calling publishFundingTx()
case None =>
blockchain ! WatchFundingLost(self, commitments.commitInput.outPoint.txid, nodeParams.channelConf.minDepthBlocks)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think that not implementing WatchFundingLost is more questionable with zero-conf.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! It would be useful to implement it in a follow-up PR.

Comment on lines 333 to 335
val channelKeyPath = keyManager.keyPath(commitments.localParams, commitments.channelConfig)
val nextPerCommitmentPoint = keyManager.commitmentPoint(channelKeyPath, 1)
val shortIds = ShortIds(RealScidStatus.Unknown, ShortChannelId.generateLocalAlias(), None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add those to DATA_WAIT_FOR_FUNDING_CONFIRMED and reduce the diff between the two code paths.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would create an issue when migrating old versions of DATA_WAIT_FOR_FUNDING_CONFIRMED, because we don't have an scid there to use in the alias field and we're not sure the alias generation function will be suitable to call during DB migration.

I instead refactored that code to a single function that is called in all three places where we do 0-conf in fcb0fe4

Copy link
Member

@pm47 pm47 Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went a bit further in branch zeroconf-scid-alias-bast-factor and factored in the 3rd transition. The semantics of skipFundingConfirmation changes to acceptFundingTx.

In a second commit I removed the "optimization" that makes us eagerly process remote's alias to emit less events. I think it's not worth it considering how it complicates the method signature.

@t-bast t-bast merged commit 79ef2c3 into zeroconf-scid-alias Jun 13, 2022
@t-bast t-bast deleted the zeroconf-scid-alias-bast branch June 13, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants