Skip to content

Commit

Permalink
renepay: update the gossmap after addgossip
Browse files Browse the repository at this point in the history
Whenever there is a payment failure that requires gossip update, for
example changing the fee rates of remote channels, we call addgossip.
For renepay to consider this changes in the coming payment attempts, it
must update gossmap.
  • Loading branch information
Lagrang3 committed Feb 15, 2024
1 parent ee210a2 commit 8974b83
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/renepay/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ static struct command_result *addgossip_done(struct command *cmd,
* happen later. */
pay_flow_finished_adding_gossip(adg->pf);

bool gossmap_changed = gossmap_refresh(pay_plugin->gossmap, NULL);

if (pay_plugin->gossmap == NULL)
plugin_err(pay_plugin->plugin, "Failed to refresh gossmap: %s",
strerror(errno));

if (gossmap_changed)
uncertainty_network_update(pay_plugin->gossmap,
pay_plugin->chan_extra_map);

return command_still_pending(cmd);
}

Expand Down
36 changes: 36 additions & 0 deletions tests/test_renepay.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,39 @@ def test_previous_sendpays(node_factory, bitcoind):
l1.rpc.call("renepay", {"invstring": invstr, "dev_use_shadow": False})
invoice = only_one(l3.rpc.listinvoices("inv2")["invoices"])
assert invoice["amount_received_msat"] == Millisatoshi("100000sat")


def test_fees(node_factory):
"""
Check that fees are correctly computed.
"""
# made up some random fees for every node
opts = [
{"disable-mpp": None, "fee-base": 1000, "fee-per-satoshi": 100},
{"disable-mpp": None, "fee-base": 2222, "fee-per-satoshi": 203},
{"disable-mpp": None, "fee-base": 3333, "fee-per-satoshi": 300},
{"disable-mpp": None, "fee-base": 2012, "fee-per-satoshi": 200},
{"disable-mpp": None, "fee-base": 1010, "fee-per-satoshi": 100},
{"disable-mpp": None, "fee-base": 1050, "fee-per-satoshi": 100},
]
nodes = node_factory.line_graph(len(opts), wait_for_announce=True, opts=opts)
source = nodes[0]
dest = nodes[-1]

# check that once gossip is in sync, fees are paid correctly
invstr = dest.rpc.invoice("100000sat", "inv1", "description")["bolt11"]
source.rpc.call("renepay", {"invstring": invstr})
invoice = only_one(dest.rpc.listinvoices("inv1")["invoices"])
assert invoice["amount_received_msat"] == Millisatoshi("100000sat")

# if we update fee policy but gossip is not updated ...
nodes[2].rpc.dev_suppress_gossip()
nodes[2].rpc.setchannel(nodes[3].info["id"], 4000, 300, enforcedelay=0)

nodes[3].rpc.dev_suppress_gossip()
nodes[3].rpc.setchannel(nodes[4].info["id"], 3000, 350, enforcedelay=0)

invstr = dest.rpc.invoice("150000sat", "inv2", "description")["bolt11"]
source.rpc.call("renepay", {"invstring": invstr})
invoice = only_one(dest.rpc.listinvoices("inv2")["invoices"])
assert invoice["amount_received_msat"] == Millisatoshi("150000sat")

0 comments on commit 8974b83

Please sign in to comment.