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

1385 commits

Author SHA1 Message Date
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
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
thomash-acinq
df63ea4783
Deprecation warning for relay fees config (#2012)
Add deprecation warning for relay fees config and update release notes
2021-10-13 13:52:14 +02:00
Bastien Teinturier
57bf86044e
Back to Dev (#1993) 2021-10-08 09:58:47 +02:00
Bastien Teinturier
6817d6f26e
Eclair v0.6.2 release (#1992) 2021-10-08 09:21:34 +02:00
Bastien Teinturier
75eafd0e4d
Configure dust in flight threshold (#1985)
Add config fields for max dust htlc exposure.
These configuration fields let node operators decide on the amount of dust
htlcs that can be in-flight in each channel.

In case the channel is force-closed, up to this amount may be lost in
miner fees.

When sending and receiving htlcs, we check whether they would overflow
our configured dust exposure, and fail them instantly if they do.

A large `update_fee` may overflow our dust exposure by removing from the
commit tx htlcs that were previously untrimmed.

Node operators can choose to automatically force-close when that happens,
to avoid risking losing large dust amounts to miner fees.
2021-10-08 08:35:55 +02:00
Bastien Teinturier
bb5e6df186
Fix remote upfront script codec (#1991)
The script wasn't length-delimited.
Fortunately this feature was disabled by default.
Since no-one reported the issue, we can probably just do this simple fix.
2021-10-06 14:59:42 +02:00
Bastien Teinturier
0621ccfe0c
Fix ZmqWatcher block timeout (#1989)
Unfortunately, `context.log` is *not* thread safe and shouldn't be used
in future continuation. We should instead use `pipeToSelf` when we want
to act on the results of a `Future`.
2021-10-05 19:14:57 +02:00
Bastien Teinturier
d6b46aed4d
Update anchor outputs feerate tolerance (#1980)
Allow any feerate when using anchor outputs and we're fundee.
This will prevent unwanted channel closure.

This can be unsafe in a high fee environment if the commit tx is below
the propagation threshold. However, even when we discover it it's too late
anyway, so our only option is to wait for package relay to save the day.

Ensure feerate is always above propagation threshold when we're funder.
We lift the limit configured by the node operator when it is below the
network propagation threshold.
2021-10-04 17:28:08 +02:00
Bastien Teinturier
c803da670c
Store published txs in AuditDb (#1976)
We previously computed the on-chain fees paid by us after the fact, when
receiving a notification that a transaction was confirmed. This worked
because lightning transactions had a single input, which we stored in
our DB to allow us to compute the fee.

With anchor outputs, this mechanism doesn't work anymore. Some txs have
their fees paid by a child tx, and may have more than one input.

We completely change our model to store every transaction we publish,
along with the fee we're paying for this transaction. We then separately
store every transaction that confirms, which lets us join these two data
sets to compute how much on-chain fees we paid.

This has the added benefit that we can now audit every transaction that
we tried to publish, which lets node operators audit the anchor outputs
internal RBF mechanism and all the on-chain footprint of a given channel.
2021-10-04 16:06:17 +02:00
Bastien Teinturier
d0be2cf6e1
Log payment failure summary (#1966)
It's quite cumbersome to investigate complex MPP payment failures.
We need to grep on the parent ID, then group together logs for each child
payment, and then we're ready for some analysis.

Most of the time, a quick look at the breakdown of all intermediate failures
is all we need to diagnose the problem. This PR adds such a log line.
2021-10-04 15:10:12 +02:00
Pierre-Marie Padiou
73744ee440
Move path-finding examples to documentation (#1983)
Having basic documentation in-place by providing examples in
`eclair.conf` is great and very convenient, but in the case of
path-finding, defining experiments take so much space that it makes
the whole configuration file actually more complicated to understand.
And since we don't want to enable experiments by default, the user still
has to figure out what to change to actually enable AB-testing.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2021-10-04 10:29:27 +02:00
Pierre-Marie Padiou
3295881e48
Json serializers refactoring (#1979)
* make custom serializers objects instead of classes

* reorder json format definition

* use minimal serializers

Having custom serializers depend on external format would introduce an
infinite recursion at runtime if not careful. Thankfully, none of our
serializers use it, so we may as well remove the possibility entirely.

* simplify serializers further

We don't need to type the serializers: this is required for deserializing,
not serializing, and we are not using it.

The fact that be had a type mismatch here shows it:
```scala
object TransactionSerializer extends MinimalSerializer[TransactionWithInputInfo]
```

* new generic json serializer

Instead of providing a `MyClass => JValue` conversion method, we
provide a `MyClass => MyClassJson` method, with the assumption that
`MyClassJson` is serializable using the base serializers.

The rationale is that it's easier to define the structure with types
rather than by building json objects.

This also means that the serialization of attributes of class C is out
of the scope when defining the serializer for class C. See for example
how `DirectedHtlcSerializer` doesn't need anymore to bring in
lower level serializers.

It also has the advantage of removing recursion from custom serializers
which sometimes generated weird stack overflows.
2021-10-04 10:13:08 +02:00
Pierre-Marie Padiou
97393b13b4
Fix race condition in 'stream updates to front' test (#1978)
As usual, the race condition is due to a delay before subscribing to the event stream.
2021-09-30 18:02:30 +02:00
thomash-acinq
6dc836daa3
Ignore channels without capacity (#1975)
Channels with 0 capacity shouldn't exist. But if it happens somehow we should ignore them, not pretend that they are big channels.
2021-09-30 16:10:32 +02:00
Bastien Teinturier
5fc980c8d9
Lower minimum remote dust limit (#1900)
We are slowly dropping support for non-segwit outputs, as proposed in
https://github.com/lightningnetwork/lightning-rfc/pull/894

We can thus safely allow dust limits all the way down to 354 satoshis.

In very rare cases where dust_limit_satoshis is negotiated to a low value,
our peer may generate closing txs that will not correctly relay on the
bitcoin network due to dust relay policies.

When that happens, we detect it and force-close instead of completing the
mutual close flow.
2021-09-29 14:06:20 +02:00
thomash-acinq
467a0bc829
Count local fees in path finding metrics (#1963)
The fee that's recorded in the path-finding metrics should count the local channel. Without it we record failing payments with a fee budget larger than the fee recorded for the successful payment to the same node.
2021-09-27 17:51:41 +02:00
Pierre-Marie Padiou
5686ad013c
Minor changes and refactoring (#1965)
* optionally record path-funding metrics

This is useful in feature branches.

Also rename `recordMetrics` to `recordPathFindingMetrics`.

* rename channel features attribute

It was a remainder of init features, which can be activated or not. But
in the context of the `ChannelFeatures` object, that naming was
confusing because all features are activated in that context.

* minor refactoring on channel_type

Moved some logic outside `Peer`.

* refactor `RouteParams`

`PathFindingConf` and `RouteParams` have almost the same set of params,
but some of them don't have the same structure (flat vs hierarchical).
2021-09-23 17:40:20 +02:00
rorp
c846781192
Make Tor optional for blockchain watchdogs (#1958)
This change lets node operators disable the use of
Tor for blockchain watchdogs if they'd rather use
cleartext HTTP instead.
2021-09-22 09:18:58 +02:00
thomash-acinq
273fae9135
Add success probabilities in path finding (#1942)
Add an alternative heuristic for path finding that combines the relay fees with virtual fees for hops, funds locked and failed payments.
2021-09-20 18:48:53 +02:00
Bastien Teinturier
5b7a474b6a
Clean up inconsistency between bitcoin client and wallet (#1939)
The separation between `ExtendedBitcoinClient` and `BitcoinCoreWallet` has
become very blurry since anchor ouputs: eclair now requires fee bumping
utilities from the underlying bitcoin wallet, and it's not yet clear what
the interface should be. The on-chain utility methods that were added to
the eclair API also made it awkward to cleanly separate concerns.

We completely remove the `BitcoinCoreWallet` and merge it inside the
bitcoin client. We may in the future re-introduce a cleaner on-chain wallet
abstraction, but that can only happen once we have stable fee bumping
mechanisms.
2021-09-15 18:20:25 +02:00
Bastien Teinturier
fb0199c069
Update Bolt 11 official test vectors (#1870)
Add payment secrets (see https://github.com/lightningnetwork/lightning-rfc/pull/887)
Add feature bits (see https://github.com/lightningnetwork/lightning-rfc/pull/898)
2021-09-14 10:02:01 +02:00
Bastien Teinturier
a228baca71
Implement anchor outputs zero fee htlc txs (#1932)
Add support for https://github.com/lightningnetwork/lightning-rfc/pull/824

When the channel type is anchor outputs with zero fee htlc txs, we set
the fees for the htlc txs to 0.

An important side-effect is that it changes the trimmed to dust calculation,
and outputs that were previously dust can now be included in the commit tx.
2021-09-10 09:40:22 +02:00
Pierre-Marie Padiou
24dd6136f7
Fix the build (#1945)
* disable pg lock auto-release in tests

It relies on akka's coordinated shutdown and causes the test jvm to
halt.

* fixup! Remove  `messageFlags` from `ChannelUpdate` (#1941)
2021-09-09 17:35:03 +02:00
thomash-acinq
64f33bada4
Fix isNode1 in tests (#1944) 2021-09-09 15:45:45 +02:00
thomash-acinq
768a74558f
AB testing (#1930)
Add AB testing framework:
- Experiments are added by adding a section in router.path-finding config. Each experiment can have different parameters.
- Traffic is randomly split among the different experiments. The size of each experiment is configurable. 0% experiments don't affect traffic but can be triggered manually with the API.
- Metrics are recorded in the audit database
2021-09-09 14:17:37 +02:00
Pierre-Marie Padiou
6c546f06c0
Remove messageFlags from ChannelUpdate (#1941)
We make it a serialization detail, which it should be. The `derive`
method from `scodec` makes it very easy to do. We should probably always
use a dedicated class to handle flags, instead of using the `byte` codec
and binary operators.

This allows to remove the `require` in the `ChannelUpdate` definition,
which recently bit us in testing.

The only annoying thing is that we still need to expose a `messageFlags`
method in order to populate the `ChannelDisabled` error message.

We also typeify channel flags, as an alternative to passing around a `Byte`.
2021-09-09 13:25:25 +02:00
rorp
88f0dfd225
Make publising of onion addresses configurable (#1936)
When using Tor, your onion address is by default added to your
list of public addresses and advertised through the gossip layer
to allow peers to find your node and connect to it.

We now allow opting out of that mechanism by setting
`tor.publish-onion-address = false` in your `eclair.conf`.

This will ensure your onion address is not advertised, and peers
will not be able to connect to you unless you've connected to
them first.
2021-09-08 15:11:17 +02:00
Anton Kumaigorodski
632d40c270
Add AbstractChannelRestored event trait (#1927)
This lets plugins define variants of the `ChannelRestored` when
using non-standard channel types, while ensuring these channels
are correctly integrated in the list of local channels for payment
relaying.
2021-09-08 14:40:40 +02:00
Bastien Teinturier
663094e0bf
More flexible mutual close fees (#1768)
Add `closing_signed` `fee_range` TLV as described in
https://github.com/lightningnetwork/lightning-rfc/pull/847
We also refactor the negotiating state, add many tests and fix #1742.

Add new fields to the `close` API to let users configure their preferred
fees for mutual close.
2021-09-08 10:03:05 +02:00
Pierre-Marie Padiou
daace535c4
Dedicated event for channel_update modifications (#1935)
Use an event `ChannelUpdateParametersChanged` for the sole purpose of tracking changes to channel_update.

Also, conf change at restore is now treated like a regular fee update. We do handle `CMD_UPDATE_RELAY_FEES` in both `OFFLINE` and `SYNCING`, because there may be a race between `CMD_UPDATE_RELAY_FEES` and
`ChannelRestablish`. And there was no good reason to behave differently in those states anyway.

* fix updateRelayFee api call

The `Register` should be used to channel actors, not the `Router`.
The former tracks all channels, whereas the latter only contains
channels in certain states. We only query the `Router` when we need
reference to external (public) nodes and channels.
2021-09-03 18:45:05 +02:00
Pierre-Marie Padiou
9f9f10e911
Conversion nits (#1937) 2021-09-03 14:36:49 +02:00