-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lncli: add loadmc command #9781
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
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 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
// It is not allowed to import a zero-amount success to mission | ||
// control if a timestamp is set. We unset it in this case. | ||
if pair.History.SuccessTime != 0 && | ||
pair.History.SuccessAmtMsat == 0 && | ||
pair.History.SuccessAmtSat == 0 { | ||
|
||
pair.History.SuccessTime = 0 | ||
} |
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.
When testing I've seen entries like that
{
"node_from": "X",
"node_to": "Y",
"history": {
"fail_time": "1746388491",
"fail_amt_sat": "0",
"fail_amt_msat": "0",
"success_time": "1746386085",
"success_amt_sat": "0",
"success_amt_msat": "0"
}
},
which is inconsistent with what we allow to import, which is why I've added those clean-ups. See here:
lnd/lnrpc/routerrpc/router_server.go
Lines 1282 to 1286 in 334a7d1
// Return an error if it does have a timestamp without an amount, and | |
// it's not expected to be a failure. | |
case !isFailure && timeSet && !amountSet: | |
return 0, time.Time{}, errors.New("non-zero timestamp " + | |
"requires non-zero amount for success pairs") |
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.
Definitely something we need to think about and potentially removing this validation check on the server side.
// If we only deal with a failure, we need to set the failure | ||
// amount to a tiny value due to a limitation in the RPC. This | ||
// will lead to a similar penalization in pathfinding. | ||
if pair.History.SuccessTime == 0 && | ||
pair.History.FailTime != 0 && | ||
pair.History.FailAmtMsat == 0 && | ||
pair.History.FailAmtSat == 0 { | ||
|
||
pair.History.FailAmtMsat = 1 | ||
} |
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.
This is an other check we would violate with the above input.
lnd/lnrpc/routerrpc/router_server.go
Lines 1240 to 1243 in 334a7d1
if successAmt == 0 && failAmt == 0 { | |
return nil, fmt.Errorf("%v: either success or failure result "+ | |
"required", pairPrefix) | |
} |
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.
tACK, LGTM 🎉
}, | ||
cli.StringFlag{ | ||
Name: "timeoffset", | ||
Usage: "Time offset to add to all timestamps. " + |
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.
Should we explain what this is useful for?
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.
Right, added an explanation.
|
||
// We discard mission control data if requested. | ||
if ctx.Bool("discard") { | ||
if !promptForConfirmation("This will discard mission control " + |
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.
nit: add word "current" here as well: This will discard all current mission control data in the database: (yes/no)
.
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.
makes sense, done!
|
||
_, err = client.XImportMissionControl( | ||
rpcCtx, | ||
&routerrpc.XImportMissionControlRequest{ |
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.
There's also the Force
flag, not sure if that's useful to expose?
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.
Yes, good to have API feature completeness
|
||
var loadMissionControlCommand = cli.Command{ | ||
Name: "loadmc", | ||
Category: "Payments", |
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.
This should go into Mission Control
. And while we're at it, we should probably move importmc
as well to that category.
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.
Nice catch, changed it 👍
This command lets one import data exported by `lncli querymc > mc.json` via `lncli loadmc --mcdatapath mc.json`.
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,
we defintily need to take a look on the server side to understand why we are creating those 0,0 values tho. => maybe create an issue so we do not forget it.
Name: "loadmc", | ||
Category: "Mission Control", | ||
Usage: "Load mission control results to the internal mission " + | ||
"control state from a file produced by querymc with the " + |
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.
Micro-Nit: use backticks for the querymc
cmd.
"information decay mechanism. Additionally " + | ||
"by setting 0m, this will report the most " + | ||
"recent result timestamp, which can be used " + | ||
"to find out how old this data is.", |
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.
Q: What do you mean by report here? The import mc data rpc does not return any information or ?
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.
ah, I was referring to the stdout text with the new max timestamp
} | ||
} | ||
|
||
fmt.Printf("Adding time offset %v to all timestamps. "+ |
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.
Nit: Adding => Added ?
// It is not allowed to import a zero-amount success to mission | ||
// control if a timestamp is set. We unset it in this case. | ||
if pair.History.SuccessTime != 0 && | ||
pair.History.SuccessAmtMsat == 0 && | ||
pair.History.SuccessAmtSat == 0 { | ||
|
||
pair.History.SuccessTime = 0 | ||
} |
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.
Definitely something we need to think about and potentially removing this validation check on the server side.
var importMissionControlCommand = cli.Command{ | ||
Name: "importmc", | ||
Category: "Payments", | ||
Category: "Mission Control", |
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.
👍
Change Description
This command lets one import data exported by
lncli querymc > mc.json
vialncli loadmc --mcdatapath mc.json
.This can be helpful to recover from mission control migration issues (#9770 (comment)) or to bootstrap a new node with another node's mission control data.
I opted to add a new command instead of adding a
--mcdatapath
flag toimportmc
, I could change this if needed.