1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 02:27:32 +01:00
Commit Graph

698 Commits

Author SHA1 Message Date
Bastien Teinturier
570fe57baa
Add friendly network name to GetInfo response (#1456)
This is friendlier to interpret than mapping this from the chain's genesis
block hash.
2020-06-19 16:07:08 +02:00
Pierre-Marie Padiou
59ea4cd606
Put back DATA_CLOSING constraints (#1462)
We go to the `CLOSING` if and only if the funding tx has been spent by
one transaction. The `require` is absolutely necessary. We could
probably enforce this constraint at the compilation level by more clever
typing but that's another matter.
2020-06-19 12:02:56 +02:00
Bastien Teinturier
50290d9481
Monitor on-chain feerate mismatch (#1453) 2020-06-18 08:59:49 +02:00
Bastien Teinturier
2461e3a32c
Fix channelstats API (#1451)
It should return stats for all channels (funder and fundee).
The previous code was incorrectly filtering on channels for which we paid
an on-chain fees, excluding the channels for which we were fundee.

Fixes #1449.
2020-06-09 12:22:53 +02:00
Bastien Teinturier
4cfb7d94ac
Fix edges with empty capacity in the routing graph (#1446)
Light clients don't always validate channels by fetching the blockchain tx.
That means they don't have access to the exact capacity.
When that happens, we can fallback to htlc_maximum_msat if
available, or to a default capacity (otherwise path-finding will ignore
these edges).
2020-06-05 17:00:47 +02:00
araspitzu
dc364a1996
Implement option_static_remotekey (#1141)
* Add feature option_static_remotekey

* Update transactions RFC test vectors for option_static_remotekey
2020-06-05 16:01:43 +02:00
Bastien Teinturier
c04a4cef2a
Accept multiple channels for some API (#1440)
It's handy to update relay fees for multiple channels at once.
Closing and force-closing channels may also make sense to do in batch.

Closes #1432
2020-06-03 11:06:45 +02:00
Bastien Teinturier
2e79ccaf3f
Correctly set new channel balance (#1431)
When we announce a new public channel, make sure we don't override the
balance information with None.

Clean up IntegrationSpec warnings.

Fix PaymentLifecycle test: this test was broken by the recent changes in
BaseRouterSpec.
2020-05-26 16:04:10 +02:00
Fabrice Drouin
e0320da383
Electrum: stop spamming logs (#1433)
* Electrum client: downgrade log-level for errors that happened before a proper handshake

We only care for errors that we received during or after the "handshake" (i.e. the exchange of "version" messages).
Other errors cause by dead/unresponsive servers... which are very common on testnet just add spams to the logs.

* Electrum client pool: downgrade log level for errors with our secondary servers

We care for errors with our master electrum servers.

* Update Electrum checkpoints
2020-05-26 11:48:44 +02:00
Bastien Teinturier
ce3629c98b
Compute max fee before route calculation (#1417)
Move the maximum fee computation outside of `findRoute`: this should be
done earlier in the payment pipeline if we want to allow accurate fee control
for MPP retries.

Right now MPP uses approximations when retrying which can lead to payments
that exceed the maximum configured fees. This is a first step towards
ensuring that this situation cannot happen anymore.
2020-05-20 10:55:44 +02:00
Bastien Teinturier
ad44ab3631
Path finding standard collections (#1428)
* Replace ArrayDeque by Queue

This is clearly not a hot path. This collection will have less than
10 elements and the bottleneck is rather on the dijkstra call.

ArrayDeque doesn't exist in Scala 2.11 so it makes the merge to
eclair-mobile more cumbersome.

* Use standard Scala collections in Dijkstra

Collections performance has improved greatly in Scala 2.13.
This change yields a consistent 10% improvement compared to the previous
implementation on my laptop based on the mainnet graph.
2020-05-20 10:51:32 +02:00
araspitzu
029cafe297
Use human readable features in configuration (#1385)
* Parse human readable features from configuration, print features in human readable format.
2020-05-19 13:58:19 +02:00
Pierre-Marie Padiou
c01031708d
Fix race condition on early connection failure (#1430)
Both `Client` and `TransportHandler` were watching the connection actor,
which resulted in undeterministic behavior during termination of
`PeerConnection`.

We now always return a message when a connection fails during
authentication.

Took the opportunity to add more typing (insert
deathtoallthestring.jpg).
2020-05-19 12:45:53 +02:00
Pierre-Marie Padiou
9faaf24934
Reduce log level of backup handler (#1429) 2020-05-18 17:20:20 +02:00
Pierre-Marie Padiou
24b43e9a49
Use actor system as conf container (#1420)
This seems to be recommended practice:
https://doc.akka.io/docs/akka/current/general/actor-systems.html#configuration-container.

As a nice side effect, it allows putting akka-related config in eclair.conf.

Also, reorganize reference.conf/application.conf.
2020-05-18 17:12:21 +02:00
Pierre-Marie Padiou
bfd25fa021
Atomically switch to new connection (#1419)
When a new connection happens while already connected, the `Peer` will
switch to the new connection.

In the current implementation, upon receiving a `ConnectionReady`, the
`Peer` will kill the current connection, then sends back the
`ConnectionReady` message to itself. In the meantime, the
`PeerConnection` will happily forward any incoming messages to the `Peer`.

This opens up to a race in the `Peer`'s mailbox between the
`ConnectionReady` message, and any incoming messages from the new
connection. If the latter win, they will get dropped because the `Peer`
is in state `DISCONNECTED`. Typically those are `ChannelReestablish`
messages and channels will get stuck in state `SYNCING`.

This PR make the `Peer` atomically switch to the new connection, without
going back to the `DISCONNECTED` state. As a result, we now have a
`CONNECTED`->`CONNECTED` transition.
2020-05-15 14:40:06 +02:00
Dominique
8629d201a7
Skip executing some plugins when skipping tests (#1418)
* Skip some plugins when skipping tests

* Add instruction in BUILD.md to install eclair-core to repo

* Reorganize BUILD.md with subsections
2020-05-13 15:19:48 +02:00
Bastien Teinturier
f22ec213dc
Feerate provider improvements (#1415)
* Use ConstantFeeProvider only on regtest
* Fail bootstrap if cannot retrieve feerates
2020-05-13 15:14:09 +02:00
Bastien Teinturier
c4d0604b72
Payment lifecycle refactor (#1414)
* Extract faulty channels selection from PaymentLifecycle

Move the logic of figuring out which channels/nodes should be ignored
when retrying after a payment failure out of the PaymentLifecycle.

We can figure this out looking only at the `PaymentFailure` generated,
and the multi-part logic could leverage these helpers.

* Refactor RouteResponse

It was useless to return `ignoreNodes` and `ignoreChannels`, it's rather
the responsibility of the caller (PaymentLifecycle) to store and update
these sets.

Preparing for the MPP move inside the router, we introduce a Route class
and let RouteResponse return a collection of Routes.

This creates some ugliness in PaymentLifecycle because of the `routePrefix`,
but this is just temporary: the `routePrefix` "hack" will be removed soon.
2020-05-12 11:41:25 +02:00
Bastien Teinturier
ba4cca29e5
Use channel balance in path-finding (#1395)
* Use channel capacity and balance in path-finding

The path finding algorithm uses channel capacity instead of htlcMaximumMsat.
It also takes into account channel balance when available and excludes
channels that don't have enough funds to relay the payment.

This change also fixes an off-by-one error in weight computation: we were
incorrectly applying a channel's fee to the amount that needs to be relayed
through that channel (whereas this is instead what the node needs to receive
to collect enough fee *before* relaying).

* Refactor Graph file

Add documentation, update comments, rename fields and reformat to (helpfully)
make the code clearer.

* Simplify path-fiding implementation

There were a couple confusing steps in the implementation of Yen's algorithm.

The first one was the computation of the `edgesToIgnore` and the specific
handling of the case i = 0. This specific case wasn't needed and made the
code a bit hard to read.

The second one was the weight provided to dijkstra for spur paths.
The weight of the root path was applied to the target node. It was probably
an attempt to take into account the fact that dijkstra wasn't computing
a complete path and that fees may not match, but it couldn't really work.
I removed that and added a fee check at the end of the path-finding.

* Update graph balance for duplicate channel_update

This case regularly happens after a restart: the router already has the
latest channel_update for that channel, but we want to update the graph's
balances because they are all at `None` after a restart.
2020-05-11 09:49:27 +02:00
Bastien Teinturier
3f127fbf06
Update kamon (#1411)
* Update Kamon libraries
* Ignore unused channel state changes post-restart
2020-05-06 15:58:08 +02:00
Fabrice Drouin
273a3f0966
Release 0.4 (#1409)
* Release 0.4

* Set version to 0.4.1-SNAPSHOT
2020-05-05 14:55:09 +02:00
Pierre-Marie Padiou
e38f706c46
Minor: catch harmless unhandled events (#1407)
* minor: catch harmless unhandled events

This prevents unnecessary warnings to clog up the logs.

* fix race condition in test

Changing the fake ip address from 1.2.3.4:42000 to localhost:42000
in 32f15c85eb made the dummy connection
fail much faster, creating a race in the test. Reverting to the previous
ip and increasing the timeout should improve things a bit.
2020-05-05 12:09:16 +02:00
Fabrice Drouin
874bd4bc26
Unlock transaction inputs if tx cannot be published (#1404)
* Unlock transaction inputs if tx cannot be published

In some cases, funding a tx will work but publishing may fail (because mempool fees are not met for example).
In that case we need to make sure that the tx inputs are unlocked.
2020-05-05 11:03:26 +02:00
Bastien Teinturier
c4d085a537
Validate channel_announcement sigs early (#1406)
We should validate the announcement signatures in the channel too.
We still validate them in the router, but it's a different layer and the
check should happen as soon as possible.
We don't want to keep the channel open if the peer is sending us garbage.
2020-05-05 10:51:01 +02:00
Pierre-Marie Padiou
32f15c85eb
Delegate client creation to a specialized actor (#1400)
This allows decoupling the reconnection task from the actual client
creation.

Also improved tests.

Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2020-04-30 18:10:55 +02:00
Pierre-Marie Padiou
a18d3a76a2
Platform.currentTime->System.currentTimeMillis (#1403)
This is a low hanging fruit, it is portable to android.
2020-04-30 16:52:14 +02:00
Bastien Teinturier
65e26c648b
Fix BitcoinCoreWalletSpec (#1401)
This test was randomly failing. There may be a rounding error or a bit of
randomness somewhere in Bitcoin Core 0.19.1, sometimes a feerate right
below the limit is accepted into the mempool.
2020-04-30 15:24:43 +02:00
Bastien Teinturier
c3a66f37a3
Disable backup handler in tests (#1399)
We've been witnessing random test suites freezes (since ages).
We've observed that when these freezes happen, there are usually a lot of
"too many open files" errors raised by the OS.

The backup handler is a likely culprit as the IntegrationSpec is running
multiple nodes and exchanging HTLCs at a fast rate.

At least it won't hurt disabling it in tests, and will speed up the
test suite.

We also increase the file limits in CI providers, when possible.
2020-04-30 11:56:44 +02:00
Pierre-Marie Padiou
0447bac58e
Remove unused attribute in Peer (#1397) 2020-04-27 18:27:51 +02:00
Bastien Teinturier
3809b023c0
Test preimage extraction from mempool (#1387)
Instead of waiting for htlc-success txs to be confirmed, eclair also looks
at mempool txs to detect preimages as soon as possible.

This has been the case for a very long time, but our integration tests
didn't showcase this correctly.

Refactored common watcher test helpers and added tests to
ZmqWatcherSpec.
2020-04-27 18:22:07 +02:00
araspitzu
22d476774d
Support bitcoin-0.19.1 (#1380)
* Support bitcoin-0.19.1

* Update supported versions of bitcoind in README
2020-04-27 16:10:45 +02:00
Pierre-Marie Padiou
19975d3d81
Update to scala 2.13 and akka 2.6 (incremental) (#1390)
This is almost a drop-in replacement. I had to relaxed compiler
parameters to allow deprecated features though.

Main changes:
- relaxed compiler parameters to minimize impact (e.g. allow
deprecated features)
- `scala.collection.JavaConverters` -> `scala.jdk.CollectionConverters`
- `MultiMap` -> `MultiDict`

Compilation is 25% faster on my machine, compiler is a bit more strict
(it found an "invalid comparison" bug).
2020-04-27 13:11:55 +02:00
Pierre-Marie Padiou
6aced1bf1c
Fix race condition in router tests (#1392)
Caused by the automated generation of node announcement following
c9f94eec6f.
2020-04-27 12:23:50 +02:00
Pierre-Marie Padiou
9c748e4d6f
Revert "Use sender instead of providing actor refs (#1379)" (#1391)
This reverts commit 86ee7eaabb.

It was error-prone (cf bff833b) and not a good practice according to @sstone.
2020-04-24 16:54:02 +02:00
Pierre-Marie Padiou
f4b56407b4
Prepare upgrade to scala 2.13 and akka 2.6 (#1389)
Do all the changes that will be required and are already possible to
minimize the diff:
- update dependencies
- `'something` -> `Symbol("something")`
- `BigDecimal.xValue()` -> `BigDecimal.xValue`
- `Map.filterKeys` -> `Map.filterKeys.toMap` (same for `Map.mapValues`)
- `def myMethod(...)` -> `def myMethod(...): Unit`
2020-04-24 15:31:25 +02:00
Bastien Teinturier
c9f94eec6f
Router channel balance (#1382)
Router uses channel events (LocalChannelUpdate and AvailableBalanceChanged)
to track the balance of local channels.

This information will be used in path-finding to improve path-finding,
especially in the MPP case.

The information is added to the graph structures, but it's not used yet in
path-finding. Some A/B testing will be needed before we can use those
safely for the path-finding algorithm.
2020-04-23 21:04:58 +02:00
Pierre-Marie Padiou
bff833b1b4
fixup! Use sender instead of providing actor refs (#1379) (#1386)
When switching to a new connection while already connected, peer
immediately kills the current connection and sends back the
`PeerConnection.ConnectionReady` to itself. Since #1379, the sender of
this message is assumed to be the `PeerConnection` actor. If peer
doesn't preserve the sender by using a `forward` instead of a `tell`, it
will assume that itself is the `PeerConnection`, which will break
everything.
2020-04-21 16:12:07 +02:00
Bastien Teinturier
e32d9ed99f
Refactor transaction generation errors (#1366)
Transaction generation functions used to throw exceptions.
We have a good TxGenerationSkipped type to express potential errors,
so these functions should return an Either to make the contract explicit.
2020-04-21 09:34:53 +02:00
Bastien Teinturier
ec7750211f
Send update_fee on reconnection (#1383)
We update transaction fees at every block (ie every 10 minutes). While this
works well when the remote peer is a node that's online for more than 10 minutes,
it's an issue for mobile wallets that usually come online for a few minutes
and then disconnect.

We want to make sure we send these wallet peers an update_fee when one
is needed, so we now check for feerate updates on reconnection.

Fixes #1381.
2020-04-20 16:23:05 +02:00
Pierre-Marie Padiou
86ee7eaabb
Use sender instead of providing actor refs (#1379)
In some messages, we provide a reference to the sending actor byt adding `self` in the message, but we could use `sender` instead.
2020-04-16 11:59:05 +02:00
Pierre-Marie Padiou
9103b99077
Add a rejection for update when channel is pruned (#1378)
In case a channel has been pruned, and we receive a recent update, we
"unprune" it and immediately request the channel announcement again
(which will cause us to revalidate it). We also discard the update,
assuming that we will receive it again with the channel announcement.

We were using a `GossipDecision.Duplicate` rejection for the channel
update, which is inaccurate. This PR introduces a new
`GossipDecision.RelatedChannelPruned`.
2020-04-15 17:05:43 +02:00
Bastien Teinturier
d56306728f
Gossip metrics (#1372)
Adding metrics for channel queries and gossip KPIs.
2020-04-15 17:00:38 +02:00
Bastien Teinturier
1483f3f88c
Revert Electrum Tor disabling SSL check (#1376)
This commit reverts #1278 where connecting to an Electrum server 
would disable the SSL check. The correct way to handle that is to
allow users to choose their SSL behavior in the frontend applications.
2020-04-14 13:45:19 +02:00
Bastien Teinturier
5fe6f675e5
Better tracking of channels count metric (#1369)
Track all channel states (cardinality shouldn't be too high).
Prevent duplicate transactions that messed up the gauge.
2020-04-10 19:25:27 +02:00
Pierre-Marie Padiou
7a5dbfdc56
Do not reconnect immediately if we keep getting disconnected (#1371)
If our latest successful connection attempt was less
than 30 seconds ago, we pick up the exponential
back-off retry delay where we left it. The
goal is to address cases where the reconnection
is successful, but we are disconnected right away.
2020-04-10 13:05:22 +02:00
Pierre-Marie Padiou
a58678eb0b
Move router handlers to separate files (#1352)
Also, acknowledge all gossip with a `GossipDecision`.
2020-04-09 16:08:10 +02:00
araspitzu
932f04851a
Support additional TLV records in SendPayentRequest (#1367)
* Support additional user defined TLVs when sending a payment (both single-part and MPP)

* Allow encoding and decoding of even TLV types above the high range
2020-04-09 10:36:30 +02:00
araspitzu
7866be11c3
Use correct type for parameters in ExtendedBitcoinClient (#1248)
* Use correct type for parameters in ExtendedBitcoinClient
2020-04-07 09:55:41 +02:00
Fabrice Drouin
d5951aa819
Release 0.3.4 (#1368)
* Release 0.3.4

* Set version to 0.3.5-SNAPSHOT
2020-04-06 13:41:17 +02:00