Commit Graph

288 Commits

Author SHA1 Message Date
Christian Decker ef7a63d8f8 elements: Move from a global is_elements to a global chainparams
We now have a pointer to chainparams, that fails valgrind if we do anything
chain-specific before setting it.

Suggested-by: Rusty Russell <@rustyrussell>
2019-10-03 04:32:57 +00:00
Rusty Russell ccbc46a476 check-bolt: escape { and }.
These are special in extended regexs, and so we fail to match once we fix
the BOLT comment in common/test/run-bigsize.c

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-22 01:17:11 +00:00
trueptolemy 090a43fd3d gossip: Add the `struct exclude_entry` and `enum exclude_entry_type` 2019-09-16 12:22:06 +08:00
Rusty Russell 6a293fd135 tools/generate-wire.py: accept multiple comma-separated options.
Somehow this change got lost, but it's needed for option_static_remotekey,
to quote gen_peer_wire_csv:

    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,option_static_remotekey
    msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 51d7a1404f tools/check-bolt: don't get confused by 'BOLT #1' in middle of a comment.
Insist it be prefixed with '* '.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 17541e22a3 update-mocks: allow a function to specify that mock should not abort.
We're going to add memleak_add_helper_, and we want the mock to be a
noop, not an abort.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-06 14:35:01 +02:00
trueptolemy cdcafdaf74 API: `txprepare` now support mutiple outputs 2019-09-05 16:05:36 -05:00
Rusty Russell 11833192a1 tools: fix Makefile warning
Makefile:424: warning: overriding recipe for target 'clean'
    tools/Makefile:12: warning: ignoring old recipe for target 'clean'

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-28 04:04:28 +00:00
darosior 77f34fad2b doc/Makefile: adapt 'check-manpages' to markdown 2019-08-22 01:35:01 +00:00
Rusty Russell 9dfc854d94 tools/Makefile: put all tools/ stuff here.
Generally a Makefile should control make within that directory.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-21 05:07:15 +00:00
Rusty Russell 278b12982d tools/test/Makefile: disable unless we're in DEVELOPER mode.
Because it required update-mocks, which is a hack which relies on the
format of linker errors (!) I'd prefer to make this --enable-developer
only.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-21 05:07:15 +00:00
Rusty Russell c74c1e56cc tools/test/Makefile: fix always-on generation of tools/test/gen_test.c
We need to tell it that the tmp file is an intermediate, so doesn't need
remaking if it doesn't exist.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-21 05:07:15 +00:00
lisa neigut e99720344e wire-gen: ensure that tlv messages are correctly ordered
Our TLV serializer relies on TLV outputs to be ordered by type
number. Prior to this commit we relied on 1) the ordering in the
RFC to be correct and 2) users to be using a version of Python that
respects stable ordering of dicts (i.e. Python 3.7+)

Instead of relying on these implicitly, we now explicitly sort messages
by type number when the TLV sets.

Resolves #2956.

Thanks-To: @ScottTre for the sort function
Reported-By: @ZmnSCPxj
2019-08-21 03:53:54 +00:00
Rusty Russell 04a57ae4af doc/MAKING-RELEASES.md: update.
1. These days we delete the [Unreleased] tag during rcs.
2. Make sure we test the release build process during rc1, since I
   screwed that up last release.
3. Add a section on rc2, etc.
4. Do final release via a github PR, since I screwed that up on the
   prior release.
5. Update `tools/build-release.sh` and instructions to show that we now
   make a reproducible build for Ubuntu 18.04 x86-64.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-19 03:43:13 +00:00
Rusty Russell 303c221641 tools/test/Makefile: we depend on tools/test/gen_test.h
This is because update-mocks actually tries to build it to get link
errors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-19 03:43:13 +00:00
Rusty Russell c0ba5879df tools/test: can't generate mocks until submodules checked out.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-17 14:08:43 +09:30
Rusty Russell dbb15b0045 Makefile: fix occasional race where we fail to compile tools/tests.
This simplifies the dependencies:
1. Objs depend on headers, not other objs.
2. Programs depend on objs.
3. A .o file will generally implicitly depend on the .c file it's built from.
4. If a file has a build line, it's often better to list all deps there.
5. I spotted some missing 'make clean' files.

The particular problem in this case seems to be that make would use
tools/test/gen_test.c before it was ready.  It's probably confused by
the use of recursive make via update-mocks, so explicitly split that
into two stages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-17 04:20:05 +00:00
Rusty Russell 4b5cd5ff84 tools/generate-wire.py: only use 'struct node_id' in announcements.
Naturally, it's a struct pubkey.  However, those are large, and take
time to marshal, so gossipd treats them as node_id which is a simple
array.  It adds explicit checks at the right points to make sure
they're valid pubkeys.

However, the next commit adds TLV test vectors, which assumes we treat
node_id as a point (thus catch invalid values when parsing).  The best
solution is to restrain our types here to exactly those we've
optimized for.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-02 17:32:48 +02:00
Rusty Russell b10e0e08bb tools/generate-wire.py: add option to expose tlv_record_type
Next update adds TLV test vectors: without this, we get a warning
about them being unused.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-02 17:32:48 +02:00
Rusty Russell 4f937ea1f0 fixup! FreeBSD: fix build. 2019-07-29 14:24:29 +02:00
Rusty Russell 9e5b9a31c9 FreeBSD: fix build.
This makes it build for me on FreeBSD 11:
1. $(MAKE) has to passed through into update-mocks.
2. FreeBSD sed doesn't turn \n into a newline on RHS.
3. Bash and mako dependencies were missing from INSTALL.md

Fixes: #2850
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-29 14:24:29 +02:00
Rusty Russell 3c3a89c483 tools/generate-wire.py: add test for implicit lengths.
Suggested-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-27 21:19:57 -05:00
Rusty Russell 3f8600e9c0 tools/generate-wire.py: handle implicit tlv length fields.
TLVs have an implicit `len` field, so allow expressions containing
that (eg. `len-1`), but assume it means "the remainder of the
message".

This means in most places, f.size() needs an fallback for the
implicit-length case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-27 21:19:57 -05:00
Rusty Russell c580225c38 wire: handle bigsize/varint fields.
They're currently called varint, but there's a proposal to call them all
bigsize.  Allow both for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-27 21:19:57 -05:00
Rusty Russell 2e68b88be8 tools: fix tlv generation
We need to hand -s to both header and body generation, or neither:

wire/gen_peer_wire.c:53:13: error: static declaration of ‘towire_channel_update_timestamps’ follows non-static declaration
In file included from wire/gen_peer_wire.c:5:
./wire/gen_peer_wire.h:78:6: note: previous declaration of ‘towire_channel_update_timestamps’ was here

We also need it for printwire, otherwise we get static unused functions for subtypes:

devtools/gen_print_wire.c:155:13: error: ‘printwire_channel_update_checksums’ defined but not used [-Werror=unused-function]
 static void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor, size_t *plen)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
devtools/gen_print_wire.c:133:13: error: ‘printwire_channel_update_timestamps’ defined but not used [-Werror=unused-function]
 static void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-27 21:19:57 -05:00
lisa neigut 42251cc5b9 bolt-gen: fixup subtype nested varsize definition
variable length varsized subtypes were being allocated as
structs at not pointers; this fixes that.
2019-07-27 05:18:27 +00:00
Rusty Russell b1738c5b89 tools: fix 32 bit compile error
```
tools/test/enum.c: In function ‘fromwire_test_enum’:
tools/test/enum.c:11:34: error: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
  printf("fromwire_test_enum at %ld\n", *max);
```

and:

```
devtools/print_wire.c: In function ‘printwire_tlvs’:
devtools/print_wire.c:201:22: error: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘u64 {aka long long unsigned int}’ [-Werror=format=]
    printf("**TYPE #%ld UNKNOWN for TLV %s**\n", type, fieldname);
                      ^
```
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-25 11:41:48 +08:00
Rusty Russell c5ae29d2b1 check: only check EXPERIMENTAL-tagged BOLT quotes if EXPERIMENTAL_FEATURES
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-24 06:35:57 +00:00
lisa neigut 46cbca97ea bolt-gen: use 'enum' instead of 'e:' prefix for enums
use 'enum ' in wirespec instead of 'e:' as an indicator
that a field is an enum.
2019-07-24 06:31:46 +00:00
lisa neigut b6d4c372bb bolt-gen: fix broken 'exposed subtype' generation
borked in 96bf7aea; fixed here.
2019-07-24 06:31:46 +00:00
lisa neigut 068496298c bolt-gen: rm unused bolt-generator; rename new bolt generator
delete now unused wire-generator and replace it with the newer
version.
2019-07-24 06:31:46 +00:00
lisa neigut 32eaae0cb9 wire-gen: move in-house wire delcarations to new format
tidying things up!
2019-07-24 06:31:46 +00:00
lisa neigut 236d26308f bolt-gen: make optional 'assignable' fields work
make assignable 'optional' fields work, add test for them
2019-07-24 06:31:46 +00:00
lisa neigut ff82c918a5 bolt-gen: formatting cleanups
add brackets for clarity when printing subtypes; also remove
unnecessary exception (`find_` will raise an exception if
the key is not present)
2019-07-24 06:31:46 +00:00
lisa neigut 316edb39a4 bolt-gen: for wire messages, print out optional fields (if present)
optional fields should be printed, if they exist. so let's print them!
2019-07-24 06:31:46 +00:00
lisa neigut 40154b35f0 bolt-gen: make needs-context not recursive
originally done so that any field within a subtype needed context,
that would be reflected at the top-most layer. in reality, we
allocate subtype fields off of the instance of the subtype, so
there's no need to check beneath the 'top' layer of field/types
in a message to determine whether or not to pass in a context.
2019-07-24 06:31:46 +00:00
lisa neigut b30d7d26ea bolt-gen: handle enums
Add parsing know-how for enum fields. This is necessary for
internally defined wire generators. Enums are denoted by prefixing
the field with an `e:`.

Ex:

   msgdata,msg_name,field_name,e:enum_type,
2019-07-24 06:31:46 +00:00
lisa neigut cfd56d86ee bolt-gen: keep single instance of type_obj per type
we rely, perhaps a bit hackily, on there only being one copy of
each type object floating about. using `deepcopy` on a Message
for message extensions destroys this paradigm, which breaks
things in the case where it's a later defined subtype that contains
variable-length members.

to fix this, we modify `__deepcopy__` on the Field class, such
that it preserves the reference to the original type_obj instance.
2019-07-24 06:31:46 +00:00
lisa neigut 009e9dc945 bolt-gen: neaten up generated comments
remove extra space from the lead-in for inline comments

so that a provided comment like this

    # This is a comment

will appear like this

    /* This is a comment */
2019-07-24 06:31:46 +00:00
lisa neigut 7f5ba35e95 bolt-gen-tests: namespace test tlv's under test_
for posterity.
2019-07-24 02:52:53 +00:00
lisa neigut 281b4c241e bolt-gen: fixup the devtool/decodemsg printing facility
Fixup TLV handling in the bolt printing utility, `devtools/decodemsg`
2019-07-24 02:52:53 +00:00
lisa neigut cedebfd2d9 bolt-gen: add truncated uint support for TLV fields
TLV's have truncated values, add support for them. plus
some 'compilation' tests.
2019-07-24 02:52:53 +00:00
lisa neigut 4261e508a9 bolt-gen: add TLV support
Add in support for buiding TLV's (minus the printing capability)
2019-07-24 02:52:53 +00:00
lisa neigut 79f13fa429 bolt-gen: add compilation tests
Add a test for checking that the bolt-gens do the right thing
for a fairly exhaustive test case set (and that it compiles).

Note that this doesn't check that we've got the memory assignment
pieces worked out.

It's got a kind of exotic reliance on the update-mocks in that in
order to depend on as little of the wire/ code as possible (we
only import wire/wire.h), we include an AUTOGENERATE comment
in the test_cases CSV file, and then run update-mocks as part of
the build for that file.
2019-07-24 02:52:53 +00:00
lisa neigut 12125ec8dc bolt-gen: small cleanups
we were incorrectly printing the references for a subtype case, plus
some errant styling,readability changes
2019-07-24 02:52:53 +00:00
lisa neigut f2819ba7d8 bolt-gen: remove 'is-optional' qualifier from msg field
we now handle optional fields, so we should include them in
the message parsing signatures
2019-07-24 02:52:53 +00:00
lisa neigut 96bf7aead5 bolt-gen: handle variable-sized and optionals
actually do the right thing for variable-sized and optional field
types
2019-07-24 02:52:53 +00:00
lisa neigut 181e1916b2 bolt-gen: add field optional handling
we'll need this for internal wire message formats. also disambiguates
from 'bolt message optional fields', which we rename to extensions here.

example of an optional field declaration (note the ? prefixing the
type):

    msgdata,msg_name,field_name,?type,count

these are handled with either a boolean if they're not present,
or a true value and then the object if they are.
2019-07-24 02:52:53 +00:00
lisa neigut ade594e941 bolt-gen: add 'top-line' file comments to output
if there are any comments that aren't "attached" to a message,
print them at the top of the generated file. we need this for
the fancy auto-gen'd dependencies in the tool-wiregen tests.
2019-07-24 02:52:53 +00:00
lisa neigut fe3f4f52a0 bolt-gen: handle csv inline comments
The bolts don't have in-line comments, but the internal wire
message CSVs do. This adds the 'comments' back in to the
generated docs.
2019-07-24 02:52:53 +00:00
lisa neigut d7a68b75f1 bolt-gen: fixup broken subtype parsing 2019-07-24 02:52:53 +00:00
lisa neigut 1044e37fee bolt-gen: use ordered-dict for fields
Use ordered dict for fields, who's order matters when iterated
through (especially for argument lists).

Reported-By: @mocacinno
2019-07-24 00:43:47 +00:00
Rusty Russell 54790c17ea wire: rename var_int to bigsize, and insist on minimal.
The new TLV spec uses BigSize, like Bitcoin's CompactInt but
*little-endian*.  So change our name for clarity, and insist that
decoding be minimal as the spec requires.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-18 06:51:35 +00:00
lisa neigut 85e325cb1f bolt: update to lightning-rfc:6f6ea63233c new fundamental types
RFC tweaks to the types used to specify message fields
2019-07-16 06:10:58 +00:00
lisa neigut 6c240ab589 bolts: new parsing script and templates for new bolt format
the RFC's extract-format.py is switching to a new format.
this script can correctly parse them.

mostly moves logic over from generate-wire.py, uses a
Python formatting libarary called mako, which needs to be
installed prior to running this script.

you can add it to your system with

    sudo apt-get install python3-mako
2019-07-16 06:10:58 +00:00
lisa neigut 118caae45b tools: simplify check
in this case, we always need a pointer, so remove the check
and just add it to the template
2019-07-16 06:10:58 +00:00
Rusty Russell 38d2899fbb common/per_per_state: generalize lightningd/peer_comm Part 1
Encapsulating the peer state was a win for lightningd; not surprisingly,
it's even more of a win for the other daemons, especially as we want
to add a little gossip information.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-04 01:29:39 +00:00
Rusty Russell cb9c44ef27 gossipd: remove unnecessary dev_unknown_channel_satoshis arg.
We now have a test blockchain for MCP which has the correct channels,
so this is not needed.

Also fix a benchmark script bug where 'mv "$DIR"/log
"$DIR"/log.old.$$' would fail if you log didn't exist from a previous run.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-22 11:28:44 +00:00
Rusty Russell eda5314cb5 tools/generate-wire.py: handle optional variable-length fields.
We generated code which didn't compile (we never had one before though).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-20 20:31:07 -04:00
Rusty Russell 7ede5aac31 gossip_store: change format so we store raw messages.
Save some overhead, plus gets us ready for giving subdaemons direct
store access.  This is the first time we *upgrade* the gossip_store,
rather than just discarding.

The downside is that we need to add an extra message after each
channel_announcement, containing the channel capacity.

After:
  store_load_msec:28337-30288(28975+/-7.4e+02)
  vsz_kb:582304-582316(582306+/-4.8)
  store_rewrite_sec:11.240000-11.800000(11.55+/-0.21)
  listnodes_sec:1.800000-1.880000(1.84+/-0.028)
  listchannels_sec:22.690000-26.260000(23.878+/-1.3)
  routing_sec:2.280000-9.570000(6.842+/-2.8)
  peer_write_all_sec:48.160000-51.480000(49.608+/-1.1)

Differences:
  -vsz_kb:582320
  +vsz_kb:582316
  -listnodes_sec:2.100000-2.170000(2.118+/-0.026)
  +listnodes_sec:1.800000-1.880000(1.84+/-0.028)
  -peer_write_all_sec:51.600000-52.550000(52.188+/-0.34)
  +peer_write_all_sec:48.160000-51.480000(49.608+/-1.1)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-13 05:16:18 +00:00
GreenAddress fb07265663 remove libbase58, use base58 from libwally (#2594)
* remove libbase58, use base58 from libwally

This removes libbase58 and uses libwally instead.

It allocates and then frees some memory, we may want to
add a function in wally that doesn't or override
wally_operations to use tal.

Signed-off-by: Lawrence Nahum lawrence@greenaddress.it
2019-04-30 23:07:31 +02:00
Christian Decker 62e1423968 fixup! tools/bench-gossipd.sh: make it work (where possible) with DEVELOPER=0 2019-04-24 13:46:39 -05:00
Rusty Russell b248bb155a tools/bench-gossipd.sh: make it work (where possible) with DEVELOPER=0
Some tests require dev support, but the rest can run.  We simplify
the gossip_store output so it's the same in non-dev mode too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-24 13:46:39 -05:00
Rusty Russell 1ccfbef4e7 tools/bench-gossipd.sh: make sure we wait for gossipd to startup sync.
It can take a while if bitcoind has the regtest chain, and grossly
distorts our benchmarks!

Reported-by: Joe Netti <jnetti@blockstream.io>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-24 13:46:39 -05:00
Joe Netti 902bb22a92 devtools/create-gossipstore: cleanups
added sanity check to make sure scid of csv is the same as scid in gossip.
Revised style, mem allocation, and error checks

[ Minor fixups, and updated benchmark script -- RR ]

With data.tar.gz: 456609740 Apr  2 12:33

store_load_msec:35300-42354(37118.2+/-2.7e+03)
vsz_kb:582832
store_rewrite_sec:12.700000-13.430000(12.988+/-0.27)
listnodes_sec:3.000000-3.160000(3.076+/-0.057)
listchannels_sec:30.790000-31.690000(31.03+/-0.34)
routing_sec:0.00
peer_write_all_sec:63.640000-67.860000(66.294+/-1.4)
2019-04-24 13:46:39 -05:00
lisa neigut 8326f6a35c wire-gen: put tlv's after subtypes
in the output, we need tlv's to come after the subtype declarations
and structs so that a tlv can use a subtype without problems
2019-04-24 14:16:15 +02:00
lisa neigut 560f45cd7f wire generator: reverse subtype struct order
nested subtypes need to come first in the struct declaration. we
reverse the order that we read them off so that this requirement
is met
2019-04-24 14:16:15 +02:00
lisa neigut 0ce287d52e tlvs: include correct reference for nested objects 2019-04-24 14:16:15 +02:00
Rusty Russell 981fa68fe0 tools/bench-gossipd.sh: fix routing.
Channels have a htlc_minimum_msat of 10000, which is why we didn't
find routes.

This makes a significant speed drop:

-routing_sec:26.940000-27.990000(27.616+/-0.39)
+routing_sec:60.70

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-18 06:33:09 +00:00
lisa neigut f2ecf8e9c3 wire-gen: simplify if statement 2019-04-10 23:42:25 +00:00
lisa neigut 88786b8f7a wire gen: add subtypes to printwires
now we print the subtypes out when you call printwire

note that we have to reverse the order the subtypes appear in
because
  1) they're static and,
  2) a few of them are nested
2019-04-10 23:42:25 +00:00
lisa neigut 51438cef21 wire gen, tlv: fixup broken methodname when tlvs are around
including tlv's in the wire docs breaks the printwire because
there's a bad method name. this fixes that
2019-04-10 23:42:25 +00:00
lisa neigut 0443b464ad wire gen: add in correct printing for arrays of subtypes
subtypes don't use the fance type registration that other
'set structs' do, see devtools/printwire.c
2019-04-10 23:42:25 +00:00
lisa neigut 2e8768a279 wire-gen: rename 'is_tlv' to 'is_embedded' etc 2019-04-10 23:42:25 +00:00
lisa neigut e31111d70b subtypes: fixup context reference for subtypes
subtype children should be allocated off of themselves. this was
failing to compile for embedded subtypes (subtype within a subtype).
2019-04-10 23:42:25 +00:00
lisa neigut 97b938a469 gen: fixup unescaped \n in printwire declaration for tlvs 2019-04-10 23:42:25 +00:00
lisa neigut a385d1de4c subtype: update parser to understand non-'$' csv output
the original version of the subtype generator emitted '$'
to designate that a field was a subtype; now it's got a different
format:

	funding_type,8,num_inputs,2
	funding_type,10,input_info,num_inputs*input_info

this patch updates our generator to understand this new format
2019-04-10 23:42:25 +00:00
lisa neigut 803b161d7e subtypes: add flag to include subtype wire functions to header file
This is needed so that some csv's can expose their subtype parsing
functions in their header. This gets used in a later PR where
we start replacing manually created 'subtype' definitions with
generated ones.
2019-04-10 23:42:25 +00:00
lisa neigut e8a10b019d gen: move an error check to catch all instances of failure
`m` might not be set on the optional set as well, so move this check
down so that we now encompass both codepaths
2019-04-10 23:42:25 +00:00
lisa neigut 48078f7572 tlv: fixup deref for embedded structs on fromwire 2019-04-10 23:42:25 +00:00
lisa neigut 37d6545191 subtypes: add some parsing for subtypes, so that it passes
this probably could be consolidated, as it splits
out all the print_to/fromwire method stuff for the Subtype class
2019-04-10 23:42:25 +00:00
lisa neigut 94395c6a9a tlv: remove requirement of having tlv_name 2019-04-10 23:42:25 +00:00
lisa neigut de2fb7c9ef tlv: move tlv-specific message functions 2019-04-10 23:42:25 +00:00
lisa neigut 86a099a62f wire-gen: initial start on subtypes
first pass at adding subtype structs
2019-04-10 23:42:25 +00:00
lisa neigut e4658c241e tlv: break out TLVs into new subclass
make TLV messages their own subclass of Message. this makes
other clean ups easier
2019-04-10 23:42:25 +00:00
Rusty Russell dc6d53e787 lightningd: don't bother pretty-printing JSON.
This doesn't result in a speedup for our benchmark, since we use the
cli tool which does the formatting.

MCP results from 5 runs, min-max(mean +/- stddev):
	store_load_msec:33422-36830(35196.2+/-1.2e+03)
	vsz_kb:2637488
	store_rewrite_sec:36.030000-37.630000(36.794+/-0.52)
	listnodes_sec:0.720000-0.950000(0.86+/-0.077)
	listchannels_sec:40.300000-41.080000(40.668+/-0.29)
	routing_sec:30.440000-31.030000(30.69+/-0.2)
	peer_write_all_sec:50.060000-52.800000(51.416+/-0.91)

MCP notable changes from 2 patches ago (>1 stddev):
	-listchannels_sec:48.560000-55.680000(52.642+/-2.7)
	+listchannels_sec:40.300000-41.080000(40.668+/-0.29)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00
Rusty Russell 5009d628a3 lightning-cli: do pretty-printing.
Plugins don't do it right anyway, and we're about to remove it from
lightningd.  Produces same format as json_pp.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00
Rusty Russell 0b484b111e gossipd: make more compact getchannels entries.
We can save significant space by combining both sides: so much that we
can reduce the WIRE_LEN_LIMIT to something sane again.

MCP results from 5 runs, min-max(mean +/- stddev):
	store_load_msec:34467-36764(35517.8+/-7.7e+02)
	vsz_kb:2637488
	store_rewrite_sec:35.310000-36.580000(35.816+/-0.44)
	listnodes_sec:1.140000-2.780000(1.596+/-0.6)
	listchannels_sec:55.390000-58.110000(56.998+/-0.99)
	routing_sec:30.330000-30.920000(30.642+/-0.19)
	peer_write_all_sec:50.640000-53.360000(51.822+/-0.91)

MCP notable changes from previous patch (>1 stddev):
	-store_rewrite_sec:34.720000-35.130000(34.94+/-0.14)
	+store_rewrite_sec:35.310000-36.580000(35.816+/-0.44)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00
Rusty Russell 91849dddc4 wire: use struct node_id for node ids.
Don't turn them to/from pubkeys implicitly.  This means nodeids in the store
don't get converted, but bitcoin keys still do.

MCP results from 5 runs, min-max(mean +/- stddev):
	store_load_msec:33934-35251(34531.4+/-5e+02)
	vsz_kb:2637488
	store_rewrite_sec:34.720000-35.130000(34.94+/-0.14)
	listnodes_sec:1.020000-1.290000(1.146+/-0.086)
	listchannels_sec:51.110000-58.240000(54.826+/-2.5)
	routing_sec:30.000000-33.320000(30.726+/-1.3)
	peer_write_all_sec:50.370000-52.970000(51.646+/-1.1)

MCP notable changes from previous patch (>1 stddev):
	-store_load_msec:46184-47474(46673.4+/-4.5e+02)
	+store_load_msec:33934-35251(34531.4+/-5e+02)
	-vsz_kb:2638880
	+vsz_kb:2637488
	-store_rewrite_sec:46.750000-48.280000(47.512+/-0.51)
	+store_rewrite_sec:34.720000-35.130000(34.94+/-0.14)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00
Rusty Russell fbb494fba3 devtools/create-gossipstore: clean up enough to pass check-source.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 04:41:43 +00:00
Rusty Russell 891ee20a59 tools/bench-gossipd.sh: rough benchmark for gossipd and the million channels project
Outputs CSV.  We add some stats for load times in developer mode, so we can
easily read them out.

peer_read_all_sec doesn't work, since we seem to reject about half the
updates for having bad signatures.  It's also very slow...

routing fails, for unknown reasons, so that failure is ignored in routing_sec.

Results from 5 runs, min-max(mean +/- stddev):
	store_load_msec,vsz_kb,store_rewrite_sec,listnodes_sec,listchannels_sec,routing_sec,peer_write_all_sec
	39275-44779(40466.8+/-2.2e+03),2899248,41.010000-44.970000(41.972+/-1.5),2.280000-2.350000(2.304+/-0.025),49.770000-63.390000(59.178+/-5),33.310000-34.260000(33.62+/-0.35),42.100000-44.080000(43.082+/-0.67)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>



Header from folded patch 'fixup!_tools-bench-gossipd.sh__rough_benchmark_for_gossipd_and_the_million_channels_project-2.patch':

fixup! tools/bench-gossipd.sh: rough benchmark for gossipd and the million channels project

Suggested-by: @niftynei



Header from folded patch 'fixup!_tools-bench-gossipd.sh__rough_benchmark_for_gossipd_and_the_million_channels_project-1.patch':

fixup! tools/bench-gossipd.sh: rough benchmark for gossipd and the million channels project

MCP filename change.



Header from folded patch 'tools-bench-gossipd.sh__dont_print_csv_by_default.patch':

tools/bench-gossipd.sh: don't print CSV by default.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>



Header from folded patch 'fixup!_tools-bench-gossipd.sh__rough_benchmark_for_gossipd_and_the_million_channels_project.patch':

fixup! tools/bench-gossipd.sh: rough benchmark for gossipd and the million channels project

Make shellcheck happy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 04:41:43 +00:00
lisa neigut ed1223492b tlvs: add methods for decodemsg utility
fixup printing methods in devtools/decodemsg such that TLV's can
now be printed as well. here's how you'd use it:

   $ ./devtools/decodemsg --tlv opening_tlv 0120001E020202020202020202020202020202020202020202020202020202020202
   > WIRE_OPTION_UPFRONT_SHUTDOWN_SCRIPT (size 32):
   > shutdown_scriptpubkey=[020202020202020202020202020202020202020202020202020202020202]
2019-04-08 00:37:29 +00:00
lisa neigut bad0ac6ed6 tlv: use `var_int`s for size of messages
TLV's use var_int's for messages sizes, both internally and
in the top level (you should really stack a var_int inside a var_int!!)

this updates our automagick generator code to understand 'var_ints'
2019-04-03 03:15:42 +00:00
lisa neigut 1213f44071 tlv: adapt to work with new output format
Updated to match what the CSV generator in the RFC repo actually
outputs, see https://github.com/lightningnetwork/lightning-rfc/pull/597
2019-04-03 03:15:42 +00:00
lisa neigut df9774c2be tlv: fixup FIXME -- remove comments + use includes
include includes for TLV _csv files
2019-04-03 03:15:42 +00:00
lisa neigut 5d8b059ccc tlv: free intermediate messages when they're created
otherwise they'll get cleaned up when the message is free'd.
it's nbd either way, but this seems tighter.
2019-04-03 03:15:42 +00:00
lisa neigut 4afcc2e5a8 tlv: fixup parsing for multi-message tlv's
need to pass in a pointer to the array so that when we advance
the array in the subcalls, it advances in the parent. oops
2019-04-03 03:15:42 +00:00
lisa neigut d0f50c8690 tlv: fail if parsed length doesn't match packet length 2019-04-03 03:15:42 +00:00
lisa neigut 28c3f9ca21 tlv: don't crash when you fail to parse the TLV
passing back a null TLV was crashing here, because we tried to
dereference a null pointer. instead, we put it into a temporary
struct that we can check for NULL-ness, before assigning to the
passed in pointer.
2019-04-03 03:15:42 +00:00
lisa neigut d8738452ed tlv: it's ok to be odd
fail if a message type is even and it's not included. otherwise,
continue with the next message type.
2019-04-03 03:15:42 +00:00