From 32f5ae8d1f07b1a169475d319ea7c8538b962e84 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Aug 2023 15:09:33 +0930 Subject: [PATCH] renepay: remove remaining calls to debug_paynote in favor of payflow_note(). Some are redundant, others simply convert. Signed-off-by: Rusty Russell --- plugins/renepay/debug.h | 6 ------ plugins/renepay/pay.c | 13 ++----------- plugins/renepay/pay_flow.c | 38 +++++++++++++++----------------------- plugins/renepay/payment.c | 11 +++++++++-- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/plugins/renepay/debug.h b/plugins/renepay/debug.h index 4e6c8b6e1..eb35e4614 100644 --- a/plugins/renepay/debug.h +++ b/plugins/renepay/debug.h @@ -30,9 +30,6 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno); #define debug_err(...) \ {_debug_info(MYLOG,__VA_ARGS__); abort();} -#define debug_paynote(p,...) \ - {payment_note(p,LOG_INFORM,__VA_ARGS__);_debug_info(MYLOG,__VA_ARGS__);} - #else /* Debugging information goes either to payment notes or to lightningd log. */ @@ -42,9 +39,6 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno); #define debug_err(...) \ plugin_err(pay_plugin->plugin,__VA_ARGS__) -#define debug_paynote(p,...) \ - payment_note(p,LOG_INFORM,__VA_ARGS__); - #endif #define debug_assert(expr) \ diff --git a/plugins/renepay/pay.c b/plugins/renepay/pay.c index a362e7026..e2396e2b1 100644 --- a/plugins/renepay/pay.c +++ b/plugins/renepay/pay.c @@ -1046,25 +1046,18 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA const u8 *raw) { struct short_channel_id errscid; - struct payment *p = pf->payment; const u8 *update; debug_assert(pf); - debug_assert(p); /* Final node is usually a hard failure */ if (erridx == tal_count(pf->path_scidds)) { - debug_paynote(p, - "onion error %s from final node #%u: %s", - onion_wire_name(onionerr), - erridx, - message); - if (onionerr == WIRE_MPP_TIMEOUT) { return pay_flow_failed(pf); } - debug_paynote(p,"final destination failure"); + payflow_note(pf, LOG_INFORM, + "final destination permanent failure"); return pay_flow_failed_final(pf, PAY_DESTINATION_PERM_FAIL, message); } @@ -1229,8 +1222,6 @@ static struct pf_result *sendpay_failure(struct pay_flow *pf, /* Only one code is really actionable */ switch (errcode) { case PAY_UNPARSEABLE_ONION: - debug_paynote(pf->payment, "Unparsable onion reply on route %s", - flow_path_to_str(tmpctx, pf)); return handle_unhandleable_error(pf, "Unparsable onion reply"); case PAY_TRY_OTHER_ROUTE: diff --git a/plugins/renepay/pay_flow.c b/plugins/renepay/pay_flow.c index 0fba1bb79..1a0206ae5 100644 --- a/plugins/renepay/pay_flow.c +++ b/plugins/renepay/pay_flow.c @@ -220,11 +220,12 @@ static u32 *shadow_additions(const tal_t *ctx, shadow_delay = shadow_one_flow(gossmap, flows[i], &shadow_fee); if (flow_delay(flows[i]) + shadow_delay > p->maxdelay) { - debug_paynote(p, "No shadow for flow %zu/%zu:" - " delay would add %u to %"PRIu64", exceeding max delay.", - i, tal_count(flows), - shadow_delay, - flow_delay(flows[i])); + payment_note(p, LOG_UNUSUAL, + "No shadow for flow %zu/%zu:" + " delay would add %u to %"PRIu64", exceeding max delay.", + i, tal_count(flows), + shadow_delay, + flow_delay(flows[i])); continue; } @@ -235,7 +236,8 @@ static u32 *shadow_additions(const tal_t *ctx, if (is_entire_payment && tal_count(flows) == 1) { if (!add_to_amounts(gossmap, flows[i], p->maxspend, shadow_fee)) { - debug_paynote(p, "No shadow fee for flow %zu/%zu:" + payment_note(p, LOG_UNUSUAL, + "No shadow fee for flow %zu/%zu:" " fee would add %s to %s, exceeding budget %s.", i, tal_count(flows), type_to_string(tmpctx, struct amount_msat, @@ -245,7 +247,8 @@ static u32 *shadow_additions(const tal_t *ctx, type_to_string(tmpctx, struct amount_msat, &p->maxspend)); } else { - debug_paynote(p, "No MPP, so added %s shadow fee", + payment_note(p, LOG_DBG, + "No MPP, so added %s shadow fee", type_to_string(tmpctx, struct amount_msat, &shadow_fee)); } @@ -444,13 +447,11 @@ const char *add_payflows(const tal_t *ctx, disabled = make_disabled_bitmap(tmpctx, pay_plugin->gossmap, p->disabled_scids); src = gossmap_find_node(pay_plugin->gossmap, &pay_plugin->my_id); if (!src) { - debug_paynote(p, "We don't have any channels?"); *ecode = PAY_ROUTE_NOT_FOUND; return tal_fmt(ctx, "We don't have any channels."); } dst = gossmap_find_node(pay_plugin->gossmap, &p->destination); if (!dst) { - debug_paynote(p, "No trace of destination in network gossip"); *ecode = PAY_ROUTE_NOT_FOUND; return tal_fmt(ctx, "Destination is unknown in the network gossip."); } @@ -472,10 +473,6 @@ const char *add_payflows(const tal_t *ctx, p->base_fee_penalty, p->prob_cost_factor); if (!flows) { - debug_paynote(p, - "minflow couldn't find a feasible flow for %s", - type_to_string(tmpctx,struct amount_msat,&amount)); - *ecode = PAY_ROUTE_NOT_FOUND; return tal_fmt(ctx, "minflow couldn't find a feasible flow for %s", @@ -487,7 +484,7 @@ const char *add_payflows(const tal_t *ctx, fee = flow_set_fee(flows); delay = flows_worst_delay(flows) + p->final_cltv; - debug_paynote(p, + payment_note(p, LOG_INFORM, "we have computed a set of %ld flows with probability %.3lf, fees %s and delay %ld", tal_count(flows), prob, @@ -497,9 +494,6 @@ const char *add_payflows(const tal_t *ctx, too_expensive = amount_msat_greater(fee, feebudget); if (too_expensive) { - debug_paynote(p, "Flows too expensive, fee = %s (max %s)", - type_to_string(tmpctx, struct amount_msat, &fee), - type_to_string(tmpctx, struct amount_msat, &feebudget)); *ecode = PAY_ROUTE_TOO_EXPENSIVE; return tal_fmt(ctx, "Fee exceeds our fee budget, " @@ -509,12 +503,8 @@ const char *add_payflows(const tal_t *ctx, } too_delayed = (delay > p->maxdelay); if (too_delayed) { - debug_paynote(p, "Flows too delayed, delay = %"PRIu64" (max %u)", - delay, p->maxdelay); - /* FIXME: What is a sane limit? */ if (p->delay_feefactor > 1000) { - debug_paynote(p, "Giving up!"); *ecode = PAY_ROUTE_TOO_EXPENSIVE; return tal_fmt(ctx, "CLTV delay exceeds our CLTV budget, " @@ -523,8 +513,10 @@ const char *add_payflows(const tal_t *ctx, } p->delay_feefactor *= 2; - debug_paynote(p, "Doubling delay_feefactor to %f", - p->delay_feefactor); + payment_note(p, LOG_INFORM, + "delay %"PRIu64" exceeds our max %u, so doubling delay_feefactor to %f", + delay, p->maxdelay, + p->delay_feefactor); continue; // retry } diff --git a/plugins/renepay/payment.c b/plugins/renepay/payment.c index 6dac1b449..0a95ae766 100644 --- a/plugins/renepay/payment.c +++ b/plugins/renepay/payment.c @@ -217,6 +217,8 @@ struct command_result *payment_fail( enum jsonrpc_errcode code, const char *fmt, ...) { + struct command *cmd; + /* We usually get called because a flow failed, but we * can also get called because we couldn't route any more * or some strange error. */ @@ -231,9 +233,14 @@ struct command_result *payment_fail( char *message = tal_vfmt(tmpctx,fmt,args); va_end(args); - debug_paynote(payment,"%s",message); + /* Don't bother notifying command, it's about to get failure */ + cmd = payment->cmd; + payment->cmd = NULL; + payment_note(payment, LOG_DBG, "%s", message); + /* Restore to keep destructor happy! */ + payment->cmd = cmd; - return command_fail(payment->cmd,code,"%s",message); + return command_fail(cmd,code,"%s",message); } u64 payment_parts(const struct payment *payment)