-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
simapp: rename MakeEncodingConfig to MakeTestEncodingConfig #7681
Conversation
+ Adding DEPRECATED attribute.
@@ -34,7 +34,7 @@ var ( | |||
}, | |||
} | |||
|
|||
encodingConfig = simapp.MakeEncodingConfig() | |||
encodingConfig = simapp.MakeTestEncodingConfig() |
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.
Any idea how we should update this README file?
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.
It seams that the MakeTestEncodingConfig
is needed to users who want to use cli
.
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.
No it shouldn't be. Not sure why this is here.
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 example code needs to be rewritten to not use EncodingConfig
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.
No it shouldn't be. Not sure why this is here.
Another point that this task is useful ;)
Codecov Report
@@ Coverage Diff @@
## master #7681 +/- ##
=======================================
Coverage 54.14% 54.14%
=======================================
Files 611 611
Lines 38558 38558
=======================================
Hits 20876 20876
Misses 15550 15550
Partials 2132 2132 |
@@ -38,7 +38,7 @@ import ( | |||
// NewRootCmd creates a new root command for simd. It is called once in the | |||
// main function. | |||
func NewRootCmd() (*cobra.Command, params.EncodingConfig) { | |||
encodingConfig := simapp.MakeEncodingConfig() | |||
encodingConfig := simapp.MakeTestEncodingConfig() |
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 line is hte line being referenced in the documentation at server/README.md
. I know that "simapp" in generally is mainly for testing purposes, but it seems strange to call this MakeTestEncodingConfig
here, when from what I understand users will mostly be copying a lot of simapp/simd
code into their own application when building their own chains.
Perhaps its fine if we have a better strategy for users than looking at simapp/
code when bootstrapping their own app.
@aaronc when you said that we shouldint depend on EncodingConfig
at all in the server/README.md
, what do you suggest we do here instead? explicitly do all the interface registry stuff here in this function to make it super clear ?
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.
MakeTestEncodingConfig
is just the wrong name for this function I'd say. What was the rationale in the first place?
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.
It's just for switching between amino and protobuf builds.
I don't think simapp is intended to be a reference for apps. The tutorial is for that. Simd was only added during stargate work for testing it was never intended as a reference.
If we want to make simapp a reference for apps we should pull out all the legacy stuff and fully deprecate amino support which will allow EncodingConfig to go away.
Apps should just create a codec and register interfaces as needed. There is a reason why EncodingConfig is in simapp and not part of the SDK proper.
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.
It makes sense to me, thanks. Yet IMHO the MakeTestEncodingConfig
name does not suggest anything like that and MakeEncodingConfig
seems still the best name?
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.
@@ -432,7 +432,7 @@ func NewSimApp( | |||
// simapp. It is useful for tests and clients who do not want to construct the | |||
// full simapp | |||
func MakeCodecs() (codec.Marshaler, *codec.LegacyAmino) { | |||
config := MakeEncodingConfig() | |||
config := MakeTestEncodingConfig() |
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.
config := MakeTestEncodingConfig() | |
config := simappparams.MakeEncodingConfig() | |
std.RegisterLegacyAminoCodec(config.Amino) | |
std.RegisterInterfaces(config.InterfaceRegistry) | |
ModuleBasics.RegisterLegacyAminoCodec(config.Amino) | |
ModuleBasics.RegisterInterfaces(config.InterfaceRegistry) |
How about:
- Move
simapp/encoding.go
totestutil/encoding.go
(That's where it really belongs) - Make the above change (as per simapp: rename MakeEncodingConfig to MakeTestEncodingConfig #7681 (comment), "Apps should just create a codec and register interfaces as needed.")
Advantages:
MakeTestEncodingConfig
lives intestutil
, which makes sense.- For users looking at simapp as a reference implementation, they will do registration directly in
NewSimApp
as above. This importsMakeEncodingConfig
from./params
, which is okay.
Disadvantages:
- We write twice the registration (once for tests, once for reference). It's only executed once though).
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 like this approach! 👍
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 is what we want to do in #7642. This PR, as noted in the description, is a temporal solution for that.
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 fact what we want to do in #7642 is to hide the MakeTestEncodingConfig
in a private method, and use app.AppCodecs
outside.
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 this change is still an improvement. It's not perfect, but "perfect" requires a way bigger refactoring. So I'm okay to merge this now.
* simapp: rename MakeEncodingConfig to MakeTestEncodingConfig * Updating the Changelog + Adding DEPRECATED attribute. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Description
Temporal solution for #7642
Refactoring
MakeEncodingConfig
is a bigger work. For the Stargate release we want to make it clear to the users that this method is rather internal and deprecated to use in their apps.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