cosmos-sdk/types
Matt Kocubinski b363e0172e
fix: call SetOrderExportGenesis from SimApp (#12048)
## Description

This was causing sim failures like: 

```
exporting genesis...
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=0/12 module=x/crisis name=gov/module-account
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=1/12 module=x/crisis name=bank/nonnegative-outstanding
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=2/12 module=x/crisis name=bank/total-supply
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=3/12 module=x/crisis name=group/Group-TotalWeight
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=4/12 module=x/crisis name=distribution/nonnegative-outstanding
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=5/12 module=x/crisis name=distribution/can-withdraw
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=6/12 module=x/crisis name=distribution/reference-count
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=7/12 module=x/crisis name=distribution/module-account
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=8/12 module=x/crisis name=staking/module-accounts
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=9/12 module=x/crisis name=staking/nonnegative-power
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=10/12 module=x/crisis name=staking/positive-delegation
2022-05-25T10:36:38-05:00 INFO asserting crisis invariants inv=11/12 module=x/crisis name=staking/delegator-shares
2022-05-25T10:36:39-05:00 INFO asserted all invariants duration=1194.381198 height=50 module=x/crisis
importing genesis...
--- FAIL: TestAppSimulationAfterImport (20.98s)
panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction ({824635701280}) [recovered]
	panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction ({824635701280})

goroutine 76 [running]:
testing.tRunner.func1.2({0x1b88020, 0xc0035d70b0})
	/home/mkoco/sdk/go1.18.2/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/home/mkoco/sdk/go1.18.2/src/testing/testing.go:1392 +0x39f
panic({0x1b88020, 0xc0035d70b0})
	/home/mkoco/sdk/go1.18.2/src/runtime/panic.go:838 +0x207
github.com/cosmos/cosmos-sdk/types/module.(*Manager).InitGenesis(_, {{0x28b5990, 0xc0001b2000}, {0x28c2da0, 0xc002494600}, {{0x0, 0x0}, {0x0, 0x0}, 0x0, ...}, ...}, ...)
	/home/mkoco/dev/regen/cosmos-sdk/types/module/module.go:329 +0x4fd
github.com/cosmos/cosmos-sdk/runtime.(*App).InitChainer(_, {{0x28b5990, 0xc0001b2000}, {0x28c2da0, 0xc002494600}, {{0x0, 0x0}, {0x0, 0x0}, 0x0, ...}, ...}, ...)
	/home/mkoco/dev/regen/cosmos-sdk/runtime/app.go:121 +0x12e
github.com/cosmos/cosmos-sdk/simapp.(*SimApp).InitChainer(_, {{0x28b5990, 0xc0001b2000}, {0x28c2da0, 0xc002494600}, {{0x0, 0x0}, {0x0, 0x0}, 0x0, ...}, ...}, ...)
	/home/mkoco/dev/regen/cosmos-sdk/simapp/app.go:504 +0x178
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).InitChain(0xc000fb1340, {{0x0, 0x0, 0x0}, {0x0, 0x0}, 0x0, {0x0, 0x0, 0x0}, ...})
	/home/mkoco/dev/regen/cosmos-sdk/baseapp/abci.go:69 +0x3f5
github.com/cosmos/cosmos-sdk/simapp.TestAppSimulationAfterImport(0xc000abf520)
	/home/mkoco/dev/regen/cosmos-sdk/simapp/sim_test.go:269 +0xd67
testing.tRunner(0xc000abf520, 0x2590ac0)
	/home/mkoco/sdk/go1.18.2/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	/home/mkoco/sdk/go1.18.2/src/testing/testing.go:1486 +0x35f
FAIL	github.com/cosmos/cosmos-sdk/simapp	21.018s
FAIL
```

### Root cause

Prior to merge of #11924, SimApp calls [module/NewManager](2b549b807c/simapp/app.go (L344)), which implicitly sets sane default values of [OrderExportGenesis](2b549b807c/types/module/module.go (L239)) from the modules passed as parameters.  Since this usage was deprecated in favor of [RegisterModules](823d2a7f28/simapp/app.go (L354)) in the app wiring work, `OrderExportGenesis` was now `nil`, resulting in empty `genesisData` in [ExportGenesis](823d2a7f28/types/module/module.go (L339))



### Fix

Explicitly set `OrderExportGenesis` with same module order as `OrderInitGenesis` from `SimApp`.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2022-05-25 21:34:51 +00:00
..
address chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
bech32 chore: move server.GenerateCoinKey and server.GenerateSaveCoinKey to … (#10957) 2022-01-18 15:24:16 +00:00
errors refactor: Revert middlewares to antehandlers (part 1/2: baseapp) (#11979) 2022-05-20 09:27:27 +00:00
grpc Add GRPCBlockHeightHeader in clientCtx gRPC requests (#7021) 2020-08-12 14:42:10 +00:00
kv fix: check store keys length before accessing (#9639) 2021-07-08 13:29:12 +02:00
module chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
msgservice feat: add message option extension to signal msg signers in a language agnostic way (#10977) 2022-01-28 17:01:56 +00:00
query chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
simulation chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
tx refactor: Revert middlewares to antehandlers (part 1/2: baseapp) (#11979) 2022-05-20 09:27:27 +00:00
abci.go Merge PR #4613: Only change rootmultistore hash when substore hashes change 2019-06-25 13:11:22 -04:00
abci.pb.go fix: call SetOrderExportGenesis from SimApp (#12048) 2022-05-25 21:34:51 +00:00
address.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
address_race_test.go refactor!: Rename AccAddressFromHex (#11888) 2022-05-06 22:09:36 +00:00
address_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
bench_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
codec.go Remove ServiceMsgs from ADR-031 (#9139) 2021-04-30 11:00:47 +00:00
coin.go feat: add Coins.Find method (#11959) 2022-05-18 11:43:52 +00:00
coin.pb.go feat: Introduce Cosmos Scalars (#9933) 2021-09-21 09:46:29 +00:00
coin_benchmark_test.go test: fix BenchmarkCoinsAdditionIntersect panic (#9904) 2021-08-11 02:13:17 -07:00
coin_internal_test.go add sorted check for the coins sub/add fun parameter (#9240) 2021-05-05 15:55:28 +00:00
coin_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
config.go Deprecate SetFullFundraiserPath in favor of SetPurpose and SetCoinType (#8629) 2021-02-22 15:14:09 +00:00
config_test.go Deprecate SetFullFundraiserPath in favor of SetPurpose and SetCoinType (#8629) 2021-02-22 15:14:09 +00:00
context.go refactor: Revert middlewares to antehandler (part 2/2: posthandler) (#11985) 2022-05-23 10:32:38 +00:00
context_test.go fix(types): make UnwrapSDKContext work after context.WithValue (#11341) 2022-03-11 14:49:17 -05:00
dec_coin.go refactor!: create math go sub module (#11788) 2022-04-28 14:05:21 -04:00
dec_coin_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
decimal.go refactor: improve error messages (#11762) 2022-05-06 12:57:17 +00:00
decimal_internal_test.go types: tests -> test suites migration (#7400) 2020-09-28 12:46:49 +02:00
decimal_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
denom.go refactor!: create math go sub module (#11788) 2022-04-28 14:05:21 -04:00
denom_internal_test.go cli: convert coins to smallest unit registered (#7777) 2020-11-16 11:34:54 +00:00
events.go test: add test on `StringifyEvents` (#11972) 2022-05-16 12:16:08 -04:00
events_test.go test: add test on `StringifyEvents` (#11972) 2022-05-16 12:16:08 -04:00
handler.go refactor: Revert middlewares to antehandlers (part 1/2: baseapp) (#11979) 2022-05-20 09:27:27 +00:00
handler_test.go refactor!: Keyring migration (#9695) 2021-09-20 12:02:15 +00:00
invariant.go Merge PR #4832: print all failed invariants only 2019-08-05 14:21:44 -04:00
invariant_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00
math.go chore: update module path for math module (#11821) 2022-04-29 10:02:55 -04:00
proto.go linter: enable nolintlint (#6162) 2020-05-08 08:46:12 +00:00
queryable.go Merge PR #5421: Refactor Error Handling 2019-12-27 12:57:54 -05:00
result.go docs: improve godoc WrapServiceResult (#11736) 2022-04-24 20:53:56 +00:00
result_test.go refactor: middleware refactor to change tx.Handler interface (#10527) 2021-12-02 06:54:38 +00:00
router.go Remove duplicated Module.Route calls (#7716) 2020-10-29 22:01:09 +00:00
router_test.go types: tests -> test suites migration (#7405) 2020-09-29 13:29:10 +02:00
staking.go revert: Revert "feat: staking config (#10988)" (#11446) 2022-03-24 12:26:25 +01:00
staking_test.go revert: Revert "feat: staking config (#10988)" (#11446) 2022-03-24 12:26:25 +01:00
store.go refactor!: abstractions for snapshot and pruning; snapshot intervals eventually pruned; unit tests (#11496) 2022-04-21 15:30:36 -04:00
store_internal_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
store_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00
tx_msg.go refactor!: change GetSigners return type to []sdk.AccAddress (#9915) 2021-08-13 15:34:00 +00:00
tx_msg_test.go refactor!: change GetSigners return type to []sdk.AccAddress (#9915) 2021-08-13 15:34:00 +00:00
utils.go chore: (x/authz) add helpers `AppendBytes`, `ParseByteSlice` (#11713) 2022-04-21 14:52:31 -04:00
utils_test.go chore: gofumpt (#11839) 2022-05-19 10:55:27 +02:00