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

Release 25.02.1 #8196

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
84fb19a
trace: minimal fix to avoid crash when > 128 traces active.
rustyrussell Mar 31, 2025
3814976
common: fix crash when we have a localmod with unrepresentable fee va…
rustyrussell Mar 31, 2025
ca92d58
lightningd: fix anchorspend HTLC deadline logic.
rustyrussell Mar 27, 2025
f725c37
lightningd: allow bitcoind_getrawblockbyheight callback to free call …
rustyrussell Mar 31, 2025
7c691b0
wallet: don't assume wally_tx outputs tal_bytelen(script) is the same…
rustyrussell Mar 28, 2025
e463ee0
lightningd: make sure we register all addresses at opening if peer do…
rustyrussell Mar 31, 2025
aea5651
wallet: do change db to watch both p2tr and p2wkph for not-yet-closed…
rustyrussell Mar 31, 2025
639d571
wallet: remove unused total arg from wallet_extract_owned_outputs.
rustyrussell Mar 31, 2025
a910f8b
wallet: extract "got utxo" function out of wallet_extract_owned_outputs.
rustyrussell Mar 31, 2025
0c4322f
lightningd: mangle parameter names in bitcoind_getrawblockbyheight_ s…
rustyrussell Mar 31, 2025
13a32be
lightningd: rescan for missing p2wkph for closed channels.
rustyrussell Mar 31, 2025
f3bc3f3
lightningd: don't spam logs on dangling outgoing HTLCs.
rustyrussell Apr 1, 2025
6a67fb8
trace: handle key being freed while suspended.
rustyrussell Apr 2, 2025
25a2e1f
make: remove old clnrest directory
daywalker90 Mar 12, 2025
dfa452c
make: remove plugins/clnrest dir prior to building clnrest
endothermicdev Apr 3, 2025
96bd0fb
wallet: don't debug spam every output script as we rescan blocks.
rustyrussell Apr 4, 2025
e984547
v25.02.1: CHANGELOG update
rustyrussell Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [25.02.1] - 2025-04-03: "Onion Packet Filler Accreditation II"

Important fixes for bugs in v25.02.

### Fixed

- wallet: we could miss our own returned outputs on mutual closes if peer doesn't support option_shutdown_anysegwit ([#8175])
- wallet: rescan for missing close outputs in case above bug happened ([#8175])
- lightningd: incorrect spamming of log and potential crash on testnet case of duplicate HTLCs and slow closing. ([#8192])
- Protocol: Egregious anchor fee paid for unilateral close txs due to HTLC timeouts; it's not as urgent as our code made out! ([#8190])
- lightningd: occasional crash on bitcoind callback. ([#8186])
- autoclean/chanbackup: fixed tracepoint crash on large number of requests. ([#8188])
- autoclean: fixed occasional crash when tracepoints compiled in. ([#8198])
- `topology` crash on invoice creation if a peer had a really high feerate. ([#8187])
- `make` cleans up old clnrest directory prior to building and installing the new plugin. ([#8201], [#8159])

[#8186]: https://github.com/ElementsProject/lightning/pull/8186
[#8192]: https://github.com/ElementsProject/lightning/pull/8192
[#8187]: https://github.com/ElementsProject/lightning/pull/8187
[#8190]: https://github.com/ElementsProject/lightning/pull/8190
[#8175]: https://github.com/ElementsProject/lightning/pull/8175
[#8188]: https://github.com/ElementsProject/lightning/pull/8188
[#8198]: https://github.com/ElementsProject/lightning/pull/8198
[#8159]: https://github.com/ElementsProject/lightning/pull/8159
[#8201]: https://github.com/ElementsProject/lightning/pull/8201
[25.02.1]: https://github.com/ElementsProject/lightning/releases/tag/v25.02.1

## [25.02] - 2025-03-04: "Onion Packet Filler Accreditation"

This release named by @s373nZ.
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ install-program: installdirs $(BIN_PROGRAMS) $(PKGLIBEXEC_PROGRAMS) $(PLUGINS) $
@$(NORMAL_INSTALL)
$(INSTALL_PROGRAM) $(BIN_PROGRAMS) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(PKGLIBEXEC_PROGRAMS) $(DESTDIR)$(pkglibexecdir)
@if [ -d "$(DESTDIR)$(plugindir)/clnrest" ]; then rm -rf $(DESTDIR)$(plugindir)/clnrest; fi
[ -z "$(PLUGINS)" ] || $(INSTALL_PROGRAM) $(PLUGINS) $(DESTDIR)$(plugindir)
for PY in $(PY_PLUGINS); do DIR=`dirname $$PY`; DST=$(DESTDIR)$(plugindir)/`basename $$DIR`; if [ -d $$DST ]; then rm -rf $$DST; fi; $(INSTALL_PROGRAM) -d $$DIR; cp -a $$DIR $$DST ; done

Expand Down
9 changes: 5 additions & 4 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,11 @@ static void fill_from_update(struct gossmap *map,
|| hc->delay != delay) {
hc->htlc_max = 0;
hc->enabled = false;
logcb(cbarg, LOG_DBG,
"Bad cupdate for %s, ignoring (delta=%u, fee=%u/%u)",
fmt_short_channel_id_dir(tmpctx, scidd),
delay, base_fee, proportional_fee);
if (logcb)
logcb(cbarg, LOG_DBG,
"Bad cupdate for %s, ignoring (delta=%u, fee=%u/%u)",
fmt_short_channel_id_dir(tmpctx, scidd),
delay, base_fee, proportional_fee);
}
}

Expand Down
54 changes: 52 additions & 2 deletions common/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
#include <common/trace.h>
#include <sodium/randombytes.h>
#include <stdio.h>
#include <unistd.h>

#if HAVE_USDT
#include <sys/sdt.h>
#include <sys/sdt.h>

#define MAX_ACTIVE_SPANS 128

Expand Down Expand Up @@ -40,6 +41,7 @@
#endif

const char *trace_service_name = "lightningd";
static bool disable_trace = false;

struct span_tag {
char *name, *value;
Expand Down Expand Up @@ -176,6 +178,9 @@ static struct span *trace_span_find(size_t key)
return NULL;
}

/* FIXME: Forward declaration for minimal patch size */
static void trace_span_clear(struct span *s);

/**
* Find an empty slot for a new span.
*/
Expand All @@ -187,7 +192,13 @@ static struct span *trace_span_slot(void)

/* Might end up here if we have more than MAX_ACTIVE_SPANS
* concurrent spans. */
assert(s);
if (!s) {
fprintf(stderr, "%u: out of spans, disabling tracing\n", getpid());
for (size_t i = 0; i < MAX_ACTIVE_SPANS; i++)
trace_span_clear(&active_spans[i]);
disable_trace = true;
return NULL;
}
assert(s->parent == NULL);

/* Be extra careful not to create cycles. If we return the
Expand Down Expand Up @@ -260,11 +271,15 @@ void trace_span_start(const char *name, const void *key)
size_t numkey = trace_key(key);
struct timeabs now = time_now();

if (disable_trace)
return;
trace_init();
trace_check_tree();

assert(trace_span_find(numkey) == NULL);
struct span *s = trace_span_slot();
if (!s)
return;
s->key = numkey;
randombytes_buf(s->id, SPAN_ID_SIZE);
s->start_time = (now.ts.tv_sec * 1000000) + now.ts.tv_nsec / 1000;
Expand Down Expand Up @@ -293,6 +308,9 @@ void trace_span_remote(u8 trace_id[TRACE_ID_SIZE], u8 span_id[SPAN_ID_SIZE])

void trace_span_end(const void *key)
{
if (disable_trace)
return;

size_t numkey = trace_key(key);
struct span *s = trace_span_find(numkey);
assert(s && "Span to end not found");
Expand Down Expand Up @@ -323,6 +341,9 @@ void trace_span_end(const void *key)

void trace_span_tag(const void *key, const char *name, const char *value)
{
if (disable_trace)
return;

size_t numkey = trace_key(key);
struct span *span = trace_span_find(numkey);
assert(span);
Expand All @@ -341,6 +362,9 @@ void trace_span_tag(const void *key, const char *name, const char *value)

void trace_span_suspend_(const void *key, const char *lbl)
{
if (disable_trace)
return;

size_t numkey = trace_key(key);
struct span *span = trace_span_find(numkey);
TRACE_DBG("Suspending span %s (%zu)\n", current->name, current->key);
Expand All @@ -349,8 +373,33 @@ void trace_span_suspend_(const void *key, const char *lbl)
DTRACE_PROBE1(lightningd, span_suspend, span->id);
}

static void destroy_trace_span(const void *key)
{
size_t numkey = trace_key(key);
struct span *span = trace_span_find(numkey);

/* It's usually ended normally. */
if (!span)
return;

/* Otherwise resume so we can terminate it */
trace_span_resume(key);
trace_span_end(key);
}

void trace_span_suspend_may_free_(const void *key, const char *lbl)
{
if (disable_trace)
return;
trace_span_suspend_(key, lbl);
tal_add_destructor(key, destroy_trace_span);
}

void trace_span_resume_(const void *key, const char *lbl)
{
if (disable_trace)
return;

size_t numkey = trace_key(key);
current = trace_span_find(numkey);
TRACE_DBG("Resuming span %s (%zu)\n", current->name, current->key);
Expand All @@ -368,6 +417,7 @@ void trace_cleanup(void)
void trace_span_start(const char *name, const void *key) {}
void trace_span_end(const void *key) {}
void trace_span_suspend_(const void *key, const char *lbl) {}
void trace_span_suspend_may_free_(const void *key, const char *lbl) {}
void trace_span_resume_(const void *key, const char *lbl) {}
void trace_span_tag(const void *key, const char *name, const char *value) {}
void trace_cleanup(void) {}
Expand Down
2 changes: 2 additions & 0 deletions common/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ void trace_span_remote(u8 trace_id[TRACE_ID_SIZE], u8 span_id[SPAN_ID_SIZE]);

#define TRACE_LBL __FILE__ ":" stringify(__LINE__)
void trace_span_suspend_(const void *key, const char *lbl);
void trace_span_suspend_may_free_(const void *key, const char *lbl);
void trace_span_resume_(const void *key, const char *lbl);
#define trace_span_suspend(key) trace_span_suspend_(key, TRACE_LBL)
#define trace_span_suspend_may_free(key) trace_span_suspend_may_free_(key, TRACE_LBL)
#define trace_span_resume(key) trace_span_resume_(key, TRACE_LBL)

#endif /* LIGHTNING_COMMON_TRACE_H */
7 changes: 6 additions & 1 deletion lightningd/anchorspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ struct anchor_details *create_anchor_details(const tal_t *ctx,
continue;

v.msat = hout->msat;
v.block = hout->cltv_expiry;
/* Our real deadline here is the INCOMING htlc. If it's us, use the default so we don't leak
* too much information about it. */
if (hout->in)
v.block = hout->in->cltv_expiry;
else
v.block = hout->cltv_expiry + ld->config.cltv_expiry_delta;
v.important = true;
tal_arr_expand(&adet->vals, v);
}
Expand Down
8 changes: 7 additions & 1 deletion lightningd/bitcoind.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,15 @@ getrawblockbyheight_callback(const char *buf, const jsmntok_t *toks,
const char *block_str, *err;
struct bitcoin_blkid blkid;
struct bitcoin_block *blk;
const tal_t *ctx;
trace_span_resume(call);
trace_span_end(call);

/* Callback may free parent of call, so steal onto context to
* free if it doesn't */
ctx = tal(NULL, char);
tal_steal(ctx, call);

/* If block hash is `null`, this means not found! Call the callback
* with NULL values. */
err = json_scan(tmpctx, buf, toks, "{result:{blockhash:null}}");
Expand All @@ -506,7 +512,7 @@ getrawblockbyheight_callback(const char *buf, const jsmntok_t *toks,
call->cb(call->bitcoind, call->height, &blkid, blk, call->cb_arg);

clean:
tal_free(call);
tal_free(ctx);
}

void bitcoind_getrawblockbyheight_(const tal_t *ctx,
Expand Down
4 changes: 2 additions & 2 deletions lightningd/bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void bitcoind_getchaininfo_(const tal_t *ctx,
void bitcoind_getrawblockbyheight_(const tal_t *ctx,
struct bitcoind *bitcoind,
u32 height,
void (*cb)(struct bitcoind *bitcoind,
u32 height,
void (*cb)(struct bitcoind *bitcoind_,
u32 height_,
struct bitcoin_blkid *blkid,
struct bitcoin_block *blk,
void *arg),
Expand Down
4 changes: 1 addition & 3 deletions lightningd/chaintopology.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static void filter_block_txs(struct chain_topology *topo, struct block *b)
{
struct txfilter *filter = topo->bitcoind->ld->owned_txfilter;
size_t i;
struct amount_sat owned;

/* Now we see if any of those txs are interesting. */
const size_t num_txs = tal_count(b->full_txs);
Expand All @@ -77,11 +76,10 @@ static void filter_block_txs(struct chain_topology *topo, struct block *b)
}
}

owned = AMOUNT_SAT(0);
txid = b->txids[i];
if (txfilter_match(filter, tx)) {
wallet_extract_owned_outputs(topo->bitcoind->ld->wallet,
tx->wtx, is_coinbase, &b->height, &owned);
tx->wtx, is_coinbase, &b->height);
wallet_transaction_add(topo->ld->wallet, tx->wtx,
b->height, i);
// invoice_check_onchain_payment(tx);
Expand Down
3 changes: 1 addition & 2 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ struct send_splice_info
static void handle_tx_broadcast(struct send_splice_info *info)
{
struct lightningd *ld = info->channel->peer->ld;
struct amount_sat unused;
struct json_stream *response;
struct bitcoin_txid txid;
u8 *tx_bytes;
Expand All @@ -496,7 +495,7 @@ static void handle_tx_broadcast(struct send_splice_info *info)
/* This might have spent UTXOs from our wallet */
num_utxos = wallet_extract_owned_outputs(ld->wallet,
info->final_tx->wtx, false,
NULL, &unused);
NULL);
if (num_utxos)
wallet_transaction_add(ld->wallet, info->final_tx->wtx, 0, 0);

Expand Down
3 changes: 2 additions & 1 deletion lightningd/closing_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
if (wallet_can_spend(
ld->wallet,
channel->shutdown_scriptpubkey[LOCAL],
tal_bytelen(channel->shutdown_scriptpubkey[LOCAL]),
&index_val)) {
if (bip32_key_from_parent(
ld->bip32_base,
Expand Down Expand Up @@ -742,7 +743,7 @@ static struct command_result *json_close(struct command *cmd,
}

/* If they give a local address, adjust final_key_idx. */
if (!wallet_can_spend(cmd->ld->wallet, close_to_script,
if (!wallet_can_spend(cmd->ld->wallet, close_to_script, tal_bytelen(close_to_script),
&final_key_idx)) {
final_key_idx = channel->final_key_idx;
}
Expand Down
8 changes: 5 additions & 3 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
u32 found_wallet_index;
if (wallet_can_spend(dualopend->ld->wallet,
payload->our_shutdown_scriptpubkey,
tal_bytelen(payload->our_shutdown_scriptpubkey),
&found_wallet_index)) {
our_shutdown_script_wallet_index = tal(tmpctx, u32);
*our_shutdown_script_wallet_index = found_wallet_index;
Expand Down Expand Up @@ -1666,14 +1667,12 @@ static void handle_tx_broadcast(struct channel_send *cs)
struct command *cmd = channel->openchannel_signed_cmd;
struct json_stream *response;
struct bitcoin_txid txid;
struct amount_sat unused;
int num_utxos;

/* This might have spent UTXOs from our wallet */
num_utxos = wallet_extract_owned_outputs(ld->wallet,
/* FIXME: what txindex? */
wtx, false, NULL,
&unused);
wtx, false, NULL);
if (num_utxos)
wallet_transaction_add(ld->wallet, wtx, 0, 0);

Expand Down Expand Up @@ -3092,6 +3091,7 @@ static struct command_result *openchannel_init(struct command *cmd,
* NULL if not found. */
if (wallet_can_spend(cmd->ld->wallet,
oa->our_upfront_shutdown_script,
tal_bytelen(oa->our_upfront_shutdown_script),
&found_wallet_index)) {
our_upfront_shutdown_script_wallet_index = &found_wallet_index;
} else
Expand Down Expand Up @@ -3860,6 +3860,7 @@ static struct command_result *json_queryrates(struct command *cmd,
u32 found_wallet_index;
if (wallet_can_spend(cmd->ld->wallet,
oa->our_upfront_shutdown_script,
tal_bytelen(oa->our_upfront_shutdown_script),
&found_wallet_index)) {
our_upfront_shutdown_script_wallet_index = tal(tmpctx, u32);
*our_upfront_shutdown_script_wallet_index = found_wallet_index;
Expand Down Expand Up @@ -4207,6 +4208,7 @@ bool peer_restart_dualopend(struct peer *peer,
u32 found_wallet_index;
if (wallet_can_spend(peer->ld->wallet,
channel->shutdown_scriptpubkey[LOCAL],
tal_bytelen(channel->shutdown_scriptpubkey[LOCAL]),
&found_wallet_index)) {
local_shutdown_script_wallet_index = tal(tmpctx, u32);
*local_shutdown_script_wallet_index = found_wallet_index;
Expand Down
6 changes: 6 additions & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,12 @@ int main(int argc, char *argv[])
if (ld->daemon_parent_fd != -1)
complete_daemonize(ld);

/*~ At one stage, we didn't catch mutual closes with old node to p2wkph
* so now we start a scan if the db doesn't say we completed it. */
db_begin_transaction(ld->wallet->db);
wallet_begin_old_close_rescan(ld);
db_commit_transaction(ld->wallet->db);

/*~ Setting this (global) activates the crash log: we don't usually need
* a backtrace if we fail during startup. */
crashlog = ld->log;
Expand Down
10 changes: 9 additions & 1 deletion lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ wallet_commit_channel(struct lightningd *ld,
/* FIXME: P2TR for elements! */
if (chainparams->is_elements)
addrtype = ADDR_BECH32;
else
else if (feature_negotiated(ld->our_features,
uc->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT))
addrtype = ADDR_P2TR;
else
/* They *may* update to OPT_SHUTDOWN_ANYSEGWIT by the
* time we close, so be prepared for both. */
addrtype = ADDR_ALL;

/* Get a key to use for closing outputs from this tx */
final_key_idx = wallet_get_newindex(ld, addrtype);
Expand Down Expand Up @@ -710,6 +716,7 @@ openchannel_hook_final(struct openchannel_hook_payload *payload STEALS)
u32 found_wallet_index;
if (wallet_can_spend(payload->openingd->ld->wallet,
our_upfront_shutdown_script,
tal_bytelen(our_upfront_shutdown_script),
&found_wallet_index)) {
upfront_shutdown_script_wallet_index = tal(tmpctx, u32);
*upfront_shutdown_script_wallet_index = found_wallet_index;
Expand Down Expand Up @@ -1400,6 +1407,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
u32 found_wallet_index;
if (wallet_can_spend(fc->cmd->ld->wallet,
fc->our_upfront_shutdown_script,
tal_bytelen(fc->our_upfront_shutdown_script),
&found_wallet_index)) {
upfront_shutdown_script_wallet_index = tal(tmpctx, u32);
*upfront_shutdown_script_wallet_index = found_wallet_index;
Expand Down
Loading
Loading