Commit Graph

6859 Commits

Author SHA1 Message Date
Rusty Russell 6dca80a375 checkchannels tool.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-29 22:01:50 +02:00
darosior 2c43606895 doc: update mrkd version
The new tag includes @cdecker's modifications for better list handling
2019-09-29 14:06:40 +02:00
darosior a4204226b4 Tidy up parse_wireaddr_from_hostname 2019-09-28 02:49:24 +00:00
Saibato 32a1b782f3 Add lines in regard to enable-autotor-v2-mode flag to doc files
Signed-off-by: Saibato <saibato.naga@pm.me>
2019-09-28 00:31:02 +02:00
Saibato 0f9ba53581 Add enable-autotor-v2 config variable
With enable-autotor-v2 defined in cmdline the default behavior to create
v3 onions with the tor service call, is set to v2 onions.

Signed-off-by: Saibato <saibato.naga@pm.me>
2019-09-28 00:31:02 +02:00
Saibato e638224092 Change default behavior of autotor onions to Version 3 onions. 2019-09-28 00:31:02 +02:00
Rusty Russell 4bf0bc1f28 gossipd: age txout_failures map.
We do this by keeping a current and an old map, and moving the current to old
every hour or 10,000 entries.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-27 02:32:53 +00:00
Rusty Russell 1450a13c1f gossipd: don't expose scids of unannounced channels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-27 02:32:53 +00:00
Rusty Russell 722b4942ed common: rename decode_short_channel_ids.{c,h} to decode_array.{c.h}
This encoding scheme is no longer just used for short_channel_ids, so make
the names more generic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-27 02:32:53 +00:00
Rusty Russell aa9024db51 gossipd: fix memleak false-positive
2019-09-26T02:00:47.832Z DEBUG lightning_hsmd(89822): Client: Received message 33 from client'
2019-09-26T02:00:47.837Z **BROKEN** lightning_gossipd(89828): MEMLEAK: 0x55eddc5d1fd8
2019-09-26T02:00:47.838Z **BROKEN** lightning_gossipd(89828):   label=gossipd/routing.c:1579:struct unupdated_channel
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):   backtrace:
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     ccan/ccan/tal/tal.c:437 (tal_alloc_)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     gossipd/routing.c:1579 (routing_add_channel_announcement)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     gossipd/routing.c:1867 (handle_pending_cannouncement)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     gossipd/gossipd.c:1543 (handle_txout_reply)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     gossipd/gossipd.c:1726 (recv_req)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     common/daemon_conn.c:31 (handle_read)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     ccan/ccan/io/io.c:59 (next_plan)
2019-09-26T02:00:47.838Z DEBUG lightning_gossipd(89828):     ccan/ccan/io/io.c:407 (do_plan)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-27 00:01:34 +00:00
Rusty Russell d24c850899 gossipd: restore a flag for fast pruning
I was seeing some accidental pruning under load / Travis, and in
particular we stopped accepting channel_updates because they were 103
seconds old.  But making it too long makes the prune test untenable,
so restore a separate flag that this test can use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-27 00:01:34 +00:00
Jorge Timón 152f9b66b9 pylightning: Responses may not be iterable 2019-09-26 11:37:53 +02:00
Christian Decker 48728d3828 docker: Use system libraries, don't bring your own
We were compiling them from source, but then not adding them in the final
docker image. This just drops the source based ones in favor of system
provided ones.

Fixes #3074
2019-09-25 22:49:41 +00:00
Christian Decker 07e6f43e1d master: Set our own rlimit for number of fds
We should never open more than 1024 file descriptors anyway, and under some
situations, namely running as root or in docker, would give us huge
allowances. This then results in a huge, unneeded, cleanup for subprocesses,
which we use a lot.

Fixes #2977
2019-09-25 22:49:41 +00:00
lambrosini 6999a4ce2d Remove the python-dev dependency which is useless in python3 2019-09-25 20:37:50 +02:00
lambrosini eb28268bd7 Install in the OS dependencies required to successfully install the python requirements 2019-09-25 20:37:50 +02:00
lambrosini 08573fbc4b Clone the repository before than installing requirements, which are specified in the repository 2019-09-25 20:37:50 +02:00
trueptolemy 12da10cd15 sendpay: Compatible with old parameters `description` 2019-09-25 12:29:53 +02:00
trueptolemy 2d184d464f pylightning: Fix the parameter `label` of `sendpay`
`description` is renamed as `label` in 0.7.0
2019-09-25 12:29:53 +02:00
Rusty Russell 4e8141aa36 features: remove INITIAL_ROUTING_SYNC.
It only had an effect if the peer didn't support option_gossip_queries, but
still, we don't want a gossip blast any more.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 2b47922ea5 gossipd: move query functions into their own file.
The only real change is dump_gossip() used to call
maybe_create_next_scid_reply(), but now I've simply renamed
that to maybe_send_query_responses() and we call it directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 38124ec287 gossipd: don't ask peers for gossip until we're synced with bitcoind.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell a071a754b3 gossipd: place limit on pending announcements.
Now we queue them, we should place a limit.  It's not the worst thing in
the world if we discard them (we'll catch up eventually), but we should
try not to in case we're just a bit behind.

Our behaviour here is also O(n^2) so we don't want a massive queue
anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell fd2d74aa9b gossipd: defer asking about txouts until we're synced or they're 6 deep.
The first one means we don't discard channels just because we're not
synced, and the second is implied by the spec: don't accept
channel_announcement if the channel isn't 6 deep.  Since LND defers in
such cases, we do too (unless it's newer than the current block, in
which case we simply discard).  Otherwise there's a risk that a slow
node might discard valid gossip.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 45381bba33 bitcoin: implement is_scid_depth_announceable helper.
The math is a bit tricky, so encapsulate it.

Includes the extra 'e' in 'announcable' as noted by @cdecker :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 2a74d53841 Move gossip_constants.h into common/
Turns out we weren't checking the BOLT comments before, so they
needed an overhaul.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 6f9c5f2936 gossipd: get fed the blockheight from lightningd when we know it.
This will let gossipd be more intelligent about gossiping before we're
synced, and also it might know how far behind we are.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 6955bf6b86 lightningd: initialize topology synclist earlier.
We were doing it in setup_topology, but that's too late if gossipd
wants to register earlier.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Rusty Russell 3c9ca5d3e1 openingd: ensure that revents fields are initialized.
Valgrind error file: valgrind-errors.112365
==112365== Conditional jump or move depends on uninitialised value(s)
==112365==    at 0x1105E0: main (openingd.c:1504)
==112365== 
==112365== Conditional jump or move depends on uninitialised value(s)
==112365==    at 0x110604: main (openingd.c:1507)
==112365== 
==112365== Conditional jump or move depends on uninitialised value(s)
==112365==    at 0x110628: main (openingd.c:1510)
==112365==

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
Saibato e74dfa7fa1 Show in info log the name of the hidden onion service
Signed-off-by: Saibato <saibato.naga@pm.me>
2019-09-25 04:26:15 +08:00
trueptolemy 765416f0ca cleanup: Use `json_out_add_u32` helper to add `max_hops` and `cltv` in `pay` plugin 2019-09-24 16:01:24 +02:00
trueptolemy d8dce6e61f cleanup: Use `u32` as the type of `max_hops` in `gossipd` 2019-09-24 16:01:24 +02:00
trueptolemy 8103e48f8c fix: remove extra semicolon in `json_prepare_tx` 2019-09-24 11:44:13 +08:00
Rusty Russell 14b55d03d5 db: use correct backend for retrieving text fields.
Otherwise we don't have a nul terminator:

ep 22 02:25:42 lntxbot lightningd[804]: 2019/09/22 02:25:42 plugin-jqmethods Initialized jqmethods plugin.
Sep 22 02:30:01 lntxbot lightningd[804]: lightningd: FATAL SIGNAL 11 (version v0.7.2.1-255-g7686068)
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a0c6be send_backtrace
Sep 22 02:30:01 lntxbot lightningd[804]:         common/daemon.c:40
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a0c751 crashdump
Sep 22 02:30:01 lntxbot lightningd[804]:         common/daemon.c:53
Sep 22 02:30:01 lntxbot lightningd[804]: 0x7f1654d30f1f ???                                                                                                                                                                            Sep 22 02:30:01 lntxbot lightningd[804]:         ???:0
Sep 22 02:30:01 lntxbot lightningd[804]: 0x7f1654dad578 ???
Sep 22 02:30:01 lntxbot lightningd[804]:         ???:0
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a48b70 memcpy
Sep 22 02:30:01 lntxbot lightningd[804]:         /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a48b70 tal_dup_
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/tal/tal.c:796
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a46e81 tal_strdup_
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/tal/str/str.c:18
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a2e680 wallet_stmt2payment
Sep 22 02:30:01 lntxbot lightningd[804]:         wallet/wallet.c:2167
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a32711 wallet_payment_list
Sep 22 02:30:01 lntxbot lightningd[804]:         wallet/wallet.c:2446
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039fb0d2 json_listsendpays
Sep 22 02:30:01 lntxbot lightningd[804]:         lightningd/pay.c:989
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039f0d6f parse_request
Sep 22 02:30:01 lntxbot lightningd[804]:         lightningd/jsonrpc.c:650
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039f1039 read_json
Sep 22 02:30:01 lntxbot lightningd[804]:         lightningd/jsonrpc.c:748
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a3ddee next_plan
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/io/io.c:59
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a3e2dd do_plan
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/io/io.c:407
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a3e30a io_ready
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/io/io.c:417
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b03a3fae2 io_loop
Sep 22 02:30:01 lntxbot lightningd[804]:         ccan/ccan/io/poll.c:445
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039ee96c io_loop_with_timers
Sep 22 02:30:01 lntxbot lightningd[804]:         lightningd/io_loop_with_timers.c:24
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039f2796 main
Sep 22 02:30:01 lntxbot lightningd[804]:         lightningd/lightningd.c:835
Sep 22 02:30:01 lntxbot lightningd[804]: 0x7f1654d13b96 ???
Sep 22 02:30:01 lntxbot lightningd[804]:         ???:0
Sep 22 02:30:01 lntxbot lightningd[804]: 0x561b039e1919 ???
Sep 22 02:30:01 lntxbot lightningd[804]:         ???:0
Sep 22 02:30:01 lntxbot lightningd[804]: 0xffffffffffffffff ???
Sep 22 02:30:01 lntxbot lightningd[804]:         ???:0

Reported-by: @fiatjaf
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-23 02:05:53 +00:00
Rusty Russell b55ff34f93 gossipd: fix corner case where gossip msg too old after pending delay.
Happened under Travis with --dev-fast-gossip (90 second prune time), but can
happen anyway if gossip is almost 2 weeks old when we receive it:

2019-09-20T19:16:51.367Z DEBUG lightning_gossipd(20972): Received node_announcement for node 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59
2019-09-20T19:16:51.376Z DEBUG lightning_gossipd(20972): Ignoring node_announcement timestamp 1569006918 for 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59
2019-09-20T19:16:51.669Z **BROKEN** lightning_gossipd(20972): pending node_announcement 01013094af771d60f4de69bb39ce045e4edf4a06fe6c80078dfa4fab58ab5617d6ad4fa34b6d3437380db0a8293cea348bbc77f714ef71fcd8515bfc82336667441f00005d852546022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59022d2253494c454e544152544953542d633961313734610000000000000000000000000000 malformed? (version c9a174a)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-22 20:56:11 +02:00
Christian Decker 9915386c4a pytest: Stabilize test_no_fee_estimate against UTXO selection issues
The test was implicitly relying on us selecting the larger output and then not
touching the smaller, leaving it there for the final `withdraw` to claim. This
ordering of UTXOs is not guaranteed, and in particular can fail when switching
DB backends. To stabilize we just need to make sure to select the change
output as well.
2019-09-22 02:03:43 +00:00
Christian Decker 063b319da1 pytest: Have the DB provider search for the postgres binary
This replaces the hard-coded path to the `postgres` and `initdb` binaries with
a slightly more flexible search. It'll pick the newest version installed.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 136d4b2568 pytest: Consolidate fee-fetching in test_setchannelfee_usage
The short_channel_id is already in text format, no need to hexlify it :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker efc4aa94a3 pytest: Skip some tests that assume we have a sqlite3 db on postgres
These will not work since they touch the DB file itself.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker b89222f2d9 db: Adjust queries to work with postgres
The DB field type has to match the size of the accessor-type, and we had to
split the `REPLACE INTO` and `INSERT INTO OR IGNORE` queries into two
queries (update and insert if not updated) since there is no portable UPSERT
operation, but impact should be minimal.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker d901304120 db: Change table field types to be more specific
sqlite3 was forgiving, postgres isn't, so let's make sure we use the strictest
field type possible, relaxing when rewriting.

The commit consists just of the following mapping

 - INTEGER -> BIGSERIAL if it is the primary key
 - INTEGER -> BIGINT if it is an amount or a reference to a primary key

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 416af636f0 db: Check execution when accessing the result of a statement
This was already done in `db_step` but `db_count_changes` and
`db_last_insert_id` also rely on the statement being executed. Furthermore we
now check that the statement was executed before freeing it, so it can't
happen that we dispose of a statement we meant to execute but forgot.

The combination of these could be used to replace the pending_statement
tracking based on lists, since we now make sure to execute all statements and
we use the memleak checker to make sure we don't keep a statement in memory.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 1f935cbd85 db: Strengthen some null-checks on queries
sqlite3 will just report 0 for anything that it thinks should be numeric, or
is accessed using a numeric accessor. Postgres does not, so we need to check
for is_null before trying to read it.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 07f8d9046a db: Change migrations to use types of the correct cardinality
sqlite3 doesn't really do any validation whatsoever, and there is no
difference between 64bit and 32bit numbers. Posgtres on the other hand gets
very upset if the size doesn't match.

This commit swaps out handwavy types with the ones that should be there :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 2ddf168d59 db: Implement SQL statement rewriting
We now have an abstract rewriter that will perform some common extractions and
replacements (type replacement for example), that can then be customized in
derived classes.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 6b26ce5764 db: Split the vars table to have type-specific columns
This was weird right from the start, so we just split the table into integers
and blobs, so each column has a well-defined format. It is also required for
postgres not to cry about explicit casts in the `paramTypes` array.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker 074af11e43 db: Select driver by dsn prefix
We were doing exact matches before, but prefix is sufficient.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker ad89699888 db: Allow some internal queries to fail
The first ever query to check if the version DB exists may fail. We allow
this, but we need to restart the DB transaction since postgres fails the
current transaction and rolls back any changes.

This just commits (and fails) and starts a new transaction so the rest of the
migration can continue.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker acf72de5be db: Implement postgres driver primitives
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Christian Decker db6abda3a4 db: Adjust some db migrations to be compatible with postgres
Needed to change a couple of migrations. The changes are mostly innocuous:

 - changing BLOB to TEXT for short_channel_ids which is the correct type
   anyway, and sqlite3 treats them the same anyway.
 - Use `int` for version since the byte representation is checked by postgres.
 - Change anything that is INT, but will be bound to u64 to BIGINT (again
   postgres checks these more carefully than sqlite3).

Two migrations were replaced with dummy values, since they are buried deep
enough, and I found no portable way of expressing `strftime()` and `INSERT OR
IGNORE`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00