feat: add changes from server modular to main (#20583)

This commit is contained in:
Marko
2024-06-06 13:00:01 +00:00
committed by GitHub
parent 031b0c94ed
commit 514830e56a
11 changed files with 60 additions and 29 deletions
+9 -1
View File
@@ -124,5 +124,13 @@ func (a *App) GetLogger() log.Logger {
}
func (a *App) ExecuteGenesisTx(_ []byte) error {
panic("not implemented")
panic("App.ExecuteGenesisTx not supported in runtime/v2")
}
func (a *App) SetAppVersion(context.Context, uint64) error {
return nil
}
func (a *App) AppVersion(context.Context) (uint64, error) {
return 0, nil
}
+5 -8
View File
@@ -148,12 +148,6 @@ func (m *MM) InitGenesisJSON(
mod := m.modules[moduleName]
// skip genutil as it's a special module that handles gentxs
// TODO: should this be an empty extension interface on genutil for server v2?
if moduleName == "genutil" {
continue
}
// we might get an adapted module, a native core API module or a legacy module
switch module := mod.(type) {
case appmodule.HasGenesisAuto:
@@ -184,7 +178,7 @@ func (m *MM) InitGenesisJSON(
// only one module will update the validator set
if len(moduleValUpdates) > 0 {
if seenValUpdates {
return errors.New("validator InitGenesis updates already set by a previous module")
return fmt.Errorf("validator InitGenesis updates already set by a previous module: current module %s", moduleName)
} else {
seenValUpdates = true
}
@@ -284,7 +278,10 @@ type hasABCIEndBlock interface {
}
// EndBlock runs the end-block logic of all modules and tx validator updates
func (m *MM) EndBlock() (endBlockFunc func(ctx context.Context) error, valUpdateFunc func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error)) {
func (m *MM) EndBlock() (
endBlockFunc func(ctx context.Context) error,
valUpdateFunc func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error),
) {
var validatorUpdates []appmodulev2.ValidatorUpdate
endBlockFunc = func(ctx context.Context) error {
for _, moduleName := range m.config.EndBlockers {
+7 -4
View File
@@ -14,6 +14,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/core/app"
"cosmossdk.io/core/appmodule"
appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/comet"
@@ -125,10 +126,6 @@ func ProvideAppBuilder(
_, _ = fmt.Fprintln(os.Stderr, err.Error())
}
// TODO register as Invoker from simapp v2; remove if not needed
// std.RegisterInterfaces(interfaceRegistrar)
// std.RegisterLegacyAminoCodec(amino)
msgRouterBuilder := stf.NewMsgRouterBuilder()
app := &App{
storeKeys: nil,
@@ -246,3 +243,9 @@ func ProvideGenesisTxHandler(appBuilder *AppBuilder) genesis.TxHandler {
func ProvideCometService() comet.Service {
return &services.ContextAwareCometInfoService{}
}
// ProvideAppVersionModifier returns nil, `app.VersionModifier` is a feature of BaseApp and neither used nor required for runtim/v2.
// nil is acceptable, see: https://github.com/cosmos/cosmos-sdk/blob/0a6ee406a02477ae8ccbfcbe1b51fc3930087f4c/x/upgrade/keeper/keeper.go#L438
func ProvideAppVersionModifier(app *AppBuilder) app.VersionModifier {
return nil
}
+4 -1
View File
@@ -13,6 +13,9 @@ type ContextAwareCometInfoService struct{}
// CometInfo implements comet.Service.
func (c *ContextAwareCometInfoService) CometInfo(ctx context.Context) comet.Info {
ci := ctx.Value(corecontext.CometInfoKey).(comet.Info)
ci, ok := ctx.Value(corecontext.CometInfoKey).(comet.Info)
if !ok {
panic("comet.Info not found in context")
}
return ci
}