Skip to content

Commit e0aaf60

Browse files
committed
askrene: don't crash, just report, when a flow's remaining capacity is 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
1 parent c31eed4 commit e0aaf60

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

plugins/askrene/refine.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,25 @@ static struct amount_msat flow_remaining_capacity(const struct route_query *rq,
315315
* accidentally cap! */
316316
remove_flow_reservations(rq, reservations, flow);
317317
flow_max_capacity(rq, flow, &max, NULL, NULL);
318-
create_flow_reservations(rq, reservations, flow);
319318

320-
if (!amount_msat_sub(&diff, max, flow->delivers))
321-
plugin_err(rq->plugin, "Flow delivers %s but max only %s",
319+
/* This seems to happen. Which is strange, since flows should
320+
already be constrained. */
321+
if (!amount_msat_sub(&diff, max, flow->delivers)) {
322+
plugin_log(rq->plugin, LOG_BROKEN,
323+
"Flow delivers %s but max only %s? flow=%s",
322324
fmt_amount_msat(tmpctx, flow->delivers),
323-
fmt_amount_msat(tmpctx, max));
324-
325+
fmt_amount_msat(tmpctx, max),
326+
fmt_flow_full(rq, rq, flow));
327+
for (size_t i = 0; i < tal_count(*reservations); i++) {
328+
plugin_log(rq->plugin, LOG_BROKEN,
329+
"Reservation #%zi: %s on %s",
330+
i,
331+
fmt_amount_msat(tmpctx, (*reservations)[i].amount),
332+
fmt_short_channel_id_dir(tmpctx, &(*reservations)[i].scidd));
333+
}
334+
diff = AMOUNT_MSAT(0);
335+
}
336+
create_flow_reservations(rq, reservations, flow);
325337
return diff;
326338
}
327339

0 commit comments

Comments
 (0)