-
Notifications
You must be signed in to change notification settings - Fork 391
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
fix(rpc): Fix http batch request to handle single item requests #3694
base: master
Are you sure you want to change the base?
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
duplicated with #3678 |
It looks like we've resolved this issue with the RPC server patch #3678 , but I still think it is worthwhile thinking about how we could make the client more forgiving as well. I'll pass long feedback line in a review. |
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.
Nice first pass, please see my comments in line for a few changes.
@notJoon I still think this is worth patching so that Batching responses for the client will work, even on older test nets. This follows the robustness principle (Postel's Law). If we can coax a slightly malformed response into a correct one, then it is better for the end-user experience. But, with the server patch, all testnets moving forward should be fine with the server side-only change. |
I updated both the server side (Omar's solution) and the client side (mine) functions associated with batch requests so that they have the same functionality but are more readable. On the server side, it tries to unmarshall into a slice of Responses and if it can't it tried to unmarshall into a single |
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Let's keep this PR simple and let's remove the server handler changes, since it has been addressed in another PR and any refactoring we might want to do can come in a separate PR.
Also - since we are modifying the client.go
, let's make sure that the functions your code touches have proper test coverage that address the expected behavior that this change is making.
Please add the tests and update your PR description as well.
Thank you for opening up the PR 🙏 Gimme a bit of time to get to this and review, it look promising 🫡 |
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.
Thanks for taking the initiative on this. I'm going to wait for feedback from @zivkovicmilos or someone else from the core team to weigh in on this, but thanks for addressing my feedback and for adding test coverage.
This pull request fixes the bug described in #3676. Using http, if a batch of requests only has one item, the request marshalls it as a single request and would create an error because the response logic is expecting a batch of responses. This pr changes how the client side unmarshalls the response by first trying to unmarshall it as a batch and returning it if successful. If it fails, it then tries to unmarshall as a response and returns that if successful. If both fail, it returns a Unmarshall error, as expected.
Omarsy's pr #3678 also fixed this issue from the server side inside the handlers.go file. I kept it as is but reverted earlier changes I made to it. The only file that changes in this pr is the client.go file.
I added a test that specifically verifies client side http batch request functionality, and this code is also covered by previous tests TestRPCClient_E2E_Endpoints from github.com/gnolang/gno/tm2/pkg/bft/rpc/client and TestClient_SendRequest from github.com/gnolang/gno/tm2/pkg/bft/rpc/lib/client/http