Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set relay fees per node and save them to database #1890

Merged
merged 8 commits into from
Aug 11, 2021

Conversation

thomash-acinq
Copy link
Member

  • Fees are set per node instead of per channel (setting different fees for different channels to the same node is most probably an error)
  • Fees are saved to a database so that we can keep a trace of historic fees and new channels with a known node use the fee that we set and not the default fee.

@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2021

Codecov Report

Merging #1890 (44da4e2) into master (131ae8b) will increase coverage by 0.01%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master    #1890      +/-   ##
==========================================
+ Coverage   87.34%   87.35%   +0.01%     
==========================================
  Files         159      159              
  Lines       12004    12110     +106     
  Branches      473      461      -12     
==========================================
+ Hits        10485    10579      +94     
- Misses       1519     1531      +12     
Impacted Files Coverage Δ
...n/scala/fr/acinq/eclair/channel/ChannelTypes.scala 100.00% <ø> (ø)
.../main/scala/fr/acinq/eclair/db/DualDatabases.scala 0.00% <0.00%> (ø)
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 86.29% <72.72%> (-0.11%) ⬇️
...c/main/scala/fr/acinq/eclair/db/pg/PgPeersDb.scala 84.37% <80.95%> (-1.99%) ⬇️
...c/main/scala/fr/acinq/eclair/db/pg/PgAuditDb.scala 95.84% <84.61%> (-1.24%) ⬇️
...cala/fr/acinq/eclair/db/sqlite/SqlitePeersDb.scala 91.22% <86.36%> (-3.22%) ⬇️
...cala/fr/acinq/eclair/db/sqlite/SqliteAuditDb.scala 98.47% <92.30%> (-0.69%) ⬇️
...r-core/src/main/scala/fr/acinq/eclair/Eclair.scala 53.06% <100.00%> (+2.01%) ⬆️
...c/main/scala/fr/acinq/eclair/channel/Helpers.scala 96.06% <100.00%> (+0.01%) ⬆️
...main/scala/fr/acinq/eclair/db/DbEventHandler.scala 92.42% <100.00%> (+0.36%) ⬆️
... and 12 more

@thomash-acinq thomash-acinq force-pushed the relay-fees-per-node branch 3 times, most recently from 6887a42 to 2ee89fc Compare July 21, 2021 09:40
@thomash-acinq thomash-acinq requested a review from t-bast July 21, 2021 11:18
@thomash-acinq thomash-acinq marked this pull request as ready for review July 21, 2021 11:18
@thomash-acinq thomash-acinq requested a review from pm47 August 3, 2021 08:47
Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup.

This PR should be rebased on top of master and use the newly introduced RelayFees class instead of tuples.


import java.io.Closeable

trait RelayFeesDb extends Closeable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rationale for not adding this to the AuditDb? It would fit right in I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuditDb should contain information for auditing only and should not be required for running the node, it should be write only. This new database is required for running the node as eclair reads from it.

Copy link
Member

@pm47 pm47 Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eclair reads from it

I missed that! In that case, it belongs to the PeersDb I think. There is an ambiguity though, because we are also using that same table as an append-only, timestamped, event log. How about a very basic key-value table in PeersDb and an event log table in AuditDb? Yes there is duplication, but it's consistent with what we have between PaymentsDb and AuditDb.

We could also just put the relay fee changes in the channel_events table, or introduce a new peer_events table.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I've added a channel_updates table in AuditDb.

- Fees are set per node instead of per channel (setting different fees for different channels to the same node is most probably an error)
- Fees are saved to a database so that we can keep a trace of historic fees and new channels with a known node use the fee that we set and not the default fee.
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I'm glad we can get rid of the ugly initialRelayFees_opt I added :)
You mention in the PR description that historical fees are kept, but that's not the case in the latest iteration, is it?

eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala Outdated Show resolved Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala Outdated Show resolved Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala Outdated Show resolved Hide resolved
t-bast
t-bast previously approved these changes Aug 10, 2021
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's wait for a final review from @pm47 before merging as he has more experience actually managing node fees than I do ;)

Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @t-bast I'm also wondering why you have dropped the historical fees, do you feel like it's not worth it anymore? Can also be added later.

@thomash-acinq
Copy link
Member Author

I've added the historical fees back. They're now in AuditDb.

@thomash-acinq thomash-acinq requested review from pm47 and t-bast August 11, 2021 13:10
@thomash-acinq thomash-acinq requested a review from pm47 August 11, 2021 15:20
@thomash-acinq thomash-acinq requested a review from pm47 August 11, 2021 15:50
@thomash-acinq thomash-acinq merged commit 8f5f6ac into master Aug 11, 2021
@@ -116,6 +118,11 @@ class DbEventHandler(nodeParams: NodeParams) extends Actor with ActorLogging {
auditDb.add(ChannelEvent(e.channelId, e.commitments.remoteParams.nodeId, e.commitments.commitInput.txOut.amount, e.commitments.localParams.isFunder, !e.commitments.announceChannel, event))
channelsDb.updateChannelMeta(e.channelId, event)

case u: LocalChannelUpdate =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: this will trigger a lot of noise, we resend this every time a peer reconnects...but maybe it's ok since it doesn't contain that much data

@evd0kim
Copy link
Contributor

evd0kim commented Sep 16, 2021

Are you sure you haven't broken old way of setting fees? @t-bast
Because this is what i get in response to my old command with channel ids

The form field 'nodeId(s)' was malformed:
Must specify nodeId or nodeIds (but not both)

@evd0kim
Copy link
Contributor

evd0kim commented Sep 16, 2021

That's for sure, you have broke old interface.
Then please maybe update documentation.

@pm47
Copy link
Member

pm47 commented Sep 16, 2021

That's for sure, you have broke old interface.

There has been a backward-incompatible change, yes. Need to use nodeId(s) instead of channelId(s).

Then please maybe update documentation.

I think @t-bast does that right before release. In the meantime:

curl -u :<eclair_api_password> -X POST -F nodeId=<node> \
     -F feeBaseMsat=<feebase> -F feeProportionalMillionths=<feeproportional> \
     "http://localhost:8080/updaterelayfee"

@t-bast
Copy link
Member

t-bast commented Sep 20, 2021

Then please maybe update documentation.

The documentation always reflects the latest release.
If you're running master, you can't expect the documentation to be up-to-date (otherwise we would need to have different documentation for every commit, which is way too much work).

I'm trying to improve that with #1951 so that release notes are written as master progresses.
That means that when you're running master, you can always check the draft release notes for the next release to see what has changed since the latest version.

@t-bast t-bast mentioned this pull request Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants