diff --git a/core/appmodule/environment.go b/core/appmodule/environment.go index 17ab778191c0..d65c32a5f83f 100644 --- a/core/appmodule/environment.go +++ b/core/appmodule/environment.go @@ -1,21 +1,8 @@ package appmodule import ( - "cosmossdk.io/core/branch" - "cosmossdk.io/core/event" - "cosmossdk.io/core/gas" - "cosmossdk.io/core/header" - "cosmossdk.io/core/store" - "cosmossdk.io/log" + "cosmossdk.io/core/appmodule/v2" ) // Environment is used to get all services to their respective module -type Environment struct { - BranchService branch.Service - EventService event.Service - GasService gas.Service - HeaderService header.Service - KVStoreService store.KVStoreService - MemStoreService store.MemoryStoreService - Logger log.Logger -} +type Environment = appmodule.Environment diff --git a/core/appmodule/migrations.go b/core/appmodule/migrations.go index fa63b7a92c88..ca2b6fab1f6d 100644 --- a/core/appmodule/migrations.go +++ b/core/appmodule/migrations.go @@ -1,22 +1,13 @@ package appmodule -import "context" +import ( + "cosmossdk.io/core/appmodule/v2" +) -type MigrationRegistrar interface { - // Register registers an in-place store migration for a module. The - // handler is a migration script to perform in-place migrations from version - // `fromVersion` to version `fromVersion+1`. - // - // EACH TIME a module's ConsensusVersion increments, a new migration MUST - // be registered using this function. If a migration handler is missing for - // a particular function, the upgrade logic (see RunMigrations function) - // will panic. If the ConsensusVersion bump does not introduce any store - // changes, then a no-op function must be registered here. - Register(moduleName string, fromVersion uint64, handler MigrationHandler) error -} +type MigrationRegistrar = appmodule.MigrationRegistrar // MigrationHandler is the migration function that each module registers. -type MigrationHandler func(context.Context) error +type MigrationHandler = appmodule.MigrationHandler // VersionMap is a map of moduleName -> version -type VersionMap map[string]uint64 +type VersionMap = appmodule.VersionMap diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 775df459015b..b1cb6c693cd5 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -5,57 +5,40 @@ import ( "google.golang.org/grpc" - "cosmossdk.io/core/transaction" + "cosmossdk.io/core/appmodule/v2" ) // AppModule is a tag interface for app module implementations to use as a basis // for extension interfaces. It provides no functionality itself, but is the // type that all valid app modules should provide so that they can be identified // by other modules (usually via depinject) as app modules. -type AppModule interface { - // IsAppModule is a dummy method to tag a struct as implementing an AppModule. - IsAppModule() +type AppModule = appmodule.AppModule - // IsOnePerModuleType is a dummy method to help depinject resolve modules. - IsOnePerModuleType() -} +// HasMigrations is the extension interface that modules should implement to register migrations. +type HasMigrations = appmodule.HasMigrations -// HasServices is the extension interface that modules should implement to register -// implementations of services defined in .proto files. -type HasServices interface { - AppModule +// HasConsensusVersion is the interface for declaring a module consensus version. +type HasConsensusVersion = appmodule.HasConsensusVersion - // RegisterServices registers the module's services with the app's service - // registrar. - // - // Two types of services are currently supported: - // - read-only gRPC query services, which are the default. - // - transaction message services, which must have the protobuf service - // option "cosmos.msg.v1.service" (defined in "cosmos/msg/v1/service.proto") - // set to true. - // - // The service registrar will figure out which type of service you are - // implementing based on the presence (or absence) of protobuf options. You - // do not need to specify this in golang code. - RegisterServices(grpc.ServiceRegistrar) error -} +// HasBeginBlocker is the extension interface that modules should implement to run +// custom logic before transaction processing in a block. +type HasBeginBlocker = appmodule.HasBeginBlocker -// HasMigrations is the extension interface that modules should implement to register migrations. -type HasMigrations interface { - AppModule - HasConsensusVersion +// HasEndBlocker is the extension interface that modules should implement to run +// custom logic after transaction processing in a block. +type HasEndBlocker = appmodule.HasEndBlocker - // RegisterMigrations registers the module's migrations with the app's migrator. - RegisterMigrations(MigrationRegistrar) error +// HasPrepareCheckState is an extension interface that contains information about the AppModule +// and PrepareCheckState. +type HasPrepareCheckState interface { + AppModule + PrepareCheckState(context.Context) error } -// 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 +// HasPrecommit is an extension interface that contains information about the AppModule and Precommit. +type HasPrecommit interface { + AppModule + Precommit(context.Context) error } // ResponsePreBlock represents the response from the PreBlock method. @@ -74,92 +57,22 @@ type HasPreBlocker interface { PreBlock(context.Context) (ResponsePreBlock, error) } -// HasBeginBlocker is the extension interface that modules should implement to run -// custom logic before transaction processing in a block. -type HasBeginBlocker interface { - AppModule - - // BeginBlock is a method that will be run before transactions are processed in - // a block. - BeginBlock(context.Context) error -} - -// HasEndBlocker is the extension interface that modules should implement to run -// custom logic after transaction processing in a block. -type HasEndBlocker interface { - AppModule - - // EndBlock is a method that will be run after transactions are processed in - // a block. - EndBlock(context.Context) error -} - -// HasTxValidation is the extension interface that modules should implement to run -// custom logic for validating transactions. -// It was previously known as AnteHandler/Decorator. -type HasTxValidation[T transaction.Tx] interface { - AppModule - - // TxValidator is a method that will be run on each transaction. - // If an error is returned: - // ,---. - // / | - // / | - // You shall not pass! / | - // / | - // \ ___,' | - // < -' : - // `-.__..--'``-,_\_ - // |o/ ` :,.)_`> - // :/ ` ||/) - // (_.).__,-` |\ - // /( `.`` `| : - // \'`-.) ` ; ; - // | ` /-< - // | ` / `. - // ,-_-..____ /| ` :__..-'\ - // /,'-.__\\ ``-./ :` ; \ - // `\ `\ `\\ \ : ( ` / , `. \ - // \` \ \\ | | ` : : .\ \ - // \ `\_ )) : ; | | ): : - // (`-.-'\ || |\ \ ` ; ; | | - // \-_ `;;._ ( ` / /_ | | - // `-.-.// ,'`-._\__/_,' ; | - // \:: : / ` , / | - // || | ( ,' / / | - // || ,' / | - TxValidator(ctx context.Context, tx T) error -} - -// HasUpdateValidators is an extension interface that contains information about the AppModule and UpdateValidators. -// It can be seen as the alternative of the Cosmos SDK' HasABCIEndBlocker. -// Both are still supported. -type HasUpdateValidators interface { - AppModule - - UpdateValidators(ctx context.Context) ([]ValidatorUpdate, error) -} - -// ValidatorUpdate defines a validator update. -type ValidatorUpdate struct { - PubKey []byte - PubKeyType string - Power int64 // updated power of the validtor -} - -// ********************************************** -// The following interfaces are baseapp specific and will be deprecated in the future. -// ********************************************** - -// HasPrepareCheckState is an extension interface that contains information about the AppModule -// and PrepareCheckState. -type HasPrepareCheckState interface { +// HasServices is the extension interface that modules should implement to register +// implementations of services defined in .proto files. +type HasServices interface { AppModule - PrepareCheckState(context.Context) error -} -// HasPrecommit is an extension interface that contains information about the AppModule and Precommit. -type HasPrecommit interface { - AppModule - Precommit(context.Context) error + // RegisterServices registers the module's services with the app's service + // registrar. + // + // Two types of services are currently supported: + // - read-only gRPC query services, which are the default. + // - transaction message services, which must have the protobuf service + // option "cosmos.msg.v1.service" (defined in "cosmos/msg/v1/service.proto") + // set to true. + // + // The service registrar will figure out which type of service you are + // implementing based on the presence (or absence) of protobuf options. You + // do not need to specify this in golang code. + RegisterServices(grpc.ServiceRegistrar) error } diff --git a/core/appmodule/v2/environment.go b/core/appmodule/v2/environment.go new file mode 100644 index 000000000000..17ab778191c0 --- /dev/null +++ b/core/appmodule/v2/environment.go @@ -0,0 +1,21 @@ +package appmodule + +import ( + "cosmossdk.io/core/branch" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + "cosmossdk.io/core/header" + "cosmossdk.io/core/store" + "cosmossdk.io/log" +) + +// Environment is used to get all services to their respective module +type Environment struct { + BranchService branch.Service + EventService event.Service + GasService gas.Service + HeaderService header.Service + KVStoreService store.KVStoreService + MemStoreService store.MemoryStoreService + Logger log.Logger +} diff --git a/core/appmodule/v2/genesis.go b/core/appmodule/v2/genesis.go new file mode 100644 index 000000000000..51cdb00fc083 --- /dev/null +++ b/core/appmodule/v2/genesis.go @@ -0,0 +1,15 @@ +package appmodule + +import ( + "context" +) + +// HasGenesis defines a custom genesis handling API implementation. +// TODO: finalize this API +type HasGenesis interface { + AppModule + DefaultGenesis() Message + ValidateGenesis(data Message) error + InitGenesis(ctx context.Context, data Message) error + ExportGenesis(ctx context.Context) (Message, error) +} diff --git a/core/appmodule/v2/handlers.go b/core/appmodule/v2/handlers.go new file mode 100644 index 000000000000..7bfc46bf24cf --- /dev/null +++ b/core/appmodule/v2/handlers.go @@ -0,0 +1,142 @@ +package appmodule + +import ( + "context" + "fmt" +) + +type ( + // PreMsgHandler is a handler that is executed before Handler. If it errors the execution reverts. + PreMsgHandler = func(ctx context.Context, msg Message) error + // Handler handles the state transition of the provided message. + Handler = func(ctx context.Context, msg Message) (msgResp Message, err error) + // PostMsgHandler runs after Handler, only if Handler does not error. If PostMsgHandler errors + // then the execution is reverted. + PostMsgHandler = func(ctx context.Context, msg, msgResp Message) error +) + +// RegisterHandler is a helper function that modules can use to not lose type safety when registering handlers to the +// QueryRouter or MsgRouter. Example usage: +// ```go +// +// func (k Keeper) QueryBalance(ctx context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { +// ... query logic ... +// } +// +// func (m Module) RegisterQueryHandlers(router appmodule.QueryRouter) { +// appmodule.RegisterHandler(router, keeper.QueryBalance) +// } +// +// ``` +func RegisterHandler[R interface{ Register(string, Handler) }, Req, Resp Message]( + router R, + handler func(ctx context.Context, msg Req) (msgResp Resp, err error), +) { + untypedHandler := func(ctx context.Context, m Message) (Message, error) { + typed, ok := m.(Req) + if !ok { + return nil, fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + return handler(ctx, typed) + } + router.Register(messageName[Req](), untypedHandler) +} + +// RegisterPreHandler is a helper function that modules can use to not lose type safety when registering PreMsgHandler to the +// PreMsgRouter. Example usage: +// ```go +// +// func (k Keeper) BeforeSend(ctx context.Context, req *types.MsgSend) (*types.QueryBalanceResponse, error) { +// ... before send logic ... +// } +// +// func (m Module) RegisterPreMsgHandlers(router appmodule.PreMsgRouter) { +// appmodule.RegisterPreHandler(router, keeper.BeforeSend) +// } +// +// ``` +func RegisterPreHandler[Req Message]( + router PreMsgRouter, + handler func(ctx context.Context, msg Req) error, +) { + untypedHandler := func(ctx context.Context, m Message) error { + typed, ok := m.(Req) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + return handler(ctx, typed) + } + router.Register(messageName[Req](), untypedHandler) +} + +// RegisterPostHandler is a helper function that modules can use to not lose type safety when registering handlers to the +// PostMsgRouter. Example usage: +// ```go +// +// func (k Keeper) AfterSend(ctx context.Context, req *types.MsgSend, resp *types.MsgSendResponse) error { +// ... query logic ... +// } +// +// func (m Module) RegisterPostMsgHandlers(router appmodule.PostMsgRouter) { +// appmodule.RegisterPostHandler(router, keeper.AfterSend) +// } +// +// ``` +func RegisterPostHandler[Req, Resp Message]( + router PostMsgRouter, + handler func(ctx context.Context, msg Req, msgResp Resp) error, +) { + untypedHandler := func(ctx context.Context, m, mResp Message) error { + typed, ok := m.(Req) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + typedResp, ok := mResp.(Resp) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Resp)) + } + return handler(ctx, typed, typedResp) + } + router.Register(messageName[Req](), untypedHandler) +} + +// msg handler + +type PreMsgRouter interface { + // Register will register a specific message handler hooking into the message with + // the provided name. + Register(msgName string, handler PreMsgHandler) + // RegisterGlobal will register a global message handler hooking into any message + // being executed. + RegisterGlobal(handler PreMsgHandler) +} + +type HasPreMsgHandlers interface { + RegisterPreMsgHandlers(router PreMsgRouter) +} + +type MsgRouter interface { + Register(msgName string, handler Handler) +} + +type HasMsgHandlers interface { + RegisterMsgHandlers(router MsgRouter) +} + +type PostMsgRouter interface { + // Register will register a specific message handler hooking after the execution of message with + // the provided name. + Register(msgName string, handler PostMsgHandler) + // RegisterGlobal will register a global message handler hooking after the execution of any message. + RegisterGlobal(handler PreMsgHandler) +} + +// query handler + +type QueryRouter interface { + Register(queryName string, handler Handler) +} + +type HasQueryHandlers interface { + RegisterQueryHandlers(router QueryRouter) +} diff --git a/core/appmodule/v2/message.go b/core/appmodule/v2/message.go new file mode 100644 index 000000000000..8a8753c9195e --- /dev/null +++ b/core/appmodule/v2/message.go @@ -0,0 +1,21 @@ +package appmodule + +import ( + gogoproto "github.com/cosmos/gogoproto/proto" + protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoiface" +) + +// Message aliases protoiface.MessageV1 for convenience. +type Message = protoiface.MessageV1 + +func messageName[M Message]() string { + switch m := any(*new(M)).(type) { + case protov2.Message: + return string(m.ProtoReflect().Descriptor().FullName()) + case gogoproto.Message: + return gogoproto.MessageName(m) + default: + panic("unknown message type") + } +} diff --git a/core/appmodule/v2/migrations.go b/core/appmodule/v2/migrations.go new file mode 100644 index 000000000000..794fb4a28cc8 --- /dev/null +++ b/core/appmodule/v2/migrations.go @@ -0,0 +1,41 @@ +package appmodule + +import "context" + +// 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 +} + +// HasMigrations is implemented by a module which upgrades or has upgraded +// to a new consensus version. +type HasMigrations interface { + AppModule + HasConsensusVersion + + // RegisterMigrations registers the module's migrations with the app's migrator. + RegisterMigrations(MigrationRegistrar) error +} + +type MigrationRegistrar interface { + // Register registers an in-place store migration for a module. The + // handler is a migration script to perform in-place migrations from version + // `fromVersion` to version `fromVersion+1`. + // + // EACH TIME a module's ConsensusVersion increments, a new migration MUST + // be registered using this function. If a migration handler is missing for + // a particular function, the upgrade logic (see RunMigrations function) + // will panic. If the ConsensusVersion bump does not introduce any store + // changes, then a no-op function must be registered here. + Register(moduleName string, fromVersion uint64, handler MigrationHandler) error +} + +// MigrationHandler is the migration function that each module registers. +type MigrationHandler func(context.Context) error + +// VersionMap is a map of moduleName -> version +type VersionMap map[string]uint64 diff --git a/core/appmodule/v2/module.go b/core/appmodule/v2/module.go new file mode 100644 index 000000000000..eb44c9f513b8 --- /dev/null +++ b/core/appmodule/v2/module.go @@ -0,0 +1,92 @@ +package appmodule + +import ( + "context" + + "cosmossdk.io/core/transaction" +) + +// AppModule is a tag interface for app module implementations to use as a basis +// for extension interfaces. It provides no functionality itself, but is the +// type that all valid app modules should provide so that they can be identified +// by other modules (usually via depinject) as app modules. +type AppModule interface { + // IsAppModule is a dummy method to tag a struct as implementing an AppModule. + IsAppModule() + + // IsOnePerModuleType is a dummy method to help depinject resolve modules. + IsOnePerModuleType() +} + +// HasBeginBlocker is the extension interface that modules should implement to run +// custom logic before transaction processing in a block. +type HasBeginBlocker interface { + AppModule + + // BeginBlock is a method that will be run before transactions are processed in + // a block. + BeginBlock(context.Context) error +} + +// HasEndBlocker is the extension interface that modules should implement to run +// custom logic after transaction processing in a block. +type HasEndBlocker interface { + AppModule + + // EndBlock is a method that will be run after transactions are processed in + // a block. + EndBlock(context.Context) error +} + +// HasTxValidation is the extension interface that modules should implement to run +// custom logic for validating transactions. +// It was previously known as AnteHandler/Decorator. +type HasTxValidation[T transaction.Tx] interface { + AppModule + + // TxValidator is a method that will be run on each transaction. + // If an error is returned: + // ,---. + // / | + // / | + // You shall not pass! / | + // / | + // \ ___,' | + // < -' : + // `-.__..--'``-,_\_ + // |o/ ` :,.)_`> + // :/ ` ||/) + // (_.).__,-` |\ + // /( `.`` `| : + // \'`-.) ` ; ; + // | ` /-< + // | ` / `. + // ,-_-..____ /| ` :__..-'\ + // /,'-.__\\ ``-./ :` ; \ + // `\ `\ `\\ \ : ( ` / , `. \ + // \` \ \\ | | ` : : .\ \ + // \ `\_ )) : ; | | ): : + // (`-.-'\ || |\ \ ` ; ; | | + // \-_ `;;._ ( ` / /_ | | + // `-.-.// ,'`-._\__/_,' ; | + // \:: : / ` , / | + // || | ( ,' / / | + // || ,' / | + TxValidator(ctx context.Context, tx T) error +} + +// HasUpdateValidators is an extension interface that contains information about the AppModule and UpdateValidators. +// It can be seen as the alternative of the Cosmos SDK' HasABCIEndBlocker. +// Both are still supported. +type HasUpdateValidators interface { + AppModule + + UpdateValidators(ctx context.Context) ([]ValidatorUpdate, error) +} + +// ValidatorUpdate defines a validator update. +type ValidatorUpdate struct { + PubKey []byte + PubKeyType string + Power int64 // updated power of the validtor +} diff --git a/core/store/database.go b/core/store/database.go new file mode 100644 index 000000000000..e536d14e4b8a --- /dev/null +++ b/core/store/database.go @@ -0,0 +1,22 @@ +package store + +// Database provides access to the underlying database for CRUD operations of non-consensus data. +type DatabaseService interface { + GetDatabase() NonConsensusStore +} + +// NonConsensusStore is a simple key-value store that is used to store non-consensus data. +// Note the non-consensus data is not committed to the blockchain and does not allow iteration +type NonConsensusStore interface { + // Get returns nil iff key doesn't exist. Errors on nil key. + Get(key []byte) ([]byte, error) + + // Has checks if a key exists. Errors on nil key. + Has(key []byte) (bool, error) + + // Set sets the key. Errors on nil key or value. + Set(key, value []byte) error + + // Delete deletes the key. Errors on nil key. + Delete(key []byte) error +} diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 9d97eb14003a..2e0704223b1b 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -16,6 +16,7 @@ import ( runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2" cosmosmsg "cosmossdk.io/api/cosmos/msg/v1" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/transaction" "cosmossdk.io/log" "cosmossdk.io/runtime/v2/protocompat" @@ -178,6 +179,7 @@ func (m *MM) EndBlock() (endBlockFunc func(ctx context.Context) error, valUpdate return nil } + valUpdateFunc = func(ctx context.Context) ([]appmodule.ValidatorUpdate, error) { // get validator updates of modules implementing directly the new HasUpdateValidators interface for _, v := range m.modules { @@ -222,7 +224,7 @@ func (m *MM) PreBlocker() func(ctx context.Context, txs []transaction.Tx) error func (m *MM) TxValidation() func(ctx context.Context, tx transaction.Tx) error { return func(ctx context.Context, tx transaction.Tx) error { for _, moduleName := range m.config.TxValidation { - if module, ok := m.modules[moduleName].(appmodule.HasTxValidation[transaction.Tx]); ok { + if module, ok := m.modules[moduleName].(appmodulev2.HasTxValidation[transaction.Tx]); ok { if err := module.TxValidator(ctx, tx); err != nil { return fmt.Errorf("failed to run txvalidator for %s: %w", moduleName, err) } diff --git a/server/v2/appmanager/go.mod b/server/v2/appmanager/go.mod index a1bd6153996e..c23c3b1e56a9 100644 --- a/server/v2/appmanager/go.mod +++ b/server/v2/appmanager/go.mod @@ -17,17 +17,12 @@ require ( require ( github.com/cosmos/gogoproto v1.4.11 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rs/zerolog v1.32.0 // indirect golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect - golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect - google.golang.org/grpc v1.62.0 // indirect google.golang.org/protobuf v1.32.0 // indirect ) diff --git a/server/v2/appmanager/go.sum b/server/v2/appmanager/go.sum index 72a863bd0b24..5493401ff70d 100644 --- a/server/v2/appmanager/go.sum +++ b/server/v2/appmanager/go.sum @@ -4,10 +4,6 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -23,22 +19,11 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index 0c18d8a305ac..04ae26f9d7c6 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -191,7 +191,6 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abci.RequestQuery) (*abci // InitChain implements types.Application. func (c *Consensus[T]) InitChain(ctx context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - // TODO: won't work for now return &abci.ResponseInitChain{ ConsensusParams: req.ConsensusParams, diff --git a/server/v2/cometbft/handlers/defaults.go b/server/v2/cometbft/handlers/defaults.go index 6d6ba398a8aa..1eb92d59f473 100644 --- a/server/v2/cometbft/handlers/defaults.go +++ b/server/v2/cometbft/handlers/defaults.go @@ -5,10 +5,10 @@ import ( "errors" "fmt" + abci "buf.build/gen/go/tendermint/tendermint/protocolbuffers/go/tendermint/abci" "github.com/cosmos/gogoproto/proto" // TODO: use protov2 consensusv1 "cosmossdk.io/api/cosmos/consensus/v1" - abci "cosmossdk.io/api/tendermint/abci" "cosmossdk.io/core/transaction" "cosmossdk.io/server/v2/cometbft/mempool" "cosmossdk.io/server/v2/core/appmanager" diff --git a/server/v2/cometbft/handlers/tx_selector.go b/server/v2/cometbft/handlers/tx_selector.go index 9536fd8a3dd9..f2e11cfd1c50 100644 --- a/server/v2/cometbft/handlers/tx_selector.go +++ b/server/v2/cometbft/handlers/tx_selector.go @@ -3,8 +3,9 @@ package handlers import ( "context" - "cosmossdk.io/core/transaction" cmttypes "github.com/cometbft/cometbft/types" + + "cosmossdk.io/core/transaction" ) // TxSelector defines a helper type that assists in selecting transactions during diff --git a/server/v2/cometbft/streaming.go b/server/v2/cometbft/streaming.go index 0765d6bcb812..ef2a5d70d68e 100644 --- a/server/v2/cometbft/streaming.go +++ b/server/v2/cometbft/streaming.go @@ -18,9 +18,8 @@ func (c *Consensus[T]) streamDeliverBlockChanges( events []event.Event, stateChanges []store.StateChanges, ) error { - // convert txresults to streaming txresults - var streamingTxResults = make([]*streaming.ExecTxResult, len(txResults)) + streamingTxResults := make([]*streaming.ExecTxResult, len(txResults)) for i, txResult := range txResults { // TODO populate this info streamingTxResults[i] = &streaming.ExecTxResult{ diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index 1969eba5f567..6131fec142db 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -7,10 +7,10 @@ import ( "strings" "time" + sdkabci "buf.build/gen/go/tendermint/tendermint/protocolbuffers/go/tendermint/abci" abci "github.com/cometbft/cometbft/abci/types" cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - types1 "github.com/cometbft/cometbft/proto/tendermint/types" gogoproto "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" @@ -20,8 +20,7 @@ import ( v1beta1 "cosmossdk.io/api/cosmos/base/abci/v1beta1" consensusv1 "cosmossdk.io/api/cosmos/consensus/v1" - sdkabci "cosmossdk.io/api/tendermint/abci" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/comet" "cosmossdk.io/core/event" errorsmod "cosmossdk.io/errors" @@ -125,7 +124,7 @@ func finalizeBlockResponse( return resp, nil } -func intoABCIValidatorUpdates(updates []appmodule.ValidatorUpdate) []abci.ValidatorUpdate { +func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.ValidatorUpdate { valsetUpdates := make([]abci.ValidatorUpdate, len(updates)) for i := range updates { @@ -196,7 +195,7 @@ func intoABCISimulationResponse(txRes appmanager.TxResult, indexSet map[string]s abciEvents := make([]*sdkabci.Event, len(txRes.Events)) for i, e := range txRes.Events { abciEvents[i] = &sdkabci.Event{ - Type_: e.Type, + Type: e.Type, Attributes: make([]*sdkabci.EventAttribute, len(e.Attributes)), } @@ -348,22 +347,22 @@ func (c *Consensus[T]) GetConsensusParams(ctx context.Context) (*cmtproto.Consen } else { // convert our params to cometbft params evidenceMaxDuration := time.Duration(r.Params.Evidence.MaxAgeDuration.Seconds) - cs = &types1.ConsensusParams{ - Block: &types1.BlockParams{ + cs = &cmtproto.ConsensusParams{ + Block: &cmtproto.BlockParams{ MaxBytes: r.Params.Block.MaxBytes, MaxGas: r.Params.Block.MaxGas, }, - Evidence: &types1.EvidenceParams{ + Evidence: &cmtproto.EvidenceParams{ MaxAgeNumBlocks: r.Params.Evidence.MaxAgeNumBlocks, MaxAgeDuration: evidenceMaxDuration, }, - Validator: &types1.ValidatorParams{ + Validator: &cmtproto.ValidatorParams{ PubKeyTypes: r.Params.Validator.PubKeyTypes, }, - Version: &types1.VersionParams{ + Version: &cmtproto.VersionParams{ App: r.Params.Version.App, }, - Abci: &types1.ABCIParams{ + Abci: &cmtproto.ABCIParams{ VoteExtensionsEnableHeight: r.Params.Abci.VoteExtensionsEnableHeight, }, } diff --git a/server/v2/core/appmanager/app.go b/server/v2/core/appmanager/app.go index c773cb553ed2..e536cfd96115 100644 --- a/server/v2/core/appmanager/app.go +++ b/server/v2/core/appmanager/app.go @@ -3,7 +3,7 @@ package appmanager import ( "time" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/event" ) @@ -28,7 +28,7 @@ type BlockRequest[T any] struct { type BlockResponse struct { Apphash []byte - ValidatorUpdates []appmodule.ValidatorUpdate + ValidatorUpdates []appmodulev2.ValidatorUpdate PreBlockEvents []event.Event BeginBlockEvents []event.Event TxResults []TxResult @@ -38,13 +38,13 @@ type BlockResponse struct { type RequestInitChain struct { Time time.Time ChainId string - Validators []appmodule.ValidatorUpdate + Validators []appmodulev2.ValidatorUpdate AppStateBytes []byte InitialHeight int64 } type ResponseInitChain struct { - Validators []appmodule.ValidatorUpdate + Validators []appmodulev2.ValidatorUpdate AppHash []byte } diff --git a/server/v2/core/go.mod b/server/v2/core/go.mod index 401ea0111013..fde74bb4ac6b 100644 --- a/server/v2/core/go.mod +++ b/server/v2/core/go.mod @@ -12,16 +12,11 @@ require ( require ( cosmossdk.io/log v1.3.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rs/zerolog v1.32.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect - google.golang.org/grpc v1.62.0 // indirect ) diff --git a/server/v2/core/go.sum b/server/v2/core/go.sum index 8241bd2179e0..6c775b18f2f6 100644 --- a/server/v2/core/go.sum +++ b/server/v2/core/go.sum @@ -4,10 +4,6 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -23,22 +19,11 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/server/v2/stf/go.mod b/server/v2/stf/go.mod index cafcbfe38e85..e57d9cfd952b 100644 --- a/server/v2/stf/go.mod +++ b/server/v2/stf/go.mod @@ -20,7 +20,6 @@ require ( require ( cosmossdk.io/log v1.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/text v0.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -28,10 +27,6 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/zerolog v1.32.0 // indirect - golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect - google.golang.org/grpc v1.62.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/server/v2/stf/go.sum b/server/v2/stf/go.sum index 23b91feddac1..cc21a9a6c976 100644 --- a/server/v2/stf/go.sum +++ b/server/v2/stf/go.sum @@ -6,10 +6,6 @@ github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSoht github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -38,22 +34,11 @@ github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/server/v2/stf/stf.go b/server/v2/stf/stf.go index b9690e7af26a..079bb4d1732e 100644 --- a/server/v2/stf/stf.go +++ b/server/v2/stf/stf.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" corecontext "cosmossdk.io/core/context" "cosmossdk.io/core/event" "cosmossdk.io/core/gas" @@ -24,7 +24,7 @@ type STF[T transaction.Tx] struct { doPreBlock func(ctx context.Context, txs []T) error doBeginBlock func(ctx context.Context) error doEndBlock func(ctx context.Context) error - doValidatorUpdate func(ctx context.Context) ([]appmodule.ValidatorUpdate, error) + doValidatorUpdate func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error) doTxValidation func(ctx context.Context, tx T) error postTxExec func(ctx context.Context, tx T, success bool) error @@ -42,7 +42,7 @@ func NewSTF[T transaction.Tx]( doBeginBlock func(ctx context.Context) error, doEndBlock func(ctx context.Context) error, doTxValidation func(ctx context.Context, tx T) error, - doValidatorUpdate func(ctx context.Context) ([]appmodule.ValidatorUpdate, error), + doValidatorUpdate func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error), branch func(store store.ReaderMap) store.WriterMap, ) *STF[T] { return &STF[T]{ @@ -257,7 +257,7 @@ func (s STF[T]) beginBlock(ctx context.Context, state store.WriterMap) (beginBlo return bbCtx.events, nil } -func (s STF[T]) endBlock(ctx context.Context, state store.WriterMap) ([]event.Event, []appmodule.ValidatorUpdate, error) { +func (s STF[T]) endBlock(ctx context.Context, state store.WriterMap) ([]event.Event, []appmodulev2.ValidatorUpdate, error) { ebCtx := s.makeContext(ctx, []transaction.Identity{runtimeIdentity}, state, gas.NoGasLimit, corecontext.ExecModeFinalize) err := s.doEndBlock(ebCtx) if err != nil { @@ -282,7 +282,7 @@ func (s STF[T]) endBlock(ctx context.Context, state store.WriterMap) ([]event.Ev } // validatorUpdates returns the validator updates for the current block. It is called by endBlock after the endblock execution has concluded -func (s STF[T]) validatorUpdates(ctx context.Context, state store.WriterMap) ([]event.Event, []appmodule.ValidatorUpdate, error) { +func (s STF[T]) validatorUpdates(ctx context.Context, state store.WriterMap) ([]event.Event, []appmodulev2.ValidatorUpdate, error) { ebCtx := s.makeContext(ctx, []transaction.Identity{runtimeIdentity}, state, gas.NoGasLimit, corecontext.ExecModeFinalize) valSetUpdates, err := s.doValidatorUpdate(ebCtx) if err != nil { diff --git a/server/v2/stf/stf_test.go b/server/v2/stf/stf_test.go index 09c89dc6c524..fbb1cb6ae476 100644 --- a/server/v2/stf/stf_test.go +++ b/server/v2/stf/stf_test.go @@ -8,10 +8,9 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/wrapperspb" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" coregas "cosmossdk.io/core/gas" "cosmossdk.io/core/transaction" - "cosmossdk.io/server/v2/core/appmanager" "cosmossdk.io/server/v2/core/store" "cosmossdk.io/server/v2/stf/branch" @@ -42,7 +41,7 @@ func TestSTF(t *testing.T) { kvSet(t, ctx, "end-block") return nil }, - doValidatorUpdate: func(ctx context.Context) ([]appmodule.ValidatorUpdate, error) { return nil, nil }, + doValidatorUpdate: func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error) { return nil, nil }, doTxValidation: func(ctx context.Context, tx mock.Tx) error { kvSet(t, ctx, "validate") return nil diff --git a/simapp/app_test.go b/simapp/app_test.go index 82a6baf9086c..c27d5949272a 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/x/accounts" @@ -246,7 +247,7 @@ func TestInitGenesisOnMigration(t *testing.T) { // Run migrations only for "mock" module. We exclude it from // the VersionMap to simulate upgrading with a new module. _, err := app.ModuleManager.RunMigrations(ctx, app.Configurator(), - appmodule.VersionMap{ + appmodulev2.VersionMap{ "bank": bank.AppModule{}.ConsensusVersion(), "auth": auth.AppModule{}.ConsensusVersion(), "authz": authzmodule.AppModule{}.ConsensusVersion(), @@ -278,7 +279,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.(appmodule.HasConsensusVersion); ok { + if i, ok := i.(appmodulev2.HasConsensusVersion); ok { require.Equal(t, vm[v], i.ConsensusVersion()) } } diff --git a/x/auth/module.go b/x/auth/module.go index 6255307019cd..ba64d67786e9 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/transaction" "cosmossdk.io/runtime/v2" "cosmossdk.io/x/auth/ante" @@ -35,10 +36,10 @@ var ( _ module.HasName = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasTxValidation[transaction.Tx] = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasTxValidation[transaction.Tx] = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the auth module. diff --git a/x/bank/module.go b/x/bank/module.go index f233d0115b4c..958a14e271b1 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/bank/client/cli" "cosmossdk.io/x/bank/keeper" "cosmossdk.io/x/bank/simulation" @@ -37,9 +38,9 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasInvariants = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the bank module. diff --git a/x/circuit/module.go b/x/circuit/module.go index 852b74d66542..23e7910c100c 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/circuit/keeper" "cosmossdk.io/x/circuit/types" @@ -29,7 +30,7 @@ var ( _ module.HasRegisterInterfaces = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} + _ appmodulev2.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} ) diff --git a/x/consensus/module.go b/x/consensus/module.go index de10392824d0..6de81384f176 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -6,7 +6,7 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -25,7 +25,7 @@ var ( _ module.HasGRPCGateway = AppModule{} _ module.HasRegisterInterfaces = AppModule{} - _ appmodule.AppModule = AppModule{} + _ appmodulev2.AppModule = AppModule{} ) // AppModule implements an application module diff --git a/x/distribution/module.go b/x/distribution/module.go index 2caf7ab534ee..abca53f0f82f 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/simulation" @@ -35,10 +36,10 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasInvariants = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasBeginBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the distribution module. diff --git a/x/evidence/module.go b/x/evidence/module.go index b09183dbb50b..c1bb6916d7cf 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" "cosmossdk.io/x/evidence/keeper" @@ -31,8 +31,8 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasBeginBlocker = AppModule{} ) const ConsensusVersion = 1 diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 969708da943c..2aa5f21ea992 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/transaction" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" @@ -30,10 +31,10 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasEndBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the feegrant module. diff --git a/x/gov/module.go b/x/gov/module.go index 85c95353513a..c352ab31ed35 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" "cosmossdk.io/x/gov/keeper" @@ -37,10 +38,10 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasInvariants = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasEndBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the gov module. diff --git a/x/mint/module.go b/x/mint/module.go index 3f8e9fbabfb8..6bb18cea95af 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" "cosmossdk.io/x/mint/types" @@ -31,10 +32,10 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasBeginBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements an application module for the mint module. diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 8f213b1305c9..aff6365698ab 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -7,7 +7,7 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/errors" "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" @@ -27,7 +27,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} + _ appmodulev2.AppModule = AppModule{} ) const ConsensusVersion = 1 diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 0257e69960eb..e0b1fae2133e 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" @@ -30,7 +31,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} + _ appmodulev2.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} ) diff --git a/x/staking/module.go b/x/staking/module.go index 504cdfb92597..c780b3edf2b5 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/depinject" "cosmossdk.io/x/staking/client/cli" "cosmossdk.io/x/staking/keeper" @@ -37,10 +38,10 @@ var ( _ module.HasABCIGenesis = AppModule{} _ module.HasABCIEndBlock = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasBeginBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodulev2.HasBeginBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} _ depinject.OnePerModuleType = AppModule{} ) diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 7a609ae4b25a..4925fe8afc1d 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" @@ -34,10 +35,10 @@ var ( _ module.HasRegisterInterfaces = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasPreBlocker = AppModule{} - _ appmodule.HasServices = AppModule{} - _ appmodule.HasMigrations = AppModule{} + _ appmodulev2.AppModule = AppModule{} + _ appmodule.HasPreBlocker = AppModule{} + _ appmodule.HasServices = AppModule{} + _ appmodulev2.HasMigrations = AppModule{} ) // AppModule implements the sdk.AppModule interface