Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Aug 18, 2023
2 parents f4fa41c + bcea0a9 commit e842e0b
Show file tree
Hide file tree
Showing 72 changed files with 2,286 additions and 1,508 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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/).


## [v23.08rc1] - 2023-08-02: "Satoshi's Successor"
## [v23.08rc2] - 2023-08-02: "Satoshi's Successor"

This release named by Matt Morehouse.

Expand Down Expand Up @@ -40,6 +40,7 @@ This release named by Matt Morehouse.
- JSON-RPC: `fundpsbt` and `utxopsbt` new parameter `opening_anchor_channel` so lightningd knowns it needs emergency reserve for anchors. ([#6334])
- Config: `min-emergency-msat` setting for (currently experimental!) anchor channels, to keep funds in reserve for forced closes. ([#6334])
- JSON-RPC: `feerates` has new fields `unilateral_anchor_close` to show the feerate used for anchor channels (currently experimental), and `unilateral_close_nonanchor_satoshis`. ([#6334])
- cln-grpc: Added `staticbackup` support to cln-grpc ([#6507])


### Changed
Expand Down Expand Up @@ -100,6 +101,8 @@ Note: You should always set `allow-deprecated-apis=false` to test for changes.
- Plugins: reloaded plugins get passed any vars from configuration files. ([#6243])
- JSON-RPC: `listconfigs` `rpc-file-mode` no longer has gratuitous quotes (e.g. "0600" not "\"0600\""). ([#6243])
- JSON-RPC: `listconfigs` `htlc-minimum-msat`, `htlc-maximum-msat` and `max-dust-htlc-exposure-msat` fields are now numbers, not strings. ([#6243])
- Protocol: We may propose mutual close transaction which has a slightly higher fee than the final commitment tx (depending on the outputs, e.g. two taproot outputs). ([#6547])
- Protocol: We now close connection with a peer if adding an HTLC times out (which may be a TCP connectivity issue). ([#6520])


### EXPERIMENTAL
Expand Down Expand Up @@ -155,7 +158,10 @@ Note: You should always set `allow-deprecated-apis=false` to test for changes.
[#6461]: https://github.com/ElementsProject/lightning/pull/6461
[#6466]: https://github.com/ElementsProject/lightning/pull/6466
[#6468]: https://github.com/ElementsProject/lightning/pull/6468
[v23.08rc1]: https://github.com/ElementsProject/lightning/releases/tag/v23.08rc1
[#6507]: https://github.com/ElementsProject/lightning/pull/6507
[#6520]: https://github.com/ElementsProject/lightning/pull/6520
[#6547]: https://github.com/ElementsProject/lightning/pull/6547
[v23.08rc2]: https://github.com/ElementsProject/lightning/releases/tag/v23.08rc2


## [23.05.2] - 2023-06-21: "Austin Texas Agreement(ATXA) III"
Expand Down
37 changes: 30 additions & 7 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,11 @@ static void send_channel_update(struct peer *peer, int disable_flag)
* they route through us */
static void send_channel_initial_update(struct peer *peer)
{
send_channel_update(peer, 0);
/* If `stfu` is already active then the channel is being mutated quickly
* after creation. These mutations (ie. splice) must announce the
* channel when they finish anyway, so it is safe to skip it here */
if (!is_stfu_active(peer) && !peer->want_stfu)
send_channel_update(peer, 0);
}

/**
Expand Down Expand Up @@ -591,6 +595,12 @@ static void announce_channel(struct peer *peer)
send_channel_update(peer, 0);
}

static void announce_channel_if_not_stfu(struct peer *peer)
{
if (!is_stfu_active(peer) && !peer->want_stfu)
announce_channel(peer);
}

/* Returns true if an announcement was sent */
static bool channel_announcement_negotiate(struct peer *peer)
{
Expand Down Expand Up @@ -665,7 +675,7 @@ static bool channel_announcement_negotiate(struct peer *peer)
/* Give other nodes time to notice new block. */
notleak(new_reltimer(&peer->timers, peer,
time_from_sec(GOSSIP_ANNOUNCE_DELAY(peer->dev_fast_gossip)),
announce_channel, peer));
announce_channel_if_not_stfu, peer));
}

return sent_announcement;
Expand Down Expand Up @@ -1494,7 +1504,7 @@ static u8 *send_commit_part(struct peer *peer,
* send unless negotiated */
if (feature_negotiated(peer->our_features,
peer->their_features,
OPT_SPLICE)) {
OPT_EXPERIMENTAL_SPLICE)) {
status_debug("send_commit_part(splice: %d, remote_splice: %d)",
(int)splice_amnt, (int)remote_splice_amnt);

Expand Down Expand Up @@ -1722,6 +1732,18 @@ static void send_commit(struct peer *peer)
start_commit_timer(peer);
}

static void send_commit_if_not_stfu(struct peer *peer)
{
if (!is_stfu_active(peer) && !peer->want_stfu) {
send_commit(peer);
}
else {
/* Timer now considered expired, you can add a new one. */
peer->commit_timer = NULL;
start_commit_timer(peer);
}
}

static void start_commit_timer(struct peer *peer)
{
/* Already armed? */
Expand All @@ -1730,7 +1752,7 @@ static void start_commit_timer(struct peer *peer)

peer->commit_timer = new_reltimer(&peer->timers, peer,
time_from_msec(peer->commit_msec),
send_commit, peer);
send_commit_if_not_stfu, peer);
}

/* If old_secret is NULL, we don't care, otherwise it is filled in. */
Expand Down Expand Up @@ -4592,7 +4614,6 @@ static void peer_reconnect(struct peer *peer,
bool dataloss_protect, check_extra_fields;
const u8 **premature_msgs = tal_arr(peer, const u8 *, 0);
struct inflight *inflight;
bool next_matches_current, next_matches_inflight;
struct bitcoin_txid *local_next_funding, *remote_next_funding;

struct tlv_channel_reestablish_tlvs *send_tlvs, *recv_tlvs;
Expand All @@ -4610,12 +4631,12 @@ static void peer_reconnect(struct peer *peer,
get_per_commitment_point(peer->next_index[LOCAL] - 1,
&my_current_per_commitment_point, NULL);

inflight = last_inflight(peer);

if (peer->experimental_upgrade) {
/* Subtle: we free tmpctx below as we loop, so tal off peer */
send_tlvs = tlv_channel_reestablish_tlvs_new(peer);

inflight = last_inflight(peer);

/* If inflight with no sigs on it, send next_funding */
if (inflight && !inflight->last_tx)
send_tlvs->next_funding = &inflight->outpoint.txid;
Expand Down Expand Up @@ -5017,6 +5038,8 @@ static void peer_reconnect(struct peer *peer,
remote_next_funding = (recv_tlvs ? recv_tlvs->next_funding : NULL);

if (local_next_funding || remote_next_funding) {
bool next_matches_current = false, next_matches_inflight = false;

if (remote_next_funding) {
next_matches_current = bitcoin_txid_eq(remote_next_funding,
&peer->channel->funding.txid);
Expand Down
5 changes: 3 additions & 2 deletions cli/lightning-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ int main(int argc, char *argv[])
jsmntok_t *toks;
const jsmntok_t *result, *error, *id;
const tal_t *ctx = tal(NULL, char);
char *net_dir, *rpc_filename;
char *config_filename, *base_dir, *net_dir, *rpc_filename;
jsmn_parser parser;
int parserr;
enum format format = DEFAULT_FORMAT;
Expand All @@ -668,7 +668,8 @@ int main(int argc, char *argv[])
setup_option_allocators();

opt_exitcode = ERROR_USAGE;
minimal_config_opts(ctx, argc, argv, &net_dir, &rpc_filename);
minimal_config_opts(ctx, argc, argv, &config_filename, &base_dir,
&net_dir, &rpc_filename);

opt_register_noarg("--help|-h", opt_usage_and_exit,
"<command> [<params>...]", "Show this message. Use the command help (without hyphens -- \"lightning-cli help\") to get a list of all RPC commands");
Expand Down
57 changes: 20 additions & 37 deletions closingd/closingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,7 @@ static size_t closing_tx_weight_estimate(u8 *scriptpubkey[NUM_SIDES],
static void calc_fee_bounds(size_t expected_weight,
u32 min_feerate,
u32 desired_feerate,
u32 *max_feerate,
struct amount_sat commitment_fee,
u32 max_feerate,
struct amount_sat funding,
enum side opener,
struct amount_sat *minfee,
Expand All @@ -620,36 +619,22 @@ static void calc_fee_bounds(size_t expected_weight,
if (opener == REMOTE) {
*maxfee = funding;

/* This used to appear in BOLT #2: we still set it for non-anchor
* peers who may still enforce it:
* - If the channel does not use `option_anchor_outputs`:
* - MUST set `fee_satoshis` less than or equal to the base fee of
* the final commitment transaction, as calculated in
* [BOLT #3](03-transactions.md#fee-calculation).
*/
} else if (max_feerate) {
*maxfee = amount_tx_fee(*max_feerate, expected_weight);

status_debug("deriving max fee from rate %u -> %s (not %s)",
*max_feerate,
type_to_string(tmpctx, struct amount_sat, maxfee),
type_to_string(tmpctx, struct amount_sat, &commitment_fee));

/* option_anchor_outputs sets commitment_fee to max, so this
* doesn't do anything */
if (amount_sat_greater(*maxfee, commitment_fee)) {
/* FIXME: would be nice to notify close cmd here! */
status_unusual("Maximum feerate %u would give fee %s:"
" we must limit it to the final commitment fee %s",
*max_feerate,
type_to_string(tmpctx, struct amount_sat,
maxfee),
type_to_string(tmpctx, struct amount_sat,
&commitment_fee));
*maxfee = commitment_fee;
}
} else
*maxfee = commitment_fee;
} else {
/* BOLT #2:
* The sending node:
*
* - SHOULD set the initial `fee_satoshis` according to its
* estimate of cost of inclusion in a block.
*
* - SHOULD set `fee_range` according to the minimum and
* maximum fees it is prepared to pay for a close
* transaction.
*/
*maxfee = amount_tx_fee(max_feerate, expected_weight);
status_debug("deriving max fee from rate %u -> %s",
max_feerate,
type_to_string(tmpctx, struct amount_sat, maxfee));
}

/* Can't exceed maxfee. */
if (amount_sat_greater(*minfee, *maxfee))
Expand Down Expand Up @@ -868,9 +853,9 @@ int main(int argc, char *argv[])
struct bitcoin_outpoint funding;
struct amount_sat funding_sats, out[NUM_SIDES];
struct amount_sat our_dust_limit;
struct amount_sat min_fee_to_accept, commitment_fee, offer[NUM_SIDES],
struct amount_sat min_fee_to_accept, offer[NUM_SIDES],
max_fee_to_accept;
u32 min_feerate, initial_feerate, *max_feerate;
u32 min_feerate, initial_feerate, max_feerate;
struct feerange feerange;
enum side opener;
u32 *local_wallet_index;
Expand Down Expand Up @@ -902,7 +887,6 @@ int main(int argc, char *argv[])
&out[REMOTE],
&our_dust_limit,
&min_feerate, &initial_feerate, &max_feerate,
&commitment_fee,
&local_wallet_index,
&local_wallet_ext_key,
&scriptpubkey[LOCAL],
Expand All @@ -929,7 +913,7 @@ int main(int argc, char *argv[])
local_wallet_index,
local_wallet_ext_key),
min_feerate, initial_feerate, max_feerate,
commitment_fee, funding_sats, opener,
funding_sats, opener,
&min_fee_to_accept, &offer[LOCAL], &max_fee_to_accept);

/* Write values into tlv for updated closing fee neg */
Expand Down Expand Up @@ -1099,7 +1083,6 @@ int main(int argc, char *argv[])
tal_free(wrong_funding);
tal_free(our_feerange);
tal_free(their_feerange);
tal_free(max_feerate);
tal_free(local_wallet_index);
tal_free(local_wallet_ext_key);
closing_dev_memleak(ctx, scriptpubkey, funding_wscript);
Expand Down
3 changes: 1 addition & 2 deletions closingd/closingd_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ msgdata,closingd_init,remote_sat,amount_sat,
msgdata,closingd_init,our_dust_limit,amount_sat,
msgdata,closingd_init,min_feerate_perksipa,u32,
msgdata,closingd_init,preferred_feerate_perksipa,u32,
msgdata,closingd_init,max_feerate_perksipa,?u32,
msgdata,closingd_init,fee_limit_satoshi,amount_sat,
msgdata,closingd_init,max_feerate_perksipa,u32,
msgdata,closingd_init,local_wallet_index,?u32,
msgdata,closingd_init,local_wallet_ext_key,?ext_key,
msgdata,closingd_init,local_scriptpubkey_len,u16,
Expand Down
10 changes: 6 additions & 4 deletions common/configdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,18 @@ static struct configvar **gather_cmdline_args(const tal_t *ctx,

void minimal_config_opts(const tal_t *ctx,
int argc, char *argv[],
char **config_filename,
char **basedir,
char **config_netdir,
char **rpc_filename)
{
char *unused_filename, *unused_basedir;

initial_config_opts(tmpctx, &argc, argv, false,
&unused_filename,
&unused_basedir,
config_filename,
basedir,
config_netdir,
rpc_filename);
tal_steal(ctx, *config_filename);
tal_steal(ctx, *basedir);
tal_steal(ctx, *config_netdir);
tal_steal(ctx, *rpc_filename);
}
Expand Down
2 changes: 2 additions & 0 deletions common/configdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void setup_option_allocators(void);
/* Minimal config parsing for tools: use opt_early_parse/opt_parse after */
void minimal_config_opts(const tal_t *ctx,
int argc, char *argv[],
char **config_filename,
char **basedir,
char **config_netdir,
char **rpc_filename);

Expand Down
39 changes: 39 additions & 0 deletions common/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ static const struct feature_style feature_styles[] = {
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
{ OPT_EXPERIMENTAL_SPLICE,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
};

struct dependency {
Expand Down Expand Up @@ -491,6 +495,41 @@ const char *feature_name(const tal_t *ctx, size_t f)
NULL,
NULL,
NULL, /* 100/101 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 110/111 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 120/121 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 130/131 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 140/141 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 150/151 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 160/161 */
"option_experimental_splice", /* https://github.com/lightning/bolts/pull/863 */
NULL,
NULL,
NULL,
NULL, /* 170/171 */
};

if (f / 2 >= ARRAY_SIZE(fnames) || !fnames[f / 2])
Expand Down
5 changes: 5 additions & 0 deletions common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
#define OPT_SHUTDOWN_ANYSEGWIT 26
#define OPT_CHANNEL_TYPE 44
#define OPT_PAYMENT_METADATA 48

/* BOLT-splice #9:
* | 62/63 | `option_splice` | ... IN ...
*/
#define OPT_SPLICE 62
#define OPT_EXPERIMENTAL_SPLICE 162

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
* | 28/29 | `option_dual_fund` | ... IN9 ...
Expand Down
5 changes: 5 additions & 0 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,14 @@ static u32 init_chan_arr(struct gossmap_chan *chan_arr, size_t start)
for (i = start; i < tal_count(chan_arr) - 1; i++) {
chan_arr[i].cann_off = i + 1;
chan_arr[i].plus_scid_off = 0;
/* We don't need to initialize this, *but* on some platforms
* (ppc, arm64) valgrind complains: this is a bitfield shared
* with plus_scid_off */
chan_arr[i].private = false;
}
chan_arr[i].cann_off = UINT_MAX;
chan_arr[i].plus_scid_off = 0;
chan_arr[i].private = false;
return start;
}

Expand Down
Loading

0 comments on commit e842e0b

Please sign in to comment.