-
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
Enable proto JSON generally and remove HybridCodec #6859
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6859 +/- ##
==========================================
+ Coverage 61.02% 61.95% +0.92%
==========================================
Files 381 520 +139
Lines 24844 32036 +7192
==========================================
+ Hits 15162 19848 +4686
- Misses 8486 10559 +2073
- Partials 1196 1629 +433 |
the genesis is encoded with a similar json style as amino. is the current approach a problem? |
Is it okay if we just use |
Applications should be free to use whatever format they want with Tendermint because the application state is json.RawMessage. |
Not sure how to debug the failing sims. Any thoughts @alexanderbez ? Quite sure it has to do with amino being used somewhere for genesis, just not sure where |
Seems only to be involved with export/import, I reran one of the seeds from CI: $ go test ./simapp -run TestAppImportExport -Enabled=true -NumBlocks=50 -Genesis= -Verbose=true -Commit=true -Seed=7 -Period=5 -v -timeout 24h
...
exporting genesis...
importing genesis...
--- FAIL: TestAppImportExport (89.33s)
panic: unknown value "NoWithVeto" for enum cosmos.gov.v1beta1.VoteOption [recovered]
panic: unknown value "NoWithVeto" for enum cosmos.gov.v1beta1.VoteOption
goroutine 50 [running]:
testing.tRunner.func1.1(0x5027600, 0xc00273ee90)
/usr/local/go/src/testing/testing.go:1057 +0x30d
testing.tRunner.func1(0xc0005d2d80)
/usr/local/go/src/testing/testing.go:1060 +0x41a
panic(0x5027600, 0xc00273ee90)
/usr/local/go/src/runtime/panic.go:969 +0x175
github.com/cosmos/cosmos-sdk/codec.(*ProtoCodec).MustUnmarshalJSON(0xc000e36aa0, 0xc00572e000, 0xc9d6b, 0xca000, 0x51b8d20, 0xc003d9be60)
/Users/aleksbez/code/cosmos/cosmos-sdk/codec/proto_codec.go:132 +0x8a
github.com/cosmos/cosmos-sdk/x/gov.AppModule.InitGenesis(0x55afce0, 0xc0013f0320, 0x0, 0x0, 0x0, 0x5588280, 0xc00247cd80, 0x559e000, 0xc0001ad200, 0x2df4c710, ...)
/Users/aleksbez/code/cosmos/cosmos-sdk/x/gov/module.go:162 +0xa4
github.com/cosmos/cosmos-sdk/types/module.(*Manager).InitGenesis(0xc004476a10, 0x559cf40, 0xc0000400b0, 0x55adae0, 0xc00302ed80, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/aleksbez/code/cosmos/cosmos-sdk/types/module/module.go:293 +0x2b5
github.com/cosmos/cosmos-sdk/simapp.TestAppImportExport(0xc0005d2d80)
/Users/aleksbez/code/cosmos/cosmos-sdk/simapp/sim_test.go:145 +0xe52
testing.tRunner(0xc0005d2d80, 0x5406428)
/usr/local/go/src/testing/testing.go:1108 +0xef
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1159 +0x386
FAIL github.com/cosmos/cosmos-sdk/simapp 90.985s
FAIL |
Thanks @alexanderbez that gave me a helpful clue. Seems related to #7010. How did you get that seed command to run btw? |
@aaronc it's in the original comment: Run the following from the root dir:
If you take a look at the CI output, it'll actually show you the command to run for all the failed seeds. The issue makes sense though. We need to remove custom JSON marshaling for types? |
Okay thanks.
Well, it appears to work in some cases. For instance |
Yeah makes sense. Can we just address enums for now? |
That's the only thing this PR takes care of, just for the failing test cases. |
Okay, I think this is ready. Unit tests are passing again and sims were fixed in the last build |
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
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.
Ah, @sahith-narahari beat me to it. LGTM.
@@ -41,7 +41,7 @@ var ( | |||
// | |||
// The actual codec used for serialization should be provided to x/distribution and | |||
// defined at the application level. | |||
ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) | |||
ModuleCdc = codec.NewAminoCodec(amino) |
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.
Are these used in queriers or in REST?
* Remove HybridCodec * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * Test fixes * Delete hybrid_codec.go * Fixes * Fixes * Fixes * Test fixes * Test fixes * Test fixes * Lint * Sim fixes * Sim fixes * Revert * Remove vesting account JSON tests * Update CHANGELOG.md * Lint * Sim fixes * Sim fixes * Docs * Migrate more amino usages * Remove custom VoteOption String() and json marshaling * Fix tests * Add comments, update CHANGELOG.md Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Closes #6837
A few notes:
LegacyAmino
explicitly. That is a lot of what is happening herex/params
is still using amino JSON and requires it explicitly now becauseHybridCodec
is gone (to be addressed in Migrate x/params JSON state #6983)EmitDefaults
was turned on for proto JSON. This should overall produce a better UX but sometimes adds empty fields which aren't too informative. We may need to experiment with this.AccountRetriever
still uses amino JSON (to be cleaned up in Migrate AccountRetriever to proto #6985)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