Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renepay refactors and cleanups #6538

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2e1d6c3
renepay: remove unused all_flows field.
rustyrussell Aug 9, 2023
8c0e4fe
renepay: remove attempt limit.
rustyrussell Aug 9, 2023
9fe203e
renepay: fix localmods.
rustyrussell Aug 9, 2023
70042fe
renepay: use more formal allocator pattern.
rustyrussell Aug 10, 2023
52260c6
renepay: move list_node to first member of struct payment.
rustyrussell Aug 10, 2023
dccf487
renepay: make memleak simpler.
rustyrussell Aug 10, 2023
698f415
renepay: merge `struct renepay` and `struct payment` into one.
rustyrussell Aug 10, 2023
fa90e58
renepay: get max group_id in single iteration.
rustyrussell Aug 10, 2023
2b813ac
renepay: simplify JSON handling.
rustyrussell Aug 10, 2023
775cebc
renepay: simplify JSON handling in notification_sendpay_success.
rustyrussell Aug 10, 2023
0fb46e1
renepay: don't re-parse bolt11 to get routehints.
rustyrussell Aug 10, 2023
e1da480
renepay: put the entire hash in the key struct.
rustyrussell Aug 10, 2023
149057f
renepay: remove unused result member.
rustyrussell Aug 10, 2023
99f331e
renepay: remove always-true "first_time" and "unlikely_ok" flags.
rustyrussell Aug 10, 2023
c358b56
renepay: fix up handling of errors from final node.
rustyrussell Aug 10, 2023
e4b386f
renepay: make pay_plugin a tal object.
rustyrussell Aug 10, 2023
8cdef9a
renepay: grab update from WIRE_TEMPORARY_CHANNEL_FAILURE if present.
rustyrussell Aug 10, 2023
a578732
renepay: drive *all* progress from termination of struct pay_flow.
rustyrussell Aug 10, 2023
d4ea3da
renepay: add dummy pf_resuly type to ensure we deal with the flow.
rustyrussell Aug 10, 2023
07d78c9
renepay: do less work in destroy_pay_flow, and reorder pay_flow.c
rustyrussell Aug 10, 2023
a64a6ba
renepay: trivial cleanup to rename `flow` to `pf` everywhere.
rustyrussell Aug 10, 2023
4f25609
renepay: add command notifications
rustyrussell Aug 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 3 additions & 15 deletions plugins/renepay/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,9 @@ static struct command_result *try_paying(struct command *cmd,
struct payment * const p = renepay->payment;
plugin_log(pay_plugin->plugin,LOG_DBG,"calling %s",__PRETTY_FUNCTION__);

// TODO(eduardo): does it make sense to have this limit on attempts?
/* I am classifying the flows in attempt cycles. */
renepay_new_attempt(renepay);
/* We try only MAX_NUM_ATTEMPTS, then we give up. */
if ( renepay_attempt_count(renepay) > MAX_NUM_ATTEMPTS)
{
return renepay_fail(renepay, PAY_STOPPED_RETRYING,
"Reached maximum number of attempts (%d)",
MAX_NUM_ATTEMPTS);
}

struct amount_msat feebudget, fees_spent, remaining;

renepay->payment->status=PAYMENT_PENDING;
if (time_after(time_now(), p->stop_time))
return renepay_fail(renepay, PAY_STOPPED_RETRYING, "Timed out");

Expand Down Expand Up @@ -556,6 +546,7 @@ static struct command_result *try_paying(struct command *cmd,

/* We let this return an unlikely path, as it's better to try once
* than simply refuse. Plus, models are not truth! */
gossmap_apply_localmods(pay_plugin->gossmap, renepay->local_gossmods);
struct pay_flow **pay_flows = get_payflows(
renepay,
remaining, feebudget,
Expand All @@ -568,6 +559,7 @@ static struct command_result *try_paying(struct command *cmd,
amount_msat_eq(p->total_delivering, AMOUNT_MSAT(0)),

&err_msg);
gossmap_remove_localmods(pay_plugin->gossmap, renepay->local_gossmods);
rustyrussell marked this conversation as resolved.
Show resolved Hide resolved

// plugin_log(pay_plugin->plugin,LOG_DBG,"get_payflows produced %s",fmt_payflows(tmpctx,pay_flows));

Expand Down Expand Up @@ -600,13 +592,9 @@ static struct command_result *listpeerchannels_done(
"listpeerchannels malformed: %.*s",
json_tok_full_len(result),
json_tok_full(buf, result));
// So we have all localmods data, now we apply it. Only once per
// payment.
// TODO(eduardo): check that there won't be a prob. cost associated with
// any gossmap local chan. The same way there aren't fees to pay for my
// local channels.
gossmap_apply_localmods(pay_plugin->gossmap,renepay->local_gossmods);
renepay->localmods_applied=true;
return try_paying(cmd, renepay, true);
}

Expand Down
1 change: 0 additions & 1 deletion plugins/renepay/pay_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ static struct pay_flow **flows_to_pay_flows(struct payment *payment,
pf->amounts = tal_steal(pf, f->amounts);
pf->path_dirs = tal_steal(pf, f->dirs);
pf->success_prob = f->success_prob;
pf->attempt = renepay_current_attempt(payment->renepay);
}
tal_free(flows);

Expand Down
3 changes: 0 additions & 3 deletions plugins/renepay/pay_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ struct pay_flow {
/* So we can be an independent object for callbacks. */
struct payment * payment;

// TODO(eduardo): remove this, unnecessary
int attempt;

/* Information to link this flow to a unique sendpay. */
struct payflow_key
{
Expand Down
28 changes: 0 additions & 28 deletions plugins/renepay/payment.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ struct renepay * renepay_new(struct command *cmd)

renepay->cmd = cmd;
renepay->payment = payment_new(renepay);
renepay->localmods_applied=false;
renepay->local_gossmods = gossmap_localmods_new(renepay);
renepay->disabled = tal_arr(renepay,struct short_channel_id,0);
renepay->rexmit_timer = NULL;
renepay->next_attempt=1;
renepay->next_partid=1;
renepay->all_flows = tal(renepay,tal_t);

return renepay;
}
Expand Down Expand Up @@ -132,20 +129,6 @@ void payment_assert_delivering_all(const struct payment *p)
}
}


int renepay_current_attempt(const struct renepay * renepay)
{
return renepay->next_attempt-1;
}
int renepay_attempt_count(const struct renepay * renepay)
{
return renepay->next_attempt-1;
}
void renepay_new_attempt(struct renepay * renepay)
{
renepay->payment->status=PAYMENT_PENDING;
renepay->next_attempt++;
}
struct command_result *renepay_success(struct renepay * renepay)
{
debug_info("calling %s",__PRETTY_FUNCTION__);
Expand Down Expand Up @@ -206,21 +189,10 @@ void renepay_cleanup(
struct gossmap * gossmap)
{
debug_info("calling %s",__PRETTY_FUNCTION__);
/* Always remove our local mods (routehints) so others can use
* gossmap. We do this only after the payment completes. */
// TODO(eduardo): it can happen that local_gossmods removed below
// contained a set of channels for which there is information in the
// uncertainty network (chan_extra_map) and that are part of some pending
// payflow (payflow_map). Handle this situation.
if(renepay->localmods_applied)
gossmap_remove_localmods(gossmap,
renepay->local_gossmods);
// TODO(eduardo): I wonder if it is possible to have two instances of
// renepay at the same time.
// 1st problem: dijkstra datastructure is global, this can be fixed,
// 2nd problem: we don't know if gossmap_apply_localmods and gossmap_remove_localmods,
// can handle different local_gossmods applied to the same gossmap.
renepay->localmods_applied=false;
tal_free(renepay->local_gossmods);

renepay->rexmit_timer = tal_free(renepay->rexmit_timer);
Expand Down
11 changes: 0 additions & 11 deletions plugins/renepay/payment.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ struct renepay
struct payment * payment;

/* Localmods to apply to gossip_map for our own use. */
bool localmods_applied;
struct gossmap_localmods *local_gossmods;

/* Channels we decided to disable for various reasons. */
Expand All @@ -120,13 +119,8 @@ struct renepay
/* Timers. */
struct plugin_timer *rexmit_timer;

/* Keep track of the number of attempts. */
int next_attempt;
/* Used in get_payflows to set ids to each pay_flow. */
u64 next_partid;

/* Root to destroy pending flows */
tal_t *all_flows;
};

struct payment * payment_new(struct renepay *renepay);
Expand All @@ -146,11 +140,6 @@ void payment_note(struct payment *p, const char *fmt, ...);
void payment_assert_delivering_incomplete(const struct payment *p);
void payment_assert_delivering_all(const struct payment *p);


int renepay_current_attempt(const struct renepay *renepay);
int renepay_attempt_count(const struct renepay *renepay);
void renepay_new_attempt(struct renepay *renepay);

struct command_result *renepay_success(struct renepay *renepay);

struct command_result *renepay_fail(
Expand Down