From 7e4f9dd70a59ca6dd66ee20bdc02175d77ae9efc Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 21 Nov 2019 12:39:08 +0100 Subject: [PATCH 1/7] routing/test: simplify context instantiation --- routing/pathfind_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 6cde160038..d12a018824 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -2299,16 +2299,13 @@ func newPathFindingTestContext(t *testing.T, testChannels []*testChannel, t: t, testGraphInstance: testGraphInstance, source: route.Vertex(sourceNode.PubKeyBytes), + pathFindingConfig: *testPathFindingConfig, + graphParams: graphParams{ + graph: testGraphInstance.graph, + }, + restrictParams: *noRestrictions, } - ctx.pathFindingConfig = *testPathFindingConfig - - ctx.graphParams.graph = testGraphInstance.graph - - ctx.restrictParams.FeeLimit = noFeeLimit - ctx.restrictParams.ProbabilitySource = noProbabilitySource - ctx.restrictParams.CltvLimit = math.MaxUint32 - return ctx } From 6774b5a007145f92e59066c91a2432c648121982 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 19 Nov 2019 19:54:20 +0100 Subject: [PATCH 2/7] routing: remove unused error codes --- routing/errors.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/routing/errors.go b/routing/errors.go index 0eb6cb37b8..6fe31a2e22 100644 --- a/routing/errors.go +++ b/routing/errors.go @@ -11,16 +11,6 @@ const ( // does not exist in the graph. ErrNoPathFound errorCode = iota - // ErrNoRouteFound is returned when the router is unable to find a - // valid route to the target destination after fees and time-lock - // limitations are factored in. - ErrNoRouteFound - - // ErrInsufficientCapacity is returned when a path if found, yet the - // capacity of one of the channels in the path is insufficient to carry - // the payment. - ErrInsufficientCapacity - // ErrMaxHopsExceeded is returned when a candidate path is found, but // the length of that path exceeds HopLimit. ErrMaxHopsExceeded @@ -39,18 +29,9 @@ const ( // announcement was given for node not found in any channel. ErrIgnored - // ErrRejected is returned if the update is for a channel ID that was - // previously added to the reject cache because of an invalid update - // was attempted to be processed. - ErrRejected - // ErrPaymentAttemptTimeout is an error that indicates that a payment // attempt timed out before we were able to successfully route an HTLC. ErrPaymentAttemptTimeout - - // ErrFeeLimitExceeded is returned when the total fees of a route exceed - // the user-specified fee limit. - ErrFeeLimitExceeded ) // routerError is a structure that represent the error inside the routing package, From ac2df9bbf4dd0fdc45ae3a8eb2f3c50579ca97ab Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 19 Nov 2019 20:00:01 +0100 Subject: [PATCH 3/7] routing: use simple errors for path finding --- routing/errors.go | 10 +--------- routing/pathfind.go | 24 +++++++++++++++++------- routing/pathfind_test.go | 16 ++++++++-------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/routing/errors.go b/routing/errors.go index 6fe31a2e22..44ad7a63dd 100644 --- a/routing/errors.go +++ b/routing/errors.go @@ -7,18 +7,10 @@ import "github.com/go-errors/errors" type errorCode uint8 const ( - // ErrNoPathFound is returned when a path to the target destination - // does not exist in the graph. - ErrNoPathFound errorCode = iota - - // ErrMaxHopsExceeded is returned when a candidate path is found, but - // the length of that path exceeds HopLimit. - ErrMaxHopsExceeded - // ErrTargetNotInNetwork is returned when the target of a path-finding // or payment attempt isn't known to be within the current version of // the channel graph. - ErrTargetNotInNetwork + ErrTargetNotInNetwork errorCode = iota // ErrOutdated is returned when the routing update already have // been applied, or a newer update is already known. diff --git a/routing/pathfind.go b/routing/pathfind.go index dee06b0c34..83014a473e 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -2,13 +2,13 @@ package routing import ( "container/heap" + "errors" "fmt" "math" "time" "github.com/btcsuite/btcd/btcec" "github.com/coreos/bbolt" - "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" @@ -63,6 +63,19 @@ var ( // DefaultAprioriHopProbability is the default a priori probability for // a hop. DefaultAprioriHopProbability = float64(0.6) + + // errNoTlvPayload is returned when the destination hop does not support + // a tlv payload. + errNoTlvPayload = errors.New("destination hop doesn't " + + "understand new TLV payloads") + + // errNoPathFound is returned when a path to the target destination does + // not exist in the graph. + errNoPathFound = errors.New("unable to find a path to destination") + + // errMaxHopsExceeded is returned when a candidate path is found, but + // the length of that path exceeds HopLimit. + errMaxHopsExceeded = errors.New("potential path has too many hops") ) // edgePolicyWithSource is a helper struct to keep track of the source node @@ -347,8 +360,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, lnwire.TLVOnionPayloadOptional, ) if !supportsTLV { - return nil, fmt.Errorf("destination hop doesn't " + - "understand new TLV paylods") + return nil, errNoTlvPayload } } } @@ -610,8 +622,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, currentNodeWithDist, ok := distance[currentNode] if !ok { // If the node doesnt have a next hop it means we didn't find a path. - return nil, newErrf(ErrNoPathFound, "unable to find a "+ - "path to destination") + return nil, errNoPathFound } // Add the next hop to the list of path edges. @@ -634,8 +645,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, // hops, then it's invalid. numEdges := len(pathEdges) if numEdges > HopLimit { - return nil, newErr(ErrMaxHopsExceeded, "potential path has "+ - "too many hops") + return nil, errMaxHopsExceeded } log.Debugf("Found route: probability=%v, hops=%v, fee=%v\n", diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index d12a018824..dcbf352dc5 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -1269,7 +1269,7 @@ func TestPathNotAvailable(t *testing.T) { noRestrictions, testPathFindingConfig, sourceNode.PubKeyBytes, unknownNode, 100, ) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("path shouldn't have been found: %v", err) } } @@ -1306,7 +1306,7 @@ func TestPathInsufficientCapacity(t *testing.T) { noRestrictions, testPathFindingConfig, sourceNode.PubKeyBytes, target, payAmt, ) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("graph shouldn't be able to support payment: %v", err) } } @@ -1339,7 +1339,7 @@ func TestRouteFailMinHTLC(t *testing.T) { noRestrictions, testPathFindingConfig, sourceNode.PubKeyBytes, target, payAmt, ) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("graph shouldn't be able to support payment: %v", err) } } @@ -1403,7 +1403,7 @@ func TestRouteFailMaxHTLC(t *testing.T) { // We'll now attempt to route through that edge with a payment above // 100k msat, which should fail. _, err = ctx.findPath(target, payAmt) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("graph shouldn't be able to support payment: %v", err) } } @@ -1491,7 +1491,7 @@ func TestRouteFailDisabledEdge(t *testing.T) { noRestrictions, testPathFindingConfig, sourceNode.PubKeyBytes, target, payAmt, ) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("graph shouldn't be able to support payment: %v", err) } } @@ -1549,7 +1549,7 @@ func TestPathSourceEdgesBandwidth(t *testing.T) { noRestrictions, testPathFindingConfig, sourceNode.PubKeyBytes, target, payAmt, ) - if !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("graph shouldn't be able to support payment: %v", err) } @@ -1971,7 +1971,7 @@ func testCltvLimit(t *testing.T, limit uint32, expectedChannel uint64) { path, err := ctx.findPath(target, paymentAmt) if expectedChannel == 0 { // Finish test if we expect no route. - if IsError(err, ErrNoPathFound) { + if err == errNoPathFound { return } t.Fatal("expected no path to be found") @@ -2137,7 +2137,7 @@ func testProbabilityRouting(t *testing.T, p10, p11, p20, minProbability float64, path, err := ctx.findPath(target, paymentAmt) if expectedChan == 0 { - if err == nil || !IsError(err, ErrNoPathFound) { + if err != errNoPathFound { t.Fatalf("expected no path found, but got %v", err) } return From b5f1bde60415bc64bee1836af3a3bb53a996bf35 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 21 Nov 2019 12:05:43 +0100 Subject: [PATCH 4/7] routing: add error var for pre-built route tried --- routing/payment_session.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/routing/payment_session.go b/routing/payment_session.go index 3b27db4226..979b7a7a4e 100644 --- a/routing/payment_session.go +++ b/routing/payment_session.go @@ -1,7 +1,7 @@ package routing import ( - "fmt" + "errors" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/lnwire" @@ -12,6 +12,12 @@ import ( // to prevent an HTLC being failed if some blocks are mined while it's in-flight. const BlockPadding uint16 = 3 +var ( + // errPrebuiltRouteTried is returned when the single pre-built route + // failed and there is nothing more we can do. + errPrebuiltRouteTried = errors.New("pre-built route already tried") +) + // PaymentSession is used during SendPayment attempts to provide routes to // attempt. It also defines methods to give the PaymentSession additional // information learned during the previous attempts. @@ -66,7 +72,7 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment, // If the pre-built route has been tried already, the payment session is // over. case p.preBuiltRoute != nil: - return nil, fmt.Errorf("pre-built route already tried") + return nil, errPrebuiltRouteTried } // Add BlockPadding to the finalCltvDelta so that the receiving node From c15b0316a2c81114144d7fc3e3d2c96332897b01 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 21 Nov 2019 12:08:09 +0100 Subject: [PATCH 5/7] routing: use FailureReasonError for internal path finding errors --- routing/payment_lifecycle.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index a8017eaa3f..3fb391eb0b 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -186,6 +186,19 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) { } +// errorToPaymentFailure takes a path finding error and converts it into a +// payment-level failure. +func errorToPaymentFailure(err error) channeldb.FailureReason { + switch err { + case errNoTlvPayload, errNoPathFound, errMaxHopsExceeded, + errPrebuiltRouteTried: + + return channeldb.FailureReasonNoRoute + } + + return channeldb.FailureReasonError +} + // createNewPaymentAttempt creates and stores a new payment attempt to the // database. func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID, @@ -230,11 +243,14 @@ func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID, log.Warnf("Failed to find route for payment %x: %v", p.payment.PaymentHash, err) + // Convert error to payment-level failure. + failure := errorToPaymentFailure(err) + // If we're unable to successfully make a payment using // any of the routes we've found, then mark the payment // as permanently failed. saveErr := p.router.cfg.Control.Fail( - p.payment.PaymentHash, channeldb.FailureReasonNoRoute, + p.payment.PaymentHash, failure, ) if saveErr != nil { return lnwire.ShortChannelID{}, nil, saveErr From 97344af8f3ad8fe15058a9485e8dc592249b40eb Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 21 Nov 2019 11:59:17 +0100 Subject: [PATCH 6/7] routing: local balance check --- channeldb/payments.go | 6 + lnrpc/routerrpc/router.pb.go | 264 ++++++++++++++++--------------- lnrpc/routerrpc/router.proto | 5 + lnrpc/routerrpc/router_server.go | 3 + routing/pathfind.go | 69 +++++++- routing/pathfind_test.go | 31 ++++ routing/payment_lifecycle.go | 3 + 7 files changed, 250 insertions(+), 131 deletions(-) diff --git a/channeldb/payments.go b/channeldb/payments.go index 7a54154311..ca9cf42f46 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -105,6 +105,10 @@ const ( // or the final cltv delta or amount is incorrect. FailureReasonPaymentDetails FailureReason = 3 + // FailureReasonInsufficientBalance indicates that we didn't have enough + // balance to complete the payment. + FailureReasonInsufficientBalance FailureReason = 4 + // TODO(halseth): cancel state. // TODO(joostjager): Add failure reasons for: @@ -122,6 +126,8 @@ func (r FailureReason) String() string { return "error" case FailureReasonPaymentDetails: return "incorrect_payment_details" + case FailureReasonInsufficientBalance: + return "insufficient_balance" } return "unknown" diff --git a/lnrpc/routerrpc/router.pb.go b/lnrpc/routerrpc/router.pb.go index c7223120ef..c6485311eb 100644 --- a/lnrpc/routerrpc/router.pb.go +++ b/lnrpc/routerrpc/router.pb.go @@ -46,6 +46,9 @@ const ( //Payment details incorrect (unknown hash, invalid amt or //invalid final cltv delta) PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS PaymentState = 5 + //* + //Insufficient local balance. + PaymentState_FAILED_INSUFFICIENT_BALANCE PaymentState = 6 ) var PaymentState_name = map[int32]string{ @@ -55,6 +58,7 @@ var PaymentState_name = map[int32]string{ 3: "FAILED_NO_ROUTE", 4: "FAILED_ERROR", 5: "FAILED_INCORRECT_PAYMENT_DETAILS", + 6: "FAILED_INSUFFICIENT_BALANCE", } var PaymentState_value = map[string]int32{ @@ -64,6 +68,7 @@ var PaymentState_value = map[string]int32{ "FAILED_NO_ROUTE": 3, "FAILED_ERROR": 4, "FAILED_INCORRECT_PAYMENT_DETAILS": 5, + "FAILED_INSUFFICIENT_BALANCE": 6, } func (x PaymentState) String() string { @@ -1505,135 +1510,136 @@ func init() { func init() { proto.RegisterFile("routerrpc/router.proto", fileDescriptor_7a0613f69d37b0a5) } var fileDescriptor_7a0613f69d37b0a5 = []byte{ - // 2038 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x58, 0x51, 0x73, 0x1a, 0xc9, - 0x11, 0xbe, 0x15, 0x20, 0x50, 0x03, 0x62, 0x35, 0xd2, 0xc9, 0x6b, 0x64, 0x9d, 0x75, 0x6b, 0xc7, - 0x47, 0xb9, 0x7c, 0x92, 0xa3, 0xd4, 0x5d, 0xb9, 0xee, 0x21, 0x29, 0x0c, 0xcb, 0x69, 0x65, 0x58, - 0xe4, 0x01, 0x7c, 0xe7, 0xdc, 0xc3, 0xd4, 0x08, 0x46, 0x62, 0x4b, 0xcb, 0x2e, 0xb7, 0x3b, 0xf8, - 0xac, 0xff, 0x90, 0xbc, 0xe7, 0x1f, 0x24, 0x0f, 0xc9, 0x53, 0xfe, 0x53, 0xf2, 0x9e, 0xaa, 0xbc, - 0xa7, 0x66, 0x66, 0x17, 0x16, 0x84, 0x7c, 0x79, 0x62, 0xe7,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0xa3, 0x72, 0xa4, 0xd5, 0x0a, 0x58, 0x97, 0x92, 0x1e, - 0xf3, 0xae, 0x62, 0x53, 0xd5, 0xef, 0xa0, 0x94, 0x36, 0x23, 0x72, 0x48, 0xec, 0x59, 0xa4, 0x55, - 0x16, 0x8b, 0x4f, 0xb4, 0x07, 0xb9, 0x0f, 0xd4, 0x9b, 0x31, 0x99, 0x57, 0x25, 0xac, 0x06, 0xdf, - 0x6d, 0xbc, 0xd2, 0xcc, 0x57, 0xb0, 0xdb, 0x0f, 0xe9, 0xf0, 0x66, 0x25, 0x35, 0x57, 0x33, 0x4b, - 0xbb, 0x93, 0x59, 0xe6, 0xdf, 0x34, 0x28, 0xc7, 0xb3, 0x7a, 0x9c, 0xf2, 0x59, 0x84, 0xbe, 0x86, - 0x5c, 0xc4, 0x29, 0x67, 0x52, 0x7b, 0xfb, 0xf4, 0x41, 0x6a, 0xe7, 0x29, 0x45, 0x86, 0x95, 0x16, - 0xaa, 0x42, 0x61, 0x1a, 0x32, 0x77, 0x42, 0xaf, 0x93, 0x75, 0xcd, 0xc7, 0xc8, 0x84, 0x9c, 0x9c, - 0x2c, 0x53, 0xba, 0x78, 0x5a, 0x4a, 0x9f, 0x3a, 0x56, 0x22, 0x54, 0x83, 0xdc, 0x98, 0x7b, 0xc3, - 0xc8, 0xc8, 0xca, 0x83, 0x46, 0xb1, 0xce, 0x59, 0xbf, 0xdd, 0xa8, 0x73, 0xce, 0x26, 0x53, 0x8e, - 0x95, 0x82, 0xf9, 0x7b, 0xa8, 0xc8, 0x99, 0x2d, 0xc6, 0x3e, 0x75, 0xf7, 0x1e, 0x80, 0xb8, 0x59, - 0x32, 0x53, 0xd5, 0xfd, 0xdb, 0xa4, 0x13, 0x91, 0xa4, 0xe6, 0x08, 0xf4, 0xc5, 0xfc, 0x68, 0x1a, - 0xf8, 0x91, 0xf0, 0xae, 0x8b, 0x65, 0x88, 0x8c, 0x14, 0x09, 0x2c, 0x53, 0x57, 0x93, 0xb3, 0xb6, - 0x63, 0xbc, 0xc5, 0x98, 0x4c, 0xde, 0x67, 0xea, 0xbe, 0x10, 0x2f, 0x18, 0xde, 0x88, 0x1b, 0x48, - 0x6f, 0x63, 0xf3, 0x65, 0x01, 0xb7, 0x83, 0xe1, 0x4d, 0x53, 0x80, 0xe6, 0x4f, 0x8a, 0x24, 0xfa, - 0x81, 0xda, 0xe5, 0xff, 0x1d, 0x89, 0xc5, 0x61, 0x6d, 0xdc, 0x7b, 0x58, 0x26, 0x81, 0xdd, 0x25, - 0xe3, 0xf1, 0x2e, 0xd2, 0x31, 0xd0, 0x56, 0x62, 0xf0, 0x02, 0xf2, 0x57, 0xd4, 0xf5, 0x66, 0x61, - 0x62, 0x18, 0xa5, 0x02, 0xda, 0x52, 0x12, 0x9c, 0xa8, 0x98, 0xff, 0xcd, 0x43, 0x3e, 0x06, 0xd1, - 0x29, 0x64, 0x87, 0xc1, 0x28, 0xc9, 0x83, 0x2f, 0xee, 0x4e, 0x4b, 0x7e, 0x1b, 0xc1, 0x88, 0x61, - 0xa9, 0x8b, 0xfe, 0x00, 0xdb, 0xe2, 0x66, 0xfb, 0xcc, 0x23, 0xb3, 0xe9, 0x88, 0xce, 0x43, 0x6f, - 0xa4, 0x66, 0x37, 0x94, 0xc2, 0x40, 0xca, 0x71, 0x79, 0x98, 0x1e, 0xa2, 0x03, 0xd8, 0x12, 0xd1, - 0x56, 0x91, 0xc8, 0xca, 0xdc, 0x2f, 0x08, 0x40, 0xc6, 0xc0, 0x84, 0x72, 0xe0, 0xbb, 0x81, 0x4f, - 0xa2, 0x31, 0x25, 0xa7, 0xdf, 0x7c, 0x2b, 0xa9, 0xad, 0x84, 0x8b, 0x12, 0xec, 0x8d, 0xe9, 0xe9, - 0x37, 0xdf, 0xa2, 0xc7, 0x50, 0x94, 0x74, 0xc0, 0x3e, 0x4e, 0xdd, 0xf0, 0x56, 0x72, 0x5a, 0x19, - 0x4b, 0x86, 0xb0, 0x24, 0x22, 0x6e, 0xd1, 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 0x84, 0x48, 0x94, 0x90, 0x50, 0x90, 0x9e, 0x62, - 0x84, 0xfc, 0x15, 0x63, 0x58, 0x9c, 0xe5, 0xdc, 0x03, 0xfd, 0xb8, 0xf0, 0x50, 0x4c, 0x79, 0x50, - 0xb8, 0xf4, 0xf0, 0x1c, 0x76, 0xd8, 0x47, 0x1e, 0x52, 0x12, 0x4c, 0xe9, 0xcf, 0x33, 0x46, 0x46, - 0x94, 0x53, 0xd9, 0x31, 0x96, 0x70, 0x45, 0x0a, 0xba, 0x12, 0x6f, 0x52, 0x4e, 0xcd, 0x47, 0x50, - 0xc5, 0x2c, 0x62, 0xbc, 0xe3, 0x46, 0x91, 0x1b, 0xf8, 0x8d, 0xc0, 0xe7, 0x61, 0xe0, 0xc5, 0x35, - 0xc7, 0x3c, 0x84, 0x83, 0xb5, 0x52, 0x55, 0x34, 0xc4, 0xe4, 0xb7, 0x33, 0x16, 0xde, 0xae, 0x9f, - 0xfc, 0x16, 0x0e, 0xd6, 0x4a, 0xe3, 0x8a, 0xf3, 0x02, 0x72, 0x53, 0xea, 0x86, 0x91, 0xb1, 0x21, - 0xab, 0xf6, 0xfe, 0x52, 0x93, 0xe0, 0x86, 0x67, 0x6e, 0xc4, 0x83, 0xf0, 0x16, 0x2b, 0xa5, 0xf3, - 0x6c, 0x41, 0xd3, 0x37, 0xcc, 0x3f, 0x69, 0x50, 0x4c, 0x09, 0x45, 0x1e, 0xf8, 0xc1, 0x88, 0x91, - 0xab, 0x30, 0x98, 0x24, 0x19, 0x36, 0x07, 0x90, 0x01, 0x79, 0x39, 0xe0, 0x41, 0x9c, 0x5e, 0xc9, - 0x10, 0x7d, 0x0d, 0xf9, 0xb1, 0x32, 0x21, 0xa3, 0x54, 0x3c, 0xdd, 0x5d, 0xf1, 0x2e, 0xce, 0x06, - 0x27, 0x3a, 0xe7, 0xd9, 0x42, 0x46, 0xcf, 0x9e, 0x67, 0x0b, 0x59, 0x3d, 0x77, 0x9e, 0x2d, 0xe4, - 0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6, 0x36, 0x82, 0xdd, 0x35, - 0xfc, 0x8c, 0x7e, 0x93, 0x5e, 0xc1, 0xbd, 0xec, 0x5e, 0x7d, 0xf6, 0x6b, 0x6a, 0x0b, 0x2f, 0x6b, - 0x88, 0x7c, 0xc9, 0xcb, 0xfd, 0x65, 0x60, 0xc9, 0xcb, 0xa7, 0xea, 0xc1, 0x4f, 0xa0, 0xaf, 0x5e, - 0x74, 0x64, 0xae, 0xce, 0xbd, 0x4b, 0x3a, 0xd5, 0x27, 0x9f, 0xd4, 0x89, 0x8d, 0xdb, 0x00, 0x8b, - 0xeb, 0x82, 0x1e, 0xa5, 0xa6, 0xdc, 0xb9, 0xee, 0xd5, 0xc3, 0x7b, 0xa4, 0xca, 0xd4, 0xeb, 0xdf, - 0xfe, 0xf1, 0xe4, 0xda, 0xe5, 0xe3, 0xd9, 0xe5, 0xf1, 0x30, 0x98, 0x9c, 0x78, 0xa2, 0x61, 0xf7, - 0x5d, 0xff, 0xda, 0x67, 0xfc, 0x97, 0x20, 0xbc, 0x39, 0xf1, 0xfc, 0xd1, 0x89, 0xbc, 0x75, 0x27, - 0x73, 0x2b, 0x97, 0x9b, 0xf2, 0xdf, 0x9f, 0xdf, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x28, 0xbb, - 0xdd, 0x1c, 0x2d, 0x12, 0x00, 0x00, + // 2053 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x58, 0x5f, 0x73, 0xdb, 0xc6, + 0x11, 0x0f, 0xc4, 0xff, 0x4b, 0x52, 0x84, 0x4e, 0x8a, 0x4c, 0x53, 0x56, 0xa2, 0x20, 0xae, 0xc3, + 0xf1, 0x38, 0x92, 0xab, 0x4e, 0x32, 0x9e, 0x3c, 0xb4, 0x43, 0x91, 0x60, 0x04, 0x99, 0x04, 0xe5, + 0x23, 0xe9, 0xc4, 0xcd, 0xc3, 0xcd, 0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+ 0x48, 0x32, 0x36, 0xa7, 0xe8, 0x39, 0xec, 0x28, 0xca, 0x71, 0x3c, 0x67, 0x3a, 0x9f, 0x2a, 0xea, + 0xc9, 0x49, 0xea, 0xa9, 0x48, 0xea, 0x51, 0xb8, 0x64, 0xa0, 0xc7, 0x90, 0xbf, 0xa2, 0x21, 0x13, + 0xc5, 0x22, 0xa2, 0x86, 0x9c, 0x18, 0xb7, 0x19, 0x13, 0x22, 0x51, 0x42, 0x02, 0x41, 0x7a, 0x8a, + 0x11, 0x72, 0xd7, 0x8c, 0x61, 0x71, 0x96, 0x0b, 0x0f, 0xf4, 0xc3, 0xd2, 0x43, 0x31, 0xe1, 0x41, + 0xe1, 0xd2, 0xc3, 0x73, 0xd8, 0x61, 0x1f, 0x78, 0x40, 0x89, 0x3f, 0xa3, 0x3f, 0xcf, 0x19, 0x19, + 0x53, 0x4e, 0x65, 0xc7, 0x58, 0xc2, 0x15, 0x29, 0xe8, 0x49, 0xbc, 0x45, 0x39, 0x35, 0x9e, 0x40, + 0x0d, 0xb3, 0x90, 0xf1, 0xae, 0x13, 0x86, 0x8e, 0xef, 0x35, 0x7d, 0x8f, 0x07, 0xbe, 0x1b, 0xd5, + 0x1c, 0xe3, 0x10, 0x0e, 0x36, 0x4a, 0x55, 0xd1, 0x10, 0x93, 0xdf, 0xcc, 0x59, 0x70, 0xb7, 0x79, + 0xf2, 0x1b, 0x38, 0xd8, 0x28, 0x8d, 0x2a, 0xce, 0x0b, 0xc8, 0xcc, 0xa8, 0x13, 0x84, 0xd5, 0x2d, + 0x59, 0xb5, 0xf7, 0x57, 0x9a, 0x04, 0x27, 0x38, 0x77, 0x42, 0xee, 0x07, 0x77, 0x58, 0x29, 0x5d, + 0xa4, 0xf3, 0x9a, 0xbe, 0x65, 0xfc, 0x49, 0x83, 0x62, 0x42, 0x28, 0xf2, 0xc0, 0xf3, 0xc7, 0x8c, + 0x5c, 0x07, 0xfe, 0x34, 0xce, 0xb0, 0x05, 0x80, 0xaa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0xe8, 0x02, 0x4a, 0xc9, 0xe7, 0x0e, 0x4a, 0xf6, 0xa6, 0x1b, 0xde, + 0x41, 0x1f, 0xb5, 0xf5, 0x1a, 0x74, 0x33, 0xe4, 0xce, 0x54, 0xf4, 0xa2, 0xd1, 0xeb, 0x00, 0xd5, + 0x12, 0xfa, 0x6b, 0x4f, 0x8e, 0xda, 0xc1, 0x46, 0x59, 0x14, 0xc2, 0x8e, 0xda, 0x62, 0xd4, 0x9f, + 0xdf, 0xdb, 0xe2, 0xea, 0xa3, 0xa0, 0xf6, 0xd9, 0x43, 0xe2, 0xc8, 0xda, 0x18, 0x76, 0x37, 0x10, + 0x38, 0xfa, 0x4d, 0x72, 0x05, 0x0f, 0xd2, 0x7f, 0xed, 0xd9, 0xaf, 0xa9, 0x2d, 0xbd, 0x6c, 0x60, + 0xfa, 0x15, 0x2f, 0x0f, 0xd7, 0x89, 0x15, 0x2f, 0x1f, 0x2b, 0x18, 0x3f, 0x81, 0xbe, 0xce, 0x04, + 0xc8, 0x58, 0x9f, 0x7b, 0x9f, 0x95, 0x6a, 0x5f, 0x7e, 0x54, 0x27, 0x32, 0x6e, 0x01, 0x2c, 0xef, + 0x13, 0x7a, 0x92, 0x98, 0x72, 0x8f, 0x0f, 0x6a, 0x87, 0x0f, 0x48, 0x95, 0xa9, 0xb3, 0xdf, 0xfe, + 0xf1, 0xe4, 0xc6, 0xe1, 0x93, 0xf9, 0xd5, 0xf1, 0xc8, 0x9f, 0x9e, 0xb8, 0xa2, 0xa3, 0xf7, 0x1c, + 0xef, 0xc6, 0x63, 0xfc, 0x17, 0x3f, 0xb8, 0x3d, 0x71, 0xbd, 0xf1, 0x89, 0xbc, 0x96, 0x27, 0x0b, + 0x2b, 0x57, 0x59, 0xf9, 0xf7, 0xd0, 0xef, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x2d, 0x5b, + 0xa8, 0x4e, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/lnrpc/routerrpc/router.proto b/lnrpc/routerrpc/router.proto index 7cd9a52908..8911257ec7 100644 --- a/lnrpc/routerrpc/router.proto +++ b/lnrpc/routerrpc/router.proto @@ -142,6 +142,11 @@ enum PaymentState { invalid final cltv delta) */ FAILED_INCORRECT_PAYMENT_DETAILS = 5; + + /** + Insufficient local balance. + */ + FAILED_INSUFFICIENT_BALANCE = 6; } diff --git a/lnrpc/routerrpc/router_server.go b/lnrpc/routerrpc/router_server.go index e815e78afa..c872afe37b 100644 --- a/lnrpc/routerrpc/router_server.go +++ b/lnrpc/routerrpc/router_server.go @@ -678,6 +678,9 @@ func marshallFailureReason(reason channeldb.FailureReason) ( case channeldb.FailureReasonPaymentDetails: return PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS, nil + + case channeldb.FailureReasonInsufficientBalance: + return PaymentState_FAILED_INSUFFICIENT_BALANCE, nil } return 0, errors.New("unknown failure reason") diff --git a/routing/pathfind.go b/routing/pathfind.go index 83014a473e..e794f814e7 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -76,6 +76,10 @@ var ( // errMaxHopsExceeded is returned when a candidate path is found, but // the length of that path exceeds HopLimit. errMaxHopsExceeded = errors.New("potential path has too many hops") + + // errInsufficientLocalBalance is returned when none of the local + // channels have enough balance for the payment. + errInsufficientBalance = errors.New("insufficient local balance") ) // edgePolicyWithSource is a helper struct to keep track of the source node @@ -305,6 +309,50 @@ type PathFindingConfig struct { MinProbability float64 } +// getMaxOutgoingAmt returns the maximum available balance in any of the +// channels of the given node. +func getMaxOutgoingAmt(node route.Vertex, outgoingChan *uint64, + g *graphParams, tx *bbolt.Tx) (lnwire.MilliSatoshi, error) { + + var max lnwire.MilliSatoshi + cb := func(_ *bbolt.Tx, edgeInfo *channeldb.ChannelEdgeInfo, outEdge, + _ *channeldb.ChannelEdgePolicy) error { + + if outEdge == nil { + return nil + } + + chanID := outEdge.ChannelID + + // Enforce outgoing channel restriction. + if outgoingChan != nil && chanID != *outgoingChan { + return nil + } + + bandwidth, ok := g.bandwidthHints[chanID] + + // If the bandwidth is not available for whatever reason, don't + // fail the pathfinding early. + if !ok { + max = lnwire.MaxMilliSatoshi + return nil + } + + if bandwidth > max { + max = bandwidth + } + + return nil + } + + // Iterate over all channels of the to node. + err := g.graph.ForEachNodeChannel(tx, node[:], cb) + if err != nil { + return 0, err + } + return max, err +} + // findPath attempts to find a path from the source node within the // ChannelGraph to the target node that's capable of supporting a payment of // `amt` value. The current approach implemented is modified version of @@ -332,7 +380,13 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, "time=%v", nodesVisited, edgesExpanded, timeElapsed) }() - var err error + // Get source node outside of the pathfinding tx, to prevent a deadlock. + selfNode, err := g.graph.SourceNode() + if err != nil { + return nil, err + } + self := selfNode.PubKeyBytes + tx := g.tx if tx == nil { tx, err = g.graph.Database().Begin(false) @@ -365,6 +419,18 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, } } + // If we are routing from ourselves, check that we have enough local + // balance available. + if source == self { + max, err := getMaxOutgoingAmt(self, r.OutgoingChannelID, g, tx) + if err != nil { + return nil, err + } + if max < amt { + return nil, errInsufficientBalance + } + } + // First we'll initialize an empty heap which'll help us to quickly // locate the next edge we should visit next during our graph // traversal. @@ -375,7 +441,6 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, additionalEdgesWithSrc := make(map[route.Vertex][]*edgePolicyWithSource) for vertex, outgoingEdgePolicies := range g.additionalEdges { - // Build reverse lookup to find incoming edges. Needed because // search is taken place from target to source. for _, outgoingEdgePolicy := range outgoingEdgePolicies { diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index dcbf352dc5..b52ad92ed2 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -2271,6 +2271,37 @@ func TestRouteToSelf(t *testing.T) { ctx.assertPath(path, []uint64{1, 3, 2}) } +// TestInsufficientBalance tests that a dedicated error is returned for +// insufficient local balance. +func TestInsufficientBalance(t *testing.T) { + t.Parallel() + + testChannels := []*testChannel{ + symmetricTestChannel("source", "target", 100000, &testChannelPolicy{ + Expiry: 144, + FeeBaseMsat: 500, + }, 1), + } + + ctx := newPathFindingTestContext(t, testChannels, "source") + defer ctx.cleanup() + + paymentAmt := lnwire.NewMSatFromSatoshis(100) + target := ctx.keyFromAlias("target") + + ctx.graphParams.bandwidthHints = map[uint64]lnwire.MilliSatoshi{ + 1: lnwire.NewMSatFromSatoshis(50), + } + + // Find the best path to self. We expect this to be source->a->source, + // because a charges the lowest forwarding fee. + _, err := ctx.findPath(target, paymentAmt) + if err != errInsufficientBalance { + t.Fatalf("expected insufficient balance error, but got: %v", + err) + } +} + type pathFindingTestContext struct { t *testing.T graphParams graphParams diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 3fb391eb0b..a15f88c982 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -194,6 +194,9 @@ func errorToPaymentFailure(err error) channeldb.FailureReason { errPrebuiltRouteTried: return channeldb.FailureReasonNoRoute + + case errInsufficientBalance: + return channeldb.FailureReasonInsufficientBalance } return channeldb.FailureReasonError From 9ae014edf6e35df59c879e40bda1dda5926deab2 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 21 Nov 2019 13:43:33 +0100 Subject: [PATCH 7/7] routing: use self instead of source node for creating unified policy A unified policy differs between local channels and other channels on the network. There is more information available for local channels and this is used in the unified policy. Previously we used the pathfinding source pubkey to determine whether to apply the local channel logic or not. If queryroutes is executed with a source node that isn't the self node, this wouldn't work. --- routing/pathfind.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index e794f814e7..583c5387f5 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -617,7 +617,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, pivot := partialPath.node // Create unified policies for all incoming connections. - u := newUnifiedPolicies(source, pivot, r.OutgoingChannelID) + u := newUnifiedPolicies(self, pivot, r.OutgoingChannelID) err := u.addGraphPolicies(g.graph, tx) if err != nil {