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

funding: use default forwarding policy if persisted values not found #7613

Merged

Conversation

ellemouton
Copy link
Collaborator

In this commit, a bug is fixed in the funding manager that could result in the funding process erroring out if the persisted initial forwarding policy is not found. This could occur if a node restarts after opening a channel that is not yet fully confirmed and also upgrades their node from a pre-0.16 version to 0.16 since the values are only expected to be persisted after 0.16 (which includes the changes made in #6753).

This addresses the issue reported in this comment

Copy link
Collaborator

@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.

Nice fix, LGTM 🎉

@guggero guggero added this to the v0.16.1 milestone Apr 19, 2023
@ziggie1984
Copy link
Collaborator

Quick Fix 🥳, wondering why the initial fwd-policy was not populated, isn't is set in the Funding Workflow and also persist in the database before 0.16 ?

Copy link
Collaborator

@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.

Very quick fix🤙 While this works, my main question is, how can we distinguish the two cases,

  • the policy is not found due to the upgrade,
  • the policy is not found due to other bugs

In a hindsight, I think #6753 is missing a migration, which is the proper way to fix this.

storedFwdingPolicy, err := f.getInitialFwdingPolicy(chanID)
if err != nil {
return nil, errors.Errorf("unable to generate channel "+
"update announcement: %v", err)
log.Errorf("No initial forwarding policy found for "+
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to do a more strict check against ErrChannelNotFound to make sure it's a not found error, tho that's the only error that could ever be returned from getInitialFwdingPolicy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated!

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm still have the question re how to distinguish the two cases tho. Is it too late to add a migration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok gotcha - I understand now.

The tricky part is passing the Default Forwarding Policy into the migration... gotta do some weird config passing again... will try 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok mostly there - just need to touch up a few things and clean it up . Will do it first thing tomorrow. Worth noting that it is quite more involved than this approach but agreed that it is better 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

But what exactly would we migrate? Before 0.16 you cannot set custom forwarding policies, so there is no data to migrate. All we have to make sure is that the parent bucket for these keys exist (which is probably already done) and that we fall back to a default policy if we don't have custom forwarding policies stored.

@ziggie1984
Copy link
Collaborator

ohh you cleared it up for me @yyforyongyu, my vscode was kind of showing that this part was 12 months old commit lol, that's why I thought the fwd-history bucket was also there before 0.16, but it was not.

In this commit, a bug is fixed in the funding manager that could result
in the funding process erroring out if the persisted initial forwarding
policy is not found. This could occur if a node restarts after opening a
channel that is not yet fully confirmed and also upgrades their node
from a pre-0.16 version to 0.16 since the values are only expected to be
persisted after 0.16.
@positiveblue
Copy link
Collaborator

Thank you for fixing this @ellemouton

My fault, I did mention that we needed to take care of this edge case in the PR and then we added the default entry in the branch but I did not noticed that it would return an error and never hit the switch 👎

We also need to also catch the same error when deleting the InitialFwdingPolicy

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🐟

@Roasbeef Roasbeef merged commit d908bec into lightningnetwork:master Apr 19, 2023
19 of 23 checks passed
positiveblue added a commit to positiveblue/lnd that referenced this pull request Apr 19, 2023
In lightningnetwork#6753 we added support to custom base and fee rate fees when opening a
channel. Since v0.16.0 all channels store their initial fwdPolicy even
if they are using the default values. However, there is an edge case
where a channel is open before migrating to >v0.16.0 but updating to
+v0.16.0 before that channel gets confirmed.

For those cases we won't be able to retrieve/delete the initial
fwdPolicy. In that case we need to use the default values but we also
need to ensure that we do not fail when trying to read/delete the
initial fwdPolicy. lightningnetwork#7613 fixed the problem for reading, here we fix it
for deleting.
positiveblue added a commit to positiveblue/lnd that referenced this pull request Apr 19, 2023
In lightningnetwork#6753 we added support to custom base and fee rate fees when opening a
channel. Since v0.16.0 all channels store their initial fwdPolicy even
if they are using the default values. However, there is an edge case
where a channel is open before migrating to >v0.16.0 but updating to
+v0.16.0 before that channel gets confirmed.

For those cases we won't be able to retrieve/delete the initial
fwdPolicy. In that case we need to use the default values but we also
need to ensure that we do not fail when trying to read/delete the
initial fwdPolicy. lightningnetwork#7613 fixed the problem for reading, here we fix it
for deleting.
@ellemouton ellemouton deleted the fndMgrDefaultPolicyValuesFix branch April 19, 2023 20:22
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.

None yet

6 participants