chainfee: make relay fee floor configurable via --fee.min-relay-feerate#10783
chainfee: make relay fee floor configurable via --fee.min-relay-feerate#10783Kilombino wants to merge 1 commit intolightningnetwork:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enables greater flexibility for LND node operators running on custom Bitcoin backends with non-standard mempool policies. By introducing a configurable minimum relay fee rate, operators can now transact at lower fee rates than the default 1 sat/vb, provided their infrastructure supports it. The changes maintain backward compatibility by defaulting to the existing 1 sat/vb floor. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
PR Severity: CRITICAL. Automated classification | 6 files | 127 lines changed (excl tests). Critical files: lnwallet/chainfee/estimator.go, lnwallet/chainfee/minfeemanager.go (lnwallet/* package), sweep/walletsweep.go (sweep/* package). Medium files: chainreg/chainregistry.go, lncfg/fee.go, sample-lnd.conf. Two distinct critical packages touched. Expert review required. <!-- pr-severity-bot --> |
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable minimum relay fee rate floor, allowing operators to specify values below the default 1 sat/vb. The changes update the configuration struct, fee estimators, and the minimum fee manager to respect the new setting. Review feedback identifies that using zero as a sentinel value in the configuration and estimator logic prevents the implementation of an actual zero floor. Additionally, a regression was noted in the wallet sweep logic regarding the handling of 1 sat/vb fee rates, and a documentation error was found in the fee rate conversion description.
The minimum relay fee rate is currently hardcoded to FeePerKwFloor (253 sat/kw, ~1 sat/vb). This prevents operators running nodes that connect to a Bitcoin backend with a lower minrelaytxfee from opening channels or sweeping funds at sub-1 sat/vb rates. This commit introduces a new --fee.min-relay-feerate option (in sat/vb) that lets operators lower the floor when their setup permits it. The default remains 1 sat/vb, preserving existing behaviour for all nodes. Changes: - lnwallet/chainfee/minfeemanager: accept a feeFloor parameter instead of always clamping to the package-level FeePerKwFloor constant - lnwallet/chainfee/estimator: thread feeFloor through BtcdEstimator, BitcoindEstimator, and WebAPIEstimator constructors; use the configured floor in EstimateFeePerKW clamping and relay fee fallback - sweep/walletsweep: remove the unconditional 250→253 sat/kw bump; the downstream minFeeRate check already enforces the relay floor - chainreg/chainregistry: pass cfg.Fee.FeeFloorKW() to all estimator constructors and to the static estimator - lncfg/fee: add MinRelayFeeRate field with Validate() and FeeFloorKW() helpers - sample-lnd.conf: document the new fee.min-relay-feerate option WARNING: lowering this value below 1 sat/vb means your node will create transactions that standard Bitcoin nodes will not relay. Only use this option if your backend has a matching minrelaytxfee and you have a direct path to a miner's mempool. Signed-off-by: Kilombino <kilombino@proton.me>
1803b49 to
532d237
Compare
|
@Kilombino, remember to re-request review from reviewers when ready |
Summary
LND currently hardcodes a minimum fee rate floor of 253 sat/kw (~1 sat/vb) in the
chainfeepackage. This floor is applied in three places:minFeeManager: clamps the fee returned by the chain backendWebAPIEstimator.EstimateFeePerKW: clamps the cached API resultsweep/walletsweep.go: silently bumps 1 sat/vb inputs to 253 sat/kwThis prevents operators who run a Bitcoin backend with a lower
minrelaytxfee(e.g. a personal mining setup, signet, regtest, or a node connected directly to a cooperative miner) from opening channels or sweeping funds below 1 sat/vb.This PR introduces a new
--fee.min-relay-feerateconfig option (sat/vb) that lets operators lower the floor when their setup permits it. The default value is unchanged (1 sat/vb = 253 sat/kw), so existing nodes are unaffected.Changes
lnwallet/chainfee/minfeemanager.gofeeFloor SatPerKWeightfield + param; replaces constant clamplnwallet/chainfee/estimator.gofeeFloorfield onBtcdEstimator,BitcoindEstimator,WebAPIEstimator; constructors updated; hardcodedFeePerKwFloorreferences replacedsweep/walletsweep.gominFeeRatecheck downstream already enforces the relay floorchainreg/chainregistry.gocfg.Fee.FeeFloorKW()to all three estimator constructorslncfg/fee.goMinRelayFeeRate chainfee.SatPerVBytefield +Validate()+FeeFloorKW()helpersample-lnd.conflnwallet/chainfee/minfeemanager_test.golnwallet/chainfee/estimator_test.goNewWebAPIEstimatorcalls for new signatureUsage
Safety
The commit message and
sample-lnd.confinclude a clear warning:Test plan
go test ./lnwallet/chainfee/...— existing tests pass, new floor tests passgo test ./sweep/...— walletsweep tests unaffectedgo build ./...— compiles cleanlyfee.min-relay-feerate=0; open a channel specifying a fee rate of 100 sat/kw; verify the channel opens without the old "fee too low" errorFixes: operators running nodes with
minrelaytxfee=0or sub-1 sat/vb mempool policies unable to transact at their configured fee rates.