Skip to content

feature: allow custom feature bits already set by default#10888

Open
Lrifton92 wants to merge 2 commits into
lightningnetwork:masterfrom
Lrifton92:fix/custom-feature-bit-already-default
Open

feature: allow custom feature bits already set by default#10888
Lrifton92 wants to merge 2 commits into
lightningnetwork:masterfrom
Lrifton92:fix/custom-feature-bit-already-default

Conversation

@Lrifton92

Copy link
Copy Markdown

Change Description

Fixes #10883.

When a custom feature bit configured via protocol.custom-init or protocol.custom-nodeann is already advertised in lnd's default feature vector, newManager returned a fatal feature bit: X already set error and lnd failed to start:

unable to create server: feature bit: 39 already set

For example, bit 39 is OnionMessagesOptional, which lnd already advertises by default. A config such as:

[protocol]
protocol.custom-nodeann=39
protocol.custom-init=39

does not change the effective feature vector at all, yet it prevented startup.

Fix

Re-advertising an already-set bit yields an identical feature vector, so it is harmless. This treats an already-set custom bit as a no-op (continue) instead of a fatal error. Genuine conflicts between the optional and required variants of a feature are still rejected by SafeSet immediately below, so the safety property is preserved.

 if raw.IsSet(custom) {
-	return nil, fmt.Errorf("feature bit: %v "+
-		"already set", custom)
+	continue
 }

Testing

Added TestManagerCustomFeatureAlreadyDefault, which configures a custom feature bit that is already set by default and asserts that:

  • newManager no longer errors, and
  • the resulting raw vector keeps the required bit set without introducing an invalid optional/required pairing.
$ go test ./feature/
ok  	github.com/lightningnetwork/lnd/feature

gofmt, go vet ./feature/ clean. Tested on go1.26.4.

Steps to Test

  1. Start lnd with protocol.custom-init=39 and protocol.custom-nodeann=39 in lnd.conf.
  2. Before this change lnd aborts with feature bit: 39 already set; after it, lnd starts normally and the feature vector is unchanged.

Pull Request Checklist

  • Change is reasonably small and self-contained.
  • Tests added/updated and passing.
  • Release notes (added in a follow-up commit referencing this PR number).

When a custom feature bit configured via protocol.custom-init or
protocol.custom-nodeann is already advertised in lnd's default feature
vector, newManager returned a "feature bit: X already set" error and lnd
failed to start. Re-advertising an already-set bit yields an identical
feature vector, so this is harmless.

Treat an already-set custom bit as a no-op instead of a fatal error.
Genuine conflicts between the optional and required variants of a feature
are still rejected by SafeSet.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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 addresses an issue where lnd would fail to start if a user configured a custom feature bit that was already included in the default feature vector. By allowing these redundant configurations to be ignored, the system remains robust while preventing unnecessary startup aborts.

Highlights

  • Error Handling Update: Modified the feature manager to treat custom feature bits that are already set by default as a no-op instead of returning a fatal error.
  • Regression Testing: Added a new test case, TestManagerCustomFeatureAlreadyDefault, to ensure that configuring pre-existing feature bits does not cause startup failures or invalid feature vector states.
New Features

🧠 You can now enable Memory (public preview) 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Lrifton92

Copy link
Copy Markdown
Author

Added the release note and contributor entry in c5b26b8 (docs/release-notes/release-notes-0.22.0.md).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the feature manager to treat duplicate custom feature bits that are already advertised by default as a no-op instead of failing startup with an error. It also adds a corresponding unit test TestManagerCustomFeatureAlreadyDefault to verify this behavior. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions github-actions Bot added the severity-high Requires knowledgeable engineer review label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Severity: HIGH (feature/* - Feature bit management). Files: feature/manager.go [HIGH], docs/release-notes/release-notes-0.22.0.md [LOW], feature/manager_internal_test.go [LOW/excluded]. Scope: 2 non-test files, 17 lines - no bump triggered. <!-- pr-severity-bot -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-high Requires knowledgeable engineer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: protocol: duplicate custom feature bit prevents startup

1 participant