Skip to content

Conversation

@MPins
Copy link
Contributor

@MPins MPins commented Jun 22, 2024

Fixes #8793

modified: rpcserver.go
modified: server.go
modified: routing/missioncontrol.go

Change Description

Changed the DebugLevel function to start updating the main cfg DebugLevel variable.

Created the function UpdateRoutingConfig to just update the main cfg values, this function is a callback function propagated by NewMissionControl function called when creating a new server on server.go. And finally, call the callback function on SetConfig on routing/missioncontrol.go

Steps to Test

After running LND with the wallet unlocked, send the lncli commands to change the debuglevel and estimator and check if they are updated unsing 'getdebuginfo'.

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 22, 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.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Nice work @MPins. I left a few comments.

Also, I don't think this commit is necessary since all you did was add comments.

@MPins
Copy link
Contributor Author

MPins commented Jun 24, 2024

Nice work @MPins. I left a few comments.

Also, I don't think this commit is necessary since all you did was add comments

Thank you! ... About this last comment ... That's weird ... because I've added the line containing 'cfg.UpdateEstimatorValue(cfg.Estimator)' also

@MPins
Copy link
Contributor Author

MPins commented Jun 30, 2024

Hello everyone, the code is working as expected! But the changes made with lncli setmccfg are not impacting the information we get from lncli getdebuginfo . It looks like the GetDebugInfo function is getting this information from somewhere else.

lnd/rpcserver.go

Line 3164 in 71ba355

func (r *rpcServer) GetDebugInfo(_ context.Context,

@Chinwendu20
Copy link
Contributor

Chinwendu20 commented Jul 3, 2024

~So GetDebugInfo is getting its info from a different config from the one that you are updating (r.cfg)

lnd/rpcserver.go

Line 3166 in b67af4a

flatConfig, _, err := configToFlatMap(*r.cfg)

You would have to change it to r.server.cfg to get the updated one.

Then maybe change this from r.cfg.LogWriter to r.server.cfg.LogWriter so that all the config updates can be in one place:

lnd/rpcserver.go

Line 6901 in b67af4a

err := build.ParseAndSetDebugLevels(req.LevelSpec, r.cfg.LogWriter)

I think maybe the config field in the rpcserver struct should be removed entirely since we can access config from the server field but I would like hear what other ppl think about it~

Edit:
Please ignore my earlier comments on this, it should work either ways if you are using r.cfg or r.server.cfg as they have same memory address. I think once you fix the pointer thing here it should work #8857 (comment)

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.

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.

utconceptack

@guggero
Copy link
Collaborator

guggero commented Jul 8, 2024

Can you rebase the PR to get rid of the merge commits please? Then I'll take another look.

@MPins
Copy link
Contributor Author

MPins commented Jul 8, 2024

Can you rebase the PR to get rid of the merge commits please? Then I'll take another look.

Sorry about that mess! I'm learning a lot of things at the same time and the git collaboration process is one of them!

Rebase done, thank you for pointing it.

@guggero
Copy link
Collaborator

guggero commented Jul 9, 2024

Thanks for the rebase. Looks a bit better now.
Unfortunately there's another bit of learning ahead of you. Open Source is quite demanding in terms of git proficiency, since crafting a Pull Request is often as much about the reviewer as it is about the code change itself.
So what you'll want to do to make sure your PRs are getting accepted quickly, is what I call "Review Oriented Programming". Basically you want to tell a coherent story to the reviewer with each commit.

That means each commit should be a small but internally consistent (e.g. each commit compiles on its own) change, with a clear description (e.g. in the commit message or code comments) of why the change is needed and why it's done in this specific way. And each commit should be in a logical order that makes sense to the reviewer.

What you want to avoid is that the commits show different iterations of things you tried or changes during the review itself. So that a new reviewer looking at the code doesn't have to look at all the different stages the code went through and can just take in the current state.

Don't worry if you don't get that perfect for the first couple of pull requests, great commit crafting is a hard skill to learn and an art form in itself.

So long story short: can you please update your PR so it only has 3 or 4 commits? You'll probably want to use interactive rebase to achieve that.

Here are a couple of links that should get you started:

@MPins
Copy link
Contributor Author

MPins commented Jul 10, 2024

Thanks for the rebase. Looks a bit better now. Unfortunately there's another bit of learning ahead of you. Open Source is quite demanding in terms of git proficiency, since crafting a Pull Request is often as much about the reviewer as it is about the code change itself. So what you'll want to do to make sure your PRs are getting accepted quickly, is what I call "Review Oriented Programming". Basically you want to tell a coherent story to the reviewer with each commit.

That means each commit should be a small but internally consistent (e.g. each commit compiles on its own) change, with a clear description (e.g. in the commit message or code comments) of why the change is needed and why it's done in this specific way. And each commit should be in a logical order that makes sense to the reviewer.

What you want to avoid is that the commits show different iterations of things you tried or changes during the review itself. So that a new reviewer looking at the code doesn't have to look at all the different stages the code went through and can just take in the current state.

Don't worry if you don't get that perfect for the first couple of pull requests, great commit crafting is a hard skill to learn and an art form in itself.

So long story short: can you please update your PR so it only has 3 or 4 commits? You'll probably want to use interactive rebase to achieve that.

Here are a couple of links that should get you started:

Thank you very much for investing time in providing such valuable guidance. I'll be working on it today and let you know when ready.

@MPins MPins force-pushed the issue-8793 branch 3 times, most recently from d07f4b1 to c8fedca Compare July 10, 2024 23:26
@MPins
Copy link
Contributor Author

MPins commented Jul 10, 2024

Thanks for the rebase. Looks a bit better now. Unfortunately there's another bit of learning ahead of you. Open Source is quite demanding in terms of git proficiency, since crafting a Pull Request is often as much about the reviewer as it is about the code change itself. So what you'll want to do to make sure your PRs are getting accepted quickly, is what I call "Review Oriented Programming". Basically you want to tell a coherent story to the reviewer with each commit.

That means each commit should be a small but internally consistent (e.g. each commit compiles on its own) change, with a clear description (e.g. in the commit message or code comments) of why the change is needed and why it's done in this specific way. And each commit should be in a logical order that makes sense to the reviewer.

What you want to avoid is that the commits show different iterations of things you tried or changes during the review itself. So that a new reviewer looking at the code doesn't have to look at all the different stages the code went through and can just take in the current state.

Don't worry if you don't get that perfect for the first couple of pull requests, great commit crafting is a hard skill to learn and an art form in itself.

So long story short: can you please update your PR so it only has 3 or 4 commits? You'll probably want to use interactive rebase to achieve that.

Here are a couple of links that should get you started:

Done ... only 3 commits!

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Code and commit structure looks pretty good now! Mostly nits remaining.

@MPins MPins force-pushed the issue-8793 branch 3 times, most recently from 1bc5103 to 4ec62b1 Compare July 15, 2024 19:14
@lightninglabs-deploy
Copy link

@Abdulkbk: review reminder
@Chinwendu20: review reminder

@guggero guggero requested review from ellemouton and removed request for Abdulkbk and Chinwendu20 August 6, 2024 15:35
Copy link
Contributor

@Abdulkbk Abdulkbk left a comment

Choose a reason for hiding this comment

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

LGTM

Abdulkbk

This comment was marked as duplicate.

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! My main comment is about ensuring that we account for all MC config values here and not just the estimator

m.estimator = cfg.Estimator

// Callback function to update the estimator value on main cfg.
m.updateEstimator(cfg.Estimator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

for call backs, we should not assume that they are necessarily set. So we should do a nil check here before invoking it

Copy link
Collaborator

Choose a reason for hiding this comment

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

for example, this commit by itself does not set UpdateEstimator and so this would panic as is

Copy link
Collaborator

Choose a reason for hiding this comment

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

or you can avoid the nil check by instead having:

UpdateEstimator fn.Option[func(estimator Estimator)]

and then:

m.cfg.UpdateEstimator.WhenSome(func(f func(estimator Estimator)) {
		f(cfg.Estimator)
})

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'll be addressing the nil check ... thanks!

@MPins
Copy link
Contributor Author

MPins commented Aug 7, 2024

nice work! My main comment is about ensuring that we account for all MC config values here and not just the estimator

Thank you for your careful review.

@ellemouton
Copy link
Collaborator

@MPins - thanks for the quick updates!

I've unresolved one comment cause it is unaddressed:

what about other config values that are not estimator related such as MaxMcHistory and MinFailureRelaxInterval? I think perhaps we should instead make this more generic: OnConfigUpdate?

I didnt just mean the name of the call-back. I meant the actual behaviour too. It should take in the cfg, not just the Estimator. Ie, if I update any MC config values via the rpc, those should be reflected in GetDebugInfo.

This also needs a rebase as there is a merge conflict

@MPins MPins force-pushed the issue-8793 branch 2 times, most recently from b10d561 to 46c64b1 Compare August 12, 2024 00:50
@MPins MPins requested a review from ellemouton August 12, 2024 00:54
@MPins MPins force-pushed the issue-8793 branch 2 times, most recently from cd7d415 to a3b5924 Compare August 12, 2024 03:50
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.

almost there 🙏

Also just note that 0.18.3 has now shipped so we will need to move the release notes over to a new doc. Currently still unsure if this will be 0.18.4 or 0.19.0. But lets just focus on getting this fully approved first & then we can worry about which doc to put the release notes in :)

@ellemouton
Copy link
Collaborator

@MPins can you rebase & add release notes to 0.19 in the mean time so that the CI can run pls 🙏

MPins added 4 commits August 14, 2024 14:42
NewMissionControl propagate the callback function defined on server.go and
SetConfig call it to update the infos on main cfg.
This callback function is called whenever the command `lncli setmccfg`
is used to change the routing settings.
@MPins
Copy link
Contributor Author

MPins commented Aug 14, 2024

@MPins can you rebase & add release notes to 0.19 in the mean time so that the CI can run pls 🙏

Thank you. Done.

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.

Thanks! 🛠️

@guggero guggero merged commit 0aced5c into lightningnetwork:master Aug 15, 2024
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.

[bug]: lncli getdebuginfo not showing the current state of config

7 participants