feat: add changes from server modular to main (#20583)
This commit is contained in:
parent
031b0c94ed
commit
514830e56a
@ -9,6 +9,7 @@ import (
|
||||
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/legacy"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/x/tx/signing"
|
||||
|
||||
@ -20,7 +21,7 @@ func ProvideInterfaceRegistry(
|
||||
addressCodec address.Codec,
|
||||
validatorAddressCodec address.ValidatorAddressCodec,
|
||||
customGetSigners []signing.CustomGetSigner,
|
||||
) (types.InterfaceRegistry, error) {
|
||||
) (types.InterfaceRegistry, registry.InterfaceRegistrar, error) {
|
||||
signingOptions := signing.Options{
|
||||
AddressCodec: addressCodec,
|
||||
ValidatorAddressCodec: validatorAddressCodec,
|
||||
@ -34,14 +35,14 @@ func ProvideInterfaceRegistry(
|
||||
SigningOptions: signingOptions,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if err := interfaceRegistry.SigningContext().Validate(); err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return interfaceRegistry, nil
|
||||
return interfaceRegistry, interfaceRegistry, nil
|
||||
}
|
||||
|
||||
func ProvideLegacyAmino() legacy.Amino {
|
||||
|
||||
@ -27,6 +27,7 @@ COPY runtime/v2/go.mod runtime/v2/go.sum /work/runtime/v2/
|
||||
COPY server/v2/appmanager/go.mod server/v2/appmanager/go.sum /work/server/v2/appmanager/
|
||||
COPY server/v2/core/go.mod server/v2/core/go.sum /work/server/v2/core/
|
||||
COPY server/v2/stf/go.mod server/v2/stf/go.sum /work/server/v2/stf/
|
||||
COPY server/v2/cometbft/go.mod server/v2/cometbft/go.sum /work/server/v2/cometbft/
|
||||
|
||||
RUN go mod download
|
||||
|
||||
|
||||
11
core/context/context._test.go
Normal file
11
core/context/context._test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_Sanity(t *testing.T) {
|
||||
require.NotEqual(t, CometInfoKey, ExecModeKey)
|
||||
}
|
||||
@ -2,12 +2,18 @@ package context
|
||||
|
||||
type contextKey uint8
|
||||
|
||||
const (
|
||||
ExecModeKey contextKey = iota
|
||||
CometInfoKey contextKey = iota
|
||||
type (
|
||||
execModeKey struct{}
|
||||
cometInfoKey struct{}
|
||||
environmentKey struct{}
|
||||
)
|
||||
|
||||
// EnvironmentContextKey is the context key for the environment.
|
||||
// A caller should not assume the environment is available in each context.
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/19640
|
||||
var EnvironmentContextKey = struct{}{}
|
||||
var (
|
||||
ExecModeKey = execModeKey{}
|
||||
CometInfoKey = cometInfoKey{}
|
||||
|
||||
// EnvironmentContextKey is the context key for the environment.
|
||||
// A caller should not assume the environment is available in each context.
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/19640
|
||||
EnvironmentContextKey = environmentKey{}
|
||||
)
|
||||
|
||||
@ -133,7 +133,7 @@ var _ KVStore = (Writer)(nil)
|
||||
|
||||
// ReaderMap represents a readonly view over all the accounts state.
|
||||
type ReaderMap interface {
|
||||
// ReaderMap must return the state for the provided actor.
|
||||
// GetReader must return the state for the provided actor.
|
||||
// Storage implements might treat this as a prefix store over an actor.
|
||||
// Prefix safety is on the implementer.
|
||||
GetReader(actor []byte) (Reader, error)
|
||||
@ -142,7 +142,7 @@ type ReaderMap interface {
|
||||
// WriterMap represents a writable actor state.
|
||||
type WriterMap interface {
|
||||
ReaderMap
|
||||
// WriterMap must the return a WritableState
|
||||
// GetWriter must the return a WritableState
|
||||
// for the provided actor namespace.
|
||||
GetWriter(actor []byte) (Writer, error)
|
||||
// ApplyStateChanges applies all the state changes
|
||||
|
||||
@ -13,6 +13,7 @@ use (
|
||||
./math
|
||||
./orm
|
||||
./simapp
|
||||
./simapp/v2
|
||||
./tests
|
||||
./server/v2/stf
|
||||
./server/v2/appmanager
|
||||
@ -23,6 +24,7 @@ use (
|
||||
./tools/confix
|
||||
./tools/hubl
|
||||
./x/accounts
|
||||
./x/accounts/defaults/lockup
|
||||
./x/auth
|
||||
./x/authz
|
||||
./x/bank
|
||||
@ -42,5 +44,4 @@ use (
|
||||
./x/tx
|
||||
./x/upgrade
|
||||
./x/epochs
|
||||
./x/accounts/defaults/lockup
|
||||
)
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
|
||||
sc *commitment.CommitStore
|
||||
err error
|
||||
ensureDir = func(dir string) error {
|
||||
if err := os.MkdirAll(dir, 0x0755); err != nil {
|
||||
if err := os.MkdirAll(dir, 0o0755); err != nil {
|
||||
return fmt.Errorf("failed to create directory %s: %w", dir, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user