Browse Source

paymod: Add invariant verification for constraints on shadowroute

This was highlighted in #3851, so I added an assertion. After the rewrite in
the next commit we would simply skip if any of the constraints were not
maintained, but this serves as the canary in the coalmine, so we don't paper over.
route-mem-overrun
Christian Decker 5 years ago
committed by Rusty Russell
parent
commit
c0d70cdfc7
  1. 5
      plugins/libplugin-pay.c

5
plugins/libplugin-pay.c

@ -1784,6 +1784,11 @@ static struct command_result *shadow_route_listchannels(struct command *cmd,
const jsmntok_t *sattok, *delaytok, *basefeetok, *propfeetok, *desttok, const jsmntok_t *sattok, *delaytok, *basefeetok, *propfeetok, *desttok,
*channelstok, *chan; *channelstok, *chan;
/* Check the invariants on the constraints between payment and modifier. */
assert(d->constraints.cltv_budget <= p->constraints.cltv_budget / 4);
assert(amount_msat_greater_eq(p->constraints.fee_budget,
d->constraints.fee_budget));
channelstok = json_get_member(buf, result, "channels"); channelstok = json_get_member(buf, result, "channels");
json_for_each_arr(i, chan, channelstok) { json_for_each_arr(i, chan, channelstok) {
u64 v = pseudorand(UINT64_MAX); u64 v = pseudorand(UINT64_MAX);

Loading…
Cancel
Save