1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-24 22:58:23 +01:00
Commit graph

2268 commits

Author SHA1 Message Date
Barry G Becker
e8c9df4ec4
Add more GraphSpec tests (#2292) (#2293)
Add test for the wikipedia example of Yen's algorithm
2022-06-13 10:59:50 +02:00
llya Evdokimov
3e3f786000
Allow disabling bitcoind requests batching (#2301)
Eclair batches bitcoind request by default for efficiency.
However this can create latency and reliability issues when
running bitcoind on a remote machine over an unreliable
network. In those cases it's better to opt-out of batching.

We also make the threshold of missing blocks for blockchain
watchdog configurable instead of a hard-coded value of 6.
2022-06-13 08:35:19 +02:00
Bastien Teinturier
c4786f3a7b
Store disabled channel update when offline (#2307)
When a channel is offline and we want to relay an HTLC through it, we emit
a new `channel_update` with the disable bit set (unless it was already
disabled).

We previously didn't persist our internal state with this new
`channel_update`, which created the following issue: if eclair is restarted
before the channel comes back online, eclair would only try to rebroadcast
the previous `channel_update` which has a lower timestamp than the one
disabling the channel. That `channel_update` is then rejected by the
network, causing the channel to stay disabled until the next refresh,
which only happens after 10 days.
2022-06-08 16:33:59 +02:00
Thomas HUET
472275573c
Estimate balances of remote channels (#2272)
We use past payments attempts to estimate the balances of all channels. This can later be used in path-finding to improve the reliability of payments.
2022-06-08 13:37:19 +02:00
Bastien Teinturier
682e9bf6a7
Fix minimal node fixture flakyness (#2302)
There was a race condition between the `wait_for_funding_locked` state
and the `normal` state.
2022-06-08 13:33:55 +02:00
Pierre-Marie Padiou
340b568d53
(Minor) Test nits (#2306)
* use zero-args method to skip fixture

This is the proper way to skip building the fixture. Using `_` actually
creates a fixture and then ignores it.

* consistency nit

* use list/map instead for test cases

* add a custom reporter to highlight slowest tests
2022-06-08 13:03:33 +02:00
Thomas HUET
c5620b2d56
Log routing hint when finding a route (#2242)
When finding a payment route (typically for routing a trampoline payment) we already log the recipient node id, however it can be a private node hidden behind a routing hint in which case it is more useful to log the public node from the routing hint.
This is added to the `audit.path_finding_metrics` and we also add the `payment_hash` so that it can be joined with the `audit.relayed` and `audit.relayed_trampoline` tables.
2022-06-08 11:08:30 +02:00
Pierre-Marie Padiou
e08353b243
Remove close() in db interfaces (#2303)
* Remove close() in db interfaces

It shouldn't be the responsibility of individual db classes to close
the underlying db connection because they typically share the same db
instance (postgres) or db files (sqlite). Closing should be handled in
the `Databases` level (which is already the case for postgres.

For sqlite, closing was only useful for mobile apps, which now use
lightning-kmp.

Also removed `DbFeeProvider`, which was only used by mobile apps.

* increase github ci build time 20min->30min
2022-06-08 10:39:21 +02:00
Bastien Teinturier
ecbec93dfe
Add traits for permanent channel features (#2282)
We create new feature traits for permanent channel features, split between
features that are part of the channel type and features that are not.
2022-06-06 13:51:44 +02:00
rorp
47c5b95eaa
Drop support for Tor v2 hidden services (#2296)
Tor v2 addresses have been officially deprecated by the
Tor team and removed from the lightning specification in
https://github.com/lightning/bolts/pull/940
2022-06-06 10:03:44 +02:00
Pierre-Marie Padiou
9610fe30e3
Define a proper base class for fixture tests (#2286)
This PR does two main things:
- introduce a new `FixtureSpec` base class for tests that involve a fixture. See the scaladoc for more info. 
- add new simple integration tests in package `integration.basic`. They are based on `MinimalNodeFixture`, which is a full setup for a node with real actors, except the bitcoin part (watcher/wallet) which is mocked. They are much lighter than our previous integration tests, which allow us to keep each test individual, as opposed to having all tests of the same suite depend on each other. We can define more complex fixtures with any number of nodes.

Other minor improvements:
- update scalatest version
- simplify `ChannelStateTestsHelperMethods`
- replace all === by ==

Triple equals allows customizing the equality method, but we never use
that.

Detailed errors (which is what we were looking for) are provided by
mixing in scalatest's `Assertions` and using the regular `assert(x==y)`
syntax. The `Assertions` trait is already mixed in by default in all
scalatest suites.
2022-06-03 09:58:53 +02:00
Bastien Teinturier
ee46c56281
Remove dependency between dual funding and anchors (#2297)
This dependency didn't actually make sense, and we're removing it from
the spec as well.
2022-06-01 21:58:42 +02:00
Bastien Teinturier
088de6f666
Don't RBF anchor if commit is confirmed (#2283)
Even though we use our anchor to CPFP our commit tx, the commit tx could
confirm on its own. If that happens, we don't care about the anchor tx so
we shouldn't RBF it. Ideally we'd like to cancel it but that's impossible,
so we just wait for it to either confirm or drop out of mempools after a
while.
2022-06-01 19:21:28 +02:00
Bastien Teinturier
749d92ba39
Add option to disable sending remote addr in init (#2285)
When running behind a load balancer that doesn't preserve the client source
IP address, it doesn't make sense to include the `remote-address` tlv in
our `init` message, it will contain an IP address that is completely
unrelated to our peer.

Fixes #2256
2022-05-31 17:20:59 +02:00
Barry G Becker
45f19f6287
Fix test when run in Intellij (#2288) (#2289)
The path needed to be adjusted from "target" to "eclair-core/target".
Also fixed a typo in a comment.
2022-05-30 16:50:03 +02:00
Pierre-Marie Padiou
9c7ddcd874
Increase closed timeout from 10s to 1min (#2281)
This gives more time to rollback the funding tx in case where we moved
from `WAIT_FOR_FUNDING_INTERNAL`->`CLOSED`.

We could do it differently, with an additional step, or by only sending
the "shutdown" symbol after we receive the wallet response for this
specific transition, but it would be more complicated.
2022-05-24 10:09:25 +02:00
Pierre-Marie Padiou
44e71277a6
(Minor) Postgres: use write instead of writePretty (#2279)
There is no point in formatting the json since the `JSONB` data type
that we use in postgres do not preserve formatting.
2022-05-20 15:01:35 +02:00
Pierre-Marie Padiou
d98da6f44f
Index unannounced channels on channelId instead of shortChannelId in the router (#2269)
This is the final preparatory step before we can introduce channel aliases, which are arbitrary values of type `ShortChannelId`. We had to move to a stable identifier for private channels. Public channels can keep using the `shortChannelId`, it is stable because it is a "real scid" (and only used after 6 confs) and is useful as an index for channel queries.
2022-05-19 13:31:27 +02:00
Pierre-Marie Padiou
6fa02a0ec1
Use long id instead of short id in ChannelRelay (#2221)
This is a preparation for https://github.com/lightning/bolts/pull/910.

The relaying logic is now based on the `channelId` instead of
`shortChannelId`.

We used to consider `shortChannelId` as a unique identifier for the
channel, but it's not true anymore: there will be multiple aliases per
channel.
2022-05-19 10:55:47 +02:00
Bastien Teinturier
1e8791c56e
Update dual funding codecs (#2245)
* Use u16 instead of varint for lengths
* Revert channel flags extension
* Remove support for non-native segwit inputs
2022-05-19 10:40:03 +02:00
Bastien Teinturier
03097b0d42
Add localChannelReserve and remoteChannelReserve (#2237)
This is easier to use than having to decide which params we should look
into (local or remote). It will also be easier to integrate with dual funding.

Rename initialFeeratePerKw: this name was very confusing.
This feerate only applies to the commit tx, so we make that explicit.
2022-05-19 09:43:08 +02:00
Pierre-Marie Padiou
bb7703aa5d
Add simple integration test between Channel and Router (#2270)
In this PR we add a basic integration test between `Channel` and `Router` that checks the proper handling of local announcements.

* disable router rebroadcast in tests

* use separate ActorSystem for alice and bob in tests

* add a simple channel-router integration test

* fix bug found in new channel-router test

The new test was failing, due to a bug. When a local
channel graduates from private to public, we do not copy existing
known `channel_update`s. Current implementation guarantees that we
will process our local `channel_update` immediately, but what about our
peer?

* fix rebroadcast for local announcements

We fix a second bug where gossip origin wasn't properly set for local
announcements

* increase ram for tests to 2G

* improve debuggability of integration tests
2022-05-19 09:39:58 +02:00
Thomas HUET
81571b95e6
Fix flaky test PeerConnectionSpec (#2277)
In tests we can sleep for at least X seconds but because of other tests running in parallel, we can't get an upper bound on the sleeping time. This makes some tests that depend on time unfeasible.

Fixes #2175 #2276
2022-05-18 16:47:31 +02:00
Pierre-Marie Padiou
8e2fc7acd3
Run channel state tests sequentially (#2271)
From scalatest's `ParallelTestExecution` doc:

> ScalaTest's normal approach for running suites of tests in parallel is to run different suites in parallel, but the tests of any one suite sequentially.
> [...]
> To make it easier for users to write tests that run in parallel, this trait runs each test in its own instance of the class. Running each test in its own instance enables tests to use the same instance vars and mutable objects referenced from instance variables without needing to synchronize. Although ScalaTest provides functional approaches to factoring out common test code that can help avoid such issues, running each test in its own instance is an insurance policy that makes running tests in parallel easier and less error prone.

This means that for each single test of the `channel.states` package, we instantiate one actor system, which contains two thread pools. With default settings, that's a minimum of 2*8 threads per individual test.

That's already pretty bad, and with 65cf238 (#2270) we add a factor of 3 on top of that, which makes us go past the OS limits on github CI.

setup | peak thread count | run time
-------|---------------------|----
baseline | 5447 | 5m 44s
sequential | 1927 | 5m 9s (*)

(*) It's actually so bad, that tests run actually faster without parallelization!
2022-05-17 10:03:49 +02:00
Bastien Teinturier
10eb9e932f
Improve wallet double-spend detection (#2258)
Our mechanism to detect double-spending wasn't correctly taking into
account unconfirmed inputs. This was only used in single-funder scenarios
so it could only be an issue in rare edge cases, where it would not lead
to any loss of funds as we keep commit tx data in our DB even for closed
channels.
2022-05-16 14:56:05 +02:00
Bastien Teinturier
b691e876c5
Fix flaky replaceable tx publisher tests (#2262)
There was a race condition when testing fee-bumping: we could emit the new
block event before the underlying actor registered to this event type.

This is fixed by emitting the `TransactionPublished` event after registering
to the new block events, and waiting for that in tests before publishing a
new block event.
2022-05-13 15:57:11 +02:00
Pierre-Marie Padiou
95213bcb1f
Remove unused LocalChannel class in the router (#2265)
Also rename `ChannelDetails` to `KnownChannel`, and some cleanup in tests.
2022-05-13 14:39:57 +02:00
Pierre-Marie Padiou
1605c0435d
Introduce ChannelRelayParams in the graph (#2264)
We have two sources for channel routing parameters:
- channel updates
- routing hints in invoices

Instead of generating fake `channel_update`s from routing hints, we
define a `ChannelRelayParams` that can be built from announcements
or routing hints.

This is cleaner but also is a first step to decorrelate the identifier
of a channel in our graph, from whatever identifies the source.
2022-05-12 17:37:09 +02:00
Bastien Teinturier
ee74f10a8d
Stop compressing with zlib (#2244)
While zlib provides good compression results for gossip, it's a dependency
that had a few important CVEs in the past. Some implementations are
reluctant to import it, so we decided to remove it from the specification
in https://github.com/lightning/bolts/pull/981

We stop compressing with zlib and only send uncompressed results, while
still supporting receiving compressed data. We will remove support for
decompression once our monitoring indicates that we stopped receiving
compressed data.

We also reduce the maximum allowed chunk size.
The previous calculation was wrong and could lead to messages bigger than 65kB.
2022-05-11 14:02:21 +02:00
Thomas HUET
74ef08294a
Use log probability in path-finding (#2257)
Dijkstra's algorithm assumes that each edge has a fixed weight that does not depend on the rest of the path. In our case this assumption is broken when computing a cost for failed payments as it depends on all the edges of the path. We fix this by adding the possibility to use log probabilities which can be added per edge and offer a good approximation as long as the probabilities stay close to 1.

Edges still don't have a perfectly fixed weight because the fee of an edge depends on the fees of the previous edges, however since fees are typically low, it shouldn't matter in practice.
2022-05-10 10:51:54 +02:00
Bastien Teinturier
69589706d3
Fix flaky MempoolTxMonitor test (#2249)
Using the same test probe to generate new blocks and watch the mempool can
lead to rare race conditions.
2022-05-03 10:48:50 +02:00
Pierre-Marie Padiou
56c9e0670e
Only define decode method in legacy codecs (#2241)
Follow up to #2038.
2022-04-28 12:05:29 +02:00
Pierre-Marie Padiou
f0994099e9
Disable invoice purger in tests (#2240)
It was creating a race condition in the test
`MultiPartHandlerSpec`.`PaymentHandler should reject incoming
multi-part payment with an invalid expiry` due the 0-expiry
invoice being immediately purged.
2022-04-25 10:47:01 +02:00
Thomas HUET
a4ddbc33ea
Give best capacity score to local channels (#2239)
In path-finding, we give a better score to channels with higher capacity because they have a higher change to have enough balance to relay the payment. But for local channels we know the balance so we can be sure that the payment can be relayed.
2022-04-25 10:19:26 +02:00
Bastien Teinturier
443266d2b8
Add dual funding codecs and feature bit (#2231)
Add dual funding feature bit, but keep it disabled for now.
Add dual funding protocol messages and codecs.
We don't actually handle these messages yet.
When we receive them, they will simply be ignored and log a warning.
2022-04-14 17:57:38 +02:00
Bastien Teinturier
9a31dfabea
Rename channel funder to initiator (#2236)
With dual funding, both peers may be funders, but only one of them is the
initiator. This is just a dumb renaming, there is not logic change.
2022-04-14 11:23:42 +02:00
Thomas HUET
86145a7470
Remove unused PerHopPayloadFormat traits (#2235) 2022-04-13 15:46:28 +02:00
Thomas HUET
c7c515a0ed
Add Bolt12 types and codecs (#2145)
Add types for representing offers and Bolt12 invoices (lightning/bolts#798)
2022-04-13 11:26:03 +02:00
Fabrice Drouin
787c51acc2
Add a "stop" API method (#2233)
* Add a "stop" API method

This API call was added for certain uses cases where killing the process was impractical but internally it just calls `sys.exit()`.
Eclair is designed to shutdown cleanly when its process is killed and this is still the recommended way of stopping it.
2022-04-13 09:48:12 +02:00
Bastien Teinturier
7cf2e209ec
Remove Phoenix workaround for PaymentSecret dependency (#2230)
When Phoenix was based on a branch of eclair, we needed a workaround for
invoice backwards-compatibility. Now that Phoenix uses lightning-kmp
instead of eclair, we can remove that work-around.
2022-04-11 11:43:22 +02:00
Fabrice Drouin
ddb52d82ea
Check that channel seed has not been modified (#2226)
* Check that channel seed has not been modified

On startup, we check that for each of our channels the public key derived from the channel seed matches the key that was
used when the channel was funded.

* Rename DBCompatChecker to DBChecker and move channel seed check there
2022-04-07 17:43:19 +02:00
Bastien Teinturier
446a780989
Refactor channel transitions (#2228)
* Rename HasCommitments
* Introduce a TransientChannelData trait, which lets us have complete pattern
  matching on channel data
* Remove channel data from the ChannelErrorOccured event
* A few fixes in Channel.scala
* Refactor channel transition handlers
2022-04-07 16:15:34 +02:00
Bastien Teinturier
36ed788d39
Update experimental trampoline feature bit (#2219)
The `option_scid_alias` feature (https://github.com/lightning/bolts/pull/910)
is going to clash with the feature bit we use for trampoline payments.

Fortunately we've never advertized it, so we can simply update it to a much
higher value for now (until the final version of trampoline is specified).
2022-04-07 11:02:59 +02:00
Fabrice Drouin
7883bf621d
Use bitcoin-kmp through bitcoin-lib (#2038)
We use a version of bitcoin-lib that uses bitcon-kmp under the hood.
Its API is the same as before, but its package is now fr.acinq.bitcoin.scalacompat
2022-04-05 17:04:33 +02:00
Thomas HUET
162768274e
Remove ipv6 zone identifier test (#2220)
The eth0 interface does not exist on some machines which causes the tests to fail.
2022-03-31 14:19:05 +02:00
Richard Myers
6f31ed2dc9
Add release notes for new min-funding settings and invoice purger (#2210) 2022-03-29 12:12:13 +02:00
Richard Myers
9358e5e1f5
Add channelbalances API call (#2196)
The `channelbalances` API call retrieves information about the balances of all local channels, not just those with usable outgoing balances that are enabled for sending.

This change also adds the `isEnabled` attribute to the json results for both the new `channelbalances` and old `usablebalances` API calls.
2022-03-29 11:10:42 +02:00
Bastien Teinturier
2872d876d0
Fix latest bitcoin build (#2218)
Update build dependencies to match bitcoind master.
2022-03-29 10:42:14 +02:00
Bastien Teinturier
d135224805
Refactor channel into separate traits (#2217)
Refactor the channel state machine into several separate traits.
This lets us split its logic into multiple files while keeping a single actor.

It also lets us isolate some parts of the state machines as if they were
small state machines: we apply this to the channel opening flow which
will let us add a new flow for dual funding.

This can also be applied to the closing mechanism in the future.
2022-03-28 17:00:10 +02:00
Thomas HUET
0e88440e6a
Make trampoline pay the right fee (#2206)
When using multipart payments, the path-finding request sent to the router does not match the actual payment, it is only a request to route a fraction of the amount but the fee budget is still the one for the full payment. As a consequence the router will return routes that will not satisfy the fee budget.
The fee budget is checked one last time before relaying the payment but ignoring the fee of the first channel (which should not be ignored for trampoline relays). I fix this last check.
2022-03-28 10:25:04 +02:00