mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 14:44:16 +01:00
plugins/renepay: convenience routing to log when we disable a chan.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
00e9af57f5
commit
574716dfd5
@ -140,10 +140,8 @@ static struct pf_result *handle_unhandleable_error(struct pay_flow *pf,
|
||||
/* Assume it's not the destination */
|
||||
n = pseudorand(n-1);
|
||||
|
||||
tal_arr_expand(&pf->payment->disabled, pf->path_scidds[n].scid);
|
||||
payflow_note(pf, LOG_DBG, "... eliminated %s",
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&pf->path_scidds[n].scid));
|
||||
payflow_disable_chan(pf, pf->path_scidds[n].scid,
|
||||
LOG_INFORM, "randomly chosen");
|
||||
|
||||
return pay_flow_failed(pf);
|
||||
}
|
||||
@ -175,14 +173,11 @@ static struct command_result *addgossip_failure(struct command *cmd,
|
||||
struct addgossip *adg)
|
||||
|
||||
{
|
||||
struct payment * payment = adg->pf->payment;
|
||||
plugin_log(pay_plugin->plugin,LOG_DBG,"calling %s",__PRETTY_FUNCTION__);
|
||||
|
||||
payflow_note(adg->pf, LOG_UNUSUAL,
|
||||
"addgossip failed, removing channel %s (%.*s)",
|
||||
type_to_string(tmpctx, struct short_channel_id, &adg->scid),
|
||||
err->end - err->start, buf + err->start);
|
||||
tal_arr_expand(&payment->disabled, adg->scid);
|
||||
payflow_disable_chan(adg->pf, adg->scid,
|
||||
LOG_INFORM, "addgossip failed (%.*s)",
|
||||
err->end - err->start, buf + err->start);
|
||||
|
||||
return addgossip_done(cmd, buf, err, adg);
|
||||
}
|
||||
@ -307,12 +302,11 @@ static struct command_result *flow_sendpay_failed(struct command *cmd,
|
||||
plugin_err(cmd->plugin, "Strange error from sendpay: %.*s",
|
||||
json_tok_full_len(err), json_tok_full(buf, err));
|
||||
|
||||
payflow_note(pf, LOG_INFORM,
|
||||
"sendpay didn't like first hop, eliminated: %s", msg);
|
||||
|
||||
/* There is no new knowledge from this kind of failure.
|
||||
* We just disable this scid. */
|
||||
tal_arr_expand(&payment->disabled, pf->path_scidds[0].scid);
|
||||
payflow_disable_chan(pf, pf->path_scidds[0].scid,
|
||||
LOG_INFORM,
|
||||
"sendpay didn't like first hop: %s", msg);
|
||||
|
||||
pay_flow_failed(pf);
|
||||
return command_still_pending(cmd);
|
||||
@ -1075,13 +1069,6 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA
|
||||
}
|
||||
|
||||
errscid = pf->path_scidds[erridx].scid;
|
||||
debug_paynote(p,
|
||||
"onion error %s from node #%u %s: %s",
|
||||
onion_wire_name(onionerr),
|
||||
erridx,
|
||||
type_to_string(tmpctx, struct short_channel_id, &errscid),
|
||||
message);
|
||||
|
||||
switch (onionerr) {
|
||||
/* These definitely mean eliminate channel */
|
||||
case WIRE_PERMANENT_CHANNEL_FAILURE:
|
||||
@ -1101,9 +1088,9 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA
|
||||
case WIRE_INVALID_ONION_PAYLOAD:
|
||||
case WIRE_INVALID_ONION_BLINDING:
|
||||
case WIRE_EXPIRY_TOO_FAR:
|
||||
debug_paynote(p, "we're removing scid %s",
|
||||
type_to_string(tmpctx,struct short_channel_id,&errscid));
|
||||
tal_arr_expand(&p->disabled, errscid);
|
||||
payflow_disable_chan(pf, errscid, LOG_UNUSUAL,
|
||||
"%s",
|
||||
onion_wire_name(onionerr));
|
||||
return pay_flow_failed(pf);
|
||||
|
||||
/* These can be fixed (maybe) by applying the included channel_update */
|
||||
@ -1118,9 +1105,8 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA
|
||||
if (update)
|
||||
return submit_update(pf, update, errscid);
|
||||
|
||||
debug_paynote(p, "missing an update, so we're removing scid %s",
|
||||
type_to_string(tmpctx,struct short_channel_id,&errscid));
|
||||
tal_arr_expand(&p->disabled, errscid);
|
||||
payflow_disable_chan(pf, errscid,
|
||||
LOG_UNUSUAL, "missing channel_update");
|
||||
return pay_flow_failed(pf);
|
||||
|
||||
case WIRE_TEMPORARY_CHANNEL_FAILURE:
|
||||
@ -1140,10 +1126,9 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA
|
||||
break;
|
||||
}
|
||||
|
||||
debug_paynote(p,"unkown onion error code %u, removing scid %s",
|
||||
onionerr,
|
||||
type_to_string(tmpctx,struct short_channel_id,&errscid));
|
||||
tal_arr_expand(&p->disabled, errscid);
|
||||
payflow_disable_chan(pf, errscid,
|
||||
LOG_UNUSUAL, "unexpected error code %u",
|
||||
onionerr);
|
||||
return pay_flow_failed(pf);
|
||||
}
|
||||
|
||||
|
@ -404,12 +404,7 @@ static bool disable_htlc_violations_oneflow(struct payment *p,
|
||||
continue;
|
||||
|
||||
scid = gossmap_chan_scid(gossmap, flow->path[i]);
|
||||
debug_paynote(p, "...disabling channel %s: %s",
|
||||
type_to_string(tmpctx, struct short_channel_id, &scid),
|
||||
reason);
|
||||
|
||||
/* Add this for future searches for this payment. */
|
||||
tal_arr_expand(&p->disabled, scid);
|
||||
payment_disable_chan(p, scid, LOG_INFORM, "%s", reason);
|
||||
/* Add to existing bitmap */
|
||||
bitmap_set_bit(disabled,
|
||||
gossmap_chan_idx(gossmap, flow->path[i]));
|
||||
@ -446,7 +441,7 @@ const char *add_payflows(const tal_t *ctx,
|
||||
bitmap *disabled;
|
||||
const struct gossmap_node *src, *dst;
|
||||
|
||||
disabled = make_disabled_bitmap(tmpctx, pay_plugin->gossmap, p->disabled);
|
||||
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?");
|
||||
|
@ -65,13 +65,48 @@ struct payment *payment_new(const tal_t *ctx,
|
||||
p->groupid=1;
|
||||
|
||||
p->local_gossmods = gossmap_localmods_new(p);
|
||||
p->disabled = tal_arr(p,struct short_channel_id,0);
|
||||
p->disabled_scids = tal_arr(p,struct short_channel_id,0);
|
||||
p->next_partid=1;
|
||||
p->progress_deadline = NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Disable this scid for this payment, and tell me why! */
|
||||
void payflow_disable_chan(struct pay_flow *pf,
|
||||
struct short_channel_id scid,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *str;
|
||||
|
||||
va_start(ap, fmt);
|
||||
str = tal_vfmt(tmpctx, fmt, ap);
|
||||
va_end(ap);
|
||||
payflow_note(pf, lvl, "disabling %s: %s",
|
||||
type_to_string(tmpctx, struct short_channel_id, &scid),
|
||||
str);
|
||||
tal_arr_expand(&pf->payment->disabled_scids, scid);
|
||||
}
|
||||
|
||||
void payment_disable_chan(struct payment *p,
|
||||
struct short_channel_id scid,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *str;
|
||||
|
||||
va_start(ap, fmt);
|
||||
str = tal_vfmt(tmpctx, fmt, ap);
|
||||
va_end(ap);
|
||||
payment_note(p, lvl, "disabling %s: %s",
|
||||
type_to_string(tmpctx, struct short_channel_id, &scid),
|
||||
str);
|
||||
tal_arr_expand(&p->disabled_scids, scid);
|
||||
}
|
||||
|
||||
struct amount_msat payment_sent(const struct payment *p)
|
||||
{
|
||||
return p->total_sent;
|
||||
|
@ -30,7 +30,7 @@ struct payment {
|
||||
struct gossmap_localmods *local_gossmods;
|
||||
|
||||
/* Channels we decided to disable for various reasons. */
|
||||
struct short_channel_id *disabled;
|
||||
struct short_channel_id *disabled_scids;
|
||||
|
||||
/* Used in get_payflows to set ids to each pay_flow. */
|
||||
u64 next_partid;
|
||||
@ -157,6 +157,18 @@ void payment_reconsider(struct payment *p);
|
||||
|
||||
u64 payment_parts(const struct payment *payment);
|
||||
|
||||
/* Disable this scid for this payment, and tell me why! */
|
||||
void payflow_disable_chan(struct pay_flow *pf,
|
||||
struct short_channel_id scid,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...);
|
||||
|
||||
/* Sometimes, disabling chan is independent of a flow. */
|
||||
void payment_disable_chan(struct payment *p,
|
||||
struct short_channel_id scid,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...);
|
||||
|
||||
struct command_result *payment_fail(
|
||||
struct payment *payment,
|
||||
enum jsonrpc_errcode code,
|
||||
|
@ -252,12 +252,8 @@ bool uncertainty_network_update_from_listpeerchannels(
|
||||
goto malformed;
|
||||
|
||||
if (!connected) {
|
||||
debug_paynote(p, "local channel %s disabled:"
|
||||
" peer disconnected",
|
||||
type_to_string(tmpctx,
|
||||
struct short_channel_id,
|
||||
&scidd.scid));
|
||||
tal_arr_expand(&p->disabled, scidd.scid);
|
||||
payment_disable_chan(p, scidd.scid, LOG_DBG,
|
||||
"peer disconnected");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -289,7 +285,10 @@ bool uncertainty_network_update_from_listpeerchannels(
|
||||
/* Don't report opening/closing channels */
|
||||
if (!json_tok_streq(buf, statetok, "CHANNELD_NORMAL")
|
||||
&& !json_tok_streq(buf, statetok, "CHANNELD_AWAITING_SPLICE")) {
|
||||
tal_arr_expand(&p->disabled, scidd.scid);
|
||||
payment_disable_chan(p, scidd.scid, LOG_DBG,
|
||||
"channel in state %.*s",
|
||||
statetok->end - statetok->start,
|
||||
buf + statetok->start);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user