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

New validator_info and manifest RPC methods #3197

Closed
wants to merge 2 commits into from
Closed

New validator_info and manifest RPC methods #3197

wants to merge 2 commits into from

Conversation

movitto
Copy link
Contributor

@movitto movitto commented Dec 30, 2019

This pull request addresses issue #3099 by adding two new RPC methods to allow the inspection of validator state.

  • validator_info will return information pertaining to the current validators keys, manifest sequence, and domain

  • manifest looks up manifest information for the specified key (either master or ephemeral)

Utility methods have been added to other modules to support this functionality

Copy link
Contributor

@nbougalis nbougalis left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for your contribution. There's a few things that I'd like to see addressed before I sign off on this.

src/ripple/app/misc/Manifest.h Show resolved Hide resolved
src/ripple/app/misc/Manifest.h Show resolved Hide resolved
src/ripple/app/misc/Manifest.h Outdated Show resolved Hide resolved
src/ripple/app/misc/impl/Manifest.cpp Show resolved Hide resolved
src/ripple/net/impl/RPCCall.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/ValidatorInfo.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/Manifest.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/ValidatorInfo.cpp Outdated Show resolved Hide resolved
src/ripple/app/main/Application.h Outdated Show resolved Hide resolved
ret[jss::master_key] = toBase58(TokenType::NodePublic, pk);

auto ek = context.app.validatorManifests().getSigningKey(pk);
ret[jss::ephemeral_key] = toBase58(TokenType::NodePublic, ek);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should detect and account for the use case where a validator is configured with a fixed key and not a manifest. If that happens, this field and those that follow are not relevant and should not be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I addressed this by checking if the ephemeral key does exists, and if not using this to imply the manifest is not present. Please correct if this is the wrong assumption

Copy link
Contributor Author

@movitto movitto left a comment

Choose a reason for hiding this comment

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

@nbougalis many thanks for the review. I believe I addressed all feedback save an item above. Let me know it there is anything else!

Edit: meant to leave this as a comment... not a review of my own patches 🤦‍♂️

Copy link
Contributor

@nbougalis nbougalis left a comment

Choose a reason for hiding this comment

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

I believe you've addressed all my concerns, thanks! We need one more review for this to be considered Passed.

@nbougalis nbougalis requested review from jwbusch and seelabs January 2, 2020 06:17
Copy link
Collaborator

@seelabs seelabs left a comment

Choose a reason for hiding this comment

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

This looks good. There are some formatting nits we should probably resolve. To resolve the formatting, you can try running clang format over Manifest.cpp and ValidatorIndo.cpp with the .clang_format rules checked in with rippled. (I'm also happy to do this and submit a patch if it's a pain for you).

src/ripple/net/impl/RPCCall.cpp Outdated Show resolved Hide resolved
src/ripple/net/impl/RPCCall.cpp Outdated Show resolved Hide resolved
src/ripple/net/impl/RPCCall.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/Manifest.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/Manifest.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/Manifest.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/Manifest.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/ValidatorInfo.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/ValidatorInfo.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/handlers/ValidatorInfo.cpp Outdated Show resolved Hide resolved
@seelabs
Copy link
Collaborator

seelabs commented Jan 6, 2020

I also noticed there are no unit tests for this. It would be good to have some simple tests for this as well.

@seelabs
Copy link
Collaborator

seelabs commented Jan 6, 2020

Non-unity build is broken. I think if both ValidatorInfo and Manifest have the following includes it should fix it:

#include <ripple/app/main/Application.h>
#include <ripple/basics/base64.h>
#include <ripple/json/json_value.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/Context.h>

@movitto
Copy link
Contributor Author

movitto commented Jan 8, 2020

@seelabs thanks for the review. Resolved the style issues and added missing includes for the unity build.

As far as static_cast, making the change results in the following error:

/home/mmorsi/Workspace/rippled/src/ripple/rpc/handlers/Manifest.cpp:55:94: error: invalid static_cast from type ‘const char*’ to type ‘const uint8_t*’ {aka ‘const unsigned char*’}
   55 |         ret[jss::manifest] = base64_encode(static_cast<std::uint8_t const*>(manifest->c_str()),

Could you advice a fix or should this be left as is?

Will look into adding some tests in the near future.

@codecov-io
Copy link

codecov-io commented Jan 8, 2020

Codecov Report

Merging #3197 into develop will decrease coverage by <.01%.
The diff coverage is 71.08%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3197      +/-   ##
===========================================
- Coverage    70.33%   70.32%   -0.01%     
===========================================
  Files          675      677       +2     
  Lines        53178    53250      +72     
===========================================
+ Hits         37402    37450      +48     
- Misses       15776    15800      +24
Impacted Files Coverage Δ
src/ripple/app/misc/Manifest.h 55.55% <ø> (ø) ⬆️
src/ripple/app/main/Application.h 100% <ø> (ø) ⬆️
src/ripple/rpc/impl/Handler.cpp 96.49% <ø> (ø) ⬆️
src/ripple/protocol/ErrorCodes.h 100% <100%> (ø) ⬆️
src/ripple/net/impl/RPCCall.cpp 93.47% <52.63%> (-1.25%) ⬇️
src/ripple/rpc/handlers/Manifest.cpp 57.69% <57.69%> (ø)
src/ripple/app/misc/impl/Manifest.cpp 85.95% <83.33%> (-0.22%) ⬇️
src/ripple/rpc/handlers/ValidatorInfo.cpp 94.44% <94.44%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc4cefa...2e5705d. Read the comment docs.

@jwbusch
Copy link

jwbusch commented Jan 9, 2020

/home/mmorsi/Workspace/rippled/src/ripple/rpc/handlers/Manifest.cpp:55:94: error: invalid static_cast from type ‘const char*’ to type ‘const uint8_t*’ {aka ‘const unsigned char*’}
   55 |         ret[jss::manifest] = base64_encode(static_cast<std::uint8_t const*>(manifest->c_str()),

Could you advice a fix or should this be left as is?

Will look into adding some tests in the near future.

ret[jss::manifest] = base64_encode(*manifest);

Should work as @seelabs mentioned.

@movitto
Copy link
Contributor Author

movitto commented Jan 9, 2020

@seelabs @jwbusch cool thanks for the feedback. Called the simpler base64_encode method, removed the cast, and added some tests. Let me know if there is anything else!

Copy link

@jwbusch jwbusch left a comment

Choose a reason for hiding this comment

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

Looked through the tests you added, LGTM.


Json::Value ret;

auto pk = context.app.getValidationPublicKey();
Copy link

@jwbusch jwbusch Jan 9, 2020

Choose a reason for hiding this comment

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

nit: Would like to see more const used if possible. i.e. auto const pk = ...

Makes it clear that the variable won't be modified later (which is the case for a lot of these).

src/ripple/rpc/handlers/ValidatorInfo.cpp Show resolved Hide resolved
@movitto
Copy link
Contributor Author

movitto commented Jan 10, 2020

@jwbusch pushed a patch constantizing the fields. As far as the scoped ephimeral_key, that method (getSigningKey, already existing before this PR) works a bit different than the new ones in the sense that if the key is not found, the input param (the master key) is simply returned. Since this is not a boost::optional we can't check it's 'truthyness' like the other fields.

@seelabs
Copy link
Collaborator

seelabs commented Jan 15, 2020

I think this is ready to go, we just need to fix the non-unity build issues. I think we just need to patch two files. I think this patch should fix things: seelabs@b47e374

@movitto
Copy link
Contributor Author

movitto commented Jan 21, 2020

I think this is ready to go, we just need to fix the non-unity build issues. I think we just need to patch two files. I think this patch should fix things: seelabs@b47e374

@seelabs cherry picked onto this branch, thanks!

Copy link
Collaborator

@seelabs seelabs left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks @movitto. I'm approving this, tho we do need to rebase this onto 1.5.0-b3.

@seelabs
Copy link
Collaborator

seelabs commented Jan 21, 2020

@movitto FYI: Rebasing should be pretty straight-forward. One change to look out for is the parameters for doValidatorInfo and doManifest need to be changed from RPC::Context to RPC::JsonContext.

@nbougalis
Copy link
Contributor

@movitto: I can handle the rebase and squashing down if you want, and would be happy to jump on a call with you to walk you through the commands and explain what I'm doing so you know for the next time.

@movitto
Copy link
Contributor Author

movitto commented Jan 27, 2020

@nbougalis sure that works. With the XRP meetup tomorrow won't have time to do the call until later on in the week, but perhaps we can schedule it for then (lets coordinate on that one via email)

Returns local validator details and specified manifest information
respectively. Folded and rebased on latest develop
@movitto
Copy link
Contributor Author

movitto commented Feb 6, 2020

@seelabs @nbougalis rebased and pushed a followup patch w/ the 'Context' -> 'JsonContext' substitution. Using @mellery451's protobuf fix from #3244 (not included in this PR) I was able to build and test locally.

@seelabs seelabs added Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. and removed Rebase labels Feb 7, 2020
@seelabs
Copy link
Collaborator

seelabs commented Feb 7, 2020

@movitto Things looks good; I just added a "passed" label. Thanks for (yet another) contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change Documentation README changes, code comments, etc. Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants