From f935bd0baf6925b2e37d7f2cd8694043de7df90f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 22 Mar 2018 17:34:42 -0700 Subject: [PATCH] routing: add vertex pruning for non-final CLTV related errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we add vertex pruning for any non-final CLTV error. Before this commit, we assumed that any source of this error was due to the local node setting the incorrect time lock. However, it’s been recently noticed on main net that there’re a set of nodes that seem to not be properly scanned to the chain. Without this patch, users aren’t able to route successfully as atm, we’ll stop all path finding attempts if we encounter this. --- routing/router.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/routing/router.go b/routing/router.go index 1947f9e5..be92e668 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1670,15 +1670,20 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route return preImage, nil, sendError // If we get a notice that the expiry was too soon for - // an intermediate node, then we'll exit early as the - // expected block height as shifted from underneath us. + // an intermediate node, then we'll prune out the node + // that sent us this error, as it doesn't now what the + // correct block height is. case *lnwire.FailExpiryTooSoon: update := onionErr.Update if err := r.applyChannelUpdate(&update); err != nil { log.Errorf("unable to apply channel "+ "update for onion error: %v", err) } - return preImage, nil, sendError + + pruneVertexFailure( + paySession, route, errSource, false, + ) + continue // If we hit an instance of onion payload corruption or // an invalid version, then we'll exit early as this @@ -1734,6 +1739,10 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route errFailedFeeChans[chanID] = struct{}{} continue + // If we get the failure for an intermediate node that + // disagrees with our time lock values, then we'll + // prune it out for now, and continue with path + // finding. case *lnwire.FailIncorrectCltvExpiry: update := onionErr.Update if err := r.applyChannelUpdate(&update); err != nil { @@ -1741,7 +1750,10 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route "update for onion error: %v", err) } - return preImage, nil, sendError + pruneVertexFailure( + paySession, route, errSource, false, + ) + continue // The outgoing channel that this node was meant to // forward one is currently disabled, so we'll apply