Skip to content

Refactor channel params: extract commitment params#3116

Merged
t-bast merged 4 commits intomasterfrom
introduce-commit-params
Jun 26, 2025
Merged

Refactor channel params: extract commitment params#3116
t-bast merged 4 commits intomasterfrom
introduce-commit-params

Conversation

@t-bast
Copy link
Member

@t-bast t-bast commented Jun 23, 2025

We extract some of the channel parameters that are currently in our LocalParams and RemoteParams classes into a CommitParams class. While we currently simply create instances of that class based on our LocalParams and RemoteParams, the goal is to later move those values out of LocalParams and RemoteParams to clearly split params that apply to the channel for its entire lifetime from params that can be updated on a per-commitment basis.

This is mostly straightforward refactoring, but there is one detail worth reviewing in-depth: we previously used the to_self_delay from the remote parameters when creating our local commitments. We now instead initially set the to_self_delay in our local CommitParams based on the remote to_remote_delay, which has been renamed to make
it more clear. This is a bit subtle, but hopefully will be better contained once we split CommitParams from ChannelParams in a future PR.

This is split into several independent commits: the bulk of the work is in the second commit.

I have tested e2e on regtest against eclair/master that I didn't mess up the commitment params: I've used one eclair instance using master and another using this branch, with different configurations for dust_limit, to_self_delay, max_accepted_htlcs, htlc_minimum, max_htlc_value_in_flight_msat and made payments that exercised those limits. Everything worked well 👍

@t-bast t-bast requested review from pm47 and sstone and removed request for pm47 June 23, 2025 08:02
requireConfirmedInputs = requireConfirmedInputs,
requestFunding_opt = c.requestFunding_opt,
localChannelParams = localParams,
proposedCommitParams = nodeParams.channelConf.commitParams(c.fundingAmount, unlimitedMaxHtlcValueInFlight = false),
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that when rebasing private feature branches, we must correctly set unlimitedMaxHtlcValueInFlight to true for mobile wallet users. Same in the non-initiator case below.

t-bast added 3 commits June 24, 2025 12:04
We previously allowed plugins to update parts of our `LocalParams` in
the `OpenChannelInterceptor` flow: this was an attempt to allow adding
funds to a dual-funded channel that wasn't initiated by us and set
`max-htlc-value-in-flight` correctly (taking into account the added
funding amount).

This isn't used yet, and we will compute `max-htlc-value-in-flight`
later in the following commits, so we remove this option, which
simplifies the code.
We extract some of the channel parameters that are currently in our
`LocalParams` and `RemoteParams` classes into a `CommitParams` class.
While we currently simply create instances of that class based on our
`LocalParams` and `RemoteParams`, the goal is to later move those
values out of `LocalParams` and `RemoteParams` to clearly split params
that apply to the channel for its entire lifetime from params that can
be updated on a per-commitment basis.

This is mostly straightforward refactoring, but there is one detail
worth reviewing in-depth: we preivously used the `to_self_delay` from
the *remote* parameters when creating our *local* commitments. We now
instead initially set the `to_self_delay` in our *local* `CommitParams`
based on the remote `to_remote_delay`, which has been renamed to make
it more clear. This is a bit subtle, but hopefully will be better
contained once we split `CommitParams` from `ChannelParams` in a future
PR.

We also refactor our unit tests to simplify the creation of the "init"
messages. This should make it less painful whenever we have to update
these tests.
We change our channel update helper to make it more compatible with the
future `CommitParams` changes. This is a trivial refactoring without
any change in behavior.
@t-bast t-bast force-pushed the introduce-commit-params branch from 3ce1335 to 8fbb684 Compare June 24, 2025 10:12
@t-bast
Copy link
Member Author

t-bast commented Jun 24, 2025

Rebased to fix minor conflict with #3117

@t-bast t-bast merged commit 6fb7ac1 into master Jun 26, 2025
1 of 2 checks passed
@t-bast t-bast deleted the introduce-commit-params branch June 26, 2025 15:19
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.

2 participants