chore: loosen assertions in SetOrderInitGenesis and SetOrderExportGenesis (#14457)

This commit is contained in:
Julien Robert 2023-01-02 10:05:09 +01:00 committed by GitHub
parent 88623edb7c
commit 461cf87218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 49 deletions

View File

@ -6,9 +6,9 @@ This guide provides instructions for upgrading to specific versions of Cosmos SD
### Database configuration
Cleveldb, Boltdb and BadgerDB are not supported anymore. To migrate from a unsupported database to a supported database please use the database migration tool
ClevelDB, BoltDB and BadgerDB are not supported anymore. To migrate from a unsupported database to a supported database please use the database migration tool.
<!-- TODO: write data base migration tool -->
<!-- TODO: write database migration tool -->
### Protobuf
@ -19,6 +19,13 @@ The SDK is in the process of removing all `gogoproto` annotations.
The `gogoproto.goproto_stringer = false` annotation has been removed from most proto files. This means that the `String()` method is being generated for types that previously had this annotation. The generated `String()` method uses `proto.CompactTextString` for _stringifying_ structs.
[Verify](https://github.com/cosmos/cosmos-sdk/pull/13850#issuecomment-1328889651) the usage of the modified `String()` methods and double-check that they are not used in state-machine code.
### SimApp
#### Module Assertions
Previously, all modules were required to be set in `OrderBeginBlockers`, `OrderEndBlockers` and `OrderInitGenesis / OrderExportGenesis` in `app.go` / `app_config.go`.
This is no longer the case, the assertion has been loosened to only require modules implementing, respectively, the `module.BeginBlockAppModule`, `module.EndBlockAppModule` and `module.HasGenesis` interfaces.
## [v0.47.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0)
### Simulation

View File

@ -245,7 +245,7 @@ func TestNotFoundErrors(t *testing.T) {
Service: testpb.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{{RpcMethod: "bar"}},
})
assert.ErrorContains(t, err, "rpc method bar not found")
assert.ErrorContains(t, err, "rpc method \"bar\" not found")
// bad positional field
_, err = b.BuildModuleQueryCommand("test", &autocliv1.ServiceCommandDescriptor{

View File

@ -51,21 +51,6 @@ import (
)
var (
// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder = []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName, consensustypes.ModuleName, runtime.ModuleName,
}
// module account permissions
moduleAccPerms = []*authmodulev1.ModuleAccountPermission{
{Account: authtypes.FeeCollectorName},
@ -126,12 +111,38 @@ var (
KvStoreKey: "acc",
},
},
InitGenesis: genesisModuleOrder,
// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
InitGenesis: []string{
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
nft.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
},
// When ExportGenesis is not specified, the export genesis module order
// is equal to the init genesis order
// ExportGenesis: genesisModuleOrder,
// ExportGenesis: []string{},
// Uncomment if you want to set a custom migration order here.
// OrderMigrations: nil,
// OrderMigrations: []string{},
}),
},
{

View File

@ -241,10 +241,9 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config {
opt(cfg)
}
// always add runtime module
beginBlockers := make([]string, 0)
endBlockers := make([]string, 0)
initGenesis := []string{"runtime"}
initGenesis := make([]string, 0)
overrides := make([]*runtimev1alpha1.StoreKeyConfig, 0)
for _, s := range beginBlockOrder {

View File

@ -293,13 +293,21 @@ func NewManagerFromMap(moduleMap map[string]appmodule.AppModule) *Manager {
// SetOrderInitGenesis sets the order of init genesis calls
func (m *Manager) SetOrderInitGenesis(moduleNames ...string) {
m.assertNoForgottenModules("SetOrderInitGenesis", moduleNames, nil)
m.assertNoForgottenModules("SetOrderInitGenesis", moduleNames, func(moduleName string) bool {
module := m.Modules[moduleName]
_, hasGenesis := module.(HasGenesis)
return !hasGenesis
})
m.OrderInitGenesis = moduleNames
}
// SetOrderExportGenesis sets the order of export genesis calls
func (m *Manager) SetOrderExportGenesis(moduleNames ...string) {
m.assertNoForgottenModules("SetOrderExportGenesis", moduleNames, nil)
m.assertNoForgottenModules("SetOrderExportGenesis", moduleNames, func(moduleName string) bool {
module := m.Modules[moduleName]
_, hasGenesis := module.(HasGenesis)
return !hasGenesis
})
m.OrderExportGenesis = moduleNames
}

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import as blank for app wiring
@ -61,7 +60,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
paramstypes.ModuleName,
consensustypes.ModuleName,
vestingtypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/authz/module" // import as blank for app wiring
@ -62,7 +61,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
authz.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -55,7 +54,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -60,7 +59,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -61,7 +60,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
evidencetypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import as blank for app wiring
@ -62,7 +61,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -5,7 +5,6 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/authz" // import as blank for app wiring
@ -64,7 +63,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
group.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -2,7 +2,6 @@ package testutil
import (
"cosmossdk.io/core/appconfig"
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -55,7 +54,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -2,7 +2,6 @@ package testutil
import (
"cosmossdk.io/core/appconfig"
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -59,7 +58,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
nft.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -50,7 +49,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -65,7 +64,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},

View File

@ -1,7 +1,6 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
@ -65,7 +64,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
runtime.ModuleName,
},
}),
},