-
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
Add height in exported genesis #7089
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7089 +/- ##
==========================================
+ Coverage 54.99% 55.02% +0.03%
==========================================
Files 562 562
Lines 38703 38737 +34
==========================================
+ Hits 21283 21315 +32
- Misses 15671 15673 +2
Partials 1749 1749 |
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 apart from the question I have. Also, this doesn't actually seem to work, but I presume it's completely unrelated to this PR:
panic: UnmarshalJSON cannot decode empty bytes
goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.Get(0x2e8a7d18, 0xc001261580, 0xc000122170, 0x59130a0, 0xc001261650, 0x5913120, 0xc0012616b0, 0xc001009340, 0x4, 0x1a, ...)
github.com/cosmos/cosmos-sdk/x/params/types/subspace.go:109 +0x30c
github.com/cosmos/cosmos-sdk/x/params/types.Subspace.GetParamSet(0x2e8a7d18, 0xc001261580, 0xc000122170, 0x59130a0, 0xc001261650, 0x5913120, 0xc0012616b0, 0xc001009340, 0x4, 0x1a, ...)
github.com/cosmos/cosmos-sdk/x/params/types/subspace.go:222 +0x188
github.com/cosmos/cosmos-sdk/x/auth/keeper.AccountKeeper.GetParams(...)
github.com/cosmos/cosmos-sdk/x/auth/keeper/params.go:15
github.com/cosmos/cosmos-sdk/x/auth.ExportGenesis(0x592e360, 0xc000126008, 0x5942200, 0xc000fe0f00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/cosmos/cosmos-sdk/x/auth/genesis.go:32 +0x130
github.com/cosmos/cosmos-sdk/x/auth.AppModule.ExportGenesis(0x59130a0, 0xc0012615e0, 0x2e8a7d18, 0xc001261580, 0x2e8a7d18, 0xc001261580, 0xc000122170, 0x59130a0, 0xc001261650, 0x5913120, ...)
github.com/cosmos/cosmos-sdk/x/auth/module.go:138 +0x98
github.com/cosmos/cosmos-sdk/types/module.(*Manager).ExportGenesis(0xc001156a10, 0x592e360, 0xc000126008, 0x5942200, 0xc000fe0f00, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/cosmos/cosmos-sdk/types/module/module.go:315 +0x11e
github.com/cosmos/cosmos-sdk/simapp.(*SimApp).ExportAppStateAndValidators(0xc000207100, 0xc001266200, 0x63f4548, 0x0, 0x0, 0x0, 0xc000122101, 0xc001269b00, 0x0, 0x0, ...)
github.com/cosmos/cosmos-sdk/simapp/export.go:31 +0x170
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.exportAppStateAndTMValidators(0x592e7e0, 0xc001266240, 0x5944400, 0xc000122038, 0x0, 0x0, 0xffffffffffffffff, 0x0, 0x63f4548, 0x0, ...)
github.com/cosmos/cosmos-sdk/simapp/simd/cmd/root.go:210 +0x251
github.com/cosmos/cosmos-sdk/server.ExportCmd.func1(0xc00116cdc0, 0xc0011ee380, 0x0, 0x2, 0x0, 0x0)
github.com/cosmos/cosmos-sdk/server/export.go:67 +0x351
github.com/spf13/cobra.(*Command).execute(0xc00116cdc0, 0xc0011ee360, 0x2, 0x2, 0xc00116cdc0, 0xc0011ee360)
github.com/spf13/cobra@v1.0.0/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc00026b340, 0x0, 0x0, 0xc00111bc80)
github.com/spf13/cobra@v1.0.0/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.0.0/command.go:887
github.com/spf13/cobra.(*Command).ExecuteContext(...)
github.com/spf13/cobra@v1.0.0/command.go:880
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.Execute(0xc00026b340, 0x5931160, 0xc00111d3e0)
github.com/cosmos/cosmos-sdk/simapp/simd/cmd/root.go:82 +0x158
main.main()
github.com/cosmos/cosmos-sdk/simapp/simd/main.go:11 +0x2a
@alexanderbez How did you get the JSON error? (i already fixed one of those in this PR in ValidateGenesis) here's how i tested:
|
$ make clean localnet-start
$ BUILDDIR=./build/macos make build-simd
// wait for a few blocks...
$ ./build/macos/simd export |
…018-export-height
…018-export-height
// as if they could withdraw from the start of the next block | ||
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) | ||
|
||
// We export at last height + 1, because that's the height at which | ||
// Tendermint will start InitChain. | ||
height := app.LastBlockHeight() + 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.
@alexanderbez I finally still decided to export at N + 1
.
Tendermint will then call InitChain with initial_height = N + 1
(or 1
if not set). So we InitChain(optionally also BeginBlock) at N+1
, and the first commit on the new/upgraded chain will be at N+1
.
Let me know if that makes sense to you.
@alexanderbez thanks for the review & test, I addressed both points (added a test case for 1.) |
@amaurymartiny did you test the flow on an actual chain? If so, feel free to merge 👍 |
Just ran these tests on an actual chain. Validated that the However, I'm getting panics when running export with a manually set
|
…018-export-height
…s-sdk into am-7018-export-height
@clevinson thanks, reproed and fixed! I also added a test case. @alexanderbez Yeah, I tested on an actual chain like how Cory did. Once #6839 is in, will try on the hub too. |
Ok, feel free to merge whenever you're good. |
…018-export-height
…s-sdk into am-7018-export-height
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.
utACK
Requested in cosmos/cosmos-sdk#7089 (comment). I didn't add a `GetInitialVersion()`, since it's not clear whether this should return only the option or the _actual_ initial version that exists in a tree. It might be cleaner to add `GetOptions()`, `SetOptions()`, and `UpdateOptions(func (o Options) Options)`, but we may not want all options to be mutable after construction. CC @amaurymartiny
* Add height in exported genesis * +1 * Add test * Refactor ctx in setupApp * Use amino in export * Use tmjson * Add custom initialVersion (set to 0 for now) * Add comment * Add mount in initChainer * app.LastBlockheight * InitializeAndSeal in InitChain? * Revert create store with initial version * Update to latest iavl * Check height in test * Make it work * Add more tests * Rename interface * Use struct isntead of 6 args * Fix lint * Remove stray fmt * Revert go mod/sum * Install iavl rc3 * Update comments * Add fee in network * Typo * Fix logic in commit * Fix tests * Only set initial version on > 1 * Genesis block num = 1 * Fresh chain, genesis block = 0 * Add comments * Revert Mutable/ImmutableTree * Allow for zero height * Fix restart * Add comments * Add comments, fix test * Fix remaining one test * Add panic test * Update comment * Add test for --height * No cast * Add check that genesis file exists * Remove duplicate imports * Fail early Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com> Co-authored-by: Cory <cjlevinson@gmail.com>
Description
closes: #7018
Important changes
initial_height
field is correctly populated in the export commandSetInitialVersion
has been added to baseapp's CommitMultiStore, which sets the initial version to IAVL storesNotes
simd export
works with the correct height.TODO:
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