Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inbound fees channel updates to notifications #8723

Conversation

bufo24
Copy link
Contributor

@bufo24 bufo24 commented May 3, 2024

Adds inbound fees to notifications, used in the SubscribeChannelGraph

Copy link

coderabbitai bot commented May 3, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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.

@bufo24
Copy link
Contributor Author

bufo24 commented May 3, 2024

I got it working, and noticed that here inbound fees are also not added, is this needed?

@bitromortac bitromortac self-requested a review May 4, 2024 08:56
@saubyk saubyk added this to the v0.18.0 milestone May 5, 2024
@bufo24 bufo24 force-pushed the add-inbound-fees-to-channel-notifications branch 2 times, most recently from b851804 to aacb4b6 Compare May 6, 2024 10:24
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

Thank you a lot for working on this 🔥! I think it may not be necessary to add the inbound fees to ChannelUpdate and ChannelEdgeUpdate because that data is already in the extra tlv data. If we pass through the tlv data instead, we can also make that info available to the stream (see my comment).

@@ -60,6 +60,15 @@ type ChannelEdgePolicy struct {
// HTLCs for each millionth of a satoshi forwarded.
FeeProportionalMillionths lnwire.MilliSatoshi

// InboundFeeBaseMSat is the base HTLC fee that will be subtracted for
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you instead add ExtraOpaqueData lnwire.ExtraOpaqueData on this struct and set it in addToTopologyChange? That way we don't have to add redundant data to ChannelUpdate and ChannelEdgeUpdate because the inbound fees are in the opaque tlv blob. We can then use this to pass that blob through to marshalTopologyChange and extract inbound fees using extractInboundFeeSafe. We can then as well set CustomRecords on the proto message preparing it with marshalExtraOpaqueData, similar to the approach that was taken in marshalDBRoutingPolicy.

@Roasbeef
Copy link
Member

Roasbeef commented May 7, 2024

Tests don't build:

Error: routing/notifications_test.go:90:3: unknown field InboundFeeBaseMSat in struct literal of type models.ChannelEdgePolicy
Error: routing/notifications_test.go:91:3: unknown field InboundFeePPM in struct literal of type models.ChannelEdgePolicy
Error: routing/notifications_test.go:516:17: edgeUpdate.InboundBaseFee undefined (type *ChannelEdgeUpdate has no field or method InboundBaseFee)
Error: routing/notifications_test.go:516:43: edgeAnn.InboundFeeBaseMSat undefined (type *models.ChannelEdgePolicy has no field or method InboundFeeBaseMSat)
Error: routing/notifications_test.go:519:13: edgeAnn.InboundFeeBaseMSat undefined (type *models.ChannelEdgePolicy has no field or method InboundFeeBaseMSat)
Error: routing/notifications_test.go:520:16: edgeUpdate.InboundBaseFee undefined (type *ChannelEdgeUpdate has no field or method InboundBaseFee)
Error: routing/notifications_test.go:522:17: edgeUpdate.InboundFeeRate undefined (type *ChannelEdgeUpdate has no field or method InboundFeeRate)
Error: routing/notifications_test.go:522:43: edgeAnn.InboundFeePPM undefined (type *models.ChannelEdgePolicy has no field or method InboundFeePPM)
Error: routing/notifications_test.go:524:36: edgeAnn.InboundFeePPM undefined (type *models.ChannelEdgePolicy has no field or method InboundFeePPM)
Error: routing/notifications_test.go:525:16: edgeUpdate.InboundFeeRate undefined (type *ChannelEdgeUpdate has no field or method InboundFeeRate)
Error: routing/notifications_test.go:525:16: too many errors

The linter is also failing:

TimeLockDelta:           uint32(channelUpdate.TimeLockDelta),
rpcserver.go:6711: line is 86 characters (lll)
				MinHtlc:                 int64(channelUpdate.MinHTLC),
rpcserver.go:6712: line is 87 characters (lll)
				MaxHtlcMsat:             uint64(channelUpdate.MaxHTLC),
rpcserver.go:6713: line is 86 characters (lll)
				FeeBaseMsat:             int64(channelUpdate.BaseFee),
rpcserver.go:6714: line is 86 characters (lll)
				FeeRateMilliMsat:        int64(channelUpdate.FeeRate),
routing/notifications_test.go:5[31](https://github.com/lightningnetwork/lnd/actions/runs/8974797777/job/24647950244?pr=8723#step:7:32): multi-line statement should be followed by a newline (whitespace)
			edgeUpdate.ExtraOpaqueData, edgeAnn.ExtraOpaqueData) {

@bufo24
Copy link
Contributor Author

bufo24 commented May 7, 2024

Those tests cases should be resolved in my latest commit.
I am not super familiar with Go, what's the best way to resolve these long lines? Which causes the linter to fail

Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

I am not super familiar with Go, what's the best way to resolve these long lines? Which causes the linter to fail

Yes, it takes a bit to get familiar with how some code formatting is done on this repo, I'd recommend to read https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md and https://github.com/lightningnetwork/lnd/blob/master/docs/code_formatting_rules.md specifically, it's described there.

Code wise this looks good to me except for the linter issues. Could you also squash your commits?

rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
routing/notifications_test.go Outdated Show resolved Hide resolved
routing/notifications_test.go Outdated Show resolved Hide resolved
@bufo24 bufo24 force-pushed the add-inbound-fees-to-channel-notifications branch 4 times, most recently from 4034205 to 4e75f30 Compare May 7, 2024 14:05
@bufo24
Copy link
Contributor Author

bufo24 commented May 7, 2024

Lint issues resolved and release notes updated. Some integration tests are failing, but are not related to my changes it seems 🤔

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.

A couple of additional nits, otherwise looks good, thanks.

routing/notifications.go Show resolved Hide resolved
routing/notifications_test.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
docs/release-notes/release-notes-0.18.0.md Show resolved Hide resolved
@bufo24 bufo24 force-pushed the add-inbound-fees-to-channel-notifications branch from 4ab7641 to af9858c Compare May 7, 2024 16:58
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.

utACK, LGTM 🎉

Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

tACK, LGTM ⚡

@Roasbeef Roasbeef merged commit 130c499 into lightningnetwork:master May 13, 2024
26 of 27 checks passed
Copy link

@Tguntenaar Tguntenaar left a comment

Choose a reason for hiding this comment

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

LGTM

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]: Inbound fees are not in the gossip message when using subscribeChannelGraph
7 participants