-
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
Specify source type for stored UNLs #3984
Conversation
@mDuo13 Doc changes |
target[jss::uri] = publisherList.siteUri; | ||
if (!publisherList.sourceUri.empty()) | ||
target[jss::source_uri] = publisherList.sourceUri; | ||
if (!publisherList.sourcePeer.empty()) | ||
target[jss::source_peer] = publisherList.sourcePeer; |
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.
Something I hadn't considered until I saw this block, but this is an API breaking change, and probably needs to be versioned. I haven't actually messed with the versioning code a lot myself, but I know RPC::JsonContext
has an apiVersion
member that you can pass to this function, or post-process in the caller.
I think what would make the most sense is to include the uri
if and only if apiVersion == 1
. You could define it as uri = sourceUri.empty() ? sourcePeer : sourceUri
. (It's not spec'd as optional, so let it be set to an empty string if both values are empty.)
I think that regardless of version, it would be safe to add both source_uri
and source_peer
in the result.
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.
I had same concern about the API breaking change. Here is an example we can probably follow, #3770. Note how the config is enabled in unit tests.
(@undertome I forgot it when we chatted.)
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.
What about when this method gets called via OverlayImpl::processCrawl
-> OverlayImpl::getUnlInfo
. In the former function the version
for the response message (response<json_body>
) is being set to "2". In this case should I use 2 as the API version?
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 say the existing code returns API version 1 response and the new code returns API version 2 response. I think we need to keep both code paths, so that the correct response can be returned.
If a RPC request has "api_version": 2
, we should return API version 2 response.
If a RPC request has "api_version": 1
or if this field is missing, API version 1 response should be returned. OverlayImpl::processCrawl
should also return API version 1 response.
I think #3770 is a good and simple example. Please take a look.
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.
That doesn't really answer my question. I'm asking whether the version in the response message sent from the OverlayImpl
should be treated the same as the RPC api_version
number. As for as I can tell #3770 doesn't address this specific question. BTW, in OverlayImpl::processCrawl
the version is being hard coded to 2
regardless of any version info in the request. Is that intended? At @ximinez maybe you can shed some light?
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.
"I'm asking whether the version in the response message sent from the OverlayImpl should be treated the same as the RPC api_version number." I think not. Let's see what @ximinez thinks.
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.
The UNL version (returned from OverlayImpl) is entirely separate from the API version.
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.
@ximinez For lists sent via the OverlaImpl
, is it ok to just always send the new fields instead of uri
?
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.
I didn't even realize that crawl
had versioning until now, and the rules don't seem to be documented other than https://xrpl.org/peer-crawler.html#response-format noting the version changed in 1.2.1. Maybe somebody else can weigh in, but my thinking is that if you don't change the version number, just add the new fields without removing any.
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.
Ok, done
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.
We probably can follow this example to handle the API breaking change. Looks good otherwise.
2e88564
to
99682e8
Compare
99682e8
to
d57db1f
Compare
@alloynetworks @WietseWind could you have a look too? |
Why does it need to be a breaking change? Retain the old behaviour by continuing to emit the |
@intelliot I don't think anything has changed since I last looked at this, so why did you request a re-review? |
It looked like the branch was force-pushed after your request for changes |
std::string siteUri, | ||
std::string source, |
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.
There are only two non-test callers to applyListsAndBroadcast
, in ValidatorSite.cpp (line 405), and PeerImp.cpp (line 2298). Instead of the overhead of parsing source
to figure out what type it is, why not add another parameter to this function, and applyLists
and applyList
? To keep it super explicit, you could make it an enum
:
enum class SourceType
{
Site,
Peer
};
@@ -28,6 +28,7 @@ | |||
#include <ripple/json/json_value.h> | |||
#include <ripple/overlay/Message.h> | |||
#include <ripple/protocol/PublicKey.h> | |||
#include <ripple/rpc/Context.h> |
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.
This violates levelization. I know RPC is included all over the place in the app, but RPC should be at a higher level, so let's not make it worse. Instead, rewrite getJson
to take a std::optional<unsigned int> apiVersion
parameter.
auto appendList = [&context]( | ||
PublisherList const& publisherList, | ||
Json::Value& target) { | ||
if ((context && context->apiVersion == 1) || !context) |
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.
This can be written as if (!context || context->apiVersion == 1)
. Or if you get rid of the context object as I suggested above, it would be if (!apiVersion || *apiVersion == 1)
.
target[jss::uri] = publisherList.sourceUri.empty() | ||
? publisherList.sourcePeer | ||
: publisherList.sourceUri; | ||
if (!publisherList.sourceUri.empty()) | ||
target[jss::source_uri] = publisherList.sourceUri; |
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.
You know, @RichardAH has a good point in his comment #3984 (comment).
What do you think about completely removing the new jss::source_uri
field, and just including the sourceUri
member as jss::uri
? You could get rid of context
entirely.
(notes: this may have been added already in a different way; @nbougalis will check on that later) |
@nbougalis @pwang200 - any thoughts on this PR? Does it still make sense to merge, or should this PR be closed without merging? |
I think Ed's comments should be addressed. So it should not be merged as is. My vote is close the PR without merging. |
Closing this PR due to inactivity. #3949 is still open and should be addressed with a new PR. |
High Level Overview of Change
This pull request resolves #3949 by specifying the source of stored validator lists as displayed in the response to the rpc command
validators
.Type of Change
Before / After
This change introduces two field names to replace an existing name. Consequently, this change may compel updates to applications that expect the old name. Specifically
uri
will become eithersource_uri
orsource_peer
depending on the source of the validator list.Test Plan
Unit tests and integration tests were conducted to confirm expected behavior.