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

2149 commits

Author SHA1 Message Date
Bastien Teinturier
8ff7dc713a
Avoid default arguments in test helpers (#2108)
A few of our test helper functions started using too many default arguments,
which makes them a bit messy to use in tests, especially when we want to
add new arguments.

We change this to use method overloading instead, which makes it easier to
add new overloads without changes to existing tests.
2021-12-15 15:49:00 +01:00
Thomas HUET
3d88c43b12
Kill idle peers (#2096)
We may create connections to new peers for relaying onion messages but we don't want to keep them open for long.
2021-12-15 14:05:51 +01:00
Bastien Teinturier
576c0f6e39
Increase timeout onion message integration tests (#2106)
In channel tests, we set a 60 seconds timeout on the receiver end,
otherwise we sometimes run into timeout on slow CI machines that run a
lot of tests in parallel.

It makes sense to do the same for onion messages, to help us figure out
whether there is a race condition or it's just the machines that are slow.
2021-12-14 19:20:48 +01:00
Bastien Teinturier
4ebc8b5d6b
Notify node operator on low fee bumping reserve (#2104)
With anchor outputs, we need to keep utxos available for fee bumping.
Having enough on-chain funds to claim HTLCs in case channels force-close
is necessary to guarantee funds safety.

There is no perfect formula to estimate how much we should reserve: it
depends on the feerate when the channels force-close, the number of
impacted HTLCs and their amount.

We use a very rough estimation, to avoid needlessly spamming node operators
while still notifying them when the situation becomes risky.
2021-12-14 16:42:22 +01:00
Bastien Teinturier
535daec065
Fix unhandled event in DbEventHandler (#2103)
We were previously subscribing to all payment events, which includes
`PaymentSettlingOnChain`, for which there is nothing to do at the
DbEventHandler level.

We now register to each concrete event instead of registering to a generic
trait.
2021-12-14 12:33:27 +01:00
Thomas HUET
ac9e274f0d
Add message relay policies (#2099)
When activating onion messages, you can chose to never relay messages, relay only through existing channels or relay everything.
2021-12-13 13:50:52 +01:00
Bastien Teinturier
34519749d2
Raise default connection timeout values (#2093)
We've seen users bump into these limits often because many nodes now run
behind Tor on poor hardware, so it makes sense to make our default values
more robust.
2021-12-13 10:34:33 +01:00
Bastien Teinturier
40cc458043
Switchboard exposes peer information (#2097)
The switchboard is our singleton actor entry point to all of our peers and
peer connections, it can be useful to have it deliver basic information
about our peers.

We also take this opportunity to fix a bug: we were not emitting the
`LastChannelClosed` event when it happened while the peer was
disconnected.
2021-12-10 18:40:10 +01:00
Pierre-Marie Padiou
ee852d6320
(Minor) Handle disconnect request when offline (#2095)
Otherwise the API hangs when requesting a disconnection to a peer that is offline.
2021-12-09 13:38:06 +01:00
Bastien Teinturier
62cc073d67
Remove network stats computation (#2094)
We introduced a task to regularly compute network statistics (mostly about
channel parameters such as expiry and fees).

The goal was to use this information in the MPP split algorithm to decide
whether to split a payment or not.

But we haven't used it, and I'm not sure anymore that it's useful at all.

If node operators are interested in network statistics, an ad-hoc
on-the-fly computation would make more sense.
2021-12-09 11:58:04 +01:00
Thomas HUET
a470d41a95
Write received onion messages to the websocket (#2091) 2021-12-09 10:56:05 +01:00
Thomas HUET
3003289328
No error when updating the relay fees not in normal state (#2086)
When using the API to update the relay fees of a channel, the changes are saved in the DB and then the channel is updated. If the channel can't be updated, because it is not ready yet for instance, that's fine because it will use the values from the DB as soon as it is ready. So there is no need to return an error in that case.
Fixes #2085
2021-12-06 12:16:51 +01:00
Bastien Teinturier
bacb31cf8d
Add channel type feature bit (#2073)
We already support channel types, but we make it explicit with a feature
bit as required by https://github.com/lightning/bolts/pull/906
2021-12-02 18:22:25 +01:00
Bastien Teinturier
86aed633e9
Remove misleading claim-htlc-success log (#2076)
Whenever a remote commitment is confirmed in which we received htlcs, we
generate a claim-htlc-success transaction even if we don't have the preimage
yet (so we can't broadcast it).

This created a confusing log line:
"tx generation success: desc=claim-htlc-success"

We want to create that log line only when we have the preimage and the node
operator can expect the HTLC to be redeemed on-chain.
2021-12-02 16:46:56 +01:00
Bastien Teinturier
589e84feab
Support private channels in SendToRoute (#2082)
For some reason, when sending to a pre-defined channel route, we only
looked at the public channel graph. This was incorrect, we should also
include private channels and routing hints.

Fixes #2081
2021-12-02 16:22:40 +01:00
Bastien Teinturier
4ad502c4c8
Abort HTLC tx publisher if remote commit confirms (#2080)
If the remote commit confirms before our local commit, there is no reason
to try to publish our HTLC transactions, we will instead directly claim
the htlc outputs from the remote commit.

We previously checked timelocks before checking preconditions, which in
this case means we would be waiting for a confirmation on our local commit
forever. We now check preconditions before timelocks, and added a
precondition that verifies that the remote commit isn't confirmed before
publishing our HTLC txs.
2021-12-02 14:10:04 +01:00
Thomas HUET
9792c725c7
Rename feeThresholdSat to maxFeeFlatSat (#2079) 2021-11-29 17:51:39 +01:00
Thomas HUET
59b403559b
Relay onion messages (#2061)
* Relay onion messages

Allow sending and relaying onion messages

Co-authored-by: Pierre-Marie Padiou <pm47@users.noreply.github.com>
Co-authored-by: t-bast <bastuc@hotmail.fr>
2021-11-29 14:00:23 +01:00
rorp
fb96e5eb3f
Add failed node ID field to FailureSummary (#2042)
The output of `getsentinfo` didn't include the `nodeId` of the failing node.
This PR adds it, as it can be used by external apps when they build routes
themselves instead of relying on eclair's internals (e.g. channel rebalancing).
2021-11-29 09:45:54 +01:00
Bastien Teinturier
6cc37cbd4f
Simplify onion message codec (#2060)
The scodec magic was quite hard to read, and the use of the prefix wasn't
very intuitive since Sphinx uses both a prefix and a suffix.

Also added more codec tests.
2021-11-09 15:57:29 +01:00
Bastien Teinturier
333e9ef04f
Clarify route blinding types (#2059)
We rename the EncryptedRecipientData types.
The data it contains is namespaced to usages for route blinding, so we
make that explicit.

This way if future scenarios use another kind of encrypted tlv stream
we won't have name clashes (e.g. encrypted state backup).

We also update the route blinding test vectors to the final spec version.
2021-11-09 11:55:43 +01:00
Thomas HUET
083dc3c8da
Onion messages (#1957)
Add basic support for onion messages (lightning/bolts#759)

Add functions and codecs to create, read and process onion messages. Does not use any of them yet.
2021-11-09 10:16:50 +01:00
Bastien Teinturier
4ac823620b
Remove dumpprivkey from tests (#2053)
We previously relied on bitcoind's dumpprivkey RPC in some of our tests.

That RPC isn't available with descriptor wallets, and descriptor wallets
are now the default wallet type.
2021-11-08 17:18:39 +01:00
Bastien Teinturier
b45dd0078e
Refactor sphinx payment packet (#2052)
We previously created restrictions in Sphinx.scala to only allow using it
for two types of onions: a 1300 bytes one for HTLCs and a 400 bytes one
for trampoline.

This doesn't make sense anymore. The latest version of trampoline allows
any onion size, and onion messages also allow any onion size. The Sphinx
protocol doesn't care either about the size of the payload.

Another reason to remove it is that it wasn't working that well with
pattern matching because of type erasure.

So now the caller must explicitly set the length of the payload, which is
more flexible. Verifying that the correct length is used is deferred to
higher level components.
2021-11-05 10:58:23 +01:00
Bastien Teinturier
3dc4ae1099
Refactor payment onion utilities (#2051)
* Rename Onion.scala to PaymentOnion.scala
* Rename payment onion types
* Rename IncomingPacket and OutgoingPacket
* Move shared OnionRouting codecs to separate file
2021-11-05 09:10:59 +01:00
Pierre-Marie Padiou
f7a79d10b4
Fix response for updaterelayfee (#2047)
Fixes #1995, which was due to a pattern matching error for the expected response type of `sendToX` helper methods in `EclairImpl`, and had nothing to do with json serialization. Added a few non-reg tests.

In the second commit I also set a basic "ok" json serializer for all default `RES_SUCCESS` messages, but didn't follow https://github.com/ACINQ/eclair/issues/1995#issuecomment-940821678, because we would either completely break backwards compatibility, or create inconsistency with non-default command responses like `RES_GETINFO`, and with other API calls not related to channels.
2021-11-03 17:52:01 +01:00
Pierre-Marie Padiou
1f613ec7a3
Handle mutual close published from the outside (#2046)
If a _local_ mutual close transaction is published from outside of the actor state machine, the channel will fail to recognize it, and will move to the `ERR_INFORMATION_LEAK` state. We could instead log a warning and handle it gracefully, since no harm has been done.

This is different from a local force close, because we do not keep the fully-signed local commit tx anymore, so an unexpected published tx would indeed be very fishy in that case. But we do store the best fully-signed, read-to-publish mutual close tx in the channel data so we must be ready to handle the case where the operator manually publishes it for whatever reason.
2021-11-03 10:31:05 +01:00
Pierre-Marie Padiou
9f65f3a3a9
Make compatibility code for waitingSince work on testnet (#2041)
We use to store UNIX timestamps in the `waitingSince` field before
moving to block count. In order to ensure backward compatibility, we
converted from timestamps to blockheight based on the value. Anything
over 1 500 000 was considered a timestamp. But this value is much too
low: on testnet the blockheight is already greater than 2 000 000.

We can use 1 500 000 000 instead, which is somewhere in 2017.

Another way to deal with this would be to simply remove this
compatibility code.
2021-10-29 13:07:20 +02:00
Pierre-Marie Padiou
4f458d356c
Alternate strategy for unhandled exceptions (#2037)
This PRs adds an alternate strategy to handle unhandled exceptions. The goal is to avoid unnecessary mass force-close, but it is reserved to advanced users who closely monitor the node.

Available strategies are:
- local force close of the channel (default)
- log an error message and stop the node

Default settings maintain the same behavior as before.
2021-10-27 18:49:11 +02:00
Pierre-Marie Padiou
2c0c24e1e1
Rework channel reestablish (#2036)
In an "outdated commitment" scenario where we are on the up-to-date side, we always react by force-closing the channel immediately, not giving our peer a chance to fix their data and restart. On top of that, we consider this a commitment sync error, instead of clearly logging that our counterparty is using outdated data.

Addressing this turned out to be rabbit-holey: our sync code is quite complicated and is a bit redundant because we separate between:
- checking whether we are late
- deciding what messages we need to retransmit

Also, discovered a missing corner case when syncing in SHUTDOWN state.
2021-10-27 11:45:07 +02:00
Victor Larsson
2e9f8d9f9e
Cookie-based authentication for Bitcoin Core RPC (#1986)
Add support for cookie authentication with bitcoind instead of
user/password. This is recommended when running eclair and
bitcoind on the same machine: it ensures only processes with
read permissions to the bitcoind cookie file are able to call the
RPC, which is safer than a user/password pair.
2021-10-26 11:34:51 +02:00
Pierre-Marie Padiou
c5fa39f754
Front: stop the jvm after coordinated shutdown (#2028)
The app must stop when connection to the backend fails. It will be gracefully restarted on Beanstalk instead of just hanging.

Fixes a regression introduced by #1912.
2021-10-25 15:54:16 +02:00
Pierre-Marie Padiou
e54aaa84be
API: fix default time boundaries (#2035)
Default upper bound was `Long.MaxValue unixsec` which overflowed when converted to `TimestampMilli`. We now enforce `min` and `max` values on timestamp types.

API tests didn't catch it because eclair is mocked and the conversion happens later.

Fixes #2031.
2021-10-25 14:41:04 +02:00
thomash-acinq
1573f7be05
EncryptedRecipientData TLV stream should not be length-prefixed (#2029)
* TLV streams contain size of fields already

* Update test vectors
2021-10-25 11:52:43 +02:00
Bastien Teinturier
765a0c5436
Add log file for important notifications (#1982)
Add a new log file for important notifications that require an action from
the node operator.

Using a separate log file makes it easier than grepping specific messages
from the standard logs, and lets us use a different style of messaging,
where we provide more information about what steps to take to resolve
the issue.

We rely on an event sent to the event stream so that plugins can also pick
it up and connect with notification systems (push, messages, mails, etc).
2021-10-25 11:21:39 +02:00
Pierre-Marie Padiou
494e346231
Minor: put htlc info logs in debug (#2030) 2021-10-25 10:25:07 +02:00
rorp
99a889636b
ignoreShortChannelIds should disable edges in both directions (#2032)
We want to ignore the given channels in our path-finding algorithm,
so we need to ensure they're ignored in both directions.
2021-10-25 10:20:46 +02:00
Bastien Teinturier
570dc223da
Fix flaky transaction published event test (#2020)
On slow CI machines, the "recv WatchFundingConfirmedTriggered" test was
flaky because there was a race between the publication of Alice's
TransactionPublished event before going to the WaitForFundingLocked state
and the tests registering event listeners (after going to the
WaitForFundingLocked state).
2021-10-25 09:32:36 +02:00
Bastien Teinturier
28d04ba7a7
Store blinding pubkey for introduction node (#2024)
It doesn't make sense to throw away this information, and it's useful in
some scenarios such as onion messages.

The ephemeral keys aren't part of the route, they're usually derived hop
by hop instead. We only need to keep the first one that must be somehow
sent to the introduction node.
2021-10-22 14:13:30 +02:00
Pierre-Marie Padiou
4e9190aaee
Minor: higher timeout in payment fsm test (#2026) 2021-10-22 12:54:21 +02:00
Pierre-Marie Padiou
9274582679
Balance: take signed fulfills into account (#2023)
For incoming htlcs, the amount needs to be included in our balance if we know the preimage, even if the htlc hasn't yet been formally settled.

We were already taking into accounts preimages in the `pending_commands` database.

But, as soon as we have sent and signed an `update_fulfill_htlc`, we clean up the `pending_commands` database. So we also need to look at current sent changes.
2021-10-22 11:19:27 +02:00
rorp
bdef8337e8
Additional parameters for findroute* API calls (#1969)
Add options to ignore specific channels or nodes for
findRoute* APIs, and an option to specify a flat maximum
fee.

With these new parameters, it's now possible to do circular
rebalancing of your channels.

Co-authored-by: Roman Taranchenko <romantaranchenko@Romans-MacBook-Pro.local>
Co-authored-by: t-bast <bastuc@hotmail.fr>
2021-10-22 09:04:29 +02:00
Pierre-Marie Padiou
93481d9943
Higher walletpassphrase timeout in tests (#2022)
Otherwise on a slow machine the wallet locks again and tests fail.
2021-10-21 14:58:33 +02:00
rorp
f3b16047eb
Add API to delete an invoice (#1984)
Add API to delete an invoice.
This only works if the invoice wasn't paid yet.

Co-authored-by: Roman Taranchenko <romantaranchenko@Romans-MacBook-Pro.local>
Co-authored-by: t-bast <bastuc@hotmail.fr>
2021-10-20 22:56:40 +02:00
Bastien Teinturier
6b202c392b
Add low-level route blinding features (#1962)
Cryptographic functions to blind and unblind a route and its associated
encrypted payloads.

Decrypt and decode the contents of an `encrypted_recipient_data` tlv field.
We could share the tlv namespace with onion tlvs, but it's cleaner to
separate them. They have a few common fields, but already diverge on
others, and will diverge even more in the future.
2021-10-19 11:13:50 +02:00
Fabrice Drouin
601898864d
Check serialization consistency in all channel tests (#1994)
* Check serialization consistency in all channel tests

We add a simple wrapper over the channels db used in all channel state unit tests, which will basically check
that deserialize(serialize(state)) == state.

* Add getChannel() method to ChannelsDb interface

This makes our serialization checks cleaner: we now test that read(write(channel)) == channel
2021-10-18 21:58:08 +02:00
Pierre-Marie Padiou
b4d285f1c4
Proper types for UNIX timestamps (#1990)
We define `TimestampSecond` and `TimestampMilli` for second and millisecond precision UNIX-style timestamps.

Let me know what you think of the syntaxic sugar, I went for `123456 unixsec` and `123456789 unixms`.

Json serialization is as follows for resp. second and millisecond precision. Note that in both case we display the unix format in second precision, but the iso format is more precise:
```
{
  "iso": "2021-10-04T14:32:41Z",
  "unix": 1633357961
}
{
  "iso": "2021-10-04T14:32:41.456Z",
  "unix": 1633357961
}
```
2021-10-18 16:13:42 +02:00
Pierre-Marie Padiou
9057c8e90a
Minor improvements (#1998)
* use a map for feature->channelType resolution

Instead of explicitly listing all the combination of features, and risk
inconsistency, we may has well build the reverse map using the channel
type objects.

* better and less spammy logs

We can switch the "funding tx already spent" router log from _warn_ to 
_debug_ because as soon as there are more than 10 of them, the peer's
announcements will be ignored and there will be a warning message about
that.

* timedOutHtlcs -> trimmedOrTimedOutHtlcs

Add a precision on trimmed htlcs, which can be failed as soon as the
commitment tx has been confirmed.

* proper logging of outgoing messages

It is also logical to make `Outgoing` a command of `Peer`. It should
have been done this way from the start if `Peer` had been a typed actor.

* fixed mixed up comments

Discovered this while working on #1838.

In the following scenario, at reconnection:
- `localCommit.index = 7`
- `nextRemoteRevocationNumber = 6`

So when `localCommit.index == nextRemoteRevocationNumber + 1` we must retransmit the revocation.

```
          local              remote
            |                   |
            |  (no pending sig) |
 commit = 6 |                   | next rev = 6
            |<----- sig 7 ------|
 commit = 7 |                   |
            |-- rev 6 --> ?     |
            |                   |
            |  (disconnection)  |
            |                   |
```
2021-10-18 15:31:16 +02:00
Pierre-Marie Padiou
b22b1cbea7
Fix API hanging on invalid remote params (#2008)
* reproduce bug causing API hang at open

In case of an error when validating channel parameters, we do not
return a message to the origin actor. That translates to API hanging
until timeout.

Took the opportunity to test return values in other cases too.

* return an error to origin actor for invalid params

* WaitForFundingCreatedInternal -> WaitForFundingInternal

* add tests to WaitForFundingInternalStateSpec

* add tests to WaitForFundingConfirmedStateSpec

* API nits

We probably don't need to print the stack trace for API errors, and the
open timeout of 10s was a bit short (it has to be << 30s though).
2021-10-18 15:06:14 +02:00
Victor Larsson
498e9a7db1
Remove CoinUtils.scala. (#2013)
Remove CoinUtils.scala since it is not used anymore. I think it is leftover from the gui.
2021-10-15 18:22:40 +02:00