1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 02:27:32 +01:00
Commit Graph

735 Commits

Author SHA1 Message Date
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
Donovan
e6909cfcb5
Implement the KeySend feature, spontaneous payments (#1485)
Support for receiving and sending KeySend payment is added.

For an explanation of the KeySend feature see: https://github.com/ElementsProject/lightning/pull/3611
2020-07-21 16:30:03 +02:00
Bastien Teinturier
625e996ae0
Update MinFinalCltvExpiryDelta default value and activate wumbo (#1483)
* Activate wumbo by default

This is safe as `max-funding-satoshis` is set to 16777215 sats, which is
the non-wumbo limit.

If users want to increase the maximum channel size, they can update this
configuration value.

* Update default minFinalCltvExpiryDelta

See https://github.com/lightningnetwork/lightning-rfc/pull/785

* Set minFinalCltvExpiryDelta in invoices

Our default fulfill-safety-window is now greater than the spec's default
min-final-expiry-delta in invoices, so we need to explicitly tell payers
what value they must use.

Otherwise we may end up closing channels if a block is produced while we're
waiting for our peer to accept an UpdateFulfillHtlc.
2020-07-21 14:37:59 +02:00
Bastien Teinturier
92a094c498
Anchor output transaction format (#1484)
* Introduce transaction commitment format trait

This lets us re-use most of our existing transaction utilities for
anchor outputs.

Channels will always use the default commitment format (current spec),
but we will be able to change that by setting the `ChannelVersion` to
something appropriate for anchor outputs (and later other commitment formats).

* Clean up transaction tests

Remove obsolete claim-htlc tests: they used a different format from what
lightning uses and are redundant with existing tests in TransactionsSpec.

Add missing test cases in TransactionsSpec.

* Implement anchor outputs commitment transaction

Add support for creating an anchor outputs commitment transaction,
without any HTLC.

Support for the new HTLC format will be added in a separate commit.

* Refactor TestVectorsSpec

For anchor outputs, some values will not match the hard-coded ones.
We will instead need to read from the test vector.

* TestVectorsSpec filter unimplemented anchor outputs

Anchor outputs isn't fully implemented yet, so we need to ignore the tests
that are currently not passing.

* Implement anchor outputs HTLC transactions

Add support for HTLC transactions with a 1-block relative delay.
Add missing anchor outputs spec tests.
Add missing tests for some revoked paths.

* Always subtract both anchors from funder amount

For simplicity's sake, we always subtract both anchors from the funder's
main output, even if only one anchor materializes.
2020-07-21 11:36:02 +02:00
Fabrice Drouin
ea57bb266c
Release 0.4.1 (#1481)
* Set version to 0.4.1

* Set version to 0.4.2-SNAPSHOT
2020-07-20 12:00:01 +02:00
Pierre-Marie Padiou
65facab141
Add debug logs to transport handler (#1488) 2020-07-17 16:35:31 +02:00
Pierre-Marie Padiou
e06325e03b
fixup! Split the Peer in two (#1347) (#1487) 2020-07-17 15:09:28 +02:00
Bastien Teinturier
ebfca8cefd
Bitcoin Core Wallet small refactoring (#1482)
Shuffle methods around between ExtendedBitcoinClient and
BitcoinCoreWallet to help readability and separate concerns.

Add some documentation and fix harmless warnings.
Add bitcoin client tests.
2020-07-09 18:12:07 +02:00
Bastien Teinturier
adf4da623d
Handle invoices with 0 amount (#1480)
We handled empty amounts (field not specified at all) but not the case
where the amount was specified and equal to 0.

Fixes #1478
2020-07-02 12:07:05 +02:00
Bastien Teinturier
23b5fb9404
Fix commitments fuzz test (#1479)
We must not let feeratePerKw be 0, otherwise we trigger FeerateMismatch
errors which isn't what we want to test.
2020-07-02 10:25:23 +02:00
Bastien Teinturier
26fdc62dab
Update backup handler and add DB metrics (#1475)
* Non blocking bounded mailbox for backup handler

Akka 2.4 introduced a non-blocking unbounded mailbox.
It makes sense to upgrade the backup handler to that mailbox type.

We also add some backup-related metrics.

* Wrap DB calls to record metrics

We record the number of times each operation is executed and its
duration.
2020-07-02 09:01:45 +02:00
Pierre-Marie Padiou
ae3d396413
Remove the command buffer (#1476)
When we receive an `UpdateFulfillHtlc` from a downstream channel, it is
critical that we don't lose it because that is what allows us to pull
funds from the corresponding upstream channel(s). But this(ese) upstream
channel(s) may very well be currently OFFLINE and unable to update the
commitment right away, so we need to remember it for later. Same applies
to an `UpdateFailHtlc` (although it is less critical), because we don't
want the upstream htlc to timeout and cause a channel to force-close.

We were previously relying on a `CommandBuffer` actor, that uses a
"pending relay" database to store commands. Once the command is processed
by the target channel, it sends back an acknowledgment to the
`CommandBuffer`, which then removes the command from the database.
Unacknowledged commands are replayed at each reconnection or app restart.
This works well, but the flow is a little cumbersome and not easy to
understand.

With this PR, the sender (channel, payment handler, ...) is responsible for
storing commands to the pending relay db, instead of the command buffer,
which is completely removed. The target channel will acknowledge the
message and remove it from the pending relay db.

In the end, the logic is the same as before, we have just dropped the
intermediate `CommandBuffer`.
2020-07-01 16:41:27 +02:00
rorp
b63c4aa5a4
Postgresql support (#1249)
Add beta support for PostgreSQL database backend.
2020-07-01 14:52:36 +02:00
Bastien Teinturier
68dfc6cb7c
Rework feerate mismatch (#1473)
* Split feerate mismatch configuration

We want to be much stricter with feerates that are below our estimation
than feerates that are above it.

This also makes this configuration parameter easier to understand
for end users.

* Tolerate feerate mismatch while channel is unused

We can relax the conditions where we close a channel because of a feerate
mismatch: when the channel has no pending HTLCs, it's ok to temporarily
disagree on the feerate.

While we disagree on feerates, we don't use this channel to offer outgoing
HTLCs. If we receive an incoming HTLC, we have to close the channel because
that HTLC would be at risk (incorrect feerate).

This mechanism gives us time to adapt to feerate changes, hopefully reducing
the amount of unnecessary channel closures.
2020-07-01 14:45:05 +02:00
Bastien Teinturier
7ec3ba829a
Fix channelstats (for real?) (#1470)
The channelstats API only returns results for the *outgoing* channels
used when relaying. We must also include the *incoming* channels, otherwise
it looks like they're inactive which doesn't reflect their real usage.

Fixes #1465
2020-06-30 17:11:04 +02:00
Fabrice Drouin
5a83d2f8de
Fix transaction fee test (#1454)
- Test was not executed (because the "tests" variable was an iterator that was emptied by the call to .size())
- HTLC regex had to be updated to skip over the HTLC number that was added to the reference test vectors
2020-06-26 10:25:24 +02:00
Pierre-Marie Padiou
85163cb356
Add context logging to route request (#1469) 2020-06-24 11:54:08 +02:00
Bastien Teinturier
6d9dbb8612
Onion payload and HTLC in-flight metrics (#1464)
* Add metric to track onion payload format

This will be useful to decide when we can safely phase out support for
the legacy format.

* Add metric to track htlcs in flight

We track both the number of HTLCs and their amounts.
We track this at the channel level and globally.
2020-06-24 11:30:04 +02:00
Bastien Teinturier
0619b202e5
Clarify trampoline route not found error (#1455)
If all trampoline retries fail, we should convert the error to a route
not found. We tried multiple fee targets and none of those was enough to
allow the trampoline node to find a satisfying route.
2020-06-23 15:52:31 +02:00
Bastien Teinturier
0563d6d6ce
Update allnodes API (#1468)
Rename to `nodes`.
Allow filtering for specific `nodeId`s.

Fixes #1460
2020-06-23 15:28:48 +02:00
Bastien Teinturier
88cb24dc81
Routing hints balance (#1443)
* Ignore routing hints for our own channels
* Update graph when private channel balance changes
2020-06-23 15:23:39 +02:00
Bastien Teinturier
365d0916df
More aggressive channel exclusion (#1441)
* Exclude channels in last payment attempt
* Exclude disabled routing hints
2020-06-23 15:14:11 +02:00
Bastien Teinturier
4199128965
MPP preimage received event (#1445)
MPP lifecycle shares preimage as soon as received.

This allows removing the use of the node-relayer as a passthrough for
fulfills, it can now simply listen to this event.

Long term, this could be sent to the event stream to share with more actors.
2020-06-23 14:57:28 +02:00
Bastien Teinturier
d9f257ada3
Multipart FSM v2 (#1439)
* PaymentLifecycle cleanup

Remove temporary hooks added for first version of MPP (route prefix,
empty routes, etc).

Allow specifying the whole route (not only nodeIds) in SendPaymentToRoute.

* Rework MultiPartPaymentLifecycle

Use the Router's new MPP RouteRequest.
Remove the "blind" split based on channel balances.
Reactivate trampoline relay to MPP non-trampoline recipient.

* Add MPP payment metrics

* Activate MPP feature by default
2020-06-23 11:44:11 +02:00
Dominique
928d47cd84
Add a fee provider saving feerates to database (#1450)
This provider will save the feerates retrieved by another provider to 
database.

This feature can be used to retrieve the last used feerates when starting 
the node, which will save time. This can have a significant effect on nodes 
running with a slow connection (e.g. mobile devices).

Note that this commit does not affect the current setup and does not
actually create the database, the feature must be implemented separately.

Fixes #1447
2020-06-22 18:31:45 +02:00
Pierre-Marie Padiou
6c81f95644
Use length-delimited byte-aligned codecs (#1442)
Legacy codecs are isolated in a separate file, with a visibility restricted to "package" in order to reduce the risk of using those codecs. Also codecs are restricted to `decodeOnly` for the same reason.
2020-06-22 18:03:08 +02:00
Bastien Teinturier
d5ec6a56e8
Increase fulfill safety window (#1466)
Increase fulfill safety window
Improve comments and explanations in various places.
2020-06-22 11:07:55 +02:00
Pierre-Marie Padiou
e07a8ecff2
Static key refactoring (#1463)
* localPaymentBasepoint->staticPaymentBasepoint

Use `getOrElse` on the option value to decide between static/dynamic
payment point, instead of the `ChannelVersion` bit.

* define explicit method to test channel features

Also reduce visibility of a few members of `ChannelVersion`, and some
cleanup.

* use `if/else` instead of `match` for version bit
2020-06-22 10:49:40 +02:00
Bastien Teinturier
c52508d216
Find multi part route (#1427)
Leverage Yen's k-shortest paths and a simple split algorithm
to move MPP entirely inside the Router.

This is currently unused, the multipart payment lifecycle needs
to be updated to leverage this new algorithm.
2020-06-22 10:08:57 +02:00
Bastien Teinturier
676a45c19c
Add on-chain APIs (#1461)
* Add on-chain balance API: fixes #1457
* Add API to list wallet on-chain transactions: fixes  #1459
* Add API to send on-chain funds: fixes #1458
2020-06-19 18:02:39 +02:00
Bastien Teinturier
570fe57baa
Add friendly network name to GetInfo response (#1456)
This is friendlier to interpret than mapping this from the chain's genesis
block hash.
2020-06-19 16:07:08 +02:00
Pierre-Marie Padiou
59ea4cd606
Put back DATA_CLOSING constraints (#1462)
We go to the `CLOSING` if and only if the funding tx has been spent by
one transaction. The `require` is absolutely necessary. We could
probably enforce this constraint at the compilation level by more clever
typing but that's another matter.
2020-06-19 12:02:56 +02:00
Bastien Teinturier
50290d9481
Monitor on-chain feerate mismatch (#1453) 2020-06-18 08:59:49 +02:00
Bastien Teinturier
2461e3a32c
Fix channelstats API (#1451)
It should return stats for all channels (funder and fundee).
The previous code was incorrectly filtering on channels for which we paid
an on-chain fees, excluding the channels for which we were fundee.

Fixes #1449.
2020-06-09 12:22:53 +02:00
Bastien Teinturier
4cfb7d94ac
Fix edges with empty capacity in the routing graph (#1446)
Light clients don't always validate channels by fetching the blockchain tx.
That means they don't have access to the exact capacity.
When that happens, we can fallback to htlc_maximum_msat if
available, or to a default capacity (otherwise path-finding will ignore
these edges).
2020-06-05 17:00:47 +02:00
araspitzu
dc364a1996
Implement option_static_remotekey (#1141)
* Add feature option_static_remotekey

* Update transactions RFC test vectors for option_static_remotekey
2020-06-05 16:01:43 +02:00
Bastien Teinturier
c04a4cef2a
Accept multiple channels for some API (#1440)
It's handy to update relay fees for multiple channels at once.
Closing and force-closing channels may also make sense to do in batch.

Closes #1432
2020-06-03 11:06:45 +02:00
Bastien Teinturier
2e79ccaf3f
Correctly set new channel balance (#1431)
When we announce a new public channel, make sure we don't override the
balance information with None.

Clean up IntegrationSpec warnings.

Fix PaymentLifecycle test: this test was broken by the recent changes in
BaseRouterSpec.
2020-05-26 16:04:10 +02:00
Fabrice Drouin
e0320da383
Electrum: stop spamming logs (#1433)
* Electrum client: downgrade log-level for errors that happened before a proper handshake

We only care for errors that we received during or after the "handshake" (i.e. the exchange of "version" messages).
Other errors cause by dead/unresponsive servers... which are very common on testnet just add spams to the logs.

* Electrum client pool: downgrade log level for errors with our secondary servers

We care for errors with our master electrum servers.

* Update Electrum checkpoints
2020-05-26 11:48:44 +02:00
Bastien Teinturier
ce3629c98b
Compute max fee before route calculation (#1417)
Move the maximum fee computation outside of `findRoute`: this should be
done earlier in the payment pipeline if we want to allow accurate fee control
for MPP retries.

Right now MPP uses approximations when retrying which can lead to payments
that exceed the maximum configured fees. This is a first step towards
ensuring that this situation cannot happen anymore.
2020-05-20 10:55:44 +02:00
Bastien Teinturier
ad44ab3631
Path finding standard collections (#1428)
* Replace ArrayDeque by Queue

This is clearly not a hot path. This collection will have less than
10 elements and the bottleneck is rather on the dijkstra call.

ArrayDeque doesn't exist in Scala 2.11 so it makes the merge to
eclair-mobile more cumbersome.

* Use standard Scala collections in Dijkstra

Collections performance has improved greatly in Scala 2.13.
This change yields a consistent 10% improvement compared to the previous
implementation on my laptop based on the mainnet graph.
2020-05-20 10:51:32 +02:00
araspitzu
029cafe297
Use human readable features in configuration (#1385)
* Parse human readable features from configuration, print features in human readable format.
2020-05-19 13:58:19 +02:00
Pierre-Marie Padiou
c01031708d
Fix race condition on early connection failure (#1430)
Both `Client` and `TransportHandler` were watching the connection actor,
which resulted in undeterministic behavior during termination of
`PeerConnection`.

We now always return a message when a connection fails during
authentication.

Took the opportunity to add more typing (insert
deathtoallthestring.jpg).
2020-05-19 12:45:53 +02:00