Browse Source

routing: Skip channels that require larger HTLCs than we are routing

The `htlc_minimum_msat` parameter was ignored so far, and we'd be attempting to
pay and hitting a brick wall by doing so. This patch just skips channels that
are not eligible anyway.
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
8201764117
  1. 3
      CHANGELOG.md
  2. 4
      gossipd/routing.c
  3. 12
      gossipd/test/run-find_route-specific.c
  4. 1
      gossipd/test/run-find_route.c

3
CHANGELOG.md

@ -29,7 +29,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
to/from peers, instead of `gossipd` doing that itself.
- Test: `python-xdist` is now a dependency for tests.
- Logging: JSON connections no longer spam debug logs.
- Routing: We no longer consider channels that are not usable either because of
their capacity or their `htlc_minimum_msat` parameter (#1777)
### Deprecated
Note: You should always set `allow-deprecated-apis=false` to test for

4
gossipd/routing.c

@ -403,6 +403,10 @@ static void bfg_one_edge(struct node *node,
/* Skip this edge if the channel has insufficient
* capacity to route the required amount */
continue;
} else if (requiredcap < c->htlc_minimum_msat) {
/* Skip a channels if it indicated that it won't route
* the requeuested amount. */
continue;
} else if (requiredcap + risk >= MAX_MSATOSHI) {
SUPERVERBOSE("...extreme %"PRIu64
" + fee %"PRIu64

12
gossipd/test/run-find_route-specific.c

@ -115,6 +115,7 @@ get_or_make_connection(struct routing_state *rstate,
{
struct short_channel_id scid;
struct chan *chan;
const int idx = pubkey_idx(from_id, to_id);
if (!short_channel_id_from_str(shortid, strlen(shortid), &scid))
abort();
@ -123,8 +124,11 @@ get_or_make_connection(struct routing_state *rstate,
chan = new_chan(rstate, &scid, from_id, to_id);
/* Make sure it's seen as initialized (update non-NULL). */
chan->half[pubkey_idx(from_id, to_id)].channel_update = (void *)chan;
chan->half[idx].channel_update = (void *)chan;
chan->half[idx].htlc_minimum_msat = 0;
chan->satoshis = satoshis;
return &chan->half[pubkey_idx(from_id, to_id)];
}
@ -194,6 +198,7 @@ int main(void)
nc->delay = 5;
nc->flags = 0;
nc->last_timestamp = 1504064344;
nc->htlc_minimum_msat = 100;
/* {'active': True, 'short_id': '6989:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'last_update': 1504064344}]} */
nc = get_or_make_connection(rstate, &a, &b, "6989:2:1", 1000);
@ -219,6 +224,11 @@ int main(void)
route = find_route(tmpctx, rstate, &a, &c, 999999, riskfactor, 0.0, NULL, &fee);
assert(!route);
/* This should fail to returns a route because it is smaller than these
* htlc_minimum_msat on the last channel. */
route = find_route(tmpctx, rstate, &a, &c, 1, riskfactor, 0.0, NULL, &fee);
assert(!route);
tal_free(tmpctx);
secp256k1_context_destroy(secp256k1_ctx);
return 0;

1
gossipd/test/run-find_route.c

@ -130,6 +130,7 @@ static void add_connection(struct routing_state *rstate,
c->proportional_fee = proportional_fee;
c->delay = delay;
c->flags = get_channel_direction(from, to);
c->htlc_minimum_msat = 0;
}
/* Returns chan connecting from and to: *idx set to refer

Loading…
Cancel
Save