Add consensus params into Simulation#6002
Merged
mergify[bot] merged 25 commits intomasterfrom Apr 21, 2020
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6002 +/- ##
==========================================
- Coverage 54.71% 54.65% -0.06%
==========================================
Files 424 424
Lines 25794 25820 +26
==========================================
Hits 14113 14113
- Misses 10710 10736 +26
Partials 971 971 |
alexanderbez
suggested changes
Apr 20, 2020
alessio
reviewed
Apr 21, 2020
alessio
reviewed
Apr 21, 2020
alessio
reviewed
Apr 21, 2020
alessio
approved these changes
Apr 21, 2020
alexanderbez
suggested changes
Apr 21, 2020
Contributor
alexanderbez
left a comment
There was a problem hiding this comment.
Thanks @jgimeno, I left a few bits of feedback.
|
|
||
| // GetGenesisStateFromAppState returns x/staking GenesisState given raw application | ||
| // genesis state. | ||
| func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState { |
Contributor
There was a problem hiding this comment.
Is this even called/used? I'd opt to remove it.
Contributor
Author
There was a problem hiding this comment.
yeah in x/simulation/params.go line 182
Contributor
There was a problem hiding this comment.
Ok so you removed the other, now removed private helper function 👍
alexanderbez
approved these changes
Apr 21, 2020
|
|
||
| // GetGenesisStateFromAppState returns x/staking GenesisState given raw application | ||
| // genesis state. | ||
| func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState { |
Contributor
There was a problem hiding this comment.
Ok so you removed the other, now removed private helper function 👍
Contributor
|
|
Contributor
Author
|
Checking |
Contributor
|
so the problem is that // TestAppImportExport L86
appState, _, cp, err := app.ExportAppStateAndValidators(false, []string{}) // return ConsensusParams
require.NoError(t, err)
require.NotNil(t, cp)
fmt.Printf("importing genesis...\n")
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
require.NoError(t, err, "simulation setup failed")
defer func() {
newDB.Close()
require.NoError(t, os.RemoveAll(newDir))
}()
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, fauxMerkleModeOpt)
require.Equal(t, "SimApp", newApp.Name())
var genesisState GenesisState
err = app.Codec().UnmarshalJSON(appState, &genesisState)
require.NoError(t, err)
genesisState["consensus_params"] = app.Codec().MustMarshalJSON(cp) // add consensus params
ctxA := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctxB, app.Codec(), genesisState) // will fail because consensus params are not part of any module |
11 tasks
Contributor
Author
|
Ok thanks! Got it, can we revert this branch meanwhile? |
alexanderbez
added a commit
that referenced
this pull request
Apr 21, 2020
This reverts commit 6504868.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #5988
Description
For contributor use:
docs/) or specification (x/<module>/spec/)godoccomments.Unreleasedsection inCHANGELOG.mdFiles changedin the Github PR explorerFor admin use:
WIP,R4R,docs, etc)