1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 10:00:04 +01:00
Commit Graph

21 Commits

Author SHA1 Message Date
Rusty Russell
aad959a297 tools: remove option handling now last optional field was removed.
6fee63fc34 made `htlc_maximum_msat`
compulsory, which was the last "optional" field.  All future options
will be TLVs, so we never need to parse the "] (optionxxx)" format
for fields again.

We allow options for messages, but only for documentation (we have
some messages which are only for `gossip_queries`), so we don't
put it in the output.

Here's the before/after diff of the output for all the spec files:

```diff
--- /tmp/before	2023-04-27 14:21:07.417170213 +0930
+++ /tmp/after	2023-04-27 14:19:39.184573086 +0930
@@ -273,7 +273,7 @@
 msgdata,channel_update,fee_base_msat,u32,
 msgdata,channel_update,fee_proportional_millionths,u32,
 msgdata,channel_update,htlc_maximum_msat,u64,
-msgtype,query_short_channel_ids,261,gossip_queries
+msgtype,query_short_channel_ids,261
 msgdata,query_short_channel_ids,chain_hash,chain_hash,
 msgdata,query_short_channel_ids,len,u16,
 msgdata,query_short_channel_ids,encoded_short_ids,byte,len
@@ -281,17 +281,17 @@
 tlvtype,query_short_channel_ids_tlvs,query_flags,1
 tlvdata,query_short_channel_ids_tlvs,query_flags,encoding_type,byte,
 tlvdata,query_short_channel_ids_tlvs,query_flags,encoded_query_flags,byte,...
-msgtype,reply_short_channel_ids_end,262,gossip_queries
+msgtype,reply_short_channel_ids_end,262
 msgdata,reply_short_channel_ids_end,chain_hash,chain_hash,
 msgdata,reply_short_channel_ids_end,full_information,byte,
-msgtype,query_channel_range,263,gossip_queries
+msgtype,query_channel_range,263
 msgdata,query_channel_range,chain_hash,chain_hash,
 msgdata,query_channel_range,first_blocknum,u32,
 msgdata,query_channel_range,number_of_blocks,u32,
 msgdata,query_channel_range,tlvs,query_channel_range_tlvs,
 tlvtype,query_channel_range_tlvs,query_option,1
 tlvdata,query_channel_range_tlvs,query_option,query_option_flags,bigsize,
-msgtype,reply_channel_range,264,gossip_queries
+msgtype,reply_channel_range,264
 msgdata,reply_channel_range,chain_hash,chain_hash,
 msgdata,reply_channel_range,first_blocknum,u32,
 msgdata,reply_channel_range,number_of_blocks,u32,
@@ -310,7 +310,7 @@
 subtype,channel_update_checksums
 subtypedata,channel_update_checksums,checksum_node_id_1,u32,
 subtypedata,channel_update_checksums,checksum_node_id_2,u32,
-msgtype,gossip_timestamp_filter,265,gossip_queries
+msgtype,gossip_timestamp_filter,265
 msgdata,gossip_timestamp_filter,chain_hash,chain_hash,
 msgdata,gossip_timestamp_filter,first_timestamp,u32,
 msgdata,gossip_timestamp_filter,timestamp_range,u32,
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-11 12:01:38 +09:30
Corné Plooy
5a86adaa77 tlvs -> tlv_stream in extract-formats.py 2020-11-09 13:10:22 -06:00
Rusty Russell
d498d2ac56 tools/extract-formats.py: allow '.' in length fields.
In practice, using '...*type' is the clearest and simplest way to specify
the common case of "the rest of the TLV is an array of 'type'", rather
than some arbitrary expression with a made-up length field.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-06 00:18:49 +00:00
Rusty Russell
9491348d27 tools/extract-formats.py: allow '*' as well as '1.'/'2.'
The format for TLV types looked pretty, but @ZmnSCPxj points out that
successive ordered lists in markdown get merged into one megalist.

If we allow ordered or unordered lists, we're a bit more futureproof
against formatting changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-06 00:18:49 +00:00
Rusty Russell
6af2ba23a8 tools/extract-formats.py: handle continuous types in tlvs.
We were swallowing the unused line after `data`, but it's
normal to do:

```
1. tlvs: `n1`
2. types:
   1. type: 1 (`tlv1`)
   2. data:
     * [`tu64`:`amount_msat`]
   1. type: 2 (`tlv2`)
   2. data:
     * [`short_channel_id`:`scid`]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
acad3fc8fe tools/extract-formats.py: recognize numerics in field names.
For some reason (typo?) we only allowed "2", not other numbers!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
d6e477be43 tools/extract-formats.py: rewrite, change output.
Editing the previous mess was horrific.  I gave up and rewrote using a
generator.

Changes to output:
1. subtypes and tlvs now handled.
2. The output format now has explicit prefixes, so readers don't have
   to rely on number of fields to interpret data.
3. Each field is split into type and count; count is empty if there's
   no '*x'.
4. TLV stream typenames are repeated; TLV record type names are not
   necessarily unique.
5. The unused offset field is removed.
6. No arguments taken: everything is always printed, and you can grep if you
   only want some.

[ Fixup by <niftynei@gmail.com> ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-09 00:48:46 +00:00
Rusty Russell
b2d1204a9f tools/extract-formats.py: handle option labels on types.
We're about to introduce new messages which are gated by options (not
just single fields).  Ignore them for the purposes of parsing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-06-28 00:21:23 +00:00
Rusty Russell
e76ed893d9 tools: remove --check-alignment option.
Alignment requirements were dropped before 1.0 of the spec.

Closes: #407
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-05-24 04:21:31 +00:00
Janus
9d48f3e52f correct feature flagged message fields syntax, update structured.py to support feature flagged fields, print to right output in extract-formats.py 2018-04-11 07:08:18 +00:00
Rusty Russell
4bb1d7e6be tools: allow `` around option names, strip them
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-28 00:09:57 +00:00
Rusty Russell
a759dff029 BOLT 1, tools: add support for our first optional field.
We've always specified that fields can be appended, and we're about to
do our first.  Make it clear that you can't just send one if we add several
fields as part of the same option.

Change extract-formats to have an optional new field appended: the
input format is to simply add ' (optionname)' in the data
specification.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-13 11:10:32 -08:00
Christian Decker
d67a28227c tools: Update formatting of python tools 2017-07-11 12:11:12 +02:00
Janus
22544d7789 Script for extracting structured protocol messages
This changes extract-formats.py so that other scripts can use it, but retains normal functionality.
The new script (structured.py) parses the CSV variant and shows a representation of an OrderedMap.
This could be used to write parsers.
2017-07-11 12:11:12 +02:00
Christian Decker
a11d234e18 tools: Disable alignment check when we have a variable length field
If we have a variable length field we should not check the alignment
of the following fields, the check will be off anyway.
2017-07-11 11:09:03 +02:00
Rusty Russell
8ee57b9773 tools: update for new format.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-11 11:20:36 +09:30
Rusty Russell
ed107e4ef0 tools/extract-formats.py: allow fields with _ in them.
eg. BOLT 4.

See also: #141

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-31 14:14:29 +10:30
Rusty Russell
347ce303ce tools/extract-formats.py: accept fields from BOLT 4.
Some have no data, and many use constant names and | in their type numbers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-28 14:10:04 +01:00
Rusty Russell
85ac709641 tools/extract-formats.py: neaten a little.
If we hand an arg, we should use it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-28 14:10:04 +01:00
Rusty Russell
b228a2e77d BOLT 2: remove attempts to align signatures.
They're really a blob of bytes, and we weren't aligning them correctly in
two cases anyway.  This gets rid of gratuitous padding, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-29 12:58:13 +10:30
Rusty Russell
fab307b57d tools/extract-formats.py: extract message definitions and check alignment.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 11:54:14 +10:30