Skip to content

funding: fix flake in itest caused by persistent fee param changes#7648

Merged
guggero merged 15 commits intolightningnetwork:masterfrom
guggero:initial-forwarding-policy
Aug 22, 2023
Merged

funding: fix flake in itest caused by persistent fee param changes#7648
guggero merged 15 commits intolightningnetwork:masterfrom
guggero:initial-forwarding-policy

Conversation

@guggero
Copy link
Copy Markdown
Collaborator

@guggero guggero commented Apr 28, 2023

Partially reverts changes of #7597, in order to fix an itest flake.

Copy link
Copy Markdown
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Very nice 🔥 i've never seen the funlen linter get triggered 😂 I think this is an OK place to put a nolint though

@guggero guggero force-pushed the initial-forwarding-policy branch from 25e7f1e to ea942f1 Compare April 28, 2023 17:53
@guggero guggero requested a review from yyforyongyu April 28, 2023 17:53
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented Apr 28, 2023

Looks like I broke something in a different itest. Will take a look on Monday.

@guggero guggero force-pushed the initial-forwarding-policy branch from ea942f1 to 080f6f2 Compare May 8, 2023 12:11
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented May 8, 2023

Looks like I broke something in a different itest. Will take a look on Monday.

Looks to have been flakes, looks better after a rebase.

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Looks to have been flakes, looks better after a rebase

Confirm they are flakes. Need to seriously fix it now as it seems to be the only one🧐 will check it later this week.

@guggero guggero force-pushed the initial-forwarding-policy branch from 080f6f2 to 908c33f Compare May 11, 2023 13:13
@guggero guggero requested a review from yyforyongyu May 11, 2023 13:15
@guggero guggero force-pushed the initial-forwarding-policy branch from 908c33f to 703b972 Compare May 26, 2023 09:36
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented May 26, 2023

@yyforyongyu there's still a bug in the unit test that I need to fix, so not ready for full review. But could you please quickly check if this new approach is more in line with what you had in mind?

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

But could you please quickly check if this new approach is more in line with what you had in mind?

Yes I like it! Thanks🙏

@guggero guggero force-pushed the initial-forwarding-policy branch from 703b972 to d66212f Compare June 14, 2023 13:44
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented Jun 14, 2023

@yyforyongyu I found the unit test flake, was just a timing issue. So this PR is now ready for full review.
@ellemouton I'm re-requesting review from you as well, since quite a few things changed in the meantime.

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Nice refactor🙏 And love how the build looks✅✅✅

Meanwhile I think we should save the policy to disk in handleFundingSigned for funder's side and handleFundingCreated in fundee's side, and only do them there in case anything goes wrong in the previous steps of the funding flow.

Also we should delete the saved policy when funding flow failed.

I don't think these are introduced in this PR tho, but need to be fixed nevertheless.

@yyforyongyu
Copy link
Copy Markdown
Member

A second thought is we can go with this one and create a new PR to fix issues around saving and deleting policies. Btw I think this one needs to be in 0.17 so we can have a clean build for other PRs cc @saubyk

@saubyk saubyk added this to the v0.17.0 milestone Jun 16, 2023
@saubyk
Copy link
Copy Markdown
Collaborator

saubyk commented Jun 16, 2023

tagged for 0.17.0

@saubyk saubyk modified the milestones: v0.17.0, v0.17.1 Jul 11, 2023
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@ellemouton: review reminder
@guggero, remember to re-request review from reviewers when ready

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Can we rebase to run the test again? I think the current failure might be fixed by #7518

Since the actual wallet backends might be different between the wallet
DB and the actual channel state DB, we pass in the correct struct to the
funding manager.
This will allow us to also set the TimeLockDelta and HTLC settings
when creating the channel. We leave the actual implementation of
the RPC and CLI changes to another PR, this is just to make
things more consistent.
@guggero guggero force-pushed the initial-forwarding-policy branch from fc8cd75 to bc27da0 Compare August 18, 2023 07:44
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented Aug 18, 2023

Rebased. Wasn't able to reproduce the Neutrino flake on my machine. Let's see how it looks now.

@yyforyongyu yyforyongyu force-pushed the initial-forwarding-policy branch from bc27da0 to ca4c16e Compare August 22, 2023 00:19
This commit moves the deletion of the initial forwarding policy to the
end of `stateStep` to make sure the router has persisted it to disk
before the deletion.
@yyforyongyu yyforyongyu force-pushed the initial-forwarding-policy branch from ca4c16e to 605062a Compare August 22, 2023 00:22
This commit is a pure code move. We add a new method
`handleChannelReadyReceived` to handle the channel's state change after
the remote's channel ready message is received.
There is a race condition,
- goroutine_1: performing `stateStep` under `channelReadySent`. Once
  `receivedChannelReady` returns true, it will mark the channel state as
  `addedToRouterGraph`, which will delete the initial forwarding policy
  for private channels.
- goroutine_2: performing `handleChannelReady`, which processes the
  remote's channelReady message. It will ask brontide to `AddNewChannel`
  in the end.
- goroutine_3: performing `handleNewActiveChannel` in brontide, which
  will query the initial forwarding policy and fail to find it because
  it's already deleted in goroutine_1.

To fix it, we require `receivedChannelReady` to also check that the
channel's barrier signal in the map `handleChannelReadyBarriers` doesn't
exist, as this signal is removed once `handleChannelReady` finishes
adding the channel in brontide.
@yyforyongyu yyforyongyu force-pushed the initial-forwarding-policy branch from 605062a to 61ea29a Compare August 22, 2023 02:26
@yyforyongyu yyforyongyu force-pushed the initial-forwarding-policy branch from 61ea29a to 6820b08 Compare August 22, 2023 03:10
Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM🤓

Copy link
Copy Markdown
Collaborator Author

@guggero guggero left a comment

Choose a reason for hiding this comment

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

I can't approve my own PR, but I'm leaving an explicit "LGTM 🎉" here since @yyforyongyu added some commits to it (thank you very much and great find with the barrier!).

@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented Aug 22, 2023

@ellemouton this is ready for a final review, thanks!

Copy link
Copy Markdown
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Very nice fix 🔥 LGTM!

return "markedOpen"
case channelReadySent:
return "channelReady"
return "channelReadySent"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -3070,14 +3070,27 @@ func (f *Manager) receivedChannelReady(node *btcec.PublicKey,
return false, err
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

really helpful commit message - thanks! 🙏

@guggero guggero merged commit e49f6fc into lightningnetwork:master Aug 22, 2023
@guggero guggero deleted the initial-forwarding-policy branch August 22, 2023 13:15
@saubyk saubyk added this to the v0.17.0 milestone Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog P1 MUST be fixed or reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants