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

Migrate x/params to protocol buffers for state encoding #7114

Closed
wants to merge 8 commits into from

Conversation

clevinson
Copy link
Contributor

@clevinson clevinson commented Aug 20, 2020

Description

This PR migrates the x/params module to use protobuf for encoding params state in its store.

The main change is updating this struct:

// source: x/params/types/paramset.go

ParamSetPair struct {
	Key         []byte
-	Value       interface{}
+	Value       codec.ProtoMarshaler
	ValidatorFn ValueValidatorFn
}

And subsequently updating all marshalers, validator functions, and other downstream refactoring...

This PR will also migrate the params for each module.

closes: #6983


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.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes


if pty != ty {
if registeredProtoMarshaler != value {
Copy link
Contributor Author

@clevinson clevinson Aug 20, 2020

Choose a reason for hiding this comment

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

This actually needs to check for type equality, not value equality.

@alexanderbez @aaronc Is there a way to do that without reflection?

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean the concrete types? No, I can't think of any other way apart from reflection.

@@ -54,7 +54,7 @@ func ParamKeyTable() paramtypes.KeyTable {
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {

return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, p.MaxMemoCharacters, validateMaxMemoCharacters),
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &pt.UInt64Value{Value: p.MaxMemoCharacters}, validateMaxMemoCharacters),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexanderbez this is the kind of stuff we would need all over the place for param values if we wanted to keep the proto representation as primitive types.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, makes sense!

@clevinson clevinson force-pushed the clevinson/params-proto-encoding branch from 83f8fd5 to a156dca Compare August 20, 2020 22:19
@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 9, 2020
@clevinson clevinson closed this Oct 14, 2020
@alessio alessio deleted the clevinson/params-proto-encoding branch March 14, 2021 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate x/params JSON state
2 participants