Commit Graph

3458 Commits

Author SHA1 Message Date
Rusty Russell 9b900138d0 gossip: put 'routing_channel' in charge of 'node_connection'.
This makes 'routing_channel' the primary object in the system; it can have
one or two 'node_connection's attached, and points to two nodes.

The nodes are freed when no more routing_channel refer to them.  The
routing_channel are freed when they contain no more 'node_connection'.
This fixes #1072 which I surmise was caused by a dangling
routing_channel after pruning.

Each node contains a single array of 'routing_channel's, not one for
each direction.  The 'routing_channel' itself orders nodes in key
order (conveniently the index is equal to the direction flag we use),
and 'node_connection' with source in the same order.

There are helpers to assist with common questions like "which
'node_connection' leads out of this node?".

There are now two ways to find a channel:
1. Direct scid lookup via rstate->channels map.
2. Node key lookup, followed by channel traversal.

Several FIXMEs are inserted for where we can now do things more optimally.

Fixes: #1072
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
Rusty Russell f8426600a6 gossipd: don't create a routing_channel while we're waiting.
We're going to make it a first-class citizen, and pending routing_channel
are not real ones (in particular, we don't want to create pending nodes).

We had a linked list called rstate->pending_cannouncement which we didn't
actually use, so put that back for now and add a FIXME to use a faster
data structure.

We need to check that list now in handle_channel_update, but we never
have a real routing_channel and a pending, unless the routing_channel
isn't public.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
Rusty Russell 2ec38ec687 gossip: factor out appending code in getchannels_req().
This moveonly makes a coming cleanup easier.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
Rusty Russell 629c3db421 ccan: update to get tal_free fix.
This allows us to make heirarchy loops, such as reference counting to
free our own parent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
ZmnSCPxj 1f6008689d payalgo: Throttle pay command if failure is due to blockheight disagreement. 2018-03-03 18:19:53 +01:00
Douglas Schilling Landgraf ef34efa93f pylightning: label is required for waitinvoice()
This patch make sure label don't have default value.
2018-03-03 18:12:26 +01:00
John Barboza 35ce13179c Add tests for peer information containing alias 2018-03-02 02:25:30 +00:00
John Barboza b50912d8b1 Print node alias when listing peers 2018-03-02 02:25:30 +00:00
Rusty Russell ca4603455b short_channel_id: remove short_channel_id_to_uint accessor.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 23:33:56 +01:00
Rusty Russell c5d41a23d7 short_channel_id: just use structeq.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 23:33:56 +01:00
Rusty Russell affc1be4d6 gossipd: get_channel() wrapper for channel lookup.
We rename the current routing.c get_channel to find_channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 23:33:56 +01:00
Rusty Russell 042d5d13f5 short_channel_id: don't use bitfields.
I leave all the now-unnecessary accessors in place to avoid churn, but
the use of bitfields has been more pain than help.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 23:33:56 +01:00
John Barboza 6f14736803 revert 0e40c8 and renable test_withdraw
I initially disabled this until 0.16 because the withdraw command
was modified to require 'brct1' addresses for regtest.
But commit bd07a9 allows a regular testnet address to work
just as well. So renable this check.
2018-03-01 23:32:58 +01:00
Igor Cota cb6820d445 Do preimage, hash and consequentially bolt11 generation before we store the invoice in db.
This way we store bolt11 to the table as well, in case a client needs it later
2018-03-01 03:55:48 +00:00
Igor Cota 3371168d54 Add bolt11 to the invoice struct.
We store this in case an RPC client asks for it
2018-03-01 03:55:48 +00:00
Igor Cota 2bb9797ddb Add bolt11 to the invoices db table as TEXT.
Saving in case an RPC client needs it later
2018-03-01 03:55:48 +00:00
Rusty Russell e10a2b63ca README.md: no need for segwit activation on regtest any more.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 03:52:21 +00:00
Rusty Russell 742885c95e test_lightning.py: reduce 121 to 101 blocks, remove segwit comment.
FWIW, the tests without valgrind take 662 seconds before we reduced
the number of blocks, and only 648 seconds now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 03:52:21 +00:00
Jan Sarenik 0017b9b363 test_lightningd.py: Enable bech32 test for DEVELOPER
Since bitcoind 0.16 is already released it is safe to enable
this test already.
2018-03-01 03:52:21 +00:00
Christian Decker 565059a12f pytest: Require bitcoin-0.16.0 and reduce number of generated blocks
0.16.0 is required since we rely on it for some tests and the block
reduction allows us to waste less time during setup. 121 blocks were
chosen so that we have at least one mature output to spend.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:52:21 +00:00
Christian Decker 136a5f2b74 contrib: Updated builder image to include v0.16.0 of bitcoind
Now that 0.16.0 is stable we should make use of it

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:52:21 +00:00
Christian Decker a90502d917 jsonrpc: Refuse to forget a channel with an open HTLC
... instead provide useful suggestions as to how to close it.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:50:50 +00:00
Christian Decker aef5780f36 htlc: Extracted htlc detection from the channel destructor
Let's have a simple function that allows us to check whether a channel
still has an HTLC open.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:50:50 +00:00
Jan Sarenik 9504a77b44 Reflow README.md with no changes to text
Can be tested by calling a following script

    #!/bin/sh
    FILE=${1:-"CONTRIBUTING.md"}
    CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD)

    {
    git checkout $CUR_BRANCH
    commonmarker $FILE | tidy > /tmp/aoeui.html
    git checkout master >/dev/null
    commonmarker $FILE | tidy | diff -u - /tmp/aoeui.html
    git checkout $CUR_BRANCH
    } 2>/dev/null

Formatted according to suggestion by @ZmnSCPxj described in
https://github.com/ElementsProject/lightning/pull/1137
2018-02-28 23:37:06 +01:00
Corné Plooy f32ebb7dca Indentation fix. 2018-02-28 21:21:25 +01:00
Corné Plooy 1e879de89e json-rpc: connection_complete_ok and json_command_malformed should never receive NULL arguments. Pass "null" instead, where needed. 2018-02-28 21:21:25 +01:00
Corné Plooy d86ad15b53 json-rpc: translate NULL into "null" instead of "(null)". 2018-02-28 21:21:25 +01:00
practicalswift ca487d5115 Add "make clean" check to Travis 2018-02-28 20:52:26 +01:00
Rusty Russell be5d945e97 gossip: only send out gossip to non-local peers when we're supposed to.
This hook is called when the queue is empty; we should only send gossip
according to the gossip timer.  We're currently dribbling it out after
every message, in violation of the spec.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell c8390ca403 gossipd: fix obsolete comments.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell a073c201e0 gossip: expose and use get_node() helper.
It's a trivial helper function from routing.c, but let's expose it
and use it in gossip.c too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell 5970890fae gossipd: use status levels for unusual reporting.
Now we have them, let's use them.  I missed one case deliberately, since
that causes merge conflicts when I replace it in a following patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell 04eb101aa6 routing: handle pending replies which are missing.
I'm not completely conviced that we can't end up removing pending things,
so change asserts to simple returns.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell 60e20b502e gossipd: simplify pruning code.
If we make destroy_node() remove itself from the map, then we simply
need to free it.

We can batch the frees (as we need) simply by reparenting all the pruned
nodes onto a single temporary parent, then freeing it, relying on tal's
internal datastructures.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell 792feb8532 gossip: Only do a single lookup in channel_update.
get_connection_by_scid() and update_to_pending() both do the same
lookup which we did in handle_channel_update().

Do the lookup once, and simplify the others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
Rusty Russell 76ff52b601 routing: remove unused txout_state field in struct routing_channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 12:48:45 +01:00
practicalswift dbb7ea1e41 Adjust log level for logging disconnected RPC users ("Command failed after jcon close")
This is a follow-up to #1121
2018-02-28 11:38:22 +01:00
ZmnSCPxj, ZmnSCPxj jxPCSmnZ 590a9a657d test_lightningd.py: Silence F841
Just do not assign to variable.
2018-02-28 11:17:08 +01:00
ZmnSCPxj efc5da9ad4 invoices: Use common code for loading r and rhash. 2018-02-28 11:17:08 +01:00
ZmnSCPxj 978e5c67d8 invoices: Remove persistent in-memory invoice structures. 2018-02-28 11:17:08 +01:00
ZmnSCPxj f05c86618c invoices: Change iteration interface to be more abstract. 2018-02-28 11:17:08 +01:00
ZmnSCPxj e9112af0bc invoices: Move expiration timer to invoices object.
In preparation for removing in-memory invoices objects.
2018-02-28 11:17:08 +01:00
ZmnSCPxj 6792acf04c test_lightningd: Add some more testing for waitinvoice. 2018-02-28 11:17:08 +01:00
ZmnSCPxj 7a6fe0704e invoices: Unify waitone/any waiters to invoices object.
In preparation for removing in-memory invoice objects.
Since they will be removed, there will no longer be any
individual invoice objects to attach to.
2018-02-28 11:17:08 +01:00
ZmnSCPxj 9b4c6699f9 invoices: Semantically separate invoice details from invoice.
In preparation for removing in-memory invoice structures.
Invoice details are requested rarely anyway.
2018-02-28 11:17:08 +01:00
Igor Cota fc3e6782dd Only make clean external submodules if Makefile present, fixes #1130 2018-02-28 10:02:07 +00:00
practicalswift a20cf5463d Adjust log level for logging disconnected RPC users ("Abandoning command" + "Command returned result after jcon close")
The following command can be used to trigger these messages:

```
$ timeout 0.01 cli/lightning-cli connect [insert-syntactically-valid-peer-id-here] 123.123.123.123 # where 123.123.123.123 is unreachable
```
2018-02-28 01:53:52 +00:00
Jan Sarenik 54b8562936 Fix libtool error
This is how the error before the fix looked like on Arch Linux with
GNU libtool 2.4.6.40-6ca5-dirty:

    $ make installcheck
    ...
    make[4]: Entering directory '/home/jasan/lightning/external/libwally-core/src/secp256k1'
     /usr/bin/mkdir -p 'testinstall/home/jasan/lightning/external/libwally-core/..'
     /bin/sh ./libtool   --mode=install /usr/bin/install -c   libsecp256k1.la 'testinstall/home/jasan/lightning/external/libwally-core/..'
    Usage: /home/jasan/lightning/external/libwally-core/src/secp256k1/libtool [OPTION]... [MODE-ARG]...
    Try 'libtool --help' for more information.
    libtool:   error: 'testinstall/home/jasan/lightning/external/libwally-core/..' must be an absolute directory name
    make[4]: *** [Makefile:910: install-libLTLIBRARIES] Error 1
    make[4]: Leaving directory '/home/jasan/lightning/external/libwally-core/src/secp256k1'
    make[3]: *** [Makefile:1253: install-exec-recursive] Error 1
    make[3]: Leaving directory '/home/jasan/lightning/external/libwally-core/src'
    make[2]: *** [Makefile:429: install-exec-recursive] Error 1
    make[2]: Leaving directory '/home/jasan/lightning/external/libwally-core'
    make[1]: *** [external/Makefile:41: external/libwallycore.a] Error 2
    rm external/libwally-core/src/secp256k1/libsecp256k1.la
    make[1]: Leaving directory '/home/jasan/lightning'
    make: *** [Makefile:430: installcheck] Error 2

Then there was linking error which needed to be fixed by correcting
the idea of installing external libraries to a particular directory.
2018-02-28 01:53:33 +00:00
Rusty Russell c7718aa2e4 test_lightningd.py: repair flaky test_bitcoin_failure
If bitcoind is still fetching blocks, we might accidentally inject
the failure between getblockhash and getblock.  That's OK, but
it's not the failure we test for.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 01:51:40 +00:00
Igor Cota a048a54f83 Add specific external libs to the makefile clean recipe. To avoid failed linking of cross compiled binaries left out after an incomplete make clean 2018-02-28 01:51:17 +00:00