-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
localchans: recreate missing edge if not found #8805
localchans: recreate missing edge if not found #8805
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
6a4c3af
to
923c139
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept Ack - if we decide to do this, we should at least add a new flag in updatechanpolicy
cli and RPC to let the user choose to re-create the missing edge policies or not.
Release notes need to be moved to the |
Maybe it's related to this? |
Hmm I don't think so, not having the edge available means somehow that our own |
Concept Ack from my side as well, I think it's the best way to fix broken channels suffering from the |
5f0672d
to
82374e5
Compare
Sorry for letting this sit for so long. Updated with your feedback now @yyforyongyu |
82374e5
to
ef7a4e0
Compare
routing/localchans/manager.go
Outdated
@@ -180,6 +216,87 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy, | |||
return failedUpdates, nil | |||
} | |||
|
|||
// createEdge recreates an edge and policy from an open channel in-memory. | |||
func (r *Manager) createEdge(channel *channeldb.OpenChannel) ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to have a unit test for this - meanwhile have you tested this cli out locally? Think it's not suitable for itest as it's hard to create this edge case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll cook a test.
I haven't tested this out yet, I was really looking for your review here before we deploy this in production (which is where the issue occurs), but we'll do that once we reach a consensus about the solution here.
what about passing the graph db as a config to the It's a mitigation to a unknown bug anyways which we will find as soon as we improved logging in the gossiper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah PropagateChanPolicyUpdate
will give ErrEdgeNotFound
since the policy is not there yet. I think it's easier to fix it this way,
diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go
index 930b4c96b..ed5de6764 100644
--- a/routing/localchans/manager.go
+++ b/routing/localchans/manager.go
@@ -40,6 +40,8 @@ type Manager struct {
FetchChannel func(tx kvdb.RTx, chanPoint wire.OutPoint) (
*channeldb.OpenChannel, error)
+ AddEdge func(edge *models.ChannelEdgeInfo) error
+
// policyUpdateLock ensures that the database and the link do not fall
// out of sync if there are concurrent fee update calls. Without it,
// there is a chance that policy A updates the database, then policy B
diff --git a/server.go b/server.go
index 84a0ceaa7..215e424c3 100644
--- a/server.go
+++ b/server.go
@@ -1056,6 +1056,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
PropagateChanPolicyUpdate: s.authGossiper.PropagateChanPolicyUpdate,
UpdateForwardingPolicies: s.htlcSwitch.UpdateForwardingPolicies,
FetchChannel: s.chanStateDB.FetchChannel,
+ AddEdge: func(edge *models.ChannelEdgeInfo) error {
+ return s.chanRouter.AddEdge(edge, nil)
+ },
}
utxnStore, err := contractcourt.NewNurseryStore(
ef7a4e0
to
6c5e7e9
Compare
Handled most comments. Still have to create a test. |
443e287
to
dd99a51
Compare
Added a test for createEdge |
dd99a51
to
bc883b4
Compare
Now also added a test to the UpdatePolicy function |
If a node contains a channel, but doesn't have a corresponding edge in the graph database, updating the channel policy would fail. In this commit the edge is recreated if the channel exists. This ensures a node can recover from a missing edge in the graph database by calling updatechanpolicy.
a3e6c86
to
4e6554b
Compare
Added comments that the |
This is a robustness option to ensure LND doesn't crash when this function is accidentally called with `AddChannelEdge(edge, nil)`.
4e6554b
to
20f7c73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, then think it's good to go!
Ok let's not change too much right now let's do the following:
We now check the policy so I don't think there is a need for the above. Then we should be good to go |
I undid the tryout commit.
This we can't do, because that wouldn't update the edge outside the
So this basically means revert commit 7d9d100 correct? That would also address this comment: |
I am not sure I understand, I am talking about the |
Ahh I see, I didn't get that. It's no longer needed to return the edge at all if So revert 7d9d100 If you agree, I'll do that. |
ahh ok yeah let's do that then and we should be good to go. |
yes but I think we don't want this in the reverted commit:
|
I think I made a commit that puts everything together now.
|
6f2d8ca
to
2665312
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⚡️, thank you for your patience while working on this PR. Tested locally via a customized DB, works as expected.
In case you wanna verify (that the whole regtest setup with the missing edge): how it looks like from the cli level:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM🚢
Change Description
Description of change / link to associated issue.If a node contains a channel, but doesn't have a corresponding edge in the graph database, updating the channel policy would fail. In this commit the edge is recreated if the channel exists. This ensures a node can recover from a missing edge in the graph database by calling
updatechanpolicy
.Alternative for #8768, namely option 2 in #8768 (comment)
Partially fixes #7261 by allowing to recreate the edge by calling
updatechanpolicy
.Steps to Test
I'm not sure how to create an integration test where I can modify the graph database to delete an edge in order to test this. Please advise.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.