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

2451 commits

Author SHA1 Message Date
Bastien Teinturier
1f32652465
Add tlv to require confirmed inputs for dual funding (#2461)
Add tlv to require confirmed inputs in dual funding: when that tlv is specified,
the peer must use confirmed inputs, otherwise the funding attempt will be
rejected. This ensures that we won't pay the fees for a low-feerate ancestor.

This can be configured at two levels:

- globally using `eclair.conf`
- on a per-channel basis by overriding the default in `Peer.OpenChannel`
2022-10-19 17:24:55 +02:00
Thomas HUET
dd3d694b60
Remove onion message size limit (#2459)
We used to drop onion messages above a certain size, but the onion message packet is already limited to 65536 bytes so we only keep this larger limit instead.
2022-10-19 15:07:52 +02:00
Bastien Teinturier
c1a925db11
Use 0-conf based on local features only (#2460)
If we have activated 0-conf support for a given peer, we send our
`channel_ready` early regardless of whether our peer has activated support
for 0-conf. If they also immediately send their `channel_ready` it's great,
if they don't it's ok, we'll just wait for confirmations, but it was worth
trying.
2022-10-19 11:57:20 +02:00
Thomas HUET
a0433aa0c0
Fix flaky CommitmentsSpec test (#2458)
In case feeRatePerKw is high and liquidity is low on the initiator side, the initiator can't send anything and the test would fail because we try to create a HTLC for an amount of 0.
2022-10-18 12:35:44 +02:00
Thomas HUET
3b12475794
Make payment secret not optional (#2457)
Payment secret is already required for doing anything but the code was still using an option.
2022-10-18 10:06:48 +02:00
Thomas HUET
dad0a51b7c
Complete codec for TLV fields (#2452)
We currently accept some malformed TLVs with additional data that we ignore. This means that decoding and reencoding may give a different result.
With this change, we now reject such TLVs.

Also add the `.as[]` part of the codec inside `tlvField` so we can remove the redundant types annotations.
2022-10-10 17:04:18 +02:00
Thomas HUET
ca6869530e
Validate payment using minFinalExpiryDelta from node params (#2448)
Currently, for an incomming payment we check that the CLTV delta is larger than the minFinalExpiryDelta from the invoice. However with BOLT 12, invoices no longer contain a minFinalExpiryDelta (not yet visible in eclair code, BOLT 12 moves fast!). I suggest to use the minFinalExpiryDelta value from the node params instead.
Since we use this value for all the invoices we create, it doesn't change much. The only case where it would have an impact would be if we create an invoice, then shutdown, change the conf, restart, and only then someone tries to pay the invoice; in that case we would probably want to enforce the new conf anyway.
2022-10-10 09:52:05 +02:00
Bastien Teinturier
06ead3cf28
Add tlvField codec (#2439)
We previously duplicated `variableSizeBytesLong(varintoverflow, ...)`
whenever we wanted to work with a tlv field.

This was confusing and error-prone, so it's now factored into a specific
helper codec. We also remove the length-prefixed truncated int codecs,
as they are always used in tlvs and should simply use this new tlv field
codec instead.
2022-10-07 09:12:04 +02:00
dependabot[bot]
0de91f4523
Bump scala-library from 2.13.8 to 2.13.9 (#2444)
Bumps [scala-library](https://github.com/scala/scala) from 2.13.8 to 2.13.9.
- [Release notes](https://github.com/scala/scala/releases)
- [Commits](https://github.com/scala/scala/compare/v2.13.8...v2.13.9)

---
updated-dependencies:
- dependency-name: org.scala-lang:scala-library
  dependency-type: direct:production
...

* bump scala maven plugin to 4.7.2

* fix weird compilation error

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pm47 <pm.padiou@gmail.com>
2022-10-03 13:05:48 +02:00
Bastien Teinturier
6e381d4004
Fix availableForSend fuzz tests (#2440)
These two fuzz tests setup a random set of HTLCs and then try to send or
receive the maximum available amount. The initial HTLC setup may fail,
if the initial balances are too low.

It is hard to set those initial balances to ensure this will always work,
but since this will only rarely randomly happen, we should simply ignore
it (instead of failing the test).
2022-09-29 13:11:51 +02:00
Richard Myers
afdaf4619d
Add initial support for async payment trampoline relay (#2435) 2022-09-29 10:08:05 +02:00
Pierre-Marie Padiou
1b36697802
Fix duplicate SLF4J loggers in tests (#2436)
When using a custom logger for log capture in tests (with `akka.loggers=["fr.acinq.eclair.testutils.MySlf4jLogger"]`), we need to explicitly disable the "hardcoded" slf4j logger for akka typed, otherwise we will end up with duplicate slf4j logging (one through our custom logger, the other one through the default slf4j logger).

See the rationale for this hardcoded sl4j logger here: https://doc.akka.io/docs/akka/current/typed/logging.html#event-bus.
2022-09-26 15:36:20 +02:00
Bastien Teinturier
1b0ce802ec
Add support for push amount with dual funding (#2433)
When using dual funding, both sides may push an initial amount to the remote
side. This is done with an experimental tlv that can be added to `open_channel2`
and `accept_channel2`.
2022-09-26 15:06:08 +02:00
Pierre-Marie Padiou
3fdad68a5f
Remove channelReserve.getOrElse(0 sat) (#2432)
With the requirements added by #2430, we can get rid of the superfluous degrees of freedom around channel reserve, while still leaving the model untouched.
2022-09-26 10:48:41 +02:00
Pierre-Marie Padiou
b00a0b2004
Don't set channel reserve for dual funded channels (#2430)
In dual funded channels the reserve is computed automatically. But our model allows setting a reserve even for dual funded channels.

Changing the model is too much work, instead this PR proposes to:
- add `require`s in the `Commitments` class to verify at runtime that we are consistent (it would cause the channel to fail before it is created)
- pass the `dualFunded` status to `Peer.makeChannelParams` so we only build valid parameters.

We could also alter the handlers for `SpawnChannelnitiator`/`SpawnChannelNonInitiator` and mutate the `LocalParams` depending on the value of `dualFunded`. It is less intrusive but arguably more hacky.
2022-09-23 10:09:12 +02:00
Bastien Teinturier
ba2b928ead
Add tests for invoice feature validation (#2421)
Add non-reg tests to ensure that we only validate invoice features,
and correctly refuse to pay invoices containing unsupported mandatory
features.
2022-09-16 10:40:52 +02:00
Thomas HUET
3191878685
Allow receiving to blinded routes (#2418)
Enable receiving blinded payments.
Unroll the dummy hops at the end of a blinded route.
2022-09-14 10:32:05 +02:00
Bastien Teinturier
9d17b1dfc1
Receive payments for Bolt 12 invoices (#2416)
When creating a blinded route, we expose the last blinding point (that the
last node will receive).  This lets the recipient derive the corresponding
blinded private key, which they may use to sign an invoice.

We add support for generating Bolt 12 invoices and storing them in our
payments DB to then receive blinded payments.

We implement the receiving part once a blinded payment has been decrypted.
This uses the same payment flow as non-blinded payments, with slightly
different validation steps.

Note that we put a random secret in the blinded paths' path_id field
to verify that an incoming payment uses a valid blinded route generated
by us. We store that as an arbitrary byte vector to allow future changes
to this strategy.
2022-09-13 15:25:10 +02:00
Bastien Teinturier
09f1940333
Implement latest route blinding spec updates (#2408)
Add InvalidOnionBlinded error and translate downstream errors when
we're inside a blinded route, with a random delay when we're the
introduction point.

Add more restrictions to the tlvs that can be used inside blinded payloads.

Add route blinding feature bit and reject blinded payments when
the feature is disabled.
2022-09-12 17:47:17 +02:00
Bastien Teinturier
59f6cdad4c
Separate tlv decoding from content validation (#2414)
* Separate tlv decoding from content validation

When decoding a tlv stream, we previously also validated the
stream's content at decoding time. This was a layer violation,
as checking that specific tlvs are present in a stream is not
an encoding concern.

This was somewhat fine when we only had very basic validation
(presence or absence of specific tlvs), but blinded paths
substantially changed that because one of the tlvs must be
decrypted to yield another tlv stream that also needs to have
its content validated.

This forced us to have an overly complex trait hierarchy in
PaymentOnion.scala and expose a blinding key in classes that
shouldn't care about whether blinding is used or not.

We now decouple that into two distinct steps:

* codecs simply return tlv streams and verify that tlvs are
  correctly encoded
* business logic case classes (such as ChannelRelayPayload)
  should be instantiated with a new `validate` method that
  takes tlv streams and verifies mandatory/forbidden tlvs

This lets us greatly simplify the trait hierarchy and deal
with case class that only contain fully decrypted and valid
data.

* Improve tests

There was redundancy in the wrong places: route blinding codec tests were
testing route blinding decryption and were missing content validation.

We also change the behavior of the route blinding decode method to return
the blinding override when present, instead of letting higher level
components duplicate that logic.

* Use hierarchical namespaces

As suggested by @pm47

* Small PR comments

* Remove confusing comment
2022-09-12 13:06:21 +02:00
Pierre-Marie Padiou
517c0fde6e
Fix collision bug in local alias generation (#2415)
The bug is due to mistakingly using the `^` as power operator, while it instead is a `xor`. As a result, the available space for local alias was tiny, resulting in collisions. This in turns causes the `relayer` to forward `UpdateAddHtlc` to the wrong node, which results in `UpdateFailMalformed` error due to the peers being unable to decrypt the onion that wasn't meant for them.
2022-09-08 12:58:24 +02:00
Pierre-Marie Padiou
40b83a7eed
Nits (#2413)
This includes a backward-incompatible change in codecs for akka cluster.
Front and back need to be updated simultaneously.
2022-09-07 13:17:33 +02:00
Pierre-Marie Padiou
7c8a777572
Add a ChannelOrigin placeholder (#2411)
May be useful in feature branches.
2022-09-06 17:26:04 +02:00
Bastien Teinturier
37863a41d7
Use deterministic serial IDs in interactive-tx (#2407)
We previously generated random values, but the randomness doesn't protect
against anything and adds a risk of re-using the same serial ID twice.

It's a better idea to just increment serial IDs (while respecting the
parity spec requirement).
2022-09-06 17:23:54 +02:00
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
Goutam Verma
a4faa908a1
Add eclair metrics grafana dashboard (#2343)
Add a basic dashboard showcasing some important eclair
metrics that node operators should be monitoring.
2022-08-22 17:32:34 +02:00
Goutam Verma
278f391a54
Add akka metrics grafana dashboard (#2347)
Add a basic dashboard showcasing some important akka
metrics that node operators should be aware of.
2022-08-22 15:09:04 +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
8f2028f600
Limit default from and to API parameters (#2384)
When not provided, we previously used unrestricted `from` and `to`
parameters when reading from the DB. This can create issues when
accidentally reading too much data.

We now limit this to the last 24 hours, unless explicitly set by the
caller. Note that when reading a lot of data, it's recommended to use
postgres and read from a replica to ensure there's no impact on the running
eclair instance.

Fixes #2383
2022-08-17 16:57:22 +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