diff --git a/channeld/channeld.c b/channeld/channeld.c index 37452adfe..21bfcd2d6 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -51,8 +51,6 @@ #include #include -#define EXPERIMENTAL_UPGRADE_ENABLED 0 - /* stdin == requests, 3 == peer, 4 = HSM */ #define MASTER_FD STDIN_FILENO #define HSM_FD 4 @@ -191,9 +189,6 @@ struct peer { /* We allow a 'tx-sigs' message between reconnect + channel_ready */ bool tx_sigs_allowed; - - /* --experimental-upgrade-protocol */ - bool experimental_upgrade; }; static void start_commit_timer(struct peer *peer); @@ -360,38 +355,6 @@ static bool handle_master_request_later(struct peer *peer, const u8 *msg) return false; } -#if EXPERIMENTAL_UPGRADE_ENABLED -/* Compare, with false if either is NULL */ -static bool match_type(const u8 *t1, const u8 *t2) -{ - /* Missing fields are possible. */ - if (!t1 || !t2) - return false; - - return featurebits_eq(t1, t2); -} - -static void set_channel_type(struct channel *channel, const u8 *type) -{ - const struct channel_type *cur = channel->type; - - if (featurebits_eq(cur->features, type)) - return; - - /* We only allow one upgrade at the moment, so that's it. */ - assert(!channel_has(channel, OPT_STATIC_REMOTEKEY)); - assert(feature_offered(type, OPT_STATIC_REMOTEKEY)); - - /* Do upgrade, tell master. */ - tal_free(channel->type); - channel->type = channel_type_from(channel, type); - status_unusual("Upgraded channel to [%s]", - fmt_featurebits(tmpctx, type)); - wire_sync_write(MASTER_FD, - take(towire_channeld_upgraded(NULL, channel->type))); -} -#endif - static void lock_signer_outpoint(const struct bitcoin_outpoint *outpoint) { const u8 *msg; @@ -5312,27 +5275,6 @@ static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg) return true; } -#if EXPERIMENTAL_UPGRADE_ENABLED -/* Unwrap a channel_type into a raw byte array for the wire: can be NULL */ -static u8 *to_bytearr(const tal_t *ctx, - const struct channel_type *channel_type TAKES) -{ - u8 *ret; - bool steal; - - steal = taken(channel_type); - if (!channel_type) - return NULL; - - if (steal) { - ret = tal_steal(ctx, channel_type->features); - tal_free(channel_type); - } else - ret = tal_dup_talarr(ctx, u8, channel_type->features); - return ret; -} -#endif - static void peer_reconnect(struct peer *peer, const struct secret *last_remote_per_commit_secret) { @@ -5370,47 +5312,6 @@ static void peer_reconnect(struct peer *peer, send_tlvs = NULL; -#if EXPERIMENTAL_UPGRADE_ENABLED - if (peer->experimental_upgrade) { - /* Subtle: we free tmpctx below as we loop, so tal off peer */ - send_tlvs = tlv_channel_reestablish_tlvs_new(peer); - - /* BOLT-upgrade_protocol #2: - * A node sending `channel_reestablish`, if it supports upgrading channels: - * - MUST set `next_to_send` the commitment number of the next - * `commitment_signed` it expects to send. - */ - send_tlvs->next_to_send = tal_dup(send_tlvs, u64, &peer->next_index[REMOTE]); - - /* BOLT-upgrade_protocol #2: - * - if it initiated the channel: - * - MUST set `desired_type` to the channel_type it wants for the - * channel. - */ - if (peer->channel->opener == LOCAL) { - send_tlvs->desired_channel_type = - to_bytearr(send_tlvs, - take(channel_desired_type(NULL, - peer->channel))); - } else { - /* BOLT-upgrade_protocol #2: - * - otherwise: - * - MUST set `current_type` to the current channel_type of the - * channel. - * - MUST set `upgradable` to the channel types it could change - * to. - * - MAY not set `upgradable` if it would be empty. - */ - send_tlvs->current_channel_type - = to_bytearr(send_tlvs, peer->channel->type); - send_tlvs->upgradable_channel_type - = to_bytearr(send_tlvs, - take(channel_upgradable_type(NULL, - peer->channel))); - } - } -#endif - inflight = last_inflight(peer); send_next_commitment_number = peer->next_index[LOCAL]; @@ -5876,86 +5777,6 @@ static void peer_reconnect(struct peer *peer, /* (If we had sent `closing_signed`, we'd be in closingd). */ maybe_send_shutdown(peer); -#if EXPERIMENTAL_UPGRADE_ENABLED - if (recv_tlvs->desired_channel_type) - status_debug("They sent desired_channel_type [%s]", - fmt_featurebits(tmpctx, - recv_tlvs->desired_channel_type)); - if (recv_tlvs->current_channel_type) - status_debug("They sent current_channel_type [%s]", - fmt_featurebits(tmpctx, - recv_tlvs->current_channel_type)); - - if (recv_tlvs->upgradable_channel_type) - status_debug("They offered upgrade to [%s]", - fmt_featurebits(tmpctx, - recv_tlvs->upgradable_channel_type)); - - /* BOLT-upgrade_protocol #2: - * - * A node receiving `channel_reestablish`: - * - if it has to retransmit `commitment_signed` or `revoke_and_ack`: - * - MUST consider the channel feature change failed. - */ - if (retransmit_commitment_signed || retransmit_revoke_and_ack) { - status_debug("No upgrade: we retransmitted"); - /* BOLT-upgrade_protocol #2: - * - * - if `next_to_send` is missing, or not equal to the - * `next_commitment_number` it sent: - * - MUST consider the channel feature change failed. - */ - } else if (!recv_tlvs->next_to_send) { - status_debug("No upgrade: no next_to_send received"); - } else if (*recv_tlvs->next_to_send != peer->next_index[LOCAL]) { - status_debug("No upgrade: they're retransmitting"); - /* BOLT-upgrade_protocol #2: - * - * - if updates are pending on either sides' commitment transaction: - * - MUST consider the channel feature change failed. - */ - /* Note that we can have HTLCs we *want* to add or remove - * but haven't yet: thats OK! */ - } else if (pending_updates(peer->channel, LOCAL, true) - || pending_updates(peer->channel, REMOTE, true)) { - status_debug("No upgrade: pending changes"); - } else if (send_tlvs && recv_tlvs) { - const struct tlv_channel_reestablish_tlvs *initr, *ninitr; - const u8 *type; - - if (peer->channel->opener == LOCAL) { - initr = send_tlvs; - ninitr = recv_tlvs; - } else { - initr = recv_tlvs; - ninitr = send_tlvs; - } - - /* BOLT-upgrade_protocol #2: - * - * - if `desired_channel_type` matches `current_channel_type` or any - * `upgradable_channel_type`: - * - MUST consider the channel type to be `desired_channel_type`. - * - otherwise: - * - MUST consider the channel type change failed. - * - if there is a `current_channel_type` field: - * - MUST consider the channel type to be `current_channel_type`. - */ - if (match_type(initr->desired_channel_type, - ninitr->current_channel_type) - || match_type(initr->desired_channel_type, - ninitr->upgradable_channel_type)) - type = initr->desired_channel_type; - else if (ninitr->current_channel_type) - type = ninitr->current_channel_type; - else - type = NULL; - - if (type) - set_channel_type(peer->channel, type); - } -#endif - tal_free(send_tlvs); /* We've reestablished! */ @@ -6645,7 +6466,6 @@ static void init_channel(struct peer *peer) &channel_type, &peer->dev_disable_commit, &pbases, - &peer->experimental_upgrade, &peer->splice_state->inflights, &peer->local_alias)) { master_badmsg(WIRE_CHANNELD_INIT, msg); diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index c28335041..43ee7af9d 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -72,7 +72,6 @@ msgdata,channeld_init,desired_type,channel_type, msgdata,channeld_init,dev_disable_commit,?u32, msgdata,channeld_init,num_penalty_bases,u32, msgdata,channeld_init,pbases,penalty_base,num_penalty_bases -msgdata,channeld_init,experimental_upgrade,bool, msgdata,channeld_init,num_inflights,u16, msgdata,channeld_init,inflights,inflight,num_inflights msgdata,channeld_init,scid_alias,short_channel_id, diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index d7cfc0ba8..86ac15dbc 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -816,13 +816,6 @@ of the prior channel balance and the new one. Specifying this option advertizes `option_quiesce`. Not very useful by itself, except for testing. -* **experimental-upgrade-protocol** - - Specifying this option means we send (and allow receipt of) a simple -protocol to update channel types. At the moment, we only support setting -`option_static_remotekey` to ancient channels. The peer must also support -this option. - BUGS diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index a2447136a..337f8f21a 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -1887,7 +1887,6 @@ bool peer_start_channeld(struct channel *channel, ? NULL : (u32 *)&ld->dev_disable_commit, pbases, - ld->experimental_upgrade_protocol, cast_const2(const struct inflight **, inflights), *channel->alias[LOCAL]); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 68b2e2462..b75a3087c 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -264,9 +264,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->recover_secret = NULL; ld->db_upgrade_ok = NULL; - /* --experimental-upgrade-protocol */ - ld->experimental_upgrade_protocol = false; - /* --invoices-onchain-fallback */ ld->unified_invoices = false; diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 65383c46b..34c8a1580 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -410,9 +410,6 @@ struct lightningd { * since we otherwise would outright reject them. */ u64 *accept_extra_tlv_types; - /* --experimental-upgrade-protocol */ - bool experimental_upgrade_protocol; - /* --invoices-onchain-fallback */ bool unified_invoices; diff --git a/lightningd/options.c b/lightningd/options.c index 115c7ded7..b55238c56 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1585,9 +1585,6 @@ static void register_opts(struct lightningd *ld) "--subdaemon=hsmd:remote_signer " "would use a hypothetical remote signing subdaemon."); - opt_register_noarg("--experimental-upgrade-protocol", - opt_set_bool, &ld->experimental_upgrade_protocol, - "experimental: allow channel types to be upgraded on reconnect"); opt_register_noarg("--invoices-onchain-fallback", opt_set_bool, &ld->unified_invoices, "Include an onchain address in invoices and mark them as paid if payment is received on-chain"); diff --git a/tests/plugins/channeld_fakenet.c b/tests/plugins/channeld_fakenet.c index 8151b875c..7b44cf381 100644 --- a/tests/plugins/channeld_fakenet.c +++ b/tests/plugins/channeld_fakenet.c @@ -1076,7 +1076,6 @@ static struct channel *handle_init(struct info *info, const u8 *init_msg) u8 *final_scriptpubkey; u8 *their_features; u8 *remote_upfront_shutdown_script; - bool experimental_upgrade; u32 *dev_disable_commit; struct inflight **inflights; struct short_channel_id local_alias; @@ -1136,7 +1135,6 @@ static struct channel *handle_init(struct info *info, const u8 *init_msg) &channel_type, &dev_disable_commit, &pbases, - &experimental_upgrade, &inflights, &local_alias)) abort(); diff --git a/wire/extracted_peer_10_upgradable.patch b/wire/extracted_peer_10_upgradable.patch deleted file mode 100644 index dc4209c8b..000000000 --- a/wire/extracted_peer_10_upgradable.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- wire/peer_wire.csv 2021-05-09 15:44:59.166135652 +0930 -+++ wire/peer_wire.csv.raw 2021-05-11 09:59:31.695459756 +0930 -@@ -244,8 +140,18 @@ - msgdata,channel_reestablish,next_revocation_number,u64, - msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32 - msgdata,channel_reestablish,my_current_per_commitment_point,point, - tlvtype,channel_reestablish_tlvs,next_funding,0 - tlvdata,channel_reestablish_tlvs,next_funding,next_funding_txid,sha256, -+tlvtype,channel_reestablish_tlvs,next_funding,0 -+tlvdata,channel_reestablish_tlvs,next_funding,next_funding_txid,sha256, -+tlvtype,channel_reestablish_tlvs,next_to_send,1 -+tlvdata,channel_reestablish_tlvs,next_to_send,commitment_number,tu64, -+tlvtype,channel_reestablish_tlvs,desired_channel_type,3 -+tlvdata,channel_reestablish_tlvs,desired_channel_type,type,byte,... -+tlvtype,channel_reestablish_tlvs,current_channel_type,5 -+tlvdata,channel_reestablish_tlvs,current_channel_type,type,byte,... -+tlvtype,channel_reestablish_tlvs,upgradable_channel_type,7 -+tlvdata,channel_reestablish_tlvs,upgradable_channel_type,type,byte,... - msgtype,announcement_signatures,259 - msgdata,announcement_signatures,channel_id,channel_id, - msgdata,announcement_signatures,short_channel_id,short_channel_id,