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

1823 commits

Author SHA1 Message Date
Bastien Teinturier
131b2e01c5
Add workaround for lnd sync issue (#1563)
When a channel gets confirmed while nodes are disconnected, recent lnd
nodes sometimes fail to send their channel_reestablish message and instead
send a funding_locked first (due to a race condition on their side).

When that happened, the channel stayed stuck in the SYNCING state.
To avoid that, we trigger a reconnection until the race condition is eventually
won by the channel_reestablish.
2020-10-14 13:22:37 +02:00
Bastien Teinturier
f9ff586cba
Release Eclair v0.4.2 (#1562)
* Set version to 0.4.2
* Set version to 0.4.3-SNAPSHOT
2020-10-13 15:14:40 +02:00
Donovan
3e3397cfb1
Fix Docker JAVA_OPTS expansion (#1561) 2020-10-13 11:44:34 +02:00
Donovan
4b55d3e71c
Fix typo in startup script (#1559) 2020-10-13 09:52:37 +02:00
Bastien Teinturier
3da76c08ae
Allow mandatory static-remotekey (#1558)
Since we optionally support static-remotekey, we should allow our peers
to make it mandatory if they wish.
2020-10-12 15:09:09 +02:00
Bastien Teinturier
a76db1c27b
Fix channel CMD_SIGN (#1556)
We're sending the type instead of sending an instantiated class...
Other commands were affected and are now fixed.
2020-10-12 10:42:48 +02:00
Anton Kumaigorodski
135ce6cc8b
Use maven plugin to include tests (#1557)
This results in eclair-core_2.13-<version>-tests.jar file and allows to easily reuse testing classes in other modules.
2020-10-12 10:41:52 +02:00
Bastien Teinturier
50363569c7
Fix forceclose API (#1555)
It was simply missing a sender ActorRef.
2020-10-09 18:29:16 +02:00
Pierre-Marie Padiou
eea1ba99b9
Add backward-compatibility tests on some database codecs (#1554)
* add backward compat tests on cmd codecs

* add backward compat test on feerate codec
2020-10-09 17:02:33 +02:00
Bastien Teinturier
b728520ad7
Prevent disabling var_onion_optin (#1552)
There is no good reason to completely disable `var_onion_optin` and it can
even be harmful: pending HTLCs after a restart may be lost if they used a
variable-length onion, causing a loss of funds and potential channel closes.
2020-10-09 16:50:38 +02:00
Pierre-Marie Padiou
ed61750436
Nits (#1553) 2020-10-09 11:30:14 +02:00
Pierre-Marie Padiou
20e0b4bc4d
Fix override-features implementation (#1549)
We were calling `nodeParams.features` from inside the channel, which is
problematic because we may have overridden those features for specific
peers. This is now fixed.
2020-10-08 17:59:01 +02:00
Bastien Teinturier
428349a341
Send to channel route (#1537)
* Send payment through specific channels

While `sendtoroute` was letting you provide a custom route as a list of
nodes, it made it difficult to have fine-grain control over the channels
used by payments.

The API now allows choosing the exact channels that will be used for the
payment; in particular, this will be helpful when consolidating and
rebalancing multiple channels to a given node.

Fixes #1472

* Fix serialization regression

#1520 introduced a regression in the serialization of channel data,
impacted the `channels` and `channel` APIs.

We restrict the custom command response serializer to revert to the
previous behavior.
2020-10-08 15:43:52 +02:00
Pierre-Marie Padiou
8885ed7f4a
(minor) Improve logs in channel relayer (#1550) 2020-10-07 15:51:07 +02:00
Pierre-Marie Padiou
56d216b91b
Separate configuration for peer-connection (#1548)
Features are now provided by the `switchboard`, in response to the
`PeerConnection.Authenticated` message.

The `switchboard` will also decide whether or not we sync with that
peer, depending on the `syncWhiteList` configuration.
2020-10-02 17:12:51 +02:00
Bastien Teinturier
382868dda2
[ChannelRelay] Prioritize lowest capacity channels (#1539)
* [ChannelRelayer] Expose Wrapped messages to tests

Exposing the private wrapped messages to tests allows removing the
dependency on capturing logs which felt very brittle.

* Prioritize low capacity channels during relay

This makes it more difficult for attackers to "squat" high-capacity channels
by sending HTLCs and then hodling them.

It results in less locked liquidity during this kind of attacks.
2020-10-02 10:09:32 +02:00
Pierre-Marie Padiou
1274168012
Make all commands extend Has*ReplyToCommand (#1543)
This way we can maintain replies in tests.
2020-09-30 10:05:55 +02:00
Bastien Teinturier
0ab7ec63f9
Add DB entry for payment router error (#1513)
When using MPP, if we can't find a route, we need to add an entry to the
DB. Otherwise when users query their payment status, nothing will be
returned which is a bad UX.

Fixes #1512
2020-09-29 18:08:08 +02:00
Bastien Teinturier
8a27b4ca85
Fixup funder fee buffer (#1364)
We were previously only counting the additional HTLC at twice
the current feerate.

An HTLC in isolation doesn't make much sense: the feerate
applies to the whole commit tx. Our fee buffer needs to account
for a x2 feerate increase on the commit tx + an additional htlc.

Note that this introduces another subtlety. The commit tx fee at twice the
current feerate may actually be lower than the commit tx fee at the current
feerate (if the commit tx contains many htlcs that are only slightly above
the trim threshold).
2020-09-29 18:06:38 +02:00
Bastien Teinturier
36c9b9b5a5
Configure bitcoin wallet (#1540)
Don't swallow bitcoind exceptions: we wrap them but preserve the
original one.

Allow configuring bitcoin core wallet: it makes sense to allow users
to use a different wallet from the default one.
There's one important caveat: once set, users shouldn't change it while
they have open channels. We mention it clearly in the documentation.

Fixes #1538
2020-09-28 12:07:15 +02:00
Bastien Teinturier
42481c66e6
Add some channel events to websocket (#1536)
Send basic channel events to websockets listeners:

* Channel open initiated
* Channel state change
* Channel closed

We only send basic, high-level data about these events.
If the listener is interested in details, it should call the `channelInfo`
API to get all of the channel's data.

Fixes #1509
2020-09-28 09:51:42 +02:00
Bastien Teinturier
483cce4ae2
Split IntegrationSpec (#1535)
This change makes `IntegrationSpec` an abstract class trait that defines
common utilities used in most integration tests, and splits the actual tests
in two separate files that extend that class. Channel tests have themselves
been split between standard and anchor commitments to gain extra
parallelism.

The tests themselves aren't changed at all, except for the TCP ports they
use, and to remove nodes that have become useless in each of the specs. `expectMsg`
have been increased to 60 seconds to account for the increased parallelization.

Some tests have been refactored, cleaned up and block expiries have been reduced.
2020-09-24 18:58:17 +02:00
Anton Kumaigorodski
3a773c1fd7
Allow plugins to handle custom messages and features (#1528)
Allow plugins to register unknown features and message types they're able to handle.
This allows plugins to add new features independently of what eclair-core understands.
Plugins are able to receive and send arbitrary lightning messages, and advertise support
for non-standard features freely.
2020-09-24 17:50:07 +02:00
Pierre-Marie Padiou
6ef72a0bd0
Set a timefactor for typed actors tests (#1541)
We use the same timefactor (5x) than for untyped actors.
2020-09-24 17:47:52 +02:00
Bastien Teinturier
662e0c4bcc
Anchor output: handle unilateral close (#1501)
Change the static_remotekey behavior to use a wallet basepoint only when
using "standard" commitments; with anchor outputs we need to claim this
output (it doesn't directly spend to our wallet) so we must use
key-derivation with our lightning keys.

Correctly claim all outputs in unilateral cases, and add corresponding
test cases.

Anchor output commitments should now work end-to-end (but there's no support
for fee bumping yet).
2020-09-22 15:30:24 +02:00
Pierre-Marie Padiou
750b372b28
Minor improvements to the watcher (#1531)
We were watching actors for ignored watches (WatchLost), and printing
useless logs when ignoring duplicate watches.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2020-09-21 10:19:32 +02:00
Pierre-Marie Padiou
eed82e262f
Update to scala 2.13.3 and akka 2.6.9 (#1532)
Need to add explicit dependency on akka-stream (see https://doc.akka.io/docs/akka-http/current/introduction.html#using-akka-http)
2020-09-18 15:27:45 +02:00
Pierre-Marie Padiou
3158c2668e
More leeway in tests (#1530)
In some tests we are parsing logs to prevent race conditions. This
change adds more leeway to wait for logging events, because they may be
delayed when we run a lot of tests in parallel.
2020-09-18 10:56:43 +02:00
Pierre-Marie Padiou
f264235637
Improve relayer logs (#1529)
We can be less repetitive given that we now have a `relayId` that we can
use to factor all info.
2020-09-18 10:00:23 +02:00
Pierre-Marie Padiou
2fc118c291
Do not reply to htlc settlement commands (#1527)
The replies are always ignored currently anyway. A new trait `NoReplyTo`
has been introduced. Those commands have a particular workflow because
they are persisted in the pending relay db.
2020-09-16 10:39:06 +02:00
Pierre-Marie Padiou
d0011005a0
Migrate relayers to akka typed (#1525)
* introduce a new relay identifier

In a channel relay, it will be unique for all retries.

In a trampoline relay, it is equal to what previously was the parent
payment id.

* moved and cleaned up remaining relayer tests

Now all relay-related tests are in the `relayer` package.
2020-09-16 09:46:51 +02:00
Bastien Teinturier
b954defa28
Update to Bitcoin Core 0.20.1 (#1526)
The only impactful change is that by default on regtest and testnet
fallback fee (used when there is not enough historical data to correctly
estimate the feerate) is now set to 0, whereas it was set to 0.0002 btc
in previous versions.

We set it manually in tests `bitcoin.conf` to preserve the previous behavior.
2020-09-08 17:59:52 +02:00
Pierre-Marie Padiou
6b05099f07
Use the replyTo pattern for Channel messages (#1520)
* typeify response to command messages

* Status.Failure(AddHtlcFailed)->RES_ADD_HTLC_FAILED

`AddHtlcFailed` is renamed `RES_ADD_FAILED` and it is just a particular
kind of `CommandError`

* remove Status.Failure from payment lifecycle

* use replyTo pattern in relayers

* return ForwardMessage in CommandResponse

Instead of having the channel send `Relayer.ForwardMessage` to the
relayer, we encapsulate the `Relayer.ForwardMessage` within a
`CommandResponse[CMD_ADD_HTLC]`.

It looks like a cosmetic change, but it's not: now when the relayer
sends a `CMD_ADD_HTLC` to the channel, it will receive one or more
`CommandResponse[CMD_ADD_HTLC]`, for example:
- success scenario:
  - `RES_SUCCESS[CMD_ADD_HTLC]`
  - `RES_ADD_COMPLETED[RelayBackward.RelayFulfill]`
- htlc failed by downstream
  - `RES_SUCCESS[CMD_ADD_HTLC]`
  - `RES_ADD_SETTLED[RelayBackward.RelayFail]`
- command rejected:
  - `RES_ADD_FAILED[_]`
- peer disconnected before signing:
  - `RES_SUCCESS[CMD_ADD_HTLC]`
  - `RES_ADD_FAILED[ChannelUnavailable]`

In addition to that, `RelayMessage` have been slightly refactored, to
better separate between `RelayForward` and `RelayBackward`.

This paves the way for typing `CMD_ADD_HTLC.replyTo` to
`ActorRef[CommandResponse[CMD_ADD_HTLC]]` and have the channel send all
related messages to the `replyTo` actor. Note that the `RelayForward`
actor will always be sent to the relayer, which makes sense since there
was no related command (the htlc was sent by the peer).

NB: `CMD_ADD_HTLC` is a special case, for all other commands there is
exactly one `CommandResponse[CMD_*]`, either `RES_SUCCESS[CMD_*]` or
`RES_FAILURE[CMD_*]`.

* use replyTo pattern in payment lifecycle

We were already close to this pattern with constructs like `case class
WaitingForRoute(sender: ActorRef, ...`

* typeify Origin/Upstream classes

The relationship between `Origin` and `Upstream` was obscure and they were
defined in two different files.

`Upstream` is the source of the payment in the context of a chain
of htlcs. For example, in the case of a typical relayed payment, it
would be an incoming htlc.

`Origin` is the source of the payment in the application: it can be an
actor, or nothing if the reference was lost after a restart.

Instead of using an `Option[ActorRef]` to differentiate between
known/unknown origin, new `Hot/Cold` traits that extend `Origin` have
been introduced. This means that now the `PostRestartHtlcCleaner` only
deals with `Cold` origins, whereas the `NodeRelayer` only handles `Hot`
origins. The channel codec will encode from both `Hot/Cold` origins, but
will only decode to `Cold`.

* refactor response types

Generalize the `CommandResponse[Command]` pattern for all commands.

There seem to be something ambiguous about the way we deal with closing
commands during the initialization phase of the channel. We used to
conflate `CommandResponse[CMD_CLOSE]` and
`ChannelOpenResponse.ChannelClosed` but those are not sent to the same
actors.

It turns out our testing of the `EclairImpl` class is very weak. We
could use this class in `IntegrationSpec` instead of sending raw
messages to channels.

* handle channel-relay in the post-htlc-restart too
2020-09-03 18:40:37 +02:00
Bastien Teinturier
e34b74f888
Fix flaky integration test (#1524)
The downstream HTLC-timeout integration test was sometimes hanging waiting
for the local commit tx to appear inside the mempool.

The reason was that the remote peer was also trying to get its version of
the commit tx in the mempool, and when it won that race we weren't testing
the right thing.

Simply disconnecting the two nodes fixes the issue as it ensure only the
local node will be broadcasting his commit tx.
2020-09-03 13:40:23 +02:00
Pierre-Marie Padiou
ea7202380f
Set the channel version in the init msg for the fundee (#1518)
Currently, the fundee computes it after receiving the `open_channel`
message, by calling `ChannelVersion.pickChannelVersion`.

Instead, we call this method in the `Peer` and add the resulting channel
version to the initialization parameters.

In the end, the behavior is exactly the same, but:
- it is more consistent with how the funder works;
- it may make sense to compute the channel version a bit earlier in the
process, because we may initiate a different kind of channel actor in
the future for some particular versions (?)
2020-09-03 13:39:44 +02:00
Bastien Teinturier
77e972bcbe
Improve blockchain watchers (#1500)
* Correctly handle the case where a tx has both a sequence and locktime set.
* Add tx publish tests to ZmqWatcher and ElectrumWatcher.
* Add documentation on watcher types.
2020-09-02 15:46:40 +02:00
Bastien Teinturier
14a69b810c
Trampoline relay exhausted liquidity (#1523)
We were previously returning TemporaryNodeFailure for trampoline payments
to neighbour nodes with depleted liquidity. This prevented us from
finding alternative, indirect routes.

In such cases, we now roughly estimate whether the fee is "big enough" to
allow finding alternative routes; if not we ask the sender to raise the fee
before telling them we're lacking liquidity.

A more costly alternative that we may implement in the future would be to
run the path-finding to find a route without bounding the fee, and send
that information back to the sender.
2020-09-02 10:56:44 +02:00
Pierre-Marie Padiou
e54066be55
Remove Status.Failure in register responses (#1516)
* add replyTo to Register messages

In preparation of the migration to typed actors, we need to remove the
use of `sender`, which doesn't exist in typed actors (and even returns
dead letters when mixing typed/untyped actors).

This also means that, in the tests, we should stop using the
`TestProbe.send()` method, which also relies on the recipient replying
to `sender`. Instead, we should use `targetActor ! msg` which guarantees
that the sender is void.

Using the `replyTo` pattern doesn't mix well with the `ask` pattern,
because we don't know the reference to the temporary actor. To deal with
that, we set `replyTo = ActorRef.noSender` which is a bit hackish.

* don't use `Status.Failure` in register responses

Encapsulating error responses in a `Status.Failure` is convenient when
using the `ask` pattern because those messages are automatically
converted to a failed future.

It does however force us to use exceptions, and make things more
complicated, especially when moving to _typed_ actors.
2020-09-01 18:01:06 +02:00
Pierre-Marie Padiou
ef1bf0b9a5
Use the replyTo pattern for Register messages (#1514)
* add replyTo to Register messages

In preparation of the migration to typed actors, we need to remove the
use of `sender`, which doesn't exist in typed actors (and even returns
dead letters when mixing typed/untyped actors).

This also means that, in the tests, we should stop using the
`TestProbe.send()` method, which also relies on the recipient replying
to `sender`. Instead, we should use `targetActor ! msg` which guarantees
that the sender is void.

Using the `replyTo` pattern doesn't mix well with the `ask` pattern,
because we don't know the reference to the temporary actor. To deal with
that, we set `replyTo = ActorRef.noSender` which is a bit hackish.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2020-09-01 16:43:15 +02:00
Bastien Teinturier
153f82c8cf
Refactor integration tests (#1494)
We don't need one node per force-close scenario, we can use different
channels to the same node which makes the spec simpler.

Force-close tests now have better isolation: they create the channel at
the beginning of the test, and the test ends with that channel closed.

Common parts have been refactored as well, which will make it easier to
add more tests for anchor outputs without duplicating too much code.

These tests have been heavily enriched and refactored; they previously
relied on many unwritten assumptions about event ordering that appeared
as soon as I tried updating them (e.g. to use push_msat to ensure both
sides had an output in the commit tx).
2020-09-01 15:45:45 +02:00
Pierre-Marie Padiou
2c437421d7
Show reminder of failed tests at the end (#1521)
From scalatest's doc [1]:

> This minimizes or eliminates the need to search and scroll backwards
to find out what tests failed or were canceled. For large test suites,
the actual failure message could have scrolled off the top of the
buffer, making it otherwise impossible to see what failed.

[1] https://www.scalatest.org/user_guide/using_the_runner
2020-08-20 12:08:52 +02:00
Pierre-Marie Padiou
3d168a5ba3
Remove semaphore build (#1517)
It is replaced by github actions.
2020-08-17 17:12:59 +02:00
Bastien Teinturier
daddfc007f
Type fee rates info (#1504)
* Type fee rates info

Fixes #1188

* Fix vsize comment

This is an alternative to #1425.
This may not correctly represent what Bitcoin Core does, it's likely that
we can in fact use a value smaller than 253, but this shows how we choose
to err on the side of safety with that calculation.

* Add 1008 feerate block target

Fixes #1486
2020-08-10 15:38:13 +02:00
Bastien Teinturier
1b21e14b97
Fix typo related to pico-bitcoin conversion (#1503)
Fixes #1502
2020-08-10 10:49:38 +02:00
Donovan
01f924ae86
Add API commands to sign & verify arbitrary messages (#1499)
It can be useful to sign arbitrary messages with the key associated with our node_id (to prove ownership of a node).

Adds 2 new API commands:
  eclair-cli signmessage --msg=${message}
  eclair-cli verifymessage --msg=${message} --sig=${signature}
2020-08-07 16:33:20 +02:00
Bastien Teinturier
5a5a0b96f0
Verify feature graph in Init (#1495)
If our remote peer doesn't correctly set transitive feature dependencies,
we close the connection until they fix it.
2020-07-30 15:42:20 +02:00
Bastien Teinturier
6f9edec109
Relax relaying requirement on expiry (#1497)
We previously refused to relay HTLCs that would result in a low expiry
delta for the next node. However it's not our decision to make, it's the
remote's. We should forward these HTLCs and let the remote decide whether
they fail them because the expiry is too close or fulfill them.
2020-07-29 14:55:35 +02:00
Bastien Teinturier
3d4e00fe18
Activate anchor output in channels (#1491)
Allow activating anchor outputs and have fully operating channels
during normal operation (open, add/fulfill/fail htlcs, close).

Interop testing has been done with lnd, and there is only one pending
issue during mutual close, where they incorrectly compute the closing
amounts, which they should fix soon.

However, anchor outputs should NOT be activated yet as unilateral
close scenario are not fully handled yet.

We don't do any kind of automatic fee bumping either; this will be done
later, once we have PSBT support and once bitcoind offers the
`psbtbumpfee` RPC (see bitcoin/bitcoin#18654).
2020-07-27 20:00:52 +02:00
araspitzu
8cd2644574
Do not merge user provided features with defaults (#1435)
* allow to explicitly disable features from configuration

* improved Features.toString

* explicitely disable unlisted features

Co-authored-by: pm47 <pm.padiou@gmail.com>
2020-07-27 17:02:51 +02:00
Pierre-Marie Padiou
bc81cd5272
Add delay before setting watches at startup (#1489)
Watching the blockchain is an asynchronous task, so it is "always late"
and it doesn't matter if we don't synchronously set the watch back when
the node is restarted.

It allows us to smoothen the load if needed at startup, because setting
tens of thousands of `watch-spent` all at once at startup is pretty
expensive.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2020-07-22 15:46:56 +02:00