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

1422 commits

Author SHA1 Message Date
Bastien Teinturier
065cb28aae
Add option to require confirmed inputs in interactive-tx (#2406)
If your peer uses unconfirmed inputs in the interactive-tx protocol, you
will end up paying for the fees of their unconfirmed previous transactions.

This may be undesirable in some cases, so we allow requiring confirmed
inputs only. This is currently set to false, but can be tweaked based on
custom tlvs or values in the open/accept messages.
2022-09-06 17:19:24 +02:00
Bastien Teinturier
611b79635e
More lenient interactive-tx RBF validation (#2402)
When fee-bumping an interactive-tx, we want to be more lenient and accept
transactions that improve the feerate, even if peers didn't contribute
equally to the feerate increase.

This is particularly useful for scenarios where the non-initiator dedicated
a full utxo for the channel and doesn't want to expose new utxos when
bumping the fees (or doesn't have more utxos to allocate).
2022-09-06 16:17:52 +02:00
Pierre-Marie Padiou
ee1136c040
Assume sent htlcs will succeed in the balance computation (#2410)
While it makes sense to assume that relayed payments will fail in the context of balance computation (meaning that we don't earn a fee), the opposite is true for payments sent from the local node, which will cause the full htlc amount to be deducted from the balance.

This way we are consistent: the balance computation is pessismistic and always assume the lowest outcome.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2022-09-06 10:44:35 +02:00
Pierre-Marie Padiou
3568dd6c17
Rework log capture in tests (#2409)
This PR enables capturing and printing logs for tests that failed, and is compatible with parallel testing. The core idea is to use a different `LoggerContext` for each test (see [logback's doc on context selection](https://logback.qos.ch/manual/contextSelector.html)).

Actual capture and printing of logs is realized through the same technique as Akka's builtin `LogCapture` helpers, that is: 
- a custom appender accumulates log events in memory
- a dedicated logger (defined in logback-test.xml and disabled by default) is manually called by the custom appender when logs need to be printed

I unfortunately had to introduce boilerplate classes `MyContextSelector`, `MySlf4jLogger` and `MyCapturingAppender`, the last two being tweaked versions of Akka's existing classes.

Note that the log capture is only enabled for tests that use `FixtureSpec`. The `ActorSystem` needs to be configured to log to `MySlf4jLogger`.

Advantages over existing technique:
- compatible with parallel testing
- no funny business with reflection in FixtureSpec.scala
- use configuratble logback formatting instead of raw println
- allows logging from lightning-kmp (depends on https://github.com/ACINQ/lightning-kmp/pull/355)

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2022-09-06 10:43:59 +02:00
Bastien Teinturier
40b2d44029
Remove support for legacy Sphinx payloads (#2190)
We previously supported a 65-bytes fixed-size sphinx payload, which has
been deprecated in favor of variable length payloads containing a tlv
stream (see https://github.com/lightning/bolts/pull/619).

It looks like the whole network now supports the variable-length format,
so we can stop accepting the old one. It is also being removed from the
spec (see https://github.com/lightning/bolts/pull/962).
2022-09-05 18:22:00 +02:00
Pierre-Marie Padiou
81af6192a8
(Minor) Ignore line ending when comparing strings in tests (#2403)
The test `ChannelCodecsSpec.backward compatibility older codecs (integrity)` uses reference json stored as text files. Depending on git settings and OS, the test may fail due to line ending differences.
2022-09-01 11:39:46 +02:00
Bastien Teinturier
c1daaf3acd
Check input out of bounds early in tx_add_input (#2393)
We need to validate early that a `tx_add_input` message can be converted
into an `OutPoint` without raising an out of bounds exception.

We also fix a flaky test on slow machines.
2022-08-23 16:42:54 +02:00
Bastien Teinturier
fb6eb485c4
Fix dual funding flaky test (#2392)
Nodes also asynchronously republish funding txs after a restart, but we
want to test the closing behavior so we ignore these events.
2022-08-23 10:37:23 +02:00
Bastien Teinturier
a735ba86b6
Dual funding RBF support (#2275)
Add support for bumping the fees of a dual funding transaction.
We spawn a transient dedicated actor: if the RBF attempt fails, or if we
are disconnected before completing the protocol, we should forget it.

Add more tests for scenarios where an unconfirmed channel is force-closed,
where the funding transaction that confirms may not be the last one.
2022-08-22 14:37:48 +02:00
Bastien Teinturier
ad19a665a1
Unlock utxos during dual funding failures (#2390)
When an alternative funding transaction confirms, we need to unlock other
candidates: we may not have published them yet if for example we didn't
receive remote signatures.
2022-08-19 18:56:00 +02:00
Bastien Teinturier
a97e88fae1
Dual funding channel confirmation (#2274)
Once we've exchanged signatures for the funding tx, we wait for it to
confirm.

Note that we don't allow mutual closing an unconfirmed channel, but that
is also the case for single-funded channels. We can improve that in the
future if necessary, but it is more efficient to double-spend an unconfirmed
channel rather than mutual close it.
2022-08-19 11:31:48 +02:00
Richard Myers
323aeec09c
Add support for the signet test network (#2387) 2022-08-19 11:15:05 +02:00
Bastien Teinturier
4e3b3774c3
Update route blinding test vectors (#2075)
To match the latest changes in https://github.com/lightning/bolts/pull/765
at commit aed5518a80aade56218da87f92e0a39963b660cf

The main change was the introduction of the `payment_relay`,
`payment_constraints` and `allowed_features` tlvs, with small
additional codec updates.
2022-08-17 14:13:30 +02:00
Bastien Teinturier
285fe97a77
Fix blinded path amount to forward calculation (#2367)
Apply @rustyrussell's neat truncating integer arithmetic formula to
calculate the amount that should be forwarded by blinded path nodes
instead of our previous approximation.
2022-08-17 11:16:19 +02:00
Richard Myers
bb6148e31c
Support DNS hostnames in node announcements (#2234)
It is now possible to specify a DNS host name as one of your
`server.public-ips` addresses.

DNS host names will not be resolved until eclair attempts to
connect to the peer.

See https://github.com/lightning/bolts/pull/911
2022-08-16 09:01:47 +02:00
Bastien Teinturier
33e6fac97b
Implement the interactive-tx protocol (#2273)
After exchanging `open_channel2` and `accept_channel2`, we start building
the funding transaction.

We stop once we've generated our signatures for the funding transaction,
at which point we should store the channel in the DB (which will be done in
future commits).
2022-08-12 16:16:58 +02:00
Bastien Teinturier
5f4f72031f
Remove legacy force-close htlc matching (#2376)
Before eclair v0.6.0, we didn't store a mapping between htlc_id and htlc
txs, which made it tricky to correctly remove identical htlcs that used
MPP during force-close, when an htlc tx was confirmed.

We have added that mapping since then and released it more than one year
ago, so we can now safely remove that code.
2022-08-12 11:56:58 +02:00
Bastien Teinturier
a13c3d5d6d
Prune channels if any update is stale (#2380)
We previously incorrectly pruned only once both channel updates were stale.
This was incorrect, we must prune channels as soon as one side becomes stale.

There are ~100 channels on the network today that have one inactive side,
while the other side regularly refreshes their channel update, but those
channels won't be usable for routing. They should eventually be closed,
but the active side is probably hoping for the inactive side to come back
online to get the opportunity to do a mutual close.
2022-08-11 17:18:40 +02:00
Bastien Teinturier
e8dda28eeb
Remove invalid channel updates from DB at startup (#2379)
Following #2361, we reject channel updates that don't contain the
`htlc_maximum_msat` field. However, the network DB may contain such
channel updates, that we need to remove when starting up.
2022-08-11 17:18:20 +02:00
Bastien Teinturier
2f590a80e2
Refactor routing hint failure updates (#2370)
This is a follow up of #2264 where we refactor handling of channel updates
in failures coming from routing hints.

For failures in one of the routing hints, we use the node_id pair (source,
destination) instead of the short_channel_id to identify the edge.
2022-08-11 11:32:43 +02:00
Bastien Teinturier
de1ac34d46
Add explicit duration to ExcludeChannel (#2368)
This lets callers override the default duration or ban channels for
unlimited durations (until they send a `ListChannelExclusion`).
2022-08-10 13:26:19 +02:00
Bastien Teinturier
0310bf5dc4
Implement first steps of the dual funding flow (#2247)
We implement the first step of the dual funding protocol: exchanging
`open_channel2` and `accept_channel2`.

We currently stop after exchanging these two messages. Future commits will
add the interactive-tx protocol used to build the funding transaction.
2022-08-09 17:13:16 +02:00
Pierre-Marie Padiou
f49eb0effe
Update sqlite to 3.39.2.0 (#2369)
This should fix an intermittent segfault, see:
- https://github.com/ACINQ/eclair/runs/7741716877
- https://github.com/xerial/sqlite-jdbc/issues/680
2022-08-09 14:31:03 +02:00
Pierre-Marie Padiou
9f9cf9ce0e
(Minor) Test improvements (#2354)
Note on log capture:
- akka version (`... with LogCapturing`): only works when tests are run sequentially (that is: useless on CI), otherwise outputs of all test are mixed together
- my version: separate between tests, but ugly formatting, because akka's `StdOutLogger` dosen't use logback settings.
2022-08-09 14:30:45 +02:00
Bastien Teinturier
c71c3b4046
Make htlc_maximum_msat mandatory in channel updates (#2361)
The specification is removing support for old channel updates that didn't
include an `htlc_maximum_msat` (https://github.com/lightning/bolts/pull/996).

Every implementation has been generating updates containing this field for
years, so we can safely reject updates that don't contain it.
2022-08-08 15:05:38 +02:00
Bastien Teinturier
85fea72720
Broadcast commit tx when nothing at stake (#2360)
When we have nothing at stake (channel was never used and we don't have
funds to claim), we previously directly went to the CLOSED state without
publishing our commitment. This can be an issue for our peer if they have
lost data or had a hard time getting a funding tx confirmed.

We now publish our commitment once to help them get their funds back in
all cases and avoid the CSV delays when getting their funds back.

Fixes #1730
2022-08-03 18:03:20 +02:00
Thomas HUET
8a42246b18
Update offers types (#2351)
Most notable changes:
- the node id is now 33 bytes like everywhere else
- blinded paths are mandatory in invoices
2022-07-27 10:44:21 +02:00
Bastien Teinturier
b171a1690f
Remove payments overview DB (#2357)
We introduced a way to get a "light" payments view in #1225.
This was a performance improvement for mobile wallets embedding eclair.

Mobile wallets should now use lightning-kmp instead of eclair, so we can
get rid of that unused code.
2022-07-26 15:16:20 +02:00
DerEwige
4fd3d90961
Emit event when receiving Pong (#2355)
This event can be useful to let plugins track the latency
of peer connections.
2022-07-26 14:52:16 +02:00
Thomas HUET
99d9bc181c
Relay blinded payments (#2253)
Allow relaying blinded payments (lightning/bolts#765)
2022-07-26 14:45:47 +02:00
Pierre-Marie Padiou
23de6c4efd
Fix flaky zeroconf test (#2352)
The flaky test was `ZeroConfAliasIntegrationSpec`.`a->b->c (b-c private)`.

Due to a race between node watchers, we were sometimes entering into
this scenario between bob and carol:

1) carol's watcher wins the race and sends her `channel_ready` to bob
  before bob has received `WatchFundingConfirmedTriggered` from his own
  watcher
2) the channel isn't officially zeroconf, but bob gladly accepts carol's
  early `channel_ready` and moves directly to `WAIT_FOR_CHANNEL_READY` and
  then `NORMAL`, *without a real scid*.
3) bob ignores the `WatchFundingConfirmedTriggered` that it receives in
  state `WAIT_FOR_CHANNEL_READY` or `NORMAL`
4) bob later receives the `WatchFundingDeeplyBuriedTriggered`, discovers
  his own real scid and emits a `ShortChannelIdAssigned` event, but the
  channel relayer only listens to `LocalChannelUpdate`.
5) subsequent a->b->c payment using a real scid for b-c as routing hint
  fails because b's relayer doesn't know it.

There are two ways of fixing this:

a) make the relayer listen to `ShortChannelIdAssigned` (like it did before)
b) emit a `LocalChannelUpdate` event containing the new real scid and
  the same `channel_update`.

In this commit, we chose to implement (b).

Co-authored-by: t-bast <bastuc@hotmail.fr>
2022-07-26 14:40:42 +02:00
Thomas HUET
214873e4a7
Use the correct extra edges to put in metrics (#2350)
We were using hints from `SendPaymentConfig.invoice` to populate `PathFindingExperimentMetrics`, but the invoice is optional and not populated for trampoline relay.
2022-07-22 16:06:41 +02:00
Thomas HUET
c20b3c9e8b
Remove redundant routing hint (#2349)
In `SendPaymentToNode`, the routing hints were present twice: once in `invoice` and once in `extraEdges`. I'm only keeping `invoice`.
Also make the `ExtraEdge` trait use `def` as there may be problems with `val`.
2022-07-22 14:16:25 +02:00
Barry G Becker
e1dc358c79
Fix RoutingHeuristics.normalize (#2331)
`RoutingHeuristics.normalize` could return 1, it now returns a value in (0, 1)
2022-07-04 14:05:12 +02:00
Pierre-Marie Padiou
31964620bd
Proper json serializer for BlockHeight (#2340)
It currently serializes to `{}`.
2022-07-01 17:46:54 +02:00
Bastien Teinturier
3b97e446aa
Allow disabling no-htlc commitment fee-bump (#2246)
When a channel force-close without any pending htlcs, funds are not at
risk. We want to eventually get our main output back, but if we are not
in a rush we can save on fees by never spending the anchors.

This is disabled by default as there is a potential risk: if the commit
tx doesn't confirm and the feerate rises, the commit tx may eventually be
below the network's min-relay-fee and won't confirm (at least until package
relay is available).
2022-07-01 16:04:41 +02:00
Pierre-Marie Padiou
2461ef08cb
Call resolve() on configuration (#2339)
From lightbend's config doc:

> A given Config must be resolved before using it to retrieve config values, but ideally should be resolved one time for your entire stack of fallbacks (see withFallback)

4458ea947a/config/src/main/java/com/typesafe/config/Config.java (L204-L206)
2022-07-01 15:36:30 +02:00
Bastien Teinturier
2790b2ff6c
Activate 0-conf based on per-peer feature override (#2329)
We restrict 0-conf activation on a per-peer basis. When 0-conf is activated
by both peers, we use it even if it wasn't part of the `channel_type`.
2022-07-01 15:13:57 +02:00
Bastien Teinturier
a1f7c1e74f
Return local channel alias in payment failures (#2323)
We now use either our local alias or the real scid in the channel update
that we store internally. When we send that channel update directly to
our peer, we override it to use the remote alias when it makes sense.
2022-07-01 15:13:26 +02:00
Bastien Teinturier
6011c867cf
Additive per-node feature override (#2328)
The `override-init-features` field in `eclair.conf` was not previously
applied on top of the `features` field, so node operators were usually
copy-pasting their `features` overrides in every `override-init-features`.

The overrides are now applied on top of the base `features` configuration,
which makes it easier and more intuitive to configure per-node features.
2022-07-01 14:33:14 +02:00
Pierre-Marie Padiou
8af14ac515
Backport from feature branches (#2326)
* improve bitcoin client metrics

* only use batching bitcoin client for the watcher

* use named args for defaultFromFeatures method

* use default min_depth in edge case scenario

* add OutgoingChannelParams trait

* update amounts in ChannelRelayerSpec

* make register take typed replyTo

* improve codecs non-reg tests
2022-06-29 16:11:05 +02:00
Thomas HUET
e880b62c13
Refactor routing hints to prepare for payments to blinded routes (#2315)
Bolt11 uses routing hints to add extra edges for the path-finding, blinded routes are also extra edges added to the path-finding but they have a different format. The new type `ExtraEdge` is more flexible and can be expanded to cover new kinds of extra edges such as blinded routes.
2022-06-29 16:08:37 +02:00
Pierre-Marie Padiou
c9810d5424
Resume reading after processing unknown messages (#2332)
If the current chunk of data read from the TCP connection only contains unknown messages (in particular, could be only one isolated unknown message on an otherwise idle connection), we never resumed reading on the connection.

This means all subsequent messages, including pings/pongs, won't be read, which is why the most visible effect is disconnecting due to no response to ping.

Related to https://github.com/ElementsProject/lightning/pull/5347.

Reported by @wtogami.
2022-06-29 15:12:04 +02:00
Pierre-Marie Padiou
08d2ad4a91
Random values for generateLocalAlias() (#2337)
We generate alias randomly, and use a value space large enough to not have to worry about duplicates.
2022-06-29 13:22:15 +02:00
Pierre-Marie Padiou
70de271312
Make actors signal when they are ready (#2322)
Since actors are initialized asynchronously, and the initialization sometimes involves subscribing to an `EventStream`, we don't know when they are ready to process messages, especially in tests, which lead to race conditions. By making actors publish `SubscriptionsComplete ` on the same `EventStream` they are subscribing to, we guarantee that if we receive `SubscriptionsComplete ` the actor has been initialized and its subscriptions have been taken into account.
2022-06-23 10:49:13 +02:00
Goutam Verma
6b2e415ecb
Expose scraping endpoint for prometheus metrics (#2321)
Allow eclair to expose a metrics scraping endpoint for Prometheus
for users who don't want to rely on Kamon's hosted infrastructure. 

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2022-06-16 17:52:57 +02:00
Pierre-Marie Padiou
26741fabca
Reuse postgres instance in tests (#2313)
Create new database for each unit test instead of spawning a new db
instance.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2022-06-16 17:50:16 +02:00
Bastien Teinturier
fc30eab0a0
Remove channelId from PublicChannel (#2324)
We can currently deduce the `channel_id` of a public channel because it
is based on the funding transaction coordinates, but that won't be the
case with dual-funding, where the `channel_id` will be private information
between the two channel peers.
2022-06-16 17:32:19 +02:00
Bastien Teinturier
6882bc9b2f
Clean up scid parsing from coordinates string (#2320)
We make it explicit that conversion from a string to an scid uses the tx
coordinates and can fail.

We also clean up compiler warnings in updated test files.
2022-06-16 13:04:21 +02:00
Pierre-Marie Padiou
7630c5169c
(Minor) Fix flaky ZeroConfAliasIntegrationSpec (#2319)
This build failure: https://github.com/ACINQ/eclair/runs/6901214111 was possibly caused by the register not yet having been notified of the real scid.
2022-06-16 10:44:23 +02:00