-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Handle invalid marker parameter in grpc call #5317
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5317 +/- ##
=======================================
Coverage 78.1% 78.1%
=======================================
Files 790 790
Lines 67908 67909 +1
Branches 8228 8229 +1
=======================================
+ Hits 53024 53025 +1
Misses 14884 14884
|
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.
In addition to the change below, is it possible to write some unit tests for this functionality?
@ximinez If there's existing unit test scaffolding for gRPC calls, similar to env.rpc, I'm happy to add tests. Otherwise, I'd prefer to focus on fixing the crash in this PR rather than setting up additional framework components. |
I thought we had some, but I can't find them now, so I guess we can move forward as-is. |
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.
Looks good
grpc::Status errorStatus{ | ||
grpc::StatusCode::INVALID_ARGUMENT, "end marker malformed"}; | ||
return {response, errorStatus}; | ||
if (auto const key = uint256::fromVoidChecked(request.end_marker()); |
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.
[nit]: It might be useful to differentiate between null and wrong position of marker. I.e.:
auto key = uint256::fromVoidChecked(request.end_marker());
if (!key)
{
return {response, {grpc::StatusCode::INVALID_ARGUMENT, "end marker malformed"}};
}
if (*key < startKey)
{
return {response, {grpc::StatusCode::INVALID_ARGUMENT, "end marker out of range"}};
}
e = ledger->sles.upper_bound(*key);
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.
LGTM, happy to approve once nit comment is answered.
p.s. I checked and can confirm that it is not very easy to add unit-test in this case.
Handle invalid marker parameter in grpc call
Context of Change
end_marker is used to limit the range of ledger entries to fetch
If end_marker is less than marker, crash can happen at https://github.com/XRPLF/rippled/blob/develop/src/xrpld/rpc/handlers/LedgerData.cpp#L185
Type of Change
Before
rippled server crashes if end_marker is smaller than marker.
After
Return
code = InvalidArgument desc = end marker malformed
error to grpc caller.Test
Test manually
This PR is to address the crash. Developing unit test setup for grpc server methods is beyond the scope of this PR.