Skip to content

Commit

Permalink
askrene: don't crash, just report, when a flow's remaining capacity i…
Browse files Browse the repository at this point in the history
…s negative.

I'm not sure why this happens, and suspect it is caused by an issue elsewhere, so
add some verbose debugging, don't crash.

Signed-off-by: Rusty Russell <[email protected]>
Fixes: #8017
  • Loading branch information
rustyrussell committed Jan 22, 2025
1 parent 8b70931 commit a2c99bb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions plugins/askrene/refine.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,25 @@ static struct amount_msat flow_remaining_capacity(const struct route_query *rq,
* accidentally cap! */
remove_flow_reservations(rq, reservations, flow);
flow_max_capacity(rq, flow, &max, NULL, NULL);
create_flow_reservations(rq, reservations, flow);

if (!amount_msat_sub(&diff, max, flow->delivers))
plugin_err(rq->plugin, "Flow delivers %s but max only %s",
/* This seems to happen. Which is strange, since flows should
already be constrained. */
if (!amount_msat_sub(&diff, max, flow->delivers)) {
plugin_log(rq->plugin, LOG_BROKEN,
"Flow delivers %s but max only %s? flow=%s",
fmt_amount_msat(tmpctx, flow->delivers),
fmt_amount_msat(tmpctx, max));

fmt_amount_msat(tmpctx, max),
fmt_flow_full(rq, rq, flow));
for (size_t i = 0; i < tal_count(*reservations); i++) {
plugin_log(rq->plugin, LOG_BROKEN,
"Reservation #%zi: %s on %s",
i,
fmt_amount_msat(tmpctx, (*reservations)[i].amount),
fmt_short_channel_id_dir(tmpctx, &(*reservations)[i].scidd));
}
diff = AMOUNT_MSAT(0);
}
create_flow_reservations(rq, reservations, flow);
return diff;
}

Expand Down

0 comments on commit a2c99bb

Please sign in to comment.