-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
x/upgrade gRPC methods for VersionMap #9073
Conversation
-add optional field to get specific module from version map -added cli test for version map query from cli
-return better errors in grpc methods
Codecov Report
@@ Coverage Diff @@
## master #9073 +/- ##
==========================================
- Coverage 60.30% 60.12% -0.18%
==========================================
Files 588 590 +2
Lines 37001 37170 +169
==========================================
+ Hits 22313 22349 +36
- Misses 12711 12841 +130
- Partials 1977 1980 +3
|
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, but we should probably avoid map
s
// RPC method. | ||
message QueryVersionMapResponse { | ||
// version_map is a map of module name to consensus version. | ||
map<string, uint64> version_map = 1; |
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.
Hmm, i'm a bit wary of this. With ADR-033, Query services are part of the state machine, so I would like to avoid map
s altogether (looping through them is not deterministic).
Could we do repeated ModuleConsensusVersion
, where is ModuleConsensusVersion
is a message
with 2 fields string and uint64? And then this array would be sorted by module name (similarly to how we sort sdk.Coins).
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 think there ends up being a trade-off here in terms of efficiency vs. safety against the novice module developer.
so if a module developer converts the map to an array for later storage, there is 100% chance that the next queried map won't have the same ordering.
we do add some overhead to the query though, as we have to convert the map to a slice, and then alphabetically sort the slice by module name. (i think thats like O(nlogn*m). this may be negligible for a small query like this though.
if we did go with returning a slice, it would probably be better to change the query name from VersionMap
to something else (ModuleConsensusVersions
?), since the underlying return type is no longer a Map
.
curious if anyone else has thoughts - @aaronc ?
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 would love to use protobuf maps, and I think it's safer to just use a repeated
field instead. Using protobuf maps in APIs is something that will require its whole own "safety study" or something.
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.
sounds good to me. the current commit on this PR has the repeated
field implemented. That just leaves the issue of the naming:
QueryVersionMap
returning a slice would be a bit odd imo. I am thinking we can either
- rename it
- convert slice to map when request resolves in client
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 call it QueryModuleVersions
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.
QueryModuleVersions
sounds good to me too
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.
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaron@regen.network>
…into ty-8941-grpc_vm
…into ty-8941-grpc_vm
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
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
x/upgrade/client/cli/cli_test.go
Outdated
@@ -0,0 +1,114 @@ | |||
package cli_test |
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.
IntegrationTestSuite
needs to be updated as per #6711
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 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.
Preapproving
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
* setup version map query * query methods * grpc methods * cleanup * grpc for VersionMap * swagger update * swagger sync * cleanup * reset docs * clean * grpc with field * daily * -add grpc methods -add optional field to get specific module from version map -added cli test for version map query from cli * -consolidate grpc test to one test function -return better errors in grpc methods * consolidate tests * swagger update * this breaks * Try stringer on individual msgs * change map to slice in proto * cleanup * add comments to proto fields * cleanup * regen proto files * jsoncodec * rename gRPC methods * * add fetch method for module version slice * add method to return version given a module name * remove sorting functions * lint * Update proto/cosmos/upgrade/v1beta1/query.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * Update proto/cosmos/upgrade/v1beta1/upgrade.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * fix up comments and regen proto/swagger * Update x/upgrade/client/cli/query.go Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> * conform to pr 6711 * lint Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com> Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network>
Description
+Adds gRPC definitions to query the VersionMap from x/upgrade store
+Adds CLI method for VersionMap gRPC query
+Adds cli_test.go file for testing VersionMap cli query
+Updates the swagger file with the new gRPC endpoint
This PR includes changes on unrelated proto files as a result of the proto formatter
closes: #8941
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes