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

1516 Commits

Author SHA1 Message Date
pm47
7af05b3eee
added balance_updated and channel_events tables 2019-01-10 19:42:52 +01:00
pm47
c75082954b
added tests...
...and found bugs!

Note that there is something fishy in BOLT 4, filed a PR:
https://github.com/lightningnetwork/lightning-rfc/pull/538

Also, first try of softwaremill's quicklens lib (in scope test for now)
2019-01-06 00:15:20 +01:00
pm47
405759f52c
relay to channel with lowest possible balance
Our current channel selection is very simplistic: we relay to the
channel with the largest balance. As time goes by, this leads to all
channels having the same balance.

A better strategy is to relay to the channel which has the smallest
balance but has enough to process the payment. This way we save larger
channels for larger payments, and also on average channels get depleted
one after the other.
2019-01-05 17:29:03 +01:00
Pierre-Marie Padiou
52f671384e
Detect broken HTLC links at startup (#757)
If we have stopped eclair while it was forwarding HTLCs, it is possible
that we are in a state were an incoming HTLC
was committed by both sides, but we didn't have time to send
and/or sign the corresponding HTLC to the downstream node.

In that case, if we do nothing, the incoming HTLC will
eventually expire and we won't lose money, but the channel
will get closed, which is a major inconvenience.

This check will detect this and will allow us
to fast-fail HTLCs and thus preserve channels.
2019-01-04 17:34:50 +01:00
araspitzu
75a18e2446 Set a max value of 2016 blocks for to_self_delay (#795)
This will be a hard requirement in BOLT 1.1
2019-01-03 16:59:26 +01:00
Pierre-Marie Padiou
ad31d89e54
Disable local channels below reserve (#763)
The goal is to reduce attempts from other nodes in the network to use
channels that are unbalanced and can't be used to relay payments.

This leaks information about the current balance and is a privacy
tradeoff, particularly in this simplistic implementation. A better way
would be to add some kind of hysteresis in order to prevent trivial
probing of channels.
2019-01-03 14:02:39 +01:00
Pierre-Marie Padiou
9da330478a
Add exclusive locks to channels sqlite db (#781)
* added an exclusive write lock to channels sqlite db

* added close() method in db traits
2019-01-03 11:01:53 +01:00
Pierre-Marie Padiou
8887ac2043
Relay fail message *after* it is cross-signed (#754)
We were previously handling `UpdateFailHtlc` and
`UpdateFailMalformedHtlc` similarly to `UpdateFulfillHtlc`, but that is
wrong:
- a fulfill needs to be propagated as soon as possible, because it
allows us to pull funds from upstream
- a fail needs to be cross-signed downstream (=irrevocably confirmed)
before forwarding it upstream, because it means that we won't
be able to pull funds anymore. In other words we need to be absolutely
sure that the htlc won't be fulfilled downstream if we fail it upstream,
otherwise we risk losing money.

Also added tests.
2019-01-02 16:44:05 +01:00
araspitzu
7f3b101426 Use BOLT specific formatting for short channel id (#793) 2019-01-02 14:40:24 +01:00
araspitzu
255c280bd0 Routing: use custom implementation for the shortest path algorithm and the graph (#779)
* Consider htlc_minimum/maximum_msat when computing a route

* Compare shortChannelIds first as it is less costly than comparing the pubkeys

* Remove export to dot functionality

* Remove dependency jgraph

* Add optimized constructor to build the graph faster

* Use fibonacci heaps from jheaps.org

* Use Set instead of Seq for extraEdges, remove redundant publishing of channel updates

* Use Set for ignored edges
2018-12-20 16:52:42 +01:00
Dominique
be5d188a38
Tweak parameters to optimize ElectrumClient connections (#788)
* use TCP_NODELAY and PooledByteBufAllocator

* added reference to interesting slidedeck
2018-12-20 14:14:23 +01:00
Dominique
a80ff1f6d9 Cleaned up mainnet electrum servers list (#786) 2018-12-18 17:21:28 +01:00
Dominique
521aa8adcd Share NioEventLoopGroup across Electrum clients (#783)
`NioEventLoopGroup` is expensive to create and should be shared with all clients. This also prevents issues when several event loop groups are created and are not shutdown correctly.
2018-12-14 11:44:11 +01:00
Pierre-Marie Padiou
723d0deed2
Optional per-node features in conf (#778)
Allow setting specific `globalfeatures` and `localfeatures` for given nodes.
2018-12-12 16:02:51 +01:00
Anton Kumaigorodski
4573d8a1e0 Make maxHtlcValueInFlight checks directional when sending and receiving HTLCs (#768) 2018-12-12 15:59:31 +01:00
Pierre-Marie Padiou
b5c96f0439
Update connection-level features at reconnection (#765)
Previously we weren't updating them since the channel creation, which
was wrong: both local and remote features may change after a
reconnection.
2018-12-12 15:12:17 +01:00
Pierre-Marie Padiou
ff588b578f
Use netty to connect to Electrum servers (#774)
* replaced akka.io by netty in electrum client and enabled ssl support

* updated docker-testkit to 0.9.8 so that electrum tests pass on windows

* use ssl port on testnet/mainnet

* removed experimental warning on electrum
2018-12-11 18:13:38 +01:00
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