routerrpc: mark QueryProbability deprecated

We deprecate `QueryProbability`, as it displays the same information as
`QueryMissionControl` less the probability. `QueryRoutes` still contains
the total probability of a route.
This commit is contained in:
bitromortac 2022-11-24 16:17:04 +01:00
parent 1dd7a37d4d
commit 2d7fda2a41
No known key found for this signature in database
GPG key ID: 1965063FC13BEBE2
7 changed files with 57 additions and 51 deletions

View file

@ -163,9 +163,10 @@ func queryMissionControl(ctx *cli.Context) error {
var queryProbCommand = cli.Command{
Name: "queryprob",
Category: "Mission Control",
Usage: "Estimate a success probability.",
Usage: "Deprecated. Estimate a success probability.",
ArgsUsage: "from-node to-node amt",
Action: actionDecorator(queryProb),
Hidden: true,
}
func queryProb(ctx *cli.Context) error {

View file

@ -77,6 +77,9 @@
GetBlock, GetBestBlock, GetBlockHash. These endpoints provide access to chain
block data.
* [`QueryProbabiltiy` is deprecated. Internal mission control state can be
obtained via `QueryMissionControl`.](
https://github.com/lightningnetwork/lnd/pull/6857)
## Wallet
@ -262,8 +265,8 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100).
## Pathfinding
* [Pathfinding takes capacity of edges into account to better estimate the
success probability.](https://github.com/lightningnetwork/lnd/pull/6857)
* [Pathfinding takes capacity of edges into account to improve success
probability estimation.](https://github.com/lightningnetwork/lnd/pull/6857)
### Tooling and documentation

View file

@ -94,8 +94,8 @@ service Router {
returns (SetMissionControlConfigResponse);
/*
QueryProbability returns the current success probability estimate for a
given node pair and amount.
Deprecated. QueryProbability returns the current success probability
estimate for a given node pair and amount.
*/
rpc QueryProbability (QueryProbabilityRequest)
returns (QueryProbabilityResponse);

View file

@ -116,7 +116,7 @@
},
"/v2/router/mc/probability/{from_node}/{to_node}/{amt_msat}": {
"get": {
"summary": "QueryProbability returns the current success probability estimate for a\ngiven node pair and amount.",
"summary": "Deprecated. QueryProbability returns the current success probability\nestimate for a given node pair and amount.",
"operationId": "Router_QueryProbability",
"responses": {
"200": {

View file

@ -65,8 +65,8 @@ type RouterClient interface {
// SetMissionControlConfig will set mission control's config, if the config
// provided is valid.
SetMissionControlConfig(ctx context.Context, in *SetMissionControlConfigRequest, opts ...grpc.CallOption) (*SetMissionControlConfigResponse, error)
// QueryProbability returns the current success probability estimate for a
// given node pair and amount.
// Deprecated. QueryProbability returns the current success probability
// estimate for a given node pair and amount.
QueryProbability(ctx context.Context, in *QueryProbabilityRequest, opts ...grpc.CallOption) (*QueryProbabilityResponse, error)
// BuildRoute builds a fully specified route based on a list of hop public
// keys. It retrieves the relevant channel policies from the graph in order to
@ -483,8 +483,8 @@ type RouterServer interface {
// SetMissionControlConfig will set mission control's config, if the config
// provided is valid.
SetMissionControlConfig(context.Context, *SetMissionControlConfigRequest) (*SetMissionControlConfigResponse, error)
// QueryProbability returns the current success probability estimate for a
// given node pair and amount.
// Deprecated. QueryProbability returns the current success probability
// estimate for a given node pair and amount.
QueryProbability(context.Context, *QueryProbabilityRequest) (*QueryProbabilityResponse, error)
// BuildRoute builds a fully specified route based on a list of hop public
// keys. It retrieves the relevant channel policies from the graph in order to

View file

@ -692,47 +692,6 @@ func getMsatPairValue(msatValue lnwire.MilliSatoshi,
satValue)
}
// QueryProbability returns the current success probability estimate for a
// given node pair and amount.
func (s *Server) QueryProbability(ctx context.Context,
req *QueryProbabilityRequest) (*QueryProbabilityResponse, error) {
fromNode, err := route.NewVertexFromBytes(req.FromNode)
if err != nil {
return nil, err
}
toNode, err := route.NewVertexFromBytes(req.ToNode)
if err != nil {
return nil, err
}
amt := lnwire.MilliSatoshi(req.AmtMsat)
// Compute the probability.
var prob float64
mc := s.cfg.RouterBackend.MissionControl
capacity, err := s.cfg.RouterBackend.FetchAmountPairCapacity(
fromNode, toNode, amt,
)
// If we cannot query the capacity this means that either we don't have
// information available or that the channel fails min/maxHtlc
// constraints, so we return a zero probability.
if err != nil {
log.Errorf("Cannot fetch capacity: %v", err)
} else {
prob = mc.GetProbability(fromNode, toNode, amt, capacity)
}
history := mc.GetPairHistorySnapshot(fromNode, toNode)
return &QueryProbabilityResponse{
Probability: prob,
History: toRPCPairData(&history),
}, nil
}
// TrackPaymentV2 returns a stream of payment state updates. The stream is
// closed when the payment completes.
func (s *Server) TrackPaymentV2(request *TrackPaymentRequest,

View file

@ -7,6 +7,8 @@ import (
"fmt"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)
// legacyTrackPaymentServer is a wrapper struct that transforms a stream of main
@ -118,3 +120,44 @@ func (s *Server) SendToRoute(ctx context.Context,
return legacyResp, err
}
// QueryProbability returns the current success probability estimate for a
// given node pair and amount.
func (s *Server) QueryProbability(ctx context.Context,
req *QueryProbabilityRequest) (*QueryProbabilityResponse, error) {
fromNode, err := route.NewVertexFromBytes(req.FromNode)
if err != nil {
return nil, err
}
toNode, err := route.NewVertexFromBytes(req.ToNode)
if err != nil {
return nil, err
}
amt := lnwire.MilliSatoshi(req.AmtMsat)
// Compute the probability.
var prob float64
mc := s.cfg.RouterBackend.MissionControl
capacity, err := s.cfg.RouterBackend.FetchAmountPairCapacity(
fromNode, toNode, amt,
)
// If we cannot query the capacity this means that either we don't have
// information available or that the channel fails min/maxHtlc
// constraints, so we return a zero probability.
if err != nil {
log.Errorf("Cannot fetch capacity: %v", err)
} else {
prob = mc.GetProbability(fromNode, toNode, amt, capacity)
}
history := mc.GetPairHistorySnapshot(fromNode, toNode)
return &QueryProbabilityResponse{
Probability: prob,
History: toRPCPairData(&history),
}, nil
}