Skip to content

Commit 67c91a7

Browse files
committed
BOLTs: Update to version with peer storage merged.
Unfortunately a spec typo means the data fields are missing (PR pending), so we still patch those in. The message "your_peer_storage" got renamed to "peer_storage_retrieval", and the option "want_peer_backup_storage" was removed. Signed-off-by: Rusty Russell <[email protected]> Changelog-EXPERIMENTAL: `experimental-peer-storage` now only advertizes feature 43, not 41.
1 parent e832784 commit 67c91a7

File tree

58 files changed

+83
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+83
-97
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CCANDIR := ccan
2626

2727
# Where we keep the BOLT RFCs
2828
BOLTDIR := ../bolts/
29-
DEFAULT_BOLTVERSION := ecf792d87367fb6ff132a0cc7a53193dfb77d001
29+
DEFAULT_BOLTVERSION := acd383145dd8c3fecd69ce94e4a789767b984ac0
3030
# Can be overridden on cmdline.
3131
BOLTVERSION := $(DEFAULT_BOLTVERSION)
3232

channeld/channeld.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4587,7 +4587,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
45874587
case WIRE_ERROR:
45884588
case WIRE_ONION_MESSAGE:
45894589
case WIRE_PEER_STORAGE:
4590-
case WIRE_YOUR_PEER_STORAGE:
4590+
case WIRE_PEER_STORAGE_RETRIEVAL:
45914591
abort();
45924592
}
45934593

common/features.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ static const struct feature_style feature_styles[] = {
132132
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
133133
[BOLT11_FEATURE] = FEATURE_DONT_REPRESENT,
134134
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
135-
{ OPT_WANT_PEER_BACKUP_STORAGE,
136-
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
137-
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT } },
138-
{ OPT_PROVIDE_PEER_BACKUP_STORAGE,
135+
{ OPT_PROVIDE_STORAGE,
139136
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
140137
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT } },
141138
{ OPT_SPLICE,
@@ -430,8 +427,8 @@ const char *feature_name(const tal_t *ctx, size_t f)
430427
"option_quiesce", /* https://github.com/lightning/bolts/pull/869 */
431428
NULL,
432429
"option_onion_messages", /* https://github.com/lightning/bolts/pull/759 */
433-
"option_want_peer_backup_storage", /* 40/41 */ /* https://github.com/lightning/bolts/pull/881/files */
434-
"option_provide_peer_backup_storage", /* https://github.com/lightning/bolts/pull/881/files */
430+
NULL,
431+
"option_provide_storage",
435432
"option_channel_type",
436433
"option_scid_alias", /* https://github.com/lightning/bolts/pull/910 */
437434
"option_payment_metadata",

common/features.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
115115
* | 24/25 | `option_route_blinding` |...IN9 ...
116116
* | 26/27 | `option_shutdown_anysegwit` |... IN ...
117117
* | 28/29 | `option_dual_fund` |... IN ...
118-
* | 34/35 | `option_quiesce` | ... IN ...
118+
* | 34/35 | `option_quiesce` |... IN ...
119119
* | 38/39 | `option_onion_messages` |... IN ...
120+
* | 42/43 | `option_provide_storage` |... IN ...
120121
* | 44/45 | `option_channel_type` |... IN ...
121122
* | 46/47 | `option_scid_alias` | ... IN ...
122123
* | 48/49 | `option_payment_metadata` |... 9 ...
@@ -138,6 +139,7 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
138139
#define OPT_DUAL_FUND 28
139140
#define OPT_QUIESCE 34
140141
#define OPT_ONION_MESSAGES 38
142+
#define OPT_PROVIDE_STORAGE 42
141143
#define OPT_CHANNEL_TYPE 44
142144
#define OPT_SCID_ALIAS 46
143145
#define OPT_PAYMENT_METADATA 48
@@ -155,12 +157,4 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
155157

156158
#define OPT_SHUTDOWN_WRONG_FUNDING 104
157159

158-
/* BOLT-peer-storage #9:
159-
*
160-
* | 40/41 | `want_peer_backup_storage` | Want to use other nodes to store encrypted backup data | IN ...
161-
* | 42/43 | `provide_peer_backup_storage` | Can store other nodes' encrypted backup data | IN ...
162-
*/
163-
#define OPT_WANT_PEER_BACKUP_STORAGE 40
164-
#define OPT_PROVIDE_PEER_BACKUP_STORAGE 42
165-
166160
#endif /* LIGHTNING_COMMON_FEATURES_H */

common/gossmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ const void *gossmap_stream_next(const tal_t *ctx,
18021802
case WIRE_UPDATE_BLOCKHEIGHT:
18031803
case WIRE_CHANNEL_REESTABLISH:
18041804
case WIRE_PEER_STORAGE:
1805-
case WIRE_YOUR_PEER_STORAGE:
1805+
case WIRE_PEER_STORAGE_RETRIEVAL:
18061806
case WIRE_ANNOUNCEMENT_SIGNATURES:
18071807
case WIRE_QUERY_SHORT_CHANNEL_IDS:
18081808
case WIRE_REPLY_SHORT_CHANNEL_IDS_END:

common/interactivetx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static u8 *read_next_msg(const tal_t *ctx,
184184
case WIRE_SHUTDOWN:
185185
case WIRE_STFU:
186186
case WIRE_PEER_STORAGE:
187-
case WIRE_YOUR_PEER_STORAGE:
187+
case WIRE_PEER_STORAGE_RETRIEVAL:
188188
case WIRE_SPLICE:
189189
case WIRE_SPLICE_ACK:
190190
case WIRE_SPLICE_LOCKED:
@@ -774,7 +774,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
774774
case WIRE_PING:
775775
case WIRE_PONG:
776776
case WIRE_PEER_STORAGE:
777-
case WIRE_YOUR_PEER_STORAGE:
777+
case WIRE_PEER_STORAGE_RETRIEVAL:
778778
case WIRE_SPLICE:
779779
case WIRE_SPLICE_ACK:
780780
case WIRE_STFU:

connectd/gossip_rcvd_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static bool is_msg_gossip_broadcast(const u8 *cursor)
8888
case WIRE_TX_ACK_RBF:
8989
case WIRE_TX_ABORT:
9090
case WIRE_PEER_STORAGE:
91-
case WIRE_YOUR_PEER_STORAGE:
91+
case WIRE_PEER_STORAGE_RETRIEVAL:
9292
case WIRE_OPEN_CHANNEL2:
9393
case WIRE_ACCEPT_CHANNEL2:
9494
case WIRE_STFU:

connectd/gossip_store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static bool public_msg_type(enum peer_wire type)
9393
case WIRE_GOSSIP_TIMESTAMP_FILTER:
9494
case WIRE_ONION_MESSAGE:
9595
case WIRE_PEER_STORAGE:
96-
case WIRE_YOUR_PEER_STORAGE:
96+
case WIRE_PEER_STORAGE_RETRIEVAL:
9797
case WIRE_STFU:
9898
case WIRE_SPLICE:
9999
case WIRE_SPLICE_ACK:

connectd/multiplex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static bool is_urgent(enum peer_wire type)
382382
case WIRE_GOSSIP_TIMESTAMP_FILTER:
383383
case WIRE_ONION_MESSAGE:
384384
case WIRE_PEER_STORAGE:
385-
case WIRE_YOUR_PEER_STORAGE:
385+
case WIRE_PEER_STORAGE_RETRIEVAL:
386386
case WIRE_STFU:
387387
case WIRE_SPLICE:
388388
case WIRE_SPLICE_ACK:

gossipd/gossipd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void handle_recv_gossip(struct daemon *daemon, const u8 *outermsg)
262262
case WIRE_ACCEPT_CHANNEL2:
263263
case WIRE_ONION_MESSAGE:
264264
case WIRE_PEER_STORAGE:
265-
case WIRE_YOUR_PEER_STORAGE:
265+
case WIRE_PEER_STORAGE_RETRIEVAL:
266266
case WIRE_STFU:
267267
case WIRE_SPLICE:
268268
case WIRE_SPLICE_ACK:

lightningd/options.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,10 +1258,7 @@ static char *opt_set_peer_storage(struct lightningd *ld)
12581258
{
12591259
feature_set_or(ld->our_features,
12601260
take(feature_set_for_feature(NULL,
1261-
OPTIONAL_FEATURE(OPT_PROVIDE_PEER_BACKUP_STORAGE))));
1262-
feature_set_or(ld->our_features,
1263-
take(feature_set_for_feature(NULL,
1264-
OPTIONAL_FEATURE(OPT_WANT_PEER_BACKUP_STORAGE))));
1261+
OPTIONAL_FEATURE(OPT_PROVIDE_STORAGE))));
12651262
return NULL;
12661263
}
12671264

openingd/dualopend.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state)
16981698
case WIRE_PING:
16991699
case WIRE_PONG:
17001700
case WIRE_PEER_STORAGE:
1701-
case WIRE_YOUR_PEER_STORAGE:
1701+
case WIRE_PEER_STORAGE_RETRIEVAL:
17021702
case WIRE_STFU:
17031703
case WIRE_SPLICE:
17041704
case WIRE_SPLICE_ACK:
@@ -2077,7 +2077,7 @@ static bool run_tx_interactive(struct state *state,
20772077
case WIRE_PING:
20782078
case WIRE_PONG:
20792079
case WIRE_PEER_STORAGE:
2080-
case WIRE_YOUR_PEER_STORAGE:
2080+
case WIRE_PEER_STORAGE_RETRIEVAL:
20812081
case WIRE_STFU:
20822082
case WIRE_SPLICE:
20832083
case WIRE_SPLICE_ACK:
@@ -4260,7 +4260,7 @@ static u8 *handle_peer_in(struct state *state)
42604260
case WIRE_PING:
42614261
case WIRE_PONG:
42624262
case WIRE_PEER_STORAGE:
4263-
case WIRE_YOUR_PEER_STORAGE:
4263+
case WIRE_PEER_STORAGE_RETRIEVAL:
42644264
case WIRE_STFU:
42654265
case WIRE_SPLICE:
42664266
case WIRE_SPLICE_ACK:

plugins/chanbackup.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static struct command_result *peer_after_listdatastore(struct command *cmd,
386386
if (!peer_backup)
387387
return command_hook_success(cmd);
388388

389-
u8 *payload = towire_your_peer_storage(cmd, hexdata);
389+
u8 *payload = towire_peer_storage_retrieval(cmd, hexdata);
390390

391391
plugin_log(cmd->plugin, LOG_DBG,
392392
"sending their backup from our datastore");
@@ -508,7 +508,7 @@ static struct command_result *after_listpeers(struct command *cmd,
508508
continue;
509509

510510
/* We shouldn't have to check, but LND hangs up? */
511-
if (feature_offered(features, OPT_PROVIDE_PEER_BACKUP_STORAGE)) {
511+
if (feature_offered(features, OPT_PROVIDE_STORAGE)) {
512512
const jsmntok_t *nodeid;
513513
struct node_id node_id;
514514

@@ -612,8 +612,7 @@ static struct command_result *peer_connected(struct command *cmd,
612612
}
613613

614614
/* We shouldn't have to check, but LND hangs up? */
615-
if (!feature_offered(features, OPT_WANT_PEER_BACKUP_STORAGE)
616-
&& !feature_offered(features, OPT_PROVIDE_PEER_BACKUP_STORAGE)) {
615+
if (!feature_offered(features, OPT_PROVIDE_STORAGE)) {
617616
return command_hook_success(cmd);
618617
}
619618

@@ -693,7 +692,7 @@ static struct command_result *handle_your_peer_storage(struct command *cmd,
693692
datastore_success,
694693
datastore_failed,
695694
"Saving chanbackup/peers/");
696-
} else if (fromwire_your_peer_storage(cmd, payload, &payload_deserialise)) {
695+
} else if (fromwire_peer_storage_retrieval(cmd, payload, &payload_deserialise)) {
697696
plugin_log(cmd->plugin, LOG_DBG,
698697
"Received peer_storage from peer.");
699698

@@ -877,7 +876,7 @@ static const char *init(struct command *init_cmd,
877876
take(json_out_obj(NULL, NULL, NULL)),
878877
"{our_features:{init:%}}",
879878
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, &features));
880-
peer_backup = feature_offered(features, OPT_WANT_PEER_BACKUP_STORAGE);
879+
peer_backup = feature_offered(features, OPT_PROVIDE_STORAGE);
881880

882881
rpc_scan(init_cmd, "staticbackup",
883882
take(json_out_obj(NULL, NULL, NULL)),
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "config.h"
2+
#include <ccan/mem/mem.h>
3+
#include <tests/fuzz/libfuzz.h>
4+
#include <tests/fuzz/wire.h>
5+
#include <wire/peer_wire.h>
6+
7+
struct peer_storage_retrieval {
8+
u8 *blob;
9+
};
10+
11+
static void *encode(const tal_t *ctx, const struct peer_storage_retrieval *s)
12+
{
13+
return towire_peer_storage_retrieval(ctx, s->blob);
14+
}
15+
16+
static struct peer_storage_retrieval *decode(const tal_t *ctx, const void *p)
17+
{
18+
struct peer_storage_retrieval *s = tal(ctx, struct peer_storage_retrieval);
19+
20+
if (fromwire_peer_storage_retrieval(s, p, &s->blob))
21+
return s;
22+
return tal_free(s);
23+
}
24+
25+
static bool equal(const struct peer_storage_retrieval *x,
26+
const struct peer_storage_retrieval *y)
27+
{
28+
return tal_arr_eq(x->blob, y->blob);
29+
}
30+
31+
void run(const u8 *data, size_t size)
32+
{
33+
test_decode_encode(data, size, WIRE_PEER_STORAGE_RETRIEVAL,
34+
struct peer_storage_retrieval);
35+
}

tests/fuzz/fuzz-wire-your_peer_storage.c

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,7 @@ def test_restorefrompeer(node_factory, bitcoind):
31363136
except RpcError as err:
31373137
assert "disconnected during connection" in err.error['message']
31383138

3139-
l1.daemon.wait_for_log('peer_in WIRE_YOUR_PEER_STORAGE')
3139+
l1.daemon.wait_for_log('peer_in WIRE_PEER_STORAGE_RETRIEVAL')
31403140

31413141
assert l1.rpc.restorefrompeer()['stubs'][0] == _['channel_id']
31423142

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
--- wire/peer_wire.csv 2022-07-18 13:49:29.079542016 +0530
22
+++ - 2022-07-18 13:58:17.706696582 +0530
3-
@@ -249,6 +249,12 @@
4-
msgdata,channel_reestablish,my_current_per_commitment_point,point,
5-
tlvtype,channel_reestablish_tlvs,next_funding,0
6-
tlvdata,channel_reestablish_tlvs,next_funding,next_funding_txid,sha256,
7-
+msgtype,peer_storage,7
3+
@@ -249,7 +249,11 @@
4+
msgdata,pong,byteslen,u16,
5+
msgdata,pong,ignored,byte,byteslen
6+
msgtype,peer_storage,7
87
+msgdata,peer_storage,len,u16,
98
+msgdata,peer_storage,blob,byte,len
10-
+msgtype,your_peer_storage,9
11-
+msgdata,your_peer_storage,len,u16,
12-
+msgdata,your_peer_storage,blob,byte,len
13-
msgtype,announcement_signatures,259
14-
msgdata,announcement_signatures,channel_id,channel_id,
15-
msgdata,announcement_signatures,short_channel_id,short_channel_id,
9+
msgtype,peer_storage_retrieval,9
10+
+msgdata,peer_storage_retrieval,len,u16,
11+
+msgdata,peer_storage_retrieval,blob,byte,len
12+
tlvtype,n1,tlv1,1
13+
tlvdata,n1,tlv1,amount_msat,tu64,
14+
tlvtype,n1,tlv2,2

wire/extracted_peer_10_upgradable.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
+tlvdata,channel_reestablish_tlvs,current_channel_type,type,byte,...
1717
+tlvtype,channel_reestablish_tlvs,upgradable_channel_type,7
1818
+tlvdata,channel_reestablish_tlvs,upgradable_channel_type,type,byte,...
19-
msgtype,peer_storage,7
20-
msgdata,peer_storage,len,u16,
21-
msgdata,peer_storage,blob,byte,len
19+
msgtype,announcement_signatures,259
20+
msgdata,announcement_signatures,channel_id,channel_id,
21+
msgdata,announcement_signatures,short_channel_id,short_channel_id,

wire/peer_wire.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static bool unknown_type(enum peer_wire t)
4646
case WIRE_TX_ACK_RBF:
4747
case WIRE_TX_ABORT:
4848
case WIRE_PEER_STORAGE:
49-
case WIRE_YOUR_PEER_STORAGE:
49+
case WIRE_PEER_STORAGE_RETRIEVAL:
5050
case WIRE_OPEN_CHANNEL2:
5151
case WIRE_ACCEPT_CHANNEL2:
5252
case WIRE_STFU:
@@ -105,7 +105,7 @@ bool is_msg_for_gossipd(const u8 *cursor)
105105
case WIRE_ACCEPT_CHANNEL2:
106106
case WIRE_ONION_MESSAGE:
107107
case WIRE_PEER_STORAGE:
108-
case WIRE_YOUR_PEER_STORAGE:
108+
case WIRE_PEER_STORAGE_RETRIEVAL:
109109
case WIRE_STFU:
110110
case WIRE_SPLICE:
111111
case WIRE_SPLICE_ACK:
@@ -130,7 +130,7 @@ bool peer_wire_is_internal(enum peer_wire type)
130130
return false;
131131

132132
/* handled by pluigns */
133-
if (type == WIRE_PEER_STORAGE || type == WIRE_YOUR_PEER_STORAGE)
133+
if (type == WIRE_PEER_STORAGE || type == WIRE_PEER_STORAGE_RETRIEVAL)
134134
return false;
135135

136136
return true;
@@ -161,7 +161,7 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
161161
case WIRE_GOSSIP_TIMESTAMP_FILTER:
162162
case WIRE_ONION_MESSAGE:
163163
case WIRE_PEER_STORAGE:
164-
case WIRE_YOUR_PEER_STORAGE:
164+
case WIRE_PEER_STORAGE_RETRIEVAL:
165165
return false;
166166

167167
/* Special cases: */

wire/peer_wire.csv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ msgdata,ping,ignored,byte,byteslen
2323
msgtype,pong,19
2424
msgdata,pong,byteslen,u16,
2525
msgdata,pong,ignored,byte,byteslen
26+
msgtype,peer_storage,7
27+
msgdata,peer_storage,len,u16,
28+
msgdata,peer_storage,blob,byte,len
29+
msgtype,peer_storage_retrieval,9
30+
msgdata,peer_storage_retrieval,len,u16,
31+
msgdata,peer_storage_retrieval,blob,byte,len
2632
tlvtype,n1,tlv1,1
2733
tlvdata,n1,tlv1,amount_msat,tu64,
2834
tlvtype,n1,tlv2,2
@@ -299,12 +305,6 @@ tlvtype,channel_reestablish_tlvs,current_channel_type,5
299305
tlvdata,channel_reestablish_tlvs,current_channel_type,type,byte,...
300306
tlvtype,channel_reestablish_tlvs,upgradable_channel_type,7
301307
tlvdata,channel_reestablish_tlvs,upgradable_channel_type,type,byte,...
302-
msgtype,peer_storage,7
303-
msgdata,peer_storage,len,u16,
304-
msgdata,peer_storage,blob,byte,len
305-
msgtype,your_peer_storage,9
306-
msgdata,your_peer_storage,len,u16,
307-
msgdata,your_peer_storage,blob,byte,len
308308
msgtype,announcement_signatures,259
309309
msgdata,announcement_signatures,channel_id,channel_id,
310310
msgdata,announcement_signatures,short_channel_id,short_channel_id,

0 commit comments

Comments
 (0)