From 15612d269a10c4588e2e231bdaec0e49576fd9de Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 26 Sep 2019 16:00:41 +0930 Subject: [PATCH] Make option_static_remotekey non-EXPERIMENTAL now it's in spec. Signed-off-by: Rusty Russell --- CHANGELOG.md | 1 + Makefile | 2 +- channeld/channeld.c | 18 +++++------------- common/features.c | 2 -- common/features.h | 2 +- common/key_derive.c | 7 +++++-- common/keyset.c | 4 ++-- hsmd/hsmd.c | 2 +- lightningd/channel_control.c | 3 --- lightningd/closing_control.c | 3 --- lightningd/opening_control.c | 2 +- onchaind/onchaind.c | 2 +- tests/test_connection.py | 14 ++++---------- tests/test_misc.py | 7 +++---- wire/extracted_peer_experimental_legacy | 12 ------------ wire/extracted_peer_wire_csv | 4 ++-- 16 files changed, 27 insertions(+), 58 deletions(-) delete mode 100644 wire/extracted_peer_experimental_legacy diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e4659f63..cdad04f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -261,6 +261,7 @@ This release named by @molxyz and [@ctrlbreak](https://twitter.com/ctrlbreak). - JSON API: `listpeers`'s `channels` now includes a `private` flag to indicate if channel is announced or not. - JSON API: `invoice` route hints may now include private channels if you have no public ones, unless new option `exposeprivatechannels` is false. - Plugins: experimental plugin support for `lightningd`, including option passthrough and JSON-RPC passthrough. +- Protocol: we now support features `option_static_remotekey` and `gossip_queries_ex` for peers. ### Changed diff --git a/Makefile b/Makefile index 6e05ee20c..91e8094ae 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := c8e53fe5bf131db142d231e88f2adb3a84876836 +BOLTVERSION := 2afe3559e89520ba28b24ff5739491313217ae13 -include config.vars diff --git a/channeld/channeld.c b/channeld/channeld.c index f6b788f31..e16dabc4f 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -2014,7 +2014,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last peer->revocations_received); } -/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2: +/* BOLT #2: * * A receiving node: * - if `option_static_remotekey` applies to the commitment transaction: @@ -2077,7 +2077,7 @@ static void check_future_dataloss_fields(struct peer *peer, peer_failed(peer->pps, &peer->channel_id, "Awaiting unilateral close"); } -/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2: +/* BOLT #2: * * A receiving node: * - if `option_static_remotekey` applies to the commitment transaction: @@ -2239,7 +2239,7 @@ static void peer_reconnect(struct peer *peer, get_per_commitment_point(peer->next_index[LOCAL] - 1, &my_current_per_commitment_point, NULL); - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2: + /* BOLT #2: * * - upon reconnection: * - if a channel is in an error state: @@ -2272,7 +2272,6 @@ static void peer_reconnect(struct peer *peer, * - MUST set `your_last_per_commitment_secret` to the last * `per_commitment_secret` it received */ -#if EXPERIMENTAL_FEATURES if (peer->channel->option_static_remotekey) { msg = towire_channel_reestablish_option_static_remotekey (NULL, &peer->channel_id, @@ -2281,9 +2280,7 @@ static void peer_reconnect(struct peer *peer, last_remote_per_commit_secret, /* Can send any (valid) point here */ &peer->remote_per_commit); - } else -#endif /* EXPERIMENTAL_FEATURES */ - if (dataloss_protect) { + } else if (dataloss_protect) { msg = towire_channel_reestablish_option_data_loss_protect (NULL, &peer->channel_id, peer->next_index[LOCAL], @@ -2310,7 +2307,6 @@ static void peer_reconnect(struct peer *peer, } while (handle_peer_gossip_or_error(peer->pps, &peer->channel_id, msg) || capture_premature_msg(&premature_msgs, msg)); -#if EXPERIMENTAL_FEATURES if (peer->channel->option_static_remotekey) { struct pubkey ignore; if (!fromwire_channel_reestablish_option_static_remotekey(msg, @@ -2325,9 +2321,7 @@ static void peer_reconnect(struct peer *peer, wire_type_name(fromwire_peektype(msg)), tal_hex(msg, msg)); } - } else -#endif /* EXPERIMENTAL_FEATURES */ - if (dataloss_protect) { + } else if (dataloss_protect) { if (!fromwire_channel_reestablish_option_data_loss_protect(msg, &channel_id, &next_commitment_number, @@ -3023,9 +3017,7 @@ static void init_channel(struct peer *peer) feerate_per_kw[LOCAL], feerate_per_kw[REMOTE], peer->feerate_min, peer->feerate_max); -#if EXPERIMENTAL_FEATURES status_debug("option_static_remotekey = %u", option_static_remotekey); -#endif if(remote_ann_node_sig && remote_ann_bitcoin_sig) { peer->announcement_node_sigs[REMOTE] = *remote_ann_node_sig; diff --git a/common/features.c b/common/features.c index e357e1dda..ff3ae89fc 100644 --- a/common/features.c +++ b/common/features.c @@ -9,9 +9,7 @@ static const u32 our_localfeatures[] = { OPTIONAL_FEATURE(LOCAL_UPFRONT_SHUTDOWN_SCRIPT), OPTIONAL_FEATURE(LOCAL_GOSSIP_QUERIES), OPTIONAL_FEATURE(LOCAL_GOSSIP_QUERIES_EX), -#if EXPERIMENTAL_FEATURES OPTIONAL_FEATURE(LOCAL_STATIC_REMOTEKEY), -#endif }; static const u32 our_globalfeatures[] = { diff --git a/common/features.h b/common/features.h index d5c93b77d..f4b677784 100644 --- a/common/features.h +++ b/common/features.h @@ -53,7 +53,7 @@ void set_feature_bit(u8 **ptr, u32 bit); #define LOCAL_GOSSIP_QUERIES 6 #define LOCAL_GOSSIP_QUERIES_EX 10 -/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #9: +/* BOLT #9: * | Bits | Name |... * | 12/13| `option_static_remotekey` |... */ diff --git a/common/key_derive.c b/common/key_derive.c index dc5ae4ad4..79dc1d05b 100644 --- a/common/key_derive.c +++ b/common/key_derive.c @@ -7,18 +7,21 @@ /* BOLT #3: * - * ### `localpubkey`, `remotepubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation + * ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation * * These pubkeys are simply generated by addition from their base points: * * pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G * * The `localpubkey` uses the local node's `payment_basepoint`; - * the `remotepubkey` uses the remote node's `payment_basepoint`; * the `local_htlcpubkey` uses the local node's `htlc_basepoint`; * the `remote_htlcpubkey` uses the remote node's `htlc_basepoint`; * the `local_delayedpubkey` uses the local node's `delayed_payment_basepoint`; * and the `remote_delayedpubkey` uses the remote node's `delayed_payment_basepoint`. + *... + * If `option_static_remotekey` is negotiated the `remotepubkey` is simply the + * remote node's `payment_basepoint`, otherwise it is calculated as above using + * the remote node's `payment_basepoint`. */ bool derive_simple_key(const struct pubkey *basepoint, const struct pubkey *per_commitment_point, diff --git a/common/keyset.c b/common/keyset.c index 559f63d86..10bf3bba9 100644 --- a/common/keyset.c +++ b/common/keyset.c @@ -8,7 +8,7 @@ bool derive_keyset(const struct pubkey *per_commitment_point, bool option_static_remotekey, struct keyset *keyset) { - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3: + /* BOLT #3: * * ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation * @@ -27,7 +27,7 @@ bool derive_keyset(const struct pubkey *per_commitment_point, &keyset->self_payment_key)) return false; - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3: + /* BOLT #3: * * ### `remotepubkey` Derivation * diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c index 3a3b7fd02..b7e9bc9c2 100644 --- a/hsmd/hsmd.c +++ b/hsmd/hsmd.c @@ -1385,7 +1385,7 @@ static void hsm_unilateral_close_privkey(struct privkey *dst, get_channel_seed(&info->peer_id, info->channel_id, &channel_seed); derive_basepoints(&channel_seed, NULL, &basepoints, &secrets, NULL); - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3: + /* BOLT #3: * * If `option_static_remotekey` is negotiated the `remotepubkey` * is simply the remote node's `payment_basepoint`, otherwise it is diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index e3e42e19c..3f8df8060 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -391,9 +391,6 @@ void peer_start_channeld(struct channel *channel, num_revocations = revocations_received(&channel->their_shachain.chain); /* BOLT #2: - * - * - if it supports `option_data_loss_protect`: - *... * - if `next_revocation_number` equals 0: * - MUST set `your_last_per_commitment_secret` to all zeroes * - otherwise: diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index c35d77f41..79a0b6d93 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -245,9 +245,6 @@ void peer_start_closingd(struct channel *channel, } /* BOLT #2: - * - * - if it supports `option_data_loss_protect`: - *... * - if `next_revocation_number` equals 0: * - MUST set `your_last_per_commitment_secret` to all zeroes * - otherwise: diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index b25cf2a1e..a70c791bb 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -198,7 +198,7 @@ wallet_commit_channel(struct lightningd *ld, /* old_remote_per_commit not valid yet, copy valid one. */ channel_info->old_remote_per_commit = channel_info->remote_per_commit; - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2: + /* BOLT #2: * 1. type: 35 (`funding_signed`) * 2. data: * * [`channel_id`:`channel_id`] diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 16f723a7c..76f183125 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -2485,7 +2485,7 @@ static void handle_unknown_commitment(const struct bitcoin_tx *tx, local_script = scriptpubkey_p2wpkh(tmpctx, &ks->other_payment_key); } else { - /* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3: + /* BOLT #3: * * ### `remotepubkey` Derivation * diff --git a/tests/test_connection.py b/tests/test_connection.py index 4cd4e9432..760a78a32 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3,7 +3,7 @@ from decimal import Decimal from fixtures import * # noqa: F401,F403 from flaky import flaky # noqa: F401 from lightning import RpcError -from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE, EXPERIMENTAL_FEATURES +from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE from bitcoin.core import CMutableTransaction, CMutableTxOut import binascii @@ -1382,9 +1382,7 @@ def test_forget_channel(node_factory): def test_peerinfo(node_factory, bitcoind): l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'may_reconnect': True}) - lfeatures = '08a2' - if EXPERIMENTAL_FEATURES: - lfeatures = '28a2' + lfeatures = '28a2' # Gossiping but no node announcement yet assert l1.rpc.getpeer(l2.info['id'])['connected'] assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0 @@ -1636,12 +1634,8 @@ def test_dataloss_protection(node_factory, bitcoind): l2 = node_factory.get_node(may_reconnect=True, log_all_io=True, feerates=(7500, 7500, 7500), allow_broken_log=True) - if EXPERIMENTAL_FEATURES: - # features 1, 3, 7, 11 and 13 (0x28a2). - lf = "28a2" - else: - # features 1, 3, 7 and 11 (0x08a2). - lf = "08a2" + # features 1, 3, 7, 11 and 13 (0x28a2). + lf = "28a2" l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # l1 should send out WIRE_INIT (0010) l1.daemon.wait_for_log(r"\[OUT\] 0010" diff --git a/tests/test_misc.py b/tests/test_misc.py index 4dca23bf7..ac1371423 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -3,7 +3,7 @@ from fixtures import * # noqa: F401,F403 from flaky import flaky # noqa: F401 from lightning import RpcError from threading import Event -from utils import DEVELOPER, TIMEOUT, VALGRIND, sync_blockheight, only_one, wait_for, TailableProc, EXPERIMENTAL_FEATURES +from utils import DEVELOPER, TIMEOUT, VALGRIND, sync_blockheight, only_one, wait_for, TailableProc from ephemeral_port_reserve import reserve import json @@ -1446,7 +1446,6 @@ def test_list_features_only(node_factory): expected = ['option_data_loss_protect/odd', 'option_upfront_shutdown_script/odd', 'option_gossip_queries/odd', - 'option_gossip_queries_ex/odd'] - if EXPERIMENTAL_FEATURES: - expected += ['option_static_remotekey/odd'] + 'option_gossip_queries_ex/odd', + 'option_static_remotekey/odd'] assert features == expected diff --git a/wire/extracted_peer_experimental_legacy b/wire/extracted_peer_experimental_legacy deleted file mode 100644 index 7f091177e..000000000 --- a/wire/extracted_peer_experimental_legacy +++ /dev/null @@ -1,12 +0,0 @@ ---- wire/extracted_peer_wire_csv 2019-08-01 11:33:48.136457293 +0930 -+++ - 2019-08-01 11:40:21.313665504 +0930 -@@ -108,7 +108,7 @@ - msgdata,channel_reestablish,channel_id,channel_id, - msgdata,channel_reestablish,next_commitment_number,u64, - msgdata,channel_reestablish,next_revocation_number,u64, --msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect -+msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey --msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect -+msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect,option_static_remotekey - msgtype,announcement_signatures,259 - msgdata,announcement_signatures,channel_id,channel_id, diff --git a/wire/extracted_peer_wire_csv b/wire/extracted_peer_wire_csv index 001b335de..6509fc970 100644 --- a/wire/extracted_peer_wire_csv +++ b/wire/extracted_peer_wire_csv @@ -122,8 +122,8 @@ msgtype,channel_reestablish,136 msgdata,channel_reestablish,channel_id,channel_id, msgdata,channel_reestablish,next_commitment_number,u64, msgdata,channel_reestablish,next_revocation_number,u64, -msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect -msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect +msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey +msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect,option_static_remotekey msgtype,announcement_signatures,259 msgdata,announcement_signatures,channel_id,channel_id, msgdata,announcement_signatures,short_channel_id,short_channel_id,