Skip to content

Conversation

@Abdulkbk
Copy link
Contributor

@Abdulkbk Abdulkbk commented Jun 10, 2024

closes #7123

replaces #8690

Change Description

This change allows a node to retain its previously configured node announcement settings after a restart, making it more consistent.

Issue:
As mentioned in the issue description:

If you set your alias using the UpdateNodeAnnouncement RPC call it will only maintain this as an update until a restart. Restarting clears all of the node announcement settings.

This creates additional work for users; for instance, if you have a list of addresses you associated with your node using the updatenodeannouncement RPC, you need to set them again each time your node restarts.

This also applies to all fields that can be updated using the updatenodeannouncement RPC, including: alias, color, addresses, and feature bit.

Solution:
This update checks for existing node announcement settings and reuses them during startup.

Since the node announcement settings can be set either through the node's config (specified in lnd.conf or passed as command line args) or using the updatenodeannouncement RPC, the hierarchy of precedence for these settings is as follows:

  • We check for what's set in config (args or lnd.conf)
  • We check for persistent settings (from graphDB)
  • We resolve to defaults

resolve-nodeann-settings

Steps to Test

  • Install LND with the peersrpc tag: make install tags="peersrpc".

Test for precedence:

  1. Set one of the fields in the lnd.conf file, for example, alias=alice.
  2. Start LND and update the alias by running: lncli peers updatenodeannouncement -alias=bob.
  3. Verify that the alias has been updated using the lncli getinfo command.
  4. Restart LND, then run lncli getinfo again to confirm that the alias is now set to alice.

Test for persistence

  1. Start LND without configuring one of the fields in the lnd.conf file.
  2. Use the command lncli peers updatenodeannouncement -color=#000000 to update the node's color, and verify the change by running lncli getinfo.
  3. Restart LND, and then execute lncli getinfo again to ensure that the color value remains the same after the restart.

Alternatively*

make build-itest # to build itest

make make itest-only  icase="node announcement persistence" # to run only the integration test

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Abdulkbk
Copy link
Contributor Author

@ellemouton, this pull request replaces #8690 as per your suggestion here. Please review when you have time. Thanks

@ellemouton
Copy link
Collaborator

@Abdulkbk - thanks! Although I think you could have just updated the commits in the original PR - no need for a new PR :)

@Abdulkbk
Copy link
Contributor Author

@Abdulkbk - thanks! Although I think you could have just updated the commits in the original PR - no need for a new PR :)

At first, I thought about doing that, but then I ended up creating a new PR. Thanks for the feedback; I'm really learning a lot.

@Abdulkbk
Copy link
Contributor Author

Hi @alexbosworth, I've opened this PR to fix the issue #7123 you reported. Could you spare some time to review it? Your input will help me improve the solution.

Copy link
Contributor

@alexbosworth alexbosworth left a comment

Choose a reason for hiding this comment

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

utconcept ack

Copy link
Contributor

@Chinwendu20 Chinwendu20 left a comment

Choose a reason for hiding this comment

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

Nice work. Left some suggestions. I think the commit message does not follow guideline (i.e. length of the message):
https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md#model-git-commit-messages

Here 6ebec6148ef072bd5cddc7, I do not think this is necessary:
'''
lnd: refactor code to elliminate duplicate nill check

lnd: fix comment
'''

Also I think this needs a release note? Maybe add here: https://github.com/lightningnetwork/lnd/blob/7065b6462edf48f3c86a58f2fd215cb0db2c0474/docs/release-notes/release-notes-0.18.1.md

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch from e2a4aa2 to b1e6571 Compare June 13, 2024 22:17
@Abdulkbk
Copy link
Contributor Author

Also I think this needs a release note? Maybe add here: https://github.com/lightningnetwork/lnd/blob/7065b6462edf48f3c86a58f2fd215cb0db2c0474/docs/release-notes/release-notes-0.18.1.md

Since this PR persists whatever was previously updated with the updatenodeannouncement lncli command, it means I should add a bullet point to explain that, right? @Chinwendu20

@Chinwendu20
Copy link
Contributor

I think you can add a bullet point to talk about what the change actually is and maybe a short explanation. Maybe under functional updates

@Abdulkbk
Copy link
Contributor Author

I think you can add a bullet point to talk about what the change actually is and maybe a short explanation. Maybe under functional updates

I just noticed that the issue this PR is addressing is under milestone 0.19.0. Shouldn't the milestone version and release notes version be the same?

@Chinwendu20
Copy link
Contributor

I think it makes sense that it should be the same.

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch from b1e6571 to 5acc286 Compare July 9, 2024 14:33
@Abdulkbk
Copy link
Contributor Author

Hi @yyforyongyu , I noticed that you are one of the code owners of netann. This PR touches nodeannouncement, which I think falls under that. Would you mind reviewing it? It is required before I can get the tests to run.

@saubyk saubyk added this to the v0.19.0 milestone Jul 12, 2024
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Approved CI run.

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch 2 times, most recently from 19d2ab7 to 367fbb7 Compare July 29, 2024 21:41
@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch 2 times, most recently from 61d4c75 to e43254e Compare August 6, 2024 22:41
@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch from e43254e to 59462a5 Compare October 26, 2024 21:41
@Abdulkbk
Copy link
Contributor Author

Abdulkbk commented Nov 4, 2024

Could you help approve the CI, @yyforyongyu?

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch from 59462a5 to d3fa798 Compare December 19, 2024 18:04
@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch 2 times, most recently from 0c08783 to 26b09ed Compare January 3, 2025 23:16
@Abdulkbk Abdulkbk changed the title lnd: use persisted node announcement data from previous runtime lnd: use persisted node announcement settings across restarts Jan 4, 2025
@Abdulkbk
Copy link
Contributor Author

Abdulkbk commented Jul 9, 2025

I have addressed the feedback @ellemouton. I've moved all the node ann logic into the getSelfNode method.

@Abdulkbk
Copy link
Contributor Author

Abdulkbk commented Jul 9, 2025

!lightninglabs-deploy unmute

@Abdulkbk Abdulkbk requested a review from ellemouton July 14, 2025 21:54
@yyforyongyu
Copy link
Member

/gemini review

Copy link

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

Choose a reason for hiding this comment

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

Code Review

The code changes introduce the ability for lnd to retain its previously configured node announcement settings after a restart, making it more consistent. The code is well-structured and the integration tests are thorough.

Comment on lines 715 to 716
return fmt.Errorf("address %v not found in "+
"node announcement", addr)

Choose a reason for hiding this comment

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

medium

This line exceeds the 80-character limit specified in the style guide1. Please reformat it to comply with the limit.

				return fmt.Errorf(
					"address %v not found in node announcement", addr,
				)

Style Guide References

Footnotes

  1. Wrap columns at 80 characters. Tabs are 8 spaces. (link)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure @gemini-code-asist? I count 77.

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

great work @Abdulkbk !

Very close.

Here is a suggested patch - let me know what you think :)

node_ann.patch

server.go Outdated
return nil, err
}

// TODO(elle): All previously persisted node announcement fields (ie,
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks - it should ideally be removed in the commit that addressed it. Ie, this commit

Comment on lines 31 to 33
* [nodeannouncement](https://github.com/lightningnetwork/lnd/pull/8825)
previously configured is now resued when a node restarts, instead of always
going back to the default configurations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isnt very clear to me tbh. "nodeannouncement previously configured" doesnt really make much sense. How about instead something to the tune of "Use persisted node announcement settings across restarts .. etc"

server.go Outdated
selfNode.AuthSigBytes,
// We now get the self node which represents our node on the channel
// graph.
selfNode, err := s.getSelfNode(
Copy link
Collaborator

Choose a reason for hiding this comment

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

get* implies that this purely does a read. I suggest rather naming it something like generateSelfNode/buildSelfNode/setSelfNode to indicate that it is doing some processing given its arguments and also some persistence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will go with setSelfNode

server.go Outdated
selfNode.AuthSigBytes,
// We now get the self node which represents our node on the channel
// graph.
selfNode, err := s.getSelfNode(
Copy link
Collaborator

Choose a reason for hiding this comment

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

note that the only thing used from the returned selfNode is the public key bytes which we actually know before ever calling this. So i dont think the new helper needs to return anything

server.go Outdated
Comment on lines 5544 to 5545
// getSelfNode returns the self node. It handles setting the node announcement,
// signing it, and updating the source node in the graph.
Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment should speak to the fact that config values that differ from defaults are prio'd, otherwise pre-existing settings found on disk are prio'd

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch 4 times, most recently from c4b2f91 to bcea84d Compare July 21, 2025 16:58
@Abdulkbk
Copy link
Contributor Author

Here is a suggested patch - let me know what you think :)

node_ann.patch

Thanks for the review @ellemouton. I am unable to access the patch, but I've addressed your feedback and left a question.

@Abdulkbk Abdulkbk requested a review from ellemouton July 28, 2025 18:42
@ellemouton
Copy link
Collaborator

I am unable to access the patch

out of curiosity, what goes wrong with accessing it? you should be able to download it and apply it to commit 655e87c

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

very nice work! pretty much g2g. The only thing i'll add (which is also answering your previous question) is about the address handling. If you take a look at my patch, you can see there that i moved all the address handling into the new helper since this sort of nicely separates all the self-node stuff into a single method.

@Abdulkbk
Copy link
Contributor Author

out of curiosity, what goes wrong with accessing it? you should be able to download it and apply it to commit 655e87c

I was getting a 404, but now it has downloaded.

@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch 2 times, most recently from 3301407 to b05ce16 Compare August 4, 2025 20:17
@Abdulkbk Abdulkbk requested a review from ellemouton August 4, 2025 22:09
Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

nice work!

@lightninglabs-deploy
Copy link

@yyforyongyu: review reminder
@Abdulkbk, remember to re-request review from reviewers when ready

This commit ensures that we start with the alias, node color,
addresses, and features as advertised in the node's previous
runtime. This approach maintains consistency in the node's
advertised information across restarts.
This commit adds an itest that verify the behaviour of correctly
reusing persisted node ann configs across restarts. It also ensures
that the node ann configs are applied using the correct hierarchy.
@Abdulkbk Abdulkbk force-pushed the restore-node-announcement branch from b05ce16 to fbac730 Compare August 16, 2025 15:41
Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM👍

// testSelfNodeAnnouncementPersistence tests that the node announcement configs
// are persisted correctly and reused when the node is restarted using the
// correct hierarchy (config > source node > defaults).
func testSelfNodeAnnouncementPersistence(ht *lntest.HarnessTest) {
Copy link
Member

Choose a reason for hiding this comment

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

👍

cfg.net.ResolveTCPAddr,
)
nodePubKey := route.NewVertex(nodeKeyDesc.PubKey)
// Set the self node which represents our node in the graph.
Copy link
Member

Choose a reason for hiding this comment

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

nit: newline above - for future PRs tho

)
nodePubKey := route.NewVertex(nodeKeyDesc.PubKey)
// Set the self node which represents our node in the graph.
err = s.setSelfNode(ctx, nodePubKey, listenAddrs)
Copy link
Member

Choose a reason for hiding this comment

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

For future PRs, changes like this should be split into two commits - the first commit is a pure refactor that introduces the setSelfNode method, and the second commit is used to modify the behavior.

// the source node that are not already in our address list yet. We
// create this map for quick lookup.
addressMap := make(map[string]struct{}, len(addrs))
// Populate the map with the existing addresses.
Copy link
Member

Choose a reason for hiding this comment

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

nit: newline above

@yyforyongyu yyforyongyu merged commit 9a49686 into lightningnetwork:master Aug 18, 2025
35 of 39 checks passed
@github-project-automation github-project-automation bot moved this from Medium Priority to High Priority in PR Review Priority Aug 18, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in lnd v0.20 Aug 18, 2025
@Abdulkbk Abdulkbk deleted the restore-node-announcement branch August 18, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: High Priority
Status: Done

Development

Successfully merging this pull request may close these issues.

[feature]: Allow persisting dynamic configured alias when not set in lnd.conf or arguments

8 participants