askrene: make children use child_log() instead of rq_log.
What changed, and why it matters
This commit is a straightforward internal cleanup in the Core Lightning 'askrene' routing plugin. It removes a temporary 'hack' where child processes used the parent logging function, and instead makes them use their own dedicated child_log() function. There is no security-relevant change visible in the diff.
No security action required. Treat as normal code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the global am_child flag and the conditional branch in rq_log() that redirected child-process log messages to child_log(). It then updates child-process code in plugins/askrene/child/*.c to call child_log()/child_err() directly, and adjusts helper signatures (e.g., flow_spend, flow_fee, flowset_fee, flowset_delivers) to no longer require a struct plugin * argument. The functional behavior of routing, logging levels, and error handling appears unchanged; it is purely a code-quality refactor.
Changed components
plugins/askrene/askrene.cplugins/askrene/child/entry.cplugins/askrene/child/entry.hplugins/askrene/child/explain_failure.cplugins/askrene/child/flow.cplugins/askrene/child/flow.hplugins/askrene/child/mcf.cplugins/askrene/child/refine.cInspect captured patch +155 / −170
diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c
index bbbae51e..0ffc12b2 100644
--- a/plugins/askrene/askrene.c
+++ b/plugins/askrene/askrene.c
@@ -315,12 +315,6 @@ const char *rq_log(const tal_t *ctx,
msg = tal_vfmt(ctx, fmt, args);
va_end(args);
- /* FIXME: This is a hack! */
- if (am_child) {
- child_log(tmpctx, level, "%s", msg);
- return msg;
- }
-
plugin_notify_message(rq->cmd, level, "%s", msg);
/* Notifications already get logged at debug. Otherwise reduce
diff --git a/plugins/askrene/child/entry.c b/plugins/askrene/child/entry.c
index 246a4a51..893bf9e4 100644
--- a/plugins/askrene/child/entry.c
+++ b/plugins/askrene/child/entry.c
@@ -14,9 +14,6 @@
#include <plugins/askrene/child/mcf.h>
#include <unistd.h>
-/* Temporary hack */
-bool am_child = false;
-
/* A single route. */
struct route {
/* Actual path to take */
@@ -222,7 +219,6 @@ int fork_router_child(struct route_query *rq,
close(logfds[0]);
close(replyfds[0]);
set_child_log_fd(logfds[1]);
- am_child = true;
if (single_path) {
err = single_path_routes(rq, rq, deadline, srcnode, dstnode,
amount, maxfee, finalcltv,
diff --git a/plugins/askrene/child/entry.h b/plugins/askrene/child/entry.h
index 2ea790a4..020d78b1 100644
--- a/plugins/askrene/child/entry.h
+++ b/plugins/askrene/child/entry.h
@@ -23,7 +23,4 @@ int fork_router_child(struct route_query *rq,
struct json_filter *cmd_filter,
int *log_fd,
int *child_pid);
-
-/* FIXME: Remove this */
-extern bool am_child;
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_ENTRY_H */
diff --git a/plugins/askrene/child/explain_failure.c b/plugins/askrene/child/explain_failure.c
index 4502a32b..4a571255 100644
--- a/plugins/askrene/child/explain_failure.c
+++ b/plugins/askrene/child/explain_failure.c
@@ -4,6 +4,7 @@
#include <common/gossmap.h>
#include <common/route.h>
#include <plugins/askrene/askrene.h>
+#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/explain_failure.h>
#include <plugins/askrene/layer.h>
#include <plugins/askrene/reserve.h>
@@ -133,33 +134,33 @@ static const char *check_capacity(const tal_t *ctx,
node_stats(rq, node, node_direction, &stats);
if (amount_msat_greater(amount, stats.total.capacity)) {
- return rq_log(ctx, rq, LOG_DBG,
- NO_USABLE_PATHS_STRING
- " Total %s capacity is only %s"
- " (in %zu channels).",
- name,
- fmt_amount_msat(tmpctx, stats.total.capacity),
- stats.total.num_channels);
+ return child_log(ctx, LOG_DBG,
+ NO_USABLE_PATHS_STRING
+ " Total %s capacity is only %s"
+ " (in %zu channels).",
+ name,
+ fmt_amount_msat(tmpctx, stats.total.capacity),
+ stats.total.num_channels);
}
if (amount_msat_greater(amount, stats.gossip_known.capacity)) {
- return rq_log(ctx, rq, LOG_DBG,
- NO_USABLE_PATHS_STRING
- " Missing gossip for %s: only known %zu/%zu channels, leaving capacity only %s of %s.",
- name,
- stats.gossip_known.num_channels,
- stats.total.num_channels,
- fmt_amount_msat(tmpctx, stats.gossip_known.capacity),
- fmt_amount_msat(tmpctx, stats.total.capacity));
+ return child_log(ctx, LOG_DBG,
+ NO_USABLE_PATHS_STRING
+ " Missing gossip for %s: only known %zu/%zu channels, leaving capacity only %s of %s.",
+ name,
+ stats.gossip_known.num_channels,
+ stats.total.num_channels,
+ fmt_amount_msat(tmpctx, stats.gossip_known.capacity),
+ fmt_amount_msat(tmpctx, stats.total.capacity));
}
if (amount_msat_greater(amount, stats.enabled.capacity)) {
- return rq_log(ctx, rq, LOG_DBG,
- NO_USABLE_PATHS_STRING
- " The %s has disabled %zu of %zu channels, leaving capacity only %s of %s.",
- name,
- stats.total.num_channels - stats.enabled.num_channels,
- stats.total.num_channels,
- fmt_amount_msat(tmpctx, stats.enabled.capacity),
- fmt_amount_msat(tmpctx, stats.total.capacity));
+ return child_log(ctx, LOG_DBG,
+ NO_USABLE_PATHS_STRING
+ " The %s has disabled %zu of %zu channels, leaving capacity only %s of %s.",
+ name,
+ stats.total.num_channels - stats.enabled.num_channels,
+ stats.total.num_channels,
+ fmt_amount_msat(tmpctx, stats.enabled.capacity),
+ fmt_amount_msat(tmpctx, stats.total.capacity));
}
return NULL;
}
@@ -241,7 +242,7 @@ const char *explain_failure(const tal_t *ctx,
hops = route_from_dijkstra(tmpctx, rq->gossmap, dij, srcnode,
AMOUNT_MSAT(0), 0);
if (!hops)
- return rq_log(ctx, rq, LOG_INFORM,
+ return child_log(ctx, LOG_INFORM,
"There is no connection between source and destination at all");
/* Description of shortest path */
@@ -268,12 +269,12 @@ const char *explain_failure(const tal_t *ctx,
explanation = tal_fmt(
tmpctx, "produces a fee overflow for amount %s",
fmt_amount_msat(tmpctx, rolling_amount));
- return rq_log(ctx, rq, LOG_INFORM,
+ return child_log(ctx, LOG_INFORM,
NO_USABLE_PATHS_STRING
- " The shortest path is %s, but %s %s",
- path,
- fmt_short_channel_id_dir(tmpctx, &scidd),
- explanation);
+ " The shortest path is %s, but %s %s",
+ path,
+ fmt_short_channel_id_dir(tmpctx, &scidd),
+ explanation);
}
}
@@ -309,16 +310,16 @@ const char *explain_failure(const tal_t *ctx,
else
continue;
- return rq_log(ctx, rq, LOG_INFORM,
- NO_USABLE_PATHS_STRING
- " The shortest path is %s, but %s %s",
- path,
- fmt_short_channel_id_dir(tmpctx, &scidd),
- explanation);
+ return child_log(ctx, LOG_INFORM,
+ NO_USABLE_PATHS_STRING
+ " The shortest path is %s, but %s %s",
+ path,
+ fmt_short_channel_id_dir(tmpctx, &scidd),
+ explanation);
}
- return rq_log(ctx, rq, LOG_BROKEN,
- "Actually, I'm not sure why we didn't find the"
- " obvious route %s: perhaps this is a bug?",
- path);
+ return child_log(ctx, LOG_BROKEN,
+ "Actually, I'm not sure why we didn't find the"
+ " obvious route %s: perhaps this is a bug?",
+ path);
}
diff --git a/plugins/askrene/child/flow.c b/plugins/askrene/child/flow.c
index 05d02680..d9cd74e7 100644
--- a/plugins/askrene/child/flow.c
+++ b/plugins/askrene/child/flow.c
@@ -6,6 +6,7 @@
#include <common/overflows.h>
#include <math.h>
#include <plugins/askrene/askrene.h>
+#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/flow.h>
#include <plugins/libplugin.h>
#include <stdio.h>
@@ -17,16 +18,15 @@
#endif
/* How much do we deliver to destination using this set of routes */
-struct amount_msat flowset_delivers(struct plugin *plugin,
- struct flow **flows)
+struct amount_msat flowset_delivers(struct flow **flows)
{
struct amount_msat final = AMOUNT_MSAT(0);
for (size_t i = 0; i < tal_count(flows); i++) {
if (!amount_msat_accumulate(&final, flows[i]->delivers)) {
- plugin_err(plugin, "Could not add flowsat %s to %s (%zu/%zu)",
- fmt_amount_msat(tmpctx, flows[i]->delivers),
- fmt_amount_msat(tmpctx, final),
- i, tal_count(flows));
+ child_err("Could not add flowsat %s to %s (%zu/%zu)",
+ fmt_amount_msat(tmpctx, flows[i]->delivers),
+ fmt_amount_msat(tmpctx, final),
+ i, tal_count(flows));
}
}
return final;
@@ -68,7 +68,7 @@ static double edge_probability(const struct route_query *rq,
return 1.0 - amount_msat_ratio(numerator, denominator);
}
-struct amount_msat flow_spend(struct plugin *plugin, const struct flow *flow)
+struct amount_msat flow_spend(const struct flow *flow)
{
const size_t pathlen = tal_count(flow->path);
struct amount_msat spend = flow->delivers;
@@ -77,38 +77,38 @@ struct amount_msat flow_spend(struct plugin *plugin, const struct flow *flow)
const struct half_chan *h = flow_edge(flow, i);
if (!amount_msat_add_fee(&spend, h->base_fee,
h->proportional_fee)) {
- plugin_err(plugin, "Could not add fee %u/%u to amount %s in %i/%zu",
- h->base_fee, h->proportional_fee,
- fmt_amount_msat(tmpctx, spend),
- i, pathlen);
+ child_err("Could not add fee %u/%u to amount %s in %i/%zu",
+ h->base_fee, h->proportional_fee,
+ fmt_amount_msat(tmpctx, spend),
+ i, pathlen);
}
}
return spend;
}
-struct amount_msat flow_fee(struct plugin *plugin, const struct flow *flow)
+struct amount_msat flow_fee(const struct flow *flow)
{
- struct amount_msat spend = flow_spend(plugin, flow);
+ struct amount_msat spend = flow_spend(flow);
struct amount_msat fee;
if (!amount_msat_sub(&fee, spend, flow->delivers)) {
- plugin_err(plugin, "Could not subtract %s from %s for fee",
- fmt_amount_msat(tmpctx, flow->delivers),
- fmt_amount_msat(tmpctx, spend));
+ child_err("Could not subtract %s from %s for fee",
+ fmt_amount_msat(tmpctx, flow->delivers),
+ fmt_amount_msat(tmpctx, spend));
}
return fee;
}
-struct amount_msat flowset_fee(struct plugin *plugin, struct flow **flows)
+struct amount_msat flowset_fee(struct flow **flows)
{
struct amount_msat fee = AMOUNT_MSAT(0);
for (size_t i = 0; i < tal_count(flows); i++) {
- struct amount_msat this_fee = flow_fee(plugin, flows[i]);
+ struct amount_msat this_fee = flow_fee(flows[i]);
if (!amount_msat_accumulate(&fee, this_fee)) {
- plugin_err(plugin, "Could not add %s to %s for flowset fee",
- fmt_amount_msat(tmpctx, this_fee),
- fmt_amount_msat(tmpctx, fee));
+ child_err("Could not add %s to %s for flowset fee",
+ fmt_amount_msat(tmpctx, this_fee),
+ fmt_amount_msat(tmpctx, fee));
}
}
return fee;
@@ -144,10 +144,10 @@ double flow_probability(const struct flow *flow,
if (!amount_msat_add_fee(&spend, h->base_fee,
h->proportional_fee)) {
- plugin_err(rq->plugin, "Could not add fee %u/%u to amount %s in %i/%zu",
- h->base_fee, h->proportional_fee,
- fmt_amount_msat(tmpctx, spend),
- i, pathlen);
+ child_err("Could not add fee %u/%u to amount %s in %i/%zu",
+ h->base_fee, h->proportional_fee,
+ fmt_amount_msat(tmpctx, spend),
+ i, pathlen);
}
}
diff --git a/plugins/askrene/child/flow.h b/plugins/askrene/child/flow.h
index d424676c..eeec5a96 100644
--- a/plugins/askrene/child/flow.h
+++ b/plugins/askrene/child/flow.h
@@ -40,17 +40,16 @@ double flow_probability(const struct flow *flow,
const struct route_query *rq);
/* How much do we need to send to make this flow arrive. */
-struct amount_msat flow_spend(struct plugin *plugin, const struct flow *flow);
+struct amount_msat flow_spend(const struct flow *flow);
/* How much do we pay in fees to make this flow arrive. */
-struct amount_msat flow_fee(struct plugin *plugin, const struct flow *flow);
+struct amount_msat flow_fee(const struct flow *flow);
/* What fee to we pay for this entire flow set? */
-struct amount_msat flowset_fee(struct plugin *plugin, struct flow **flows);
+struct amount_msat flowset_fee(struct flow **flows);
/* How much does this entire flowset deliver? */
-struct amount_msat flowset_delivers(struct plugin *plugin,
- struct flow **flows);
+struct amount_msat flowset_delivers(struct flow **flows);
/* How much CLTV does this flow require? */
u64 flow_delay(const struct flow *flow);
diff --git a/plugins/askrene/child/mcf.c b/plugins/askrene/child/mcf.c
index 4cca00cc..e5af6fd9 100644
--- a/plugins/askrene/child/mcf.c
+++ b/plugins/askrene/child/mcf.c
@@ -11,6 +11,7 @@
#include <math.h>
#include <plugins/askrene/askrene.h>
#include <plugins/askrene/child/algorithm.h>
+#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/dijkstra.h>
#include <plugins/askrene/child/explain_failure.h>
#include <plugins/askrene/child/flow.h>
@@ -1015,8 +1016,8 @@ static struct flow **minflow(const tal_t *ctx,
if (!simple_feasibleflow(working_ctx, graph, src, dst,
arc_capacity, pay_amount)) {
- rq_log(tmpctx, rq, LOG_INFORM,
- "%s failed: unable to find a feasible flow.", __func__);
+ child_log(tmpctx, LOG_INFORM,
+ "%s failed: unable to find a feasible flow.", __func__);
goto fail;
}
combine_cost_function(working_ctx, graph, arc_prob_cost, arc_fee_cost,
@@ -1029,8 +1030,8 @@ static struct flow **minflow(const tal_t *ctx,
arc_capacity,
arc_cost,
node_potential)) {
- rq_log(tmpctx, rq, LOG_BROKEN,
- "%s: MCF optimization step failed", __func__);
+ child_log(tmpctx, LOG_BROKEN,
+ "%s: MCF optimization step failed", __func__);
goto fail;
}
@@ -1039,10 +1040,10 @@ static struct flow **minflow(const tal_t *ctx,
* channel in the routes. */
flow_paths = get_flow_paths(ctx, working_ctx, params,
graph, arc_capacity);
- if(!flow_paths){
- rq_log(tmpctx, rq, LOG_BROKEN,
- "%s: failed to extract flow paths from the MCF solution",
- __func__);
+ if (!flow_paths) {
+ child_log(tmpctx, LOG_BROKEN,
+ "%s: failed to extract flow paths from the MCF solution",
+ __func__);
goto fail;
}
tal_free(working_ctx);
@@ -1211,8 +1212,8 @@ static struct flow **single_path_flow(const tal_t *ctx, const struct route_query
distance)) {
/* This might fail if we are unable to find a suitable route, it
* doesn't mean the plugin is broken, that's why we LOG_INFORM. */
- rq_log(tmpctx, rq, LOG_INFORM,
- "%s: could not find a feasible single path", __func__);
+ child_log(tmpctx, LOG_INFORM,
+ "%s: could not find a feasible single path", __func__);
goto fail;
}
const u64 pay_amount =
@@ -1224,17 +1225,16 @@ static struct flow **single_path_flow(const tal_t *ctx, const struct route_query
flow_paths = get_flow_singlepath(ctx, params, graph, rq->gossmap,
src, dst, pay_amount, prev);
if (!flow_paths) {
- rq_log(tmpctx, rq, LOG_BROKEN,
- "%s: failed to extract flow paths from the single-path "
- "solution",
- __func__);
+ child_log(tmpctx, LOG_BROKEN,
+ "%s: failed to extract flow paths from the single-path "
+ "solution",
+ __func__);
goto fail;
}
if (tal_count(flow_paths) != 1) {
- rq_log(
- tmpctx, rq, LOG_BROKEN,
- "%s: single-path solution returned a multi route solution",
- __func__);
+ child_log(tmpctx, LOG_BROKEN,
+ "%s: single-path solution returned a multi route solution",
+ __func__);
goto fail;
}
tal_free(working_ctx);
@@ -1369,9 +1369,9 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
while (!amount_msat_is_zero(amount_to_deliver)) {
if (timemono_after(time_mono(), deadline)) {
- error_message = rq_log(ctx, rq, LOG_BROKEN,
- "%s: timed out after deadline",
- __func__);
+ error_message = child_log(ctx, LOG_BROKEN,
+ "%s: timed out after deadline",
+ __func__);
goto fail;
}
@@ -1408,7 +1408,7 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
goto fail;
/* we finished removing flows and excess */
- all_deliver = flowset_delivers(rq->plugin, new_flows);
+ all_deliver = flowset_delivers(new_flows);
if (amount_msat_is_zero(all_deliver)) {
/* We removed all flows and we have not modified the
* MCF parameters. We will not have an infinite loop
@@ -1437,19 +1437,18 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
* flows deliver with respect to the total remaining amount,
* ie. we avoid "consuming" all the feebudget if we still need
* to run MCF again for some remaining amount. */
- struct amount_msat all_fees =
- flowset_fee(rq->plugin, new_flows);
+ struct amount_msat all_fees = flowset_fee(new_flows);
const double deliver_fraction =
amount_msat_ratio(all_deliver, amount_to_deliver);
struct amount_msat partial_feebudget;
if (!amount_msat_scale(&partial_feebudget, feebudget,
deliver_fraction)) {
error_message =
- rq_log(ctx, rq, LOG_BROKEN,
- "%s: failed to scale the fee budget (%s) by "
- "fraction (%lf)",
- __func__, fmt_amount_msat(tmpctx, feebudget),
- deliver_fraction);
+ child_log(ctx, LOG_BROKEN,
+ "%s: failed to scale the fee budget (%s) by "
+ "fraction (%lf)",
+ __func__, fmt_amount_msat(tmpctx, feebudget),
+ deliver_fraction);
goto fail;
}
if (amount_msat_greater(all_fees, partial_feebudget)) {
@@ -1461,8 +1460,8 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
else
mu += 10;
mu = MIN(mu, MU_MAX);
- rq_log(
- tmpctx, rq, LOG_INFORM,
+ child_log(
+ tmpctx, LOG_INFORM,
"The flows had a fee of %s, greater than "
"max of %s, retrying with mu of %u%%...",
fmt_amount_msat(tmpctx, all_fees),
@@ -1473,16 +1472,16 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
/* we cannot increase mu anymore and all_fees
* already exceeds feebudget we fail. */
error_message =
- rq_log(ctx, rq, LOG_UNUSUAL,
- "Could not find route without "
- "excessive cost");
+ child_log(ctx, LOG_UNUSUAL,
+ "Could not find route without "
+ "excessive cost");
goto fail;
} else {
/* mu cannot be increased but at least all_fees
* does not exceed feebudget, we give it a shot.
*/
- rq_log(
- tmpctx, rq, LOG_UNUSUAL,
+ child_log(
+ tmpctx, LOG_UNUSUAL,
"The flows had a fee of %s, greater than "
"max of %s, but still within the fee "
"budget %s, we accept those flows.",
@@ -1496,18 +1495,18 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
if (finalcltv + flows_worst_delay(new_flows) > maxdelay) {
if (delay_feefactor > 10) {
error_message =
- rq_log(ctx, rq, LOG_UNUSUAL,
- "Could not find route without "
- "excessive delays");
+ child_log(ctx, LOG_UNUSUAL,
+ "Could not find route without "
+ "excessive delays");
goto fail;
}
delay_feefactor *= 2;
- rq_log(tmpctx, rq, LOG_INFORM,
- "The worst flow delay is %" PRIu64
- " (> %i), retrying with delay_feefactor %f...",
- flows_worst_delay(new_flows), maxdelay - finalcltv,
- delay_feefactor);
+ child_log(tmpctx, LOG_INFORM,
+ "The worst flow delay is %" PRIu64
+ " (> %i), retrying with delay_feefactor %f...",
+ flows_worst_delay(new_flows), maxdelay - finalcltv,
+ delay_feefactor);
continue;
}
@@ -1526,7 +1525,7 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
&all_deliver, new_flows[i]->delivers) ||
!amount_msat_accumulate(
&all_fees,
- flow_fee(rq->plugin, new_flows[i])))
+ flow_fee(new_flows[i])))
abort();
}
}
@@ -1534,10 +1533,10 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
if (!amount_msat_deduct(&feebudget, all_fees) ||
!amount_msat_deduct(&amount_to_deliver, all_deliver)) {
error_message =
- rq_log(ctx, rq, LOG_BROKEN,
- "%s: unexpected arithmetic operation "
- "failure on amount_msat",
- __func__);
+ child_log(ctx, LOG_BROKEN,
+ "%s: unexpected arithmetic operation "
+ "failure on amount_msat",
+ __func__);
goto fail;
}
}
@@ -1562,19 +1561,17 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
}
/* Check fee budget! */
- fee = flowset_fee(rq->plugin, *flows);
+ fee = flowset_fee(*flows);
if (amount_msat_greater(fee, maxfee)) {
- error_message = rq_log(rq, rq, LOG_INFORM,
- "After reducing the flows to %zu (i.e. maxparts),"
- " we had a fee of %s, greater than "
- "max of %s.",
- tal_count(*flows),
- fmt_amount_msat(tmpctx, fee),
- fmt_amount_msat(tmpctx, maxfee));
- if (error_message) {
- *flows = tal_free(*flows);
- return error_message;
- }
+ error_message = child_log(rq, LOG_INFORM,
+ "After reducing the flows to %zu (i.e. maxparts),"
+ " we had a fee of %s, greater than "
+ "max of %s.",
+ tal_count(*flows),
+ fmt_amount_msat(tmpctx, fee),
+ fmt_amount_msat(tmpctx, maxfee));
+ *flows = tal_free(*flows);
+ return error_message;
}
}
@@ -1587,24 +1584,24 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
* verify" */
if (!check_htlc_min_limits(rq, *flows)) {
error_message =
- rq_log(rq, rq, LOG_BROKEN,
+ child_log(rq, LOG_BROKEN,
"%s: check_htlc_min_limits failed", __func__);
*flows = tal_free(*flows);
return error_message;
}
if (!check_htlc_max_limits(rq, *flows)) {
*flows = tal_free(*flows);
- return rq_log(rq, rq, LOG_BROKEN,
- "%s: check_htlc_max_limits failed", __func__);
+ return child_log(rq, LOG_BROKEN,
+ "%s: check_htlc_max_limits failed", __func__);
}
if (tal_count(*flows) > rq->maxparts) {
size_t num_flows = tal_count(*flows);
*flows = tal_free(*flows);
- return rq_log(rq, rq, LOG_BROKEN,
- "%s: the number of flows (%zu) exceeds the limit set "
- "on payment parts (%" PRIu32
- "), please submit a bug report",
- __func__, num_flows, rq->maxparts);
+ return child_log(rq, LOG_BROKEN,
+ "%s: the number of flows (%zu) exceeds the limit set "
+ "on payment parts (%" PRIu32
+ "), please submit a bug report",
+ __func__, num_flows, rq->maxparts);
}
return NULL;
diff --git a/plugins/askrene/child/refine.c b/plugins/askrene/child/refine.c
index dd0b0d06..e257c469 100644
--- a/plugins/askrene/child/refine.c
+++ b/plugins/askrene/child/refine.c
@@ -4,6 +4,7 @@
#include <ccan/tal/str/str.h>
#include <common/gossmap.h>
#include <plugins/askrene/askrene.h>
+#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/flow.h>
#include <plugins/askrene/child/refine.h>
#include <plugins/askrene/reserve.h>
@@ -109,7 +110,7 @@ void create_flow_reservations(const struct route_query *rq,
amount_to_reserve);
if (!amount_msat_add_fee(&msat,
h->base_fee, h->proportional_fee))
- plugin_err(rq->plugin, "Adding fee to amount");
+ child_err("Adding fee to amount");
}
}
@@ -281,8 +282,8 @@ remove_htlc_min_violations(const tal_t *ctx, struct route_query *rq,
+ 2 * gossmap_chan_idx(rq->gossmap, flow->path[i]);
get_scidd(rq->gossmap, flow, i, &scidd);
- rq_log(
- ctx, rq, LOG_INFORM,
+ child_log(
+ ctx, LOG_INFORM,
"Sending %s across %s would violate htlc_min "
"(~%s), disabling this channel",
fmt_amount_msat(ctx, msat),
@@ -295,8 +296,8 @@ remove_htlc_min_violations(const tal_t *ctx, struct route_query *rq,
&msat, hc->base_fee,
hc->proportional_fee)) {
error_message =
- rq_log(ctx, rq, LOG_BROKEN,
- "%s: Adding fee to amount", __func__);
+ child_log(ctx, LOG_BROKEN,
+ "%s: Adding fee to amount", __func__);
break;
}
}
@@ -325,13 +326,13 @@ static const char *remove_bottleneck(const tal_t *ctx, struct route_query *rq,
}
}
if (min_pos >= tal_count(flow->path)) {
- error_message = rq_log(
- ctx, rq, LOG_BROKEN,
+ error_message = child_log(
+ ctx, LOG_BROKEN,
"%s: failed to find any bottleneck, flow has no hops? %s",
__func__, fmt_flow_full(tmpctx, rq, flow));
} else {
get_scidd(rq->gossmap, flow, min_pos, &scidd);
- rq_log(ctx, rq, LOG_INFORM,
+ child_log(tmpctx, LOG_INFORM,
"Disabling bottleneck channel %s with "
"htlc_max/known_max at %s",
fmt_short_channel_id_dir(ctx, &scidd),
@@ -489,11 +490,11 @@ static bool increase_flows(const struct route_query *rq,
* capacity. That shouldn't happen, but if it does,
* we don't crash */
if (!amount_msat_sub(&remaining, capacity, flows[i]->delivers)) {
- rq_log(rq, rq, LOG_BROKEN,
- "%s: flow %s delivers %s which is more than the path's capacity %s", __func__,
- fmt_flow_full(tmpctx, rq, flows[i]),
- fmt_amount_msat(tmpctx, flows[i]->delivers),
- fmt_amount_msat(tmpctx, capacity));
+ child_log(rq, LOG_BROKEN,
+ "%s: flow %s delivers %s which is more than the path's capacity %s", __func__,
+ fmt_flow_full(tmpctx, rq, flows[i]),
+ fmt_amount_msat(tmpctx, flows[i]->delivers),
+ fmt_amount_msat(tmpctx, capacity));
continue;
}
if (amount_msat_greater(remaining, best_remaining)) {
@@ -541,9 +542,9 @@ const char *refine_flows(const tal_t *ctx, struct route_query *rq,
/* We don't expect to have a zero flow amount here. Just report
* it. */
if (amount_msat_is_zero(try_deliver)) {
- rq_log(ctx, rq, LOG_UNUSUAL,
- "Tried to refine a flow with zero amount: %s",
- fmt_flow_full(tmpctx, rq, (*flows)[i]));
+ child_log(tmpctx, LOG_UNUSUAL,
+ "Tried to refine a flow with zero amount: %s",
+ fmt_flow_full(tmpctx, rq, (*flows)[i]));
del_flow_from_arr(flows, i);
continue;
}
@@ -715,9 +716,9 @@ const char *reduce_num_flows(const tal_t *ctx,
del_flow_from_arr(flows, tal_count(*flows) - 1);
if (!increase_flows(rq, *flows, deliver, -1.0))
- return rq_log(ctx, rq, LOG_INFORM,
- "Failed to reduce %zu flows down to maxparts (%zu)",
- orig_num_flows, num_parts);
+ return child_log(ctx, LOG_INFORM,
+ "Failed to reduce %zu flows down to maxparts (%zu)",
+ orig_num_flows, num_parts);
return NULL;
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.