-
Notifications
You must be signed in to change notification settings - Fork 2.2k
rpcserver: enforce max_events limit of 50000 for ForwardingHistory #10503
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
base: master
Are you sure you want to change the base?
rpcserver: enforce max_events limit of 50000 for ForwardingHistory #10503
Conversation
The API documentation states that ForwardingHistory responses can only contain 50k records, but this limit was not actually enforced in the code. Add a cap to ensure the documented behavior is implemented. Closes lightningnetwork#10496 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @EricGrill, 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 ensures consistency between the 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
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 correctly enforces the documented 50,000 event limit for ForwardingHistory responses. The implementation is sound, but it introduces a new constant for a limit that is already defined elsewhere. My feedback suggests using the existing channeldb.MaxResponseEvents constant to avoid duplication and improve maintainability.
rpcserver.go
Outdated
| // Cap at 50000 as documented in the API. | ||
| const maxForwardingEvents = 50000 | ||
| if numEvents > maxForwardingEvents { | ||
| numEvents = maxForwardingEvents | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid code duplication, it's better to use the existing channeldb.MaxResponseEvents constant, which is defined for this exact purpose. This ensures the limit is defined in a single place, improving maintainability.
// Cap at the maximum number of events as documented in the API.
if numEvents > channeldb.MaxResponseEvents {
numEvents = channeldb.MaxResponseEvents
}Address review feedback to use the existing channeldb.MaxResponseEvents constant instead of defining a local constant. This avoids code duplication and ensures the limit is defined in a single place. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The API documentation states that ForwardingHistory responses can only contain 50k records, but this limit was not actually enforced in the code. This change adds validation to return an error when a client requests more than the maximum allowed events, rather than silently capping or allowing potentially oversized responses. This implementation uses the existing channeldb.MaxResponseEvents constant to avoid code duplication and ensure the limit is defined in a single place. Comprehensive unit tests cover various scenarios including valid values, boundary conditions, and exceeding the limit. This change consolidates the approaches from PR lightningnetwork#10503 and lightningnetwork#10512, combining the error-returning validation with the use of the existing channeldb constant. Closes lightningnetwork#10496 Co-Authored-By: Warp <agent@warp.dev>
|
Thanks for working on this! I've consolidated your approach with #10512. The consolidated PR (#10512) now uses the The implementation also includes comprehensive unit tests to ensure the validation works correctly across various scenarios. Feel free to review #10512 and let me know if you have any suggestions! |
Summary
num_max_eventsat 50000 as stated in the proto documentationBackground
The API documentation states "each response can only contain 50k records" but this limit was not actually enforced. This PR implements the documented behavior.
Test plan
Closes #10496
🤖 Generated with Claude Code