refactor(types): align genesis api (#19735)
This commit is contained in:
parent
a569ba6d29
commit
cdc329189b
10
CHANGELOG.md
10
CHANGELOG.md
@ -59,9 +59,10 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
|
||||
* (types) [#19672](https://github.com/cosmos/cosmos-sdk/pull/19672) `PreBlock` now returns only an error for consistency with server/v2. The SDK has upgraded x/upgrade accordingly. `ResponsePreBlock` hence has been removed.
|
||||
* (server) [#19455](https://github.com/cosmos/cosmos-sdk/pull/19455) Allow calling back into the application struct in PostSetup.
|
||||
* (types) [#19512](https://github.com/cosmos/cosmos-sdk/pull/19512) The notion of basic manager does not exist anymore.
|
||||
* (types) [#19512](https://github.com/cosmos/cosmos-sdk/pull/19512) The notion of basic manager does not exist anymore (and all related helpers).
|
||||
* The module manager now can do everything that the basic manager was doing.
|
||||
* `AppModuleBasic` has been deprecated for extension interfaces. Modules can now implement `HasRegisterInterfaces`, `HasGRPCGateway` and `HasAminoCodec` when relevant.
|
||||
* `AppModuleBasic` has been deprecated for extension interfaces.
|
||||
* Modules can now implement `appmodule.HasRegisterInterfaces`, `modue.HasGRPCGateway` and `module.HasAminoCodec` when relevant.
|
||||
* SDK modules now directly implement those extension interfaces on `AppModule` instead of `AppModuleBasic`.
|
||||
* (client/keys) [#18950](https://github.com/cosmos/cosmos-sdk/pull/18950) Improve `<appd> keys add`, `<appd> keys import` and `<appd> keys rename` by checking name validation.
|
||||
* (client/keys) [#18745](https://github.com/cosmos/cosmos-sdk/pull/18745) Improve `<appd> keys export` and `<appd> keys mnemonic` by adding --yes option to skip interactive confirmation.
|
||||
@ -82,6 +83,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
* (crypto | x/auth) [#14372](https://github.com/cosmos/cosmos-sdk/pull/18194) Key checks on signatures antehandle.
|
||||
* (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding
|
||||
* (x/auth) [#19651](https://github.com/cosmos/cosmos-sdk/pull/19651) Allow empty public keys in `GetSignBytesAdapter`.
|
||||
* (x/genutil) [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) Update genesis api to match new `appmodule.HasGenesis` interface.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@ -144,7 +146,9 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
* (types) [#19652](https://github.com/cosmos/cosmos-sdk/pull/19652)
|
||||
* Moved`types/module.HasRegisterInterfaces` to `cosmossdk.io/core`.
|
||||
* Moved `RegisterInterfaces` and `RegisterImplementations` from `InterfaceRegistry` to `cosmossdk.io/core/registry.LegacyRegistry` interface.
|
||||
* (types) [#19627](https://github.com/cosmos/cosmos-sdk/pull/19627) All genesis interfaces now don't take `codec.JsonCodec`. Every module has the codec already, passing it created an unneeded dependency. Additionally, to reflect this change, the module manager does not take a codec either.
|
||||
* (types) [#19627](https://github.com/cosmos/cosmos-sdk/pull/19627) and [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) All genesis interfaces now don't take `codec.JsonCodec`.
|
||||
* Every module has the codec already, passing it created an unneeded dependency.
|
||||
* Additionally, to reflect this change, the module manager does not take a codec either.
|
||||
|
||||
### Client Breaking Changes
|
||||
|
||||
|
||||
11
UPGRADING.md
11
UPGRADING.md
@ -52,6 +52,8 @@ For non depinject users, simply call `RegisterLegacyAminoCodec` and `RegisterInt
|
||||
+app.ModuleManager.RegisterInterfaces(interfaceRegistry)
|
||||
```
|
||||
|
||||
Additionally, thanks to the genesis simplification, as explained in [the genesis interface update](#genesis-interface), the module manager `InitGenesis` and `ExportGenesis` methods do not require the codec anymore.
|
||||
|
||||
##### AnteHandlers
|
||||
|
||||
The `GasConsumptionDecorator` and `IncreaseSequenceDecorator` have been merged with the SigVerificationDecorator, so you'll
|
||||
@ -182,15 +184,16 @@ Previous module migrations have been removed. It is required to migrate to v0.50
|
||||
|
||||
##### Genesis Interface
|
||||
|
||||
All genesis interfaces have been migrated to take context.Context instead of sdk.Context. Secondly, the codec is no longer passed in by the framework. The codec is now passed in by the module.
|
||||
All genesis interfaces have been migrated to take `context.Context` instead of `sdk.Context`.
|
||||
Secondly, the codec is no longer passed in by the framework. The codec is now passed in by the module.
|
||||
Lastly, all InitGenesis and ExportGenesis functions now return an error.
|
||||
|
||||
```go
|
||||
// InitGenesis performs genesis initialization for the authz module.
|
||||
// InitGenesis performs genesis initialization for the module.
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the authz
|
||||
// module.
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the module.
|
||||
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||
}
|
||||
```
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package appmodule
|
||||
|
||||
import (
|
||||
appmodule "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/appmodule/v2"
|
||||
)
|
||||
|
||||
// Environment is used to get all services to their respective module
|
||||
|
||||
@ -15,3 +15,6 @@ type MigrationRegistrar = appmodule.MigrationRegistrar
|
||||
|
||||
// MigrationHandler is the migration function that each module registers.
|
||||
type MigrationHandler = appmodule.MigrationHandler
|
||||
|
||||
// VersionMap is a map of moduleName -> version
|
||||
type VersionMap = appmodule.VersionMap
|
||||
|
||||
@ -187,9 +187,9 @@ func (a *App) PrepareCheckStater(ctx sdk.Context) {
|
||||
func (a *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
|
||||
var genesisState map[string]json.RawMessage
|
||||
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
return a.ModuleManager.InitGenesis(ctx, a.cdc, genesisState)
|
||||
return a.ModuleManager.InitGenesis(ctx, genesisState)
|
||||
}
|
||||
|
||||
// RegisterAPIRoutes registers all application module routes with the provided
|
||||
|
||||
@ -17,7 +17,6 @@ import (
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/accounts"
|
||||
@ -644,7 +643,7 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*ab
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
|
||||
return app.ModuleManager.InitGenesis(ctx, genesisState)
|
||||
}
|
||||
|
||||
// LoadHeight loads a particular height
|
||||
@ -680,18 +679,8 @@ func (app *SimApp) TxConfig() client.TxConfig {
|
||||
|
||||
// AutoCliOpts returns the autocli options for the app.
|
||||
func (app *SimApp) AutoCliOpts() autocli.AppOptions {
|
||||
modules := make(map[string]appmodule.AppModule, 0)
|
||||
for _, m := range app.ModuleManager.Modules {
|
||||
if moduleWithName, ok := m.(module.HasName); ok {
|
||||
moduleName := moduleWithName.Name()
|
||||
if appModule, ok := moduleWithName.(appmodule.AppModule); ok {
|
||||
modules[moduleName] = appModule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return autocli.AppOptions{
|
||||
Modules: modules,
|
||||
Modules: app.ModuleManager.Modules,
|
||||
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.ModuleManager.Modules),
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ func TestUpgradeStateOnGenesis(t *testing.T) {
|
||||
vm, err := app.UpgradeKeeper.GetModuleVersionMap(ctx)
|
||||
require.NoError(t, err)
|
||||
for v, i := range app.ModuleManager.Modules {
|
||||
if i, ok := i.(module.HasConsensusVersion); ok {
|
||||
if i, ok := i.(appmodule.HasConsensusVersion); ok {
|
||||
require.Equal(t, vm[v], i.ConsensusVersion())
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ func TestAppImportExport(t *testing.T) {
|
||||
|
||||
ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
|
||||
ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
|
||||
_, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState)
|
||||
_, err = newApp.ModuleManager.InitGenesis(ctxB, genesisState)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "validator set is empty after InitGenesis") {
|
||||
logger.Info("Skipping simulation as all validators have been unbonded")
|
||||
|
||||
@ -11,8 +11,7 @@ import (
|
||||
|
||||
appmodule "cosmossdk.io/core/appmodule"
|
||||
registry "cosmossdk.io/core/registry"
|
||||
types "github.com/cometbft/cometbft/abci/types"
|
||||
types0 "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
module "github.com/cosmos/cosmos-sdk/types/module"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
@ -69,10 +68,10 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) DefaultGenesis() *gomock.C
|
||||
}
|
||||
|
||||
// EndBlock mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensions) EndBlock(arg0 context.Context) ([]types.ValidatorUpdate, error) {
|
||||
func (m *MockAppModuleWithAllExtensions) EndBlock(arg0 context.Context) ([]module.ValidatorUpdate, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EndBlock", arg0)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
ret0, _ := ret[0].([]module.ValidatorUpdate)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -163,7 +162,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) RegisterInterfaces(arg0 in
|
||||
}
|
||||
|
||||
// RegisterInvariants mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensions) RegisterInvariants(arg0 types0.InvariantRegistry) {
|
||||
func (m *MockAppModuleWithAllExtensions) RegisterInvariants(arg0 types.InvariantRegistry) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RegisterInvariants", arg0)
|
||||
}
|
||||
@ -252,10 +251,10 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) DefaultGenesis() *gomo
|
||||
}
|
||||
|
||||
// EndBlock mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) EndBlock(arg0 context.Context) ([]types.ValidatorUpdate, error) {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) EndBlock(arg0 context.Context) ([]module.ValidatorUpdate, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EndBlock", arg0)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
ret0, _ := ret[0].([]module.ValidatorUpdate)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -267,11 +266,12 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) EndBlock(arg0 interfac
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(arg0 context.Context) json.RawMessage {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(arg0 context.Context) (json.RawMessage, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
return ret0
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ExportGenesis indicates an expected call of ExportGenesis.
|
||||
@ -281,11 +281,12 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ExportGenesis(arg0 int
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(arg0 context.Context, arg1 json.RawMessage) []types.ValidatorUpdate {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(arg0 context.Context, arg1 json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
return ret0
|
||||
ret0, _ := ret[0].([]module.ValidatorUpdate)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// InitGenesis indicates an expected call of InitGenesis.
|
||||
@ -345,7 +346,7 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) RegisterInterfaces(arg
|
||||
}
|
||||
|
||||
// RegisterInvariants mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) RegisterInvariants(arg0 types0.InvariantRegistry) {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) RegisterInvariants(arg0 types.InvariantRegistry) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RegisterInvariants", arg0)
|
||||
}
|
||||
|
||||
@ -10,10 +10,9 @@ import (
|
||||
reflect "reflect"
|
||||
|
||||
registry "cosmossdk.io/core/registry"
|
||||
types "github.com/cometbft/cometbft/abci/types"
|
||||
client "github.com/cosmos/cosmos-sdk/client"
|
||||
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||
types0 "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
module "github.com/cosmos/cosmos-sdk/types/module"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
runtime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
@ -375,11 +374,12 @@ func (mr *MockHasABCIGenesisMockRecorder) DefaultGenesis() *gomock.Call {
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockHasABCIGenesis) ExportGenesis(arg0 context.Context) json.RawMessage {
|
||||
func (m *MockHasABCIGenesis) ExportGenesis(arg0 context.Context) (json.RawMessage, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
return ret0
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ExportGenesis indicates an expected call of ExportGenesis.
|
||||
@ -389,11 +389,12 @@ func (mr *MockHasABCIGenesisMockRecorder) ExportGenesis(arg0 interface{}) *gomoc
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockHasABCIGenesis) InitGenesis(arg0 context.Context, arg1 json.RawMessage) []types.ValidatorUpdate {
|
||||
func (m *MockHasABCIGenesis) InitGenesis(arg0 context.Context, arg1 json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
return ret0
|
||||
ret0, _ := ret[0].([]module.ValidatorUpdate)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// InitGenesis indicates an expected call of InitGenesis.
|
||||
@ -454,7 +455,7 @@ func (m *MockHasInvariants) EXPECT() *MockHasInvariantsMockRecorder {
|
||||
}
|
||||
|
||||
// RegisterInvariants mocks base method.
|
||||
func (m *MockHasInvariants) RegisterInvariants(arg0 types0.InvariantRegistry) {
|
||||
func (m *MockHasInvariants) RegisterInvariants(arg0 types.InvariantRegistry) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RegisterInvariants", arg0)
|
||||
}
|
||||
@ -500,43 +501,6 @@ func (mr *MockHasServicesMockRecorder) RegisterServices(arg0 interface{}) *gomoc
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterServices", reflect.TypeOf((*MockHasServices)(nil).RegisterServices), arg0)
|
||||
}
|
||||
|
||||
// MockHasConsensusVersion is a mock of HasConsensusVersion interface.
|
||||
type MockHasConsensusVersion struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockHasConsensusVersionMockRecorder
|
||||
}
|
||||
|
||||
// MockHasConsensusVersionMockRecorder is the mock recorder for MockHasConsensusVersion.
|
||||
type MockHasConsensusVersionMockRecorder struct {
|
||||
mock *MockHasConsensusVersion
|
||||
}
|
||||
|
||||
// NewMockHasConsensusVersion creates a new mock instance.
|
||||
func NewMockHasConsensusVersion(ctrl *gomock.Controller) *MockHasConsensusVersion {
|
||||
mock := &MockHasConsensusVersion{ctrl: ctrl}
|
||||
mock.recorder = &MockHasConsensusVersionMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockHasConsensusVersion) EXPECT() *MockHasConsensusVersionMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ConsensusVersion mocks base method.
|
||||
func (m *MockHasConsensusVersion) ConsensusVersion() uint64 {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ConsensusVersion")
|
||||
ret0, _ := ret[0].(uint64)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ConsensusVersion indicates an expected call of ConsensusVersion.
|
||||
func (mr *MockHasConsensusVersionMockRecorder) ConsensusVersion() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsensusVersion", reflect.TypeOf((*MockHasConsensusVersion)(nil).ConsensusVersion))
|
||||
}
|
||||
|
||||
// MockHasABCIEndBlock is a mock of HasABCIEndBlock interface.
|
||||
type MockHasABCIEndBlock struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -561,10 +525,10 @@ func (m *MockHasABCIEndBlock) EXPECT() *MockHasABCIEndBlockMockRecorder {
|
||||
}
|
||||
|
||||
// EndBlock mocks base method.
|
||||
func (m *MockHasABCIEndBlock) EndBlock(arg0 context.Context) ([]types.ValidatorUpdate, error) {
|
||||
func (m *MockHasABCIEndBlock) EndBlock(arg0 context.Context) ([]module.ValidatorUpdate, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EndBlock", arg0)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
ret0, _ := ret[0].([]module.ValidatorUpdate)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@ -95,21 +94,21 @@ func (c coreAppModuleAdaptor) ValidateGenesis(bz json.RawMessage) error {
|
||||
}
|
||||
|
||||
// ExportGenesis implements HasGenesis
|
||||
func (c coreAppModuleAdaptor) ExportGenesis(ctx context.Context) json.RawMessage {
|
||||
func (c coreAppModuleAdaptor) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||
if module, ok := c.module.(appmodule.HasGenesisAuto); ok {
|
||||
ctx := sdk.UnwrapSDKContext(ctx).WithGasMeter(storetypes.NewInfiniteGasMeter()) // avoid race conditions
|
||||
target := genesis.RawJSONTarget{}
|
||||
err := module.ExportGenesis(ctx, target.Target())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawJSON, err := target.JSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rawJSON
|
||||
return rawJSON, nil
|
||||
}
|
||||
|
||||
if mod, ok := c.module.(HasABCIGenesis); ok {
|
||||
@ -119,26 +118,26 @@ func (c coreAppModuleAdaptor) ExportGenesis(ctx context.Context) json.RawMessage
|
||||
if mod, ok := c.module.(HasGenesis); ok {
|
||||
eg, err := mod.ExportGenesis(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
return eg
|
||||
|
||||
return eg, nil
|
||||
}
|
||||
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// InitGenesis implements HasGenesis
|
||||
func (c coreAppModuleAdaptor) InitGenesis(ctx context.Context, bz json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (c coreAppModuleAdaptor) InitGenesis(ctx context.Context, bz json.RawMessage) ([]ValidatorUpdate, error) {
|
||||
if module, ok := c.module.(appmodule.HasGenesisAuto); ok {
|
||||
// core API genesis
|
||||
source, err := genesis.SourceFromRawJSON(bz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = module.InitGenesis(ctx, source)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if err = module.InitGenesis(ctx, source); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,13 +146,12 @@ func (c coreAppModuleAdaptor) InitGenesis(ctx context.Context, bz json.RawMessag
|
||||
}
|
||||
|
||||
if mod, ok := c.module.(HasGenesis); ok {
|
||||
err := mod.InitGenesis(ctx, bz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if err := mod.InitGenesis(ctx, bz); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Name implements HasName
|
||||
|
||||
@ -14,9 +14,9 @@ import (
|
||||
type AppModuleWithAllExtensions interface {
|
||||
module.AppModule
|
||||
module.HasServices
|
||||
appmodulev2.HasGenesis
|
||||
module.HasInvariants
|
||||
module.HasConsensusVersion
|
||||
appmodulev2.HasConsensusVersion
|
||||
appmodulev2.HasGenesis
|
||||
module.HasABCIEndBlock
|
||||
module.HasName
|
||||
}
|
||||
@ -27,7 +27,7 @@ type AppModuleWithAllExtensionsABCI interface {
|
||||
module.HasServices
|
||||
module.HasABCIGenesis
|
||||
module.HasInvariants
|
||||
module.HasConsensusVersion
|
||||
appmodulev2.HasConsensusVersion
|
||||
module.HasABCIEndBlock
|
||||
module.HasName
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import (
|
||||
"sort"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtcryptoproto "github.com/cometbft/cometbft/proto/tendermint/crypto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/exp/maps"
|
||||
@ -46,11 +47,11 @@ import (
|
||||
|
||||
// Deprecated: use the embed extension interfaces instead, when needed.
|
||||
type AppModuleBasic interface {
|
||||
appmodulev2.HasRegisterInterfaces
|
||||
|
||||
HasName
|
||||
HasGRPCGateway
|
||||
HasAminoCodec
|
||||
|
||||
appmodulev2.HasRegisterInterfaces
|
||||
}
|
||||
|
||||
// AppModule is the form for an application module. Most of
|
||||
@ -84,22 +85,20 @@ type HasAminoCodec interface {
|
||||
RegisterLegacyAminoCodec(*codec.LegacyAmino)
|
||||
}
|
||||
|
||||
// HasRegisterInterfaces is the interface for modules to register their msg types.
|
||||
type HasRegisterInterfaces appmodulev2.HasRegisterInterfaces
|
||||
|
||||
// HasGRPCGateway is the interface for modules to register their gRPC gateway routes.
|
||||
type HasGRPCGateway interface {
|
||||
RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux)
|
||||
}
|
||||
|
||||
// HasGenesis is the extension interface for stateful genesis methods.
|
||||
// Prefer directly importing appmodulev2 or appmodule instead of using this alias.
|
||||
type HasGenesis = appmodulev2.HasGenesis
|
||||
|
||||
// HasABCIGenesis is the extension interface for stateful genesis methods which returns validator updates.
|
||||
type HasABCIGenesis interface {
|
||||
HasGenesisBasics
|
||||
InitGenesis(context.Context, json.RawMessage) []abci.ValidatorUpdate
|
||||
ExportGenesis(context.Context) json.RawMessage
|
||||
InitGenesis(context.Context, json.RawMessage) ([]ValidatorUpdate, error)
|
||||
ExportGenesis(context.Context) (json.RawMessage, error)
|
||||
}
|
||||
|
||||
// HasInvariants is the interface for registering invariants.
|
||||
@ -114,19 +113,19 @@ type HasServices interface {
|
||||
RegisterServices(Configurator)
|
||||
}
|
||||
|
||||
// HasConsensusVersion is the interface for declaring a module consensus version.
|
||||
type HasConsensusVersion interface {
|
||||
// ConsensusVersion is a sequence number for state-breaking change of the
|
||||
// module. It should be incremented on each consensus-breaking change
|
||||
// introduced by the module. To avoid wrong/empty versions, the initial version
|
||||
// should be set to 1.
|
||||
ConsensusVersion() uint64
|
||||
}
|
||||
// MigrationHandler is the migration function that each module registers.
|
||||
type MigrationHandler func(sdk.Context) error
|
||||
|
||||
// VersionMap is a map of moduleName -> version
|
||||
type VersionMap appmodule.VersionMap
|
||||
|
||||
// ValidatorUpdate is the type for validator updates.
|
||||
type ValidatorUpdate = appmodulev2.ValidatorUpdate
|
||||
|
||||
// HasABCIEndBlock is the interface for modules that need to run code at the end of the block.
|
||||
type HasABCIEndBlock interface {
|
||||
AppModule
|
||||
EndBlock(context.Context) ([]abci.ValidatorUpdate, error)
|
||||
EndBlock(context.Context) ([]ValidatorUpdate, error)
|
||||
}
|
||||
|
||||
// Manager defines a module manager that provides the high level utility for managing and executing
|
||||
@ -324,11 +323,13 @@ func (m *Manager) RegisterInterfaces(registry registry.LegacyRegistry) {
|
||||
// DefaultGenesis provides default genesis information for all modules
|
||||
func (m *Manager) DefaultGenesis() map[string]json.RawMessage {
|
||||
genesisData := make(map[string]json.RawMessage)
|
||||
for _, b := range m.Modules {
|
||||
for name, b := range m.Modules {
|
||||
if mod, ok := b.(HasGenesisBasics); ok {
|
||||
genesisData[mod.Name()] = mod.DefaultGenesis()
|
||||
} else if mod, ok := b.(HasName); ok {
|
||||
genesisData[mod.Name()] = []byte("{}")
|
||||
} else if mod, ok := b.(appmodule.HasGenesis); ok {
|
||||
genesisData[name] = mod.DefaultGenesis()
|
||||
} else {
|
||||
genesisData[name] = []byte("{}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,12 +338,15 @@ func (m *Manager) DefaultGenesis() map[string]json.RawMessage {
|
||||
|
||||
// ValidateGenesis performs genesis state validation for all modules
|
||||
func (m *Manager) ValidateGenesis(genesisData map[string]json.RawMessage) error {
|
||||
for _, b := range m.Modules {
|
||||
// first check if the module is an adapted Core API Module
|
||||
for name, b := range m.Modules {
|
||||
if mod, ok := b.(HasGenesisBasics); ok {
|
||||
if err := mod.ValidateGenesis(genesisData[mod.Name()]); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if mod, ok := b.(appmodule.HasGenesis); ok {
|
||||
if err := mod.ValidateGenesis(genesisData[name]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,8 +429,8 @@ func (m *Manager) RegisterServices(cfg Configurator) error {
|
||||
// InitGenesis performs init genesis functionality for modules. Exactly one
|
||||
// module must return a non-empty validator set update to correctly initialize
|
||||
// the chain.
|
||||
func (m *Manager) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, genesisData map[string]json.RawMessage) (*abci.ResponseInitChain, error) {
|
||||
var validatorUpdates []abci.ValidatorUpdate
|
||||
func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (*abci.ResponseInitChain, error) {
|
||||
var validatorUpdates []ValidatorUpdate
|
||||
ctx.Logger().Info("initializing blockchain state from genesis.json")
|
||||
for _, moduleName := range m.OrderInitGenesis {
|
||||
if genesisData[moduleName] == nil {
|
||||
@ -454,7 +458,10 @@ func (m *Manager) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, genesisData ma
|
||||
}
|
||||
} else if module, ok := mod.(HasABCIGenesis); ok {
|
||||
ctx.Logger().Debug("running initialization for module", "module", moduleName)
|
||||
moduleValUpdates := module.InitGenesis(ctx, genesisData[moduleName])
|
||||
moduleValUpdates, err := module.InitGenesis(ctx, genesisData[moduleName])
|
||||
if err != nil {
|
||||
return &abci.ResponseInitChain{}, err
|
||||
}
|
||||
|
||||
// use these validator updates if provided, the module manager assumes
|
||||
// only one module will update the validator set
|
||||
@ -472,8 +479,32 @@ func (m *Manager) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, genesisData ma
|
||||
return &abci.ResponseInitChain{}, fmt.Errorf("validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction (%d)", sdk.DefaultPowerReduction)
|
||||
}
|
||||
|
||||
cometValidatorUpdates := make([]abci.ValidatorUpdate, len(validatorUpdates))
|
||||
for i, v := range validatorUpdates {
|
||||
var pubkey cmtcryptoproto.PublicKey
|
||||
switch v.PubKeyType {
|
||||
case "ed25519":
|
||||
pubkey = cmtcryptoproto.PublicKey{
|
||||
Sum: &cmtcryptoproto.PublicKey_Ed25519{
|
||||
Ed25519: v.PubKey,
|
||||
},
|
||||
}
|
||||
case "secp256k1":
|
||||
pubkey = cmtcryptoproto.PublicKey{
|
||||
Sum: &cmtcryptoproto.PublicKey_Secp256K1{
|
||||
Secp256K1: v.PubKey,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
cometValidatorUpdates[i] = abci.ValidatorUpdate{
|
||||
PubKey: pubkey,
|
||||
Power: v.Power,
|
||||
}
|
||||
}
|
||||
|
||||
return &abci.ResponseInitChain{
|
||||
Validators: validatorUpdates,
|
||||
Validators: cometValidatorUpdates,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -535,7 +566,11 @@ func (m *Manager) ExportGenesisForModules(ctx sdk.Context, modulesToExport []str
|
||||
channels[moduleName] = make(chan genesisResult)
|
||||
go func(module HasABCIGenesis, ch chan genesisResult) {
|
||||
ctx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) // avoid race conditions
|
||||
ch <- genesisResult{module.ExportGenesis(ctx), nil}
|
||||
jm, err := module.ExportGenesis(ctx)
|
||||
if err != nil {
|
||||
ch <- genesisResult{nil, err}
|
||||
}
|
||||
ch <- genesisResult{jm, nil}
|
||||
}(module, channels[moduleName])
|
||||
}
|
||||
}
|
||||
@ -590,12 +625,6 @@ func (m *Manager) assertNoForgottenModules(setOrderFnName string, moduleNames []
|
||||
}
|
||||
}
|
||||
|
||||
// MigrationHandler is the migration function that each module registers.
|
||||
type MigrationHandler func(sdk.Context) error
|
||||
|
||||
// VersionMap is a map of moduleName -> version
|
||||
type VersionMap map[string]uint64
|
||||
|
||||
// RunMigrations performs in-place store migrations for all modules. This
|
||||
// function MUST be called inside an x/upgrade UpgradeHandler.
|
||||
//
|
||||
@ -663,7 +692,7 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver
|
||||
module := m.Modules[moduleName]
|
||||
fromVersion, exists := fromVM[moduleName]
|
||||
toVersion := uint64(0)
|
||||
if module, ok := module.(HasConsensusVersion); ok {
|
||||
if module, ok := module.(appmodule.HasConsensusVersion); ok {
|
||||
toVersion = module.ConsensusVersion()
|
||||
}
|
||||
|
||||
@ -688,7 +717,11 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver
|
||||
}
|
||||
}
|
||||
if module, ok := m.Modules[moduleName].(HasABCIGenesis); ok {
|
||||
moduleValUpdates := module.InitGenesis(sdkCtx, module.DefaultGenesis())
|
||||
moduleValUpdates, err := module.InitGenesis(sdkCtx, module.DefaultGenesis())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The module manager assumes only one module will update the
|
||||
// validator set, and it can't be a new module.
|
||||
if len(moduleValUpdates) > 0 {
|
||||
@ -741,7 +774,7 @@ func (m *Manager) BeginBlock(ctx sdk.Context) (sdk.BeginBlock, error) {
|
||||
// modules.
|
||||
func (m *Manager) EndBlock(ctx sdk.Context) (sdk.EndBlock, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
validatorUpdates := []abci.ValidatorUpdate{}
|
||||
validatorUpdates := []ValidatorUpdate{}
|
||||
|
||||
for _, moduleName := range m.OrderEndBlockers {
|
||||
if module, ok := m.Modules[moduleName].(appmodule.HasEndBlocker); ok {
|
||||
@ -766,8 +799,32 @@ func (m *Manager) EndBlock(ctx sdk.Context) (sdk.EndBlock, error) {
|
||||
}
|
||||
}
|
||||
|
||||
cometValidatorUpdates := make([]abci.ValidatorUpdate, len(validatorUpdates))
|
||||
for i, v := range validatorUpdates {
|
||||
var pubkey cmtcryptoproto.PublicKey
|
||||
switch v.PubKeyType {
|
||||
case "ed25519":
|
||||
pubkey = cmtcryptoproto.PublicKey{
|
||||
Sum: &cmtcryptoproto.PublicKey_Ed25519{
|
||||
Ed25519: v.PubKey,
|
||||
},
|
||||
}
|
||||
case "secp256k1":
|
||||
pubkey = cmtcryptoproto.PublicKey{
|
||||
Sum: &cmtcryptoproto.PublicKey_Secp256K1{
|
||||
Secp256K1: v.PubKey,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
cometValidatorUpdates[i] = abci.ValidatorUpdate{
|
||||
PubKey: pubkey,
|
||||
Power: v.Power,
|
||||
}
|
||||
}
|
||||
|
||||
return sdk.EndBlock{
|
||||
ValidatorUpdates: validatorUpdates,
|
||||
ValidatorUpdates: cometValidatorUpdates,
|
||||
Events: ctx.EventManager().ABCIEvents(),
|
||||
}, nil
|
||||
}
|
||||
@ -805,7 +862,7 @@ func (m *Manager) GetVersionMap() VersionMap {
|
||||
vermap := make(VersionMap)
|
||||
for name, v := range m.Modules {
|
||||
version := uint64(0)
|
||||
if v, ok := v.(HasConsensusVersion); ok {
|
||||
if v, ok := v.(appmodule.HasConsensusVersion); ok {
|
||||
version = v.ConsensusVersion()
|
||||
}
|
||||
name := name
|
||||
|
||||
@ -172,16 +172,14 @@ func TestManager_InitGenesis(t *testing.T) {
|
||||
require.Equal(t, 3, len(mm.Modules))
|
||||
|
||||
ctx := sdk.NewContext(nil, false, log.NewNopLogger())
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||
genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)}
|
||||
|
||||
// this should panic since the validator set is empty even after init genesis
|
||||
// this should error since the validator set is empty even after init genesis
|
||||
mockAppModule1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module1"])).Times(1)
|
||||
_, err := mm.InitGenesis(ctx, cdc, genesisData)
|
||||
_, err := mm.InitGenesis(ctx, genesisData)
|
||||
require.ErrorContains(t, err, "validator set is empty after InitGenesis")
|
||||
|
||||
// test panic
|
||||
// test error
|
||||
genesisData = map[string]json.RawMessage{
|
||||
"module1": json.RawMessage(`{"key": "value"}`),
|
||||
"module2": json.RawMessage(`{"key": "value"}`),
|
||||
@ -193,19 +191,19 @@ func TestManager_InitGenesis(t *testing.T) {
|
||||
mockAppModuleABCI1.EXPECT().Name().Times(4).Return("module1")
|
||||
mockAppModuleABCI2.EXPECT().Name().Times(2).Return("module2")
|
||||
mmABCI := module.NewManager(mockAppModuleABCI1, mockAppModuleABCI2)
|
||||
// panic because more than one module returns validator set updates
|
||||
mockAppModuleABCI1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module1"])).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
mockAppModuleABCI2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module2"])).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
_, err = mmABCI.InitGenesis(ctx, cdc, genesisData)
|
||||
// errors because more than one module returns validator set updates
|
||||
mockAppModuleABCI1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module1"])).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
mockAppModuleABCI2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module2"])).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
_, err = mmABCI.InitGenesis(ctx, genesisData)
|
||||
require.ErrorContains(t, err, "validator InitGenesis updates already set by a previous module")
|
||||
|
||||
// happy path
|
||||
|
||||
mm2 := module.NewManager(mockAppModuleABCI1, mockAppModule2, module.CoreAppModuleAdaptor("module3", mockAppModule3))
|
||||
mockAppModuleABCI1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module1"])).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
mockAppModuleABCI1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module1"])).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(genesisData["module2"])).Times(1)
|
||||
mockAppModule3.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Any()).Times(1).Return(nil)
|
||||
_, err = mm2.InitGenesis(ctx, cdc, genesisData)
|
||||
_, err = mm2.InitGenesis(ctx, genesisData)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -268,15 +266,15 @@ func TestManager_EndBlock(t *testing.T) {
|
||||
require.NotNil(t, mm)
|
||||
require.Equal(t, 3, len(mm.Modules))
|
||||
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]abci.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any()).Times(1)
|
||||
ret, err := mm.EndBlock(sdk.Context{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []abci.ValidatorUpdate{{}}, ret.ValidatorUpdates)
|
||||
|
||||
// test panic
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]abci.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]abci.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any()).Times(1).Return([]module.ValidatorUpdate{{}}, nil)
|
||||
_, err = mm.EndBlock(sdk.Context{})
|
||||
require.Error(t, err)
|
||||
}
|
||||
@ -307,13 +305,11 @@ func TestCoreAPIManager_InitGenesis(t *testing.T) {
|
||||
require.Equal(t, 1, len(mm.Modules))
|
||||
|
||||
ctx := sdk.NewContext(nil, false, log.NewNopLogger())
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||
genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)}
|
||||
|
||||
// this should panic since the validator set is empty even after init genesis
|
||||
mockAppModule1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Any()).Times(1).Return(nil)
|
||||
_, err := mm.InitGenesis(ctx, cdc, genesisData)
|
||||
_, err := mm.InitGenesis(ctx, genesisData)
|
||||
require.ErrorContains(t, err, "validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction")
|
||||
|
||||
// TODO: add happy path test. We are not returning any validator updates, this will come with the services.
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/accounts/cli"
|
||||
v1 "cosmossdk.io/x/accounts/v1"
|
||||
@ -22,22 +21,20 @@ import (
|
||||
const (
|
||||
ModuleName = "accounts"
|
||||
StoreKey = "_" + ModuleName // unfortunately accounts collides with auth store key
|
||||
|
||||
ConsensusVersion = 1
|
||||
)
|
||||
|
||||
// ModuleAccountAddress defines the x/accounts module address.
|
||||
var ModuleAccountAddress = address.Module(ModuleName)
|
||||
|
||||
const (
|
||||
ConsensusVersion = 1
|
||||
)
|
||||
|
||||
var (
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
|
||||
_ module.HasName = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasConsensusVersion = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasConsensusVersion = AppModule{}
|
||||
)
|
||||
|
||||
func NewAppModule(cdc codec.Codec, k Keeper) AppModule {
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
"cosmossdk.io/x/auth/simulation"
|
||||
@ -30,8 +29,8 @@ const (
|
||||
var (
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/authz"
|
||||
@ -28,17 +27,17 @@ import (
|
||||
const ConsensusVersion = 2
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements the sdk.AppModule interface
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/bank/client/cli"
|
||||
"cosmossdk.io/x/bank/keeper"
|
||||
@ -28,17 +27,17 @@ import (
|
||||
const ConsensusVersion = 4
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the bank module.
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/circuit/keeper"
|
||||
"cosmossdk.io/x/circuit/types"
|
||||
@ -25,13 +24,13 @@ import (
|
||||
const ConsensusVersion = 1
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the circuit module.
|
||||
|
||||
@ -20,12 +20,12 @@ import (
|
||||
const ConsensusVersion = 1
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module
|
||||
|
||||
@ -12,10 +12,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -24,15 +23,15 @@ import (
|
||||
const ConsensusVersion = 2
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
// Module init related flags
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/distribution/client/cli"
|
||||
"cosmossdk.io/x/distribution/keeper"
|
||||
@ -28,18 +27,18 @@ import (
|
||||
const ConsensusVersion = 4
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the distribution module.
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
eviclient "cosmossdk.io/x/evidence/client"
|
||||
"cosmossdk.io/x/evidence/client/cli"
|
||||
@ -25,15 +24,15 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
const ConsensusVersion = 1
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/feegrant"
|
||||
@ -24,17 +23,17 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the feegrant module.
|
||||
|
||||
@ -5,8 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/genesis"
|
||||
"cosmossdk.io/core/registry"
|
||||
@ -77,19 +75,39 @@ func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the genutil module.
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
var genesisState types.GenesisState
|
||||
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
validators, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
cometValidatorUpdates, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
return validators
|
||||
|
||||
validatorUpdates := make([]module.ValidatorUpdate, len(cometValidatorUpdates))
|
||||
for i, v := range cometValidatorUpdates {
|
||||
if ed25519 := v.PubKey.GetEd25519(); len(ed25519) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: ed25519,
|
||||
PubKeyType: "ed25519",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else if secp256k1 := v.PubKey.GetSecp256K1(); len(secp256k1) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: secp256k1,
|
||||
PubKeyType: "secp256k1",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("unexpected validator pubkey type: %T", v.PubKey)
|
||||
}
|
||||
}
|
||||
|
||||
return validatorUpdates, nil
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the genutil module.
|
||||
func (am AppModule) ExportGenesis(_ context.Context) json.RawMessage {
|
||||
return am.DefaultGenesis()
|
||||
func (am AppModule) ExportGenesis(_ context.Context) (json.RawMessage, error) {
|
||||
return am.DefaultGenesis(), nil
|
||||
}
|
||||
|
||||
// GenTxValidator returns the genutil module's genesis transaction validator.
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
govclient "cosmossdk.io/x/gov/client"
|
||||
"cosmossdk.io/x/gov/client/cli"
|
||||
@ -30,18 +29,18 @@ import (
|
||||
const ConsensusVersion = 6
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the gov module.
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/group"
|
||||
"cosmossdk.io/x/group/client/cli"
|
||||
@ -29,18 +28,18 @@ import (
|
||||
const ConsensusVersion = 2
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasEndBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
type AppModule struct {
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/mint/keeper"
|
||||
"cosmossdk.io/x/mint/simulation"
|
||||
@ -25,17 +24,17 @@ import (
|
||||
const ConsensusVersion = 2
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the mint module.
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/nft"
|
||||
@ -23,13 +22,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
const ConsensusVersion = 1
|
||||
|
||||
@ -18,14 +18,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// ConsensusVersion defines the current x/params module consensus version.
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/protocolpool/keeper"
|
||||
"cosmossdk.io/x/protocolpool/types"
|
||||
@ -23,16 +22,15 @@ import (
|
||||
const ConsensusVersion = 1
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the pool module
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/slashing/keeper"
|
||||
"cosmossdk.io/x/slashing/simulation"
|
||||
@ -26,17 +25,17 @@ import (
|
||||
const ConsensusVersion = 4
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.HasRegisterInterfaces = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements an application module for the slashing module.
|
||||
|
||||
@ -41,7 +41,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* [#18198](https://github.com/cosmos/cosmos-sdk/pull/18198): `Validator` and `Delegator` interfaces were moved to `github.com/cosmos/cosmos-sdk/types` to avoid interface dependency on staking in other modules.
|
||||
* [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) Update genesis api to match new `appmodule.HasGenesis` interface.
|
||||
* [#18198](https://github.com/cosmos/cosmos-sdk/pull/18198) `Validator` and `Delegator` interfaces were moved to `github.com/cosmos/cosmos-sdk/types` to avoid interface dependency on staking in other modules.
|
||||
* [#17778](https://github.com/cosmos/cosmos-sdk/pull/17778) Use collections for `Params`
|
||||
* remove from `Keeper`: `GetParams`, `SetParams`
|
||||
* [#17486](https://github.com/cosmos/cosmos-sdk/pull/17486) Use collections for `RedelegationQueueKey`:
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/grpc"
|
||||
@ -28,19 +27,19 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasABCIGenesis = AppModule{}
|
||||
_ module.HasABCIEndBlock = AppModule{}
|
||||
_ module.AppModuleSimulation = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.HasInvariants = AppModule{}
|
||||
_ module.HasABCIGenesis = AppModule{}
|
||||
_ module.HasABCIEndBlock = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasBeginBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
|
||||
_ depinject.OnePerModuleType = AppModule{}
|
||||
)
|
||||
@ -146,18 +145,37 @@ func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the staking module.
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
var genesisState types.GenesisState
|
||||
|
||||
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
|
||||
return am.keeper.InitGenesis(ctx, &genesisState)
|
||||
cometValidatorUpdates := am.keeper.InitGenesis(ctx, &genesisState) // TODO: refactor to return ValidatorUpdate higher up the stack
|
||||
validatorUpdates := make([]module.ValidatorUpdate, len(cometValidatorUpdates))
|
||||
for i, v := range cometValidatorUpdates {
|
||||
if ed25519 := v.PubKey.GetEd25519(); len(ed25519) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: ed25519,
|
||||
PubKeyType: "ed25519",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else if secp256k1 := v.PubKey.GetSecp256K1(); len(secp256k1) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: secp256k1,
|
||||
PubKeyType: "secp256k1",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("unexpected validator pubkey type: %T", v.PubKey)
|
||||
}
|
||||
}
|
||||
|
||||
return validatorUpdates, nil
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the staking
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx context.Context) json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(am.keeper.ExportGenesis(ctx))
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the staking module.
|
||||
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||
return am.cdc.MarshalJSON(am.keeper.ExportGenesis(ctx))
|
||||
}
|
||||
|
||||
// ConsensusVersion implements HasConsensusVersion
|
||||
@ -169,6 +187,30 @@ func (am AppModule) BeginBlock(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// EndBlock returns the end blocker for the staking module.
|
||||
func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) {
|
||||
return am.keeper.EndBlocker(ctx)
|
||||
func (am AppModule) EndBlock(ctx context.Context) ([]module.ValidatorUpdate, error) {
|
||||
cometValidatorUpdates, err := am.keeper.EndBlocker(ctx) // TODO: refactor to return appmodule.ValidatorUpdate higher up the stack
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorUpdates := make([]module.ValidatorUpdate, len(cometValidatorUpdates))
|
||||
for i, v := range cometValidatorUpdates {
|
||||
if ed25519 := v.PubKey.GetEd25519(); len(ed25519) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: ed25519,
|
||||
PubKeyType: "ed25519",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else if secp256k1 := v.PubKey.GetSecp256K1(); len(secp256k1) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: secp256k1,
|
||||
PubKeyType: "secp256k1",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("unexpected validator pubkey type: %T", v.PubKey)
|
||||
}
|
||||
}
|
||||
|
||||
return validatorUpdates, nil
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/upgrade/client/cli"
|
||||
"cosmossdk.io/x/upgrade/keeper"
|
||||
@ -29,16 +28,16 @@ func init() {
|
||||
const ConsensusVersion uint64 = 3
|
||||
|
||||
var (
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
_ module.HasRegisterInterfaces = AppModule{}
|
||||
_ appmodulev2.HasGenesis = AppModule{}
|
||||
_ module.HasName = AppModule{}
|
||||
_ module.HasAminoCodec = AppModule{}
|
||||
_ module.HasGRPCGateway = AppModule{}
|
||||
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasPreBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ appmodule.HasPreBlocker = AppModule{}
|
||||
_ appmodule.HasServices = AppModule{}
|
||||
_ appmodule.HasMigrations = AppModule{}
|
||||
_ appmodule.HasGenesis = AppModule{}
|
||||
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||
)
|
||||
|
||||
// AppModule implements the sdk.AppModule interface
|
||||
|
||||
Loading…
Reference in New Issue
Block a user