1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 10:39:19 +01:00
Commit Graph

1299 Commits

Author SHA1 Message Date
Pierre-Marie Padiou
99566f525c
Disconnect peer after a timeout when waiting for revocation (#761)
* added a revocation timeout

If a peer doesn't quickly reply to a `commit_sig`, we assume that it is
experiencing technical issues, and we disconnect. This will make pending
(unsigned) `update_add_htlc` to be fast-failed and will hopefully limit
the number of htlc that time out in the network.

By default we wait 20 seconds, configurable with
`eclair.revocation-timeout`.

This fixes #745.
2018-12-07 14:49:51 +01:00
rorp
fadfabfd33 Wait for Router to be initialized at startup (#769) 2018-12-04 15:37:52 +01:00
Pierre-Marie Padiou
1c0e24a909
Watch future remote commit on restore (#766)
We need to put back watches on restart in "future remote commit published" scenarii, otherwise we will never consider the channel closed if we restart before the "claim main output" tx is confirmed. Note that there was no risk of losing funds, but the channel would have lingered forever.
2018-11-23 16:38:07 +01:00
Pierre-Marie Padiou
fa1b2e4c00
Switch sttp backend async-http-client -> okhttp (#764)
Okhttp works better on Android.
2018-11-23 11:58:23 +01:00
Anton Kumaigorodski
65a854caf3 Disconnect peer if it does not reply to pings (#755)
* Also ignore invalid pings
2018-11-20 14:03:46 +01:00
n1bor
738b4fa8e9 Reject received payments where PaymentRequest Expiry Tag time has been exceeded. (#749)
This fixes #748.

Also renamed htlc `expiry` to `cltvExpiry`. This removes confusion between different types of expiries and is how the spec is written.
2018-11-15 14:08:27 +01:00
Jens Schendel
93464aa7fb Updated readme.md and eclair-cli (#750)
* Minor changes. Typos and grammar corrected.

* Added check for curl and hint ift not installed
2018-11-13 17:35:16 +01:00
Pierre-Marie Padiou
2de7c6b07d
Use sttp lib instead of akka-http-client (#720)
Also updated json4s-jackson to 3.6.0
2018-10-25 16:45:27 +02:00
Fabrice Drouin
5141cd7d4d
Use different ZMQ block and tx subscriptions
Fixes #733
2018-10-25 14:28:28 +02:00
Dominique
3a221e7e98
Support for custom Electrum server (#739)
We can now use the `overrideDefaults` parameter in `Setup` to programmatically 
provide a custom electrum address when starting eclair, by setting the 
`eclair.electrum.host` and `eclair.electrum.port` entries in the configuration.

When these entries are set, eclair-core will always try to connect to this server
instead of relying on a random server picked from the preset lists.
2018-10-23 19:07:20 +02:00
Pierre-Marie Padiou
2bdf258c78
Always add 1 block to the finalCltvExpiry (#742)
This fixes #651.
2018-10-23 17:31:22 +02:00
sstone
4e0702a923
set version to 0.2-SNAPSHOT 2018-10-20 21:38:16 +02:00
sstone
52821b8664
set version to 0.2-beta8 2018-10-20 21:34:34 +02:00
Fabrice Drouin
6126ed4b9e
Fix encoding of FinalIncorrectHtlcAmount error message (#740) 2018-10-19 17:58:20 +02:00
Pierre-Marie Padiou
c77c276c77
Add htlcMaximumMsat field to ChannelUpdate message (#738)
* Add `htlcMaximumMsat` field to `ChannelUpdate` message

* added compatibility test with c-lightning
2018-10-19 17:47:13 +02:00
sstone
b0305b0551
set version to 0.2-SNAPSHOT 2018-10-15 17:00:40 +02:00
sstone
c564f51d24
set version to 0.2-beta7 2018-10-15 16:48:13 +02:00
Pierre-Marie Padiou
22b6bfb0ab
Only persist trimmed htlcs (#724)
We persist htlc data in order to be able to claim htlc outputs in
case a revoked tx is published by our counterparty, so only htlcs
above remote's `dust_limit` matter.

Removed the TODO because we need data to be indexed by commit number so
it is ok to write the same htlc data for every commitment it is included
in.
2018-10-15 14:46:51 +02:00
Fabrice Drouin
ac791d955d
Add instructions for Bitcoin Core 0.17.0 [ci skip] (#732)
* Add instructions for Bitcoin Core 0.17.0 [ci skip]

Bitcoin Core 0.17.0 deprecates the `signrawtransaction` RPC call, which will be removed in version 0.18.0, you need to enable this call if you want your eclair node to use a 0.1.70 node.

* README: add an example of how to use the new bitcoin.conf sections [ci skip]
2018-10-15 14:28:19 +02:00
Pierre-Marie Padiou
892770b1ed
Update scalatest and remove junit runner (#728)
* updated to scalatest 3.0.5

* use scalatest runner instead of junit

Output is far more readable, and makes console (incl. travis) reports
actually usable.

Turned off test logs as error reporting is enough to figure out what
happens.

The only downside is that we can't use junit's categories to group
tests, like we did for docker related tests. We	could use nested suites,
but that seems to be overkill so I just removed the categories. Users
will only have the possibility to either skip/run all tests.

* update scala-maven-plugin to 3.4.2

NB: This requires maven 3.5.4, which means that we currently need to
manually install maven on travis.

Also updated Docker java version to 8u181 (8u171 for compiling).
2018-10-11 19:01:41 +02:00
Fabrice Drouin
d490480b7e
Simplify bitcoind version check (#731)
Bitcoind returns version as MMmmrr (major, minor, revision), use an int representation
and compare it to our minimum version target.
2018-10-11 18:54:12 +02:00
sstone
997aceea82
set version back to 0.2-SNAPSHOT 2018-09-26 14:05:57 +02:00
sstone
3fc5da0a7b
set version to 0.2-beta6 2018-09-26 14:04:38 +02:00
Fabrice Drouin
b07bb2a39e
Logging: use a rolling file appender (#721)
* Logging: use a rolling file appender

Use one file per day, keep 90 days of logs with a total maximum size
capped at 5 Gb

* Router: log routing broadcast in debug level only
2018-09-24 20:00:36 +02:00
Pierre-Marie Padiou
f38748c0b6
Fixed regression caused by 7a4f175 (#722)
When updating relay fee in state OFFLINE, the new channel_update must
have the disabled flag on.

This caused tests to be flaky, added necessary checks to always make
them fail in case that kind of regression happens again.
2018-09-24 19:41:27 +02:00
Pierre-Marie Padiou
7a4f175f2f
Handle update relay fee in OFFLINE state (#719)
Previously it was only possible to update relay fee in NORMAL state,
which is not very convenient because most of the time there are always
some channels in OFFLINE state.

This works like the NORMAL case, except that the new `channel_update`
won't be broadcast immediately. It will be sent out next time the
channel goes back to NORMAL, in the same `channel_update` that sets the
`enable` flag to true.

Also added a default handler that properly rejects the
CMD_UPDATE_RELAY_FEE command in all other states.
2018-09-24 13:59:01 +02:00
Pierre-Marie Padiou
83b00e37f4
Improved eclair-cli (#718)
This fixes #695, and also adds the channel point in the default channel output.

```bash
$ ./eclair-cli channel 00fd4d56d94af93765561bb6cb081f519b9627d3f455eba3215a7846a1af0e46
{
  "nodeId": "0232e20e7b68b9b673fb25f48322b151a93186bffe4550045040673797ceca43cf",
  "shortChannelId": "845230006070001",
  "channelId": "00fd4d56d94af93765561bb6cb081f519b9627d3f455eba3215a7846a1af0e46",
  "state": "NORMAL",
  "balanceSat": 9858759,
  "capacitySat": 10000000,
  "channelPoint": "470eafa146785a21a3eb55f4d327969b511f08cbb61b566537f94ad9564dfd00:1"
}
```
2018-09-24 11:49:05 +02:00
Pierre-Marie Padiou
8160e793e7
Make publishTransaction idempotent (#711)
Bitcoin core returns an error `missing inputs (code: -25)` if the tx that we want to publish has already been published and its output have been spent. When we receive this error, we try to get the tx, in order to know if it is in the blockchain, or if its inputs were spent by another tx.

Note: If the outputs of the tx were still unspent, bitcoin core would return "transaction already in block chain (code: -27)" and this is already handled.
2018-09-20 17:22:38 +02:00
Fabrice Drouin
6f2a74e030
Tests: use bitcoind 0.16.3 (#715)
Bitcoind 0.16.0 is no longer available
2018-09-20 16:37:57 +02:00
Pierre-Marie Padiou
8d2ec18557
Replace update_fee in commitments (#709)
This is a simple optimisation, we don't have to keep all `update_fee`, just the last one.

cf BOLT 2:
> An update_fee message is sent by the node which is paying the Bitcoin fee. Like any update, it's first committed to the receiver's commitment transaction and then (once acknowledged) committed to the sender's. Unlike an HTLC, update_fee is never closed but simply replaced.
2018-09-20 16:18:17 +02:00
Fabrice Drouin
f3d11cf098
Fix handling of born again channels (#717)
* Fix handling of born again channels

When we receive a recent update for a channel that we had marked as stale we
must send a query to the underlying transport, not the origin of the update (which
would send the query back to the router)
2018-09-20 16:17:15 +02:00
Pierre-Marie Padiou
9178b5aa38
Ignore 'origin htlc not found' in CLOSING (#708)
If we don't have the origin, it means that we already have forwarded the fulfill so that's not a big deal.

This can happen if they send a signature containing the fulfill, then fail the channel before we have time to sign it.
2018-09-20 16:12:38 +02:00
Fabrice Drouin
512c9823b4
Routing sync fixes (#712)
* Router: reset sync state on reconnection

When we're reconnected to a peer we will start a new sync process and should reset our sync
state with that peer.
2018-09-19 17:35:21 +02:00
Pierre-Marie Padiou
b56f0359fe
Fixed regression in rebroadcast (#713)
Fixed regression caused by 2c1811d: we now don't force sending a
channel_update at the same time with channel_announcement.
This greatly simplifies the rebroadcast logic, and is what caused the
integration test to fail.

Added proper test on Peer, testing the actor, not only static methods.
2018-09-19 16:42:09 +02:00
Pierre-Marie Padiou
448a1e4a82
Set default max-htlc-value-in-flight-msat=50mBTC (#707) 2018-09-18 17:04:11 +02:00
Pierre-Marie Padiou
db96c17fd2
Improve integration tests (#710)
* added more logs and improved integration test

* make travis cache maven data
2018-09-18 17:03:49 +02:00
Pierre-Marie Padiou
2c1811d18f
Remember pruned channels (#706)
Currently we don't remember channels that we have pruned, so we will happily revalidate the same channels again if a node re-sends them to us, and prune them again, a.k.a. the "zombie churn".

Before channel queries, rejecting a stale channel without validating it wasn't trivial,  because nodes sent us the `channel_announcement` before `channel_update`s, and only after receiving the `channel_update` could we know if the channel was still stale. Since we had no way of requesting the `channel_announcement` for one particular channel, we would have to buffer it, which would lead to potential DOS issues. 

But now that we have channel queries, we can now be much more efficient. Process goes like this:
(1) channel x is detected as stale gets pruned, and its id is added to the pruned db
(2) later on we receive a `channel_announcement` from Eve, we ignore it because the channel is in the pruned db
(3) we also receive old `channel_update`s from Eve nodes, just ignore them because we don't know the channel
(4) then one day some other node George sends us the `channel_announcement`, we still ignore it because the channel is still in the pruned db
(5) but then George sends us recent `channel_update`s, and we know that the channel is back from the dead. We ignore those `channel_update`s, but we aldo remove the channel id from the pruned db, and we request announcements for that node from George
(6) George sends us the `channel_announcement` again, we validate it
(7) George then sends us the `channel_update`s again, we process them
(8) done!

This also allows removing the pruning code that we were doing on-the-fly when answering to routing table sync requests.

Needless to say that this leads to a huge reduction in CPU/bandwidth usage on well-connected nodes.

Fixes #623, #624.
2018-09-17 18:30:10 +02:00
Pierre-Marie Padiou
52b161f5e9
Ignore bad announcements sent by peers (#705)
Nodes currently receive tons of bogus channel_announcements, mainly with unexisting or long-spent funding transactions. Of course those don't pass the validation and are rejected, but that takes a significant amount of resources: bandwidth, multiple calls to bitcoind, etc.

On top of that, we forget those announcements as soon as we have rejected them, and will happily revalidate them next time we receive them. As a result, a typical node on mainnet will validate 10s of thousands of useless announcements every day.

As far as we know, this is apparently due to bug in another implementation, but that may very well be used as a DOS attack vector in the future.

This PR adds a simple mechanism to react to misbehaving peer and handle three types of misbehaviors:
(a) bad announcement sigs: that is a serious offense, for now we just close the connection, but in the future we will ban the peer for that kind of things (the same way bitcoin core does)
(b) funding tx already spent: peer send us channel_announcement, but the channel has been closed (funding tx already spent); if we receive too many of those, we will ignore future announcements from this peer for a given time
(c) same as (b), but the channel doesn't even exist (funding tx not found). That may be due to reorgs on testnet.

Needless to say that this leads to a huge reduction in CPU/bandwidth usage on well-connected nodes.
2018-09-17 17:12:41 +02:00
Pierre-Marie Padiou
1ce486ad20
Added LocalCommitConfirmed event (#701)
This event includes the block height at which we will be able to claim
our main output, which comes in handy for user interfaces.
2018-09-17 17:09:50 +02:00
rorp
a85b6d6175 Improve startup error handling (#696)
* Improve startup error handling

* minor changes to ZMQACtor

Scheduler now sends messages instead of directly calling our checkXX methods.
It will work the same but should fix the NPE we sometimes get when we stop the app.
2018-09-17 15:29:43 +02:00
Fabrice Drouin
8c075ee73a
Correctly handle multiple channel_range_replies (#704)
* Correctly handle multiple channel_range_replies

The scheme we use to keep tracks of channel queries with each peer would forget about
missing data when several channel_range_replies are sent back for a single channel_range_queries.

* RoutingSync: remove peer entry properly

* Remove peer entry on our sync map only when we've received a `reply_short_channel_ids_end` message.
* Make routing sync test more explicit

* Routing Sync: rename Sync.count to Sync.totalMissingCount
2018-09-17 15:25:39 +02:00
Pierre-Marie Padiou
c9184146d5
Added catch-all handler for local commit (minor) (#699) 2018-09-12 20:25:22 +02:00
Pierre-Marie Padiou
8645038943
Switched commitment log level to info (minor) (#700)
* switched commitment log level to info

* reduced test log level

* attempt at fixing tests timeout
2018-09-12 19:13:39 +02:00
Pierre-Marie Padiou
b60183628f
Handle overriden htlcs in remote close scenario (#697)
When we just signed an outgoing htlc, it is only present in the next
remote commit (which will become the remote commit once the current one
is revoked).

If we unilaterally close the channel, and our commitment is confirmed,
then the htlc will never reach the chain, it has been "overriden" and
should be failed ASAP. This is correctly handled since
6d5ec8c4fa.

But if remote unilaterally close the channel with its *current*
commitment (that doesn't contain the htlc), then the same thing happens:
the htlc is also "overriden", and we should fail it.

This fixes #691.
2018-09-12 18:24:18 +02:00
Pierre-Marie Padiou
f5a5985205
Multiple fixes in payment lifecycle (#693)
* permissive codec for failure messages

Some implementations were including/ommitting the message type when
including a `channel_update` in failure messages.

We now use a codec that supports both versions for decoding, and
will encode *with* the message type.

* make router handle updates from failure messages

This is a regression caused by 9f708acf04,
which made the `Peer` class encapsulates network announcements inside
`PeerRoutingMessage`, in order to preserve the origin of the messages.

But when we get channel updates as part of failure messages when making
payments, they weren't encapsulated and were ignored by the router.

Re-enabled a non-regression test in `IntegrationSpec` which will prevent
this from happening in the future.

* improve handling of `Update` payment failures

Exclude nodes that send us multiple `Update` failures for the same
payment (they may be bad actors)
2018-09-11 18:07:24 +02:00
Fabrice Drouin
12a80afd03
Mention Docker in our build instructions (fixes #669) (#685)
Mention Docker in our build instructions (fixes #669)
2018-09-03 18:03:40 +02:00
Pierre-Marie Padiou
6e0d087c5f
Fixed htlc absolute expiry checks (#687)
There are two different expiry checks:
(a) relative checks: when relaying an htlc, we need to be sure that
the difference of expiries between the outgoing htlc and the incoming
htlc is equal to the `cltv_expiry_delta` that we advertise in the
`channel_update` for the outgoing channel;
(b) absolute checks: we need to make sure that those values are not too
early or too far compared to the current "blockchain time".

The check for (a) needs to be done in the `Relayer`, which is the case
currently. This means that we will check the expiry delta *after* having
signed the incoming htlc, and we will fail the htlc (not the channel) if
the delta is incorrect.

The check for (b) was done in the `Commitments.receiveAdd` method. This
seems to make sense, because we would want to make sure as early as
possible that an incoming htlc has correct expiries, but it is actually
incorrect: the spec tells us to accept (=cross-sign) the htlc, and only
then to fail it before relaying it to the next node.

Indeed there is no risk in accepting an htlc that has an expiry in the
past, or an expiry very far in the future, because this only affects the
counterparty's balance. We just don't want to sign that kind of outgoing
htlcs.

Moving the check to the `sendAdd` will result in an error being return
to the relayer, which will then fail the corresponding incoming htlc.
2018-09-03 17:49:36 +02:00
Pierre-Marie Padiou
15c73273b6
Removed max body size in http client (#686)
* removed max body size in http client

This is required because since f3676c6497
we retrieve multiple full blocks in parallel.

* trivial: removed unused code

* trivial: added log

* trivial: more unused code removal
2018-08-31 15:46:41 +02:00
Fabrice Drouin
f0f8f0c24a
Add a "smooth" fee provider (#684)
* Add a "smooth" fee provider

It will return the moving average of fee estimates provided by
its internal fee provider, within a user defined window that can
be set with eclair.smooth-feerate-window. 

* Use a default fee rate smoothing window of 3

This should smooth our fee rate when there is a sudden change in
onchain fees and prevent channels with c-lightning node from getting
closed because they disagree with our fee rate.
2018-08-30 17:46:17 +02:00
Gustavo Fernandes
4b6a7c0aad Add logging customisation info (#680) 2018-08-30 14:00:24 +02:00