diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c80e2ed64b7..eb7dfca2bdc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Features * (types) [#19511](https://github.com/cosmos/cosmos-sdk/pull/19511) Replace regex parsing of denom validation to direct matching methods. +* (runtime) [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Implement `core/router.Service` it in runtime. This service is present in all modules (when using depinject). * (types) [#19164](https://github.com/cosmos/cosmos-sdk/pull/19164) Add a ValueCodec for the math.Uint type that can be used in collections maps. * (types) [#19281](https://github.com/cosmos/cosmos-sdk/pull/19281) Added a new method, `IsGT`, for `types.Coin`. This method is used to check if a `types.Coin` is greater than another `types.Coin`. * (client) [#18557](https://github.com/cosmos/cosmos-sdk/pull/18557) Add `--qrcode` flag to `keys show` command to support displaying keys address QR code. diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index 450f4c9b235c..e4ae40f71273 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/comet" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" ) @@ -46,8 +47,8 @@ func ValidateVoteExtensions( ) error { // Get values from context cp := ctx.ConsensusParams() - currentHeight := ctx.BlockHeight() - chainID := ctx.BlockHeader().ChainID + currentHeight := ctx.HeaderInfo().Height + chainID := ctx.HeaderInfo().ChainID commitInfo := ctx.CometInfo().LastCommit // Check that both extCommit + commit are ordered in accordance with vp/address. diff --git a/baseapp/abci_utils_test.go b/baseapp/abci_utils_test.go index 7157d3ac9cc3..f2b636fc39d3 100644 --- a/baseapp/abci_utils_test.go +++ b/baseapp/abci_utils_test.go @@ -17,10 +17,11 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "cosmossdk.io/core/comet" + "cosmossdk.io/core/header" "cosmossdk.io/log" authtx "cosmossdk.io/x/auth/tx" - "cosmossdk.io/core/comet" "github.com/cosmos/cosmos-sdk/baseapp" baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/baseapp/testutil/mock" @@ -66,13 +67,6 @@ func (t testValidator) toValidator(power int64) abci.Validator { } } -func (t testValidator) toSDKValidator(power int64) comet.Validator { - return comet.Validator{ - Address: t.consAddr.Bytes(), - Power: power, - } -} - type ABCIUtilsTestSuite struct { suite.Suite @@ -139,7 +133,7 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsHappyPath() { extSig2, err := s.vals[2].privKey.Sign(bz) s.Require().NoError(err) - s.ctx = s.ctx.WithBlockHeight(3) // enable vote-extensions + s.ctx = s.ctx.WithBlockHeight(3).WithHeaderInfo(header.Info{Height: 3, ChainID: chainID}) // enable vote-extensions llc := abci.ExtendedCommitInfo{ Round: 0, @@ -778,23 +772,6 @@ func extendedCommitToLastCommit(ec abci.ExtendedCommitInfo) (abci.ExtendedCommit } } -type voteInfos []comet.VoteInfo - -func (v voteInfos) Len() int { - return len(v) -} - -func (v voteInfos) Less(i, j int) bool { - if v[i].Validator.Power == v[j].Validator.Power { - return bytes.Compare(v[i].Validator.Address, v[j].Validator.Address) == -1 - } - return v[i].Validator.Power > v[j].Validator.Power -} - -func (v voteInfos) Swap(i, j int) { - v[i], v[j] = v[j], v[i] -} - type extendedVoteInfos []abci.ExtendedVoteInfo func (v extendedVoteInfos) Len() int { diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7f7ef4ac5279..672e5a6dea30 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -281,10 +281,8 @@ func (app *BaseApp) Trace() bool { // MsgServiceRouter returns the MsgServiceRouter of a BaseApp. func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter } -// SetMsgServiceRouter sets the MsgServiceRouter of a BaseApp. -func (app *BaseApp) SetMsgServiceRouter(msgServiceRouter *MsgServiceRouter) { - app.msgServiceRouter = msgServiceRouter -} +// GRPCQueryRouter returns the GRPCQueryRouter of a BaseApp. +func (app *BaseApp) GRPCQueryRouter() *GRPCQueryRouter { return app.grpcQueryRouter } // MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp // multistore. diff --git a/baseapp/grpcrouter.go b/baseapp/grpcrouter.go index a1acc0b9cf2b..b12c3bd6ac3a 100644 --- a/baseapp/grpcrouter.go +++ b/baseapp/grpcrouter.go @@ -24,6 +24,8 @@ type GRPCQueryRouter struct { // hybridHandlers maps the request name to the handler. It is a hybrid handler which seamlessly // handles both gogo and protov2 messages. hybridHandlers map[string][]func(ctx context.Context, req, resp protoiface.MessageV1) error + // responseByRequestName maps the request name to the response name. + responseByRequestName map[string]string // binaryCodec is used to encode/decode binary protobuf messages. binaryCodec codec.BinaryCodec // cdc is the gRPC codec used by the router to correctly unmarshal messages. @@ -43,8 +45,9 @@ var _ gogogrpc.Server = &GRPCQueryRouter{} // NewGRPCQueryRouter creates a new GRPCQueryRouter func NewGRPCQueryRouter() *GRPCQueryRouter { return &GRPCQueryRouter{ - routes: map[string]GRPCQueryHandler{}, - hybridHandlers: map[string][]func(ctx context.Context, req, resp protoiface.MessageV1) error{}, + routes: map[string]GRPCQueryHandler{}, + hybridHandlers: map[string][]func(ctx context.Context, req, resp protoiface.MessageV1) error{}, + responseByRequestName: map[string]string{}, } } @@ -133,16 +136,26 @@ func (qrt *GRPCQueryRouter) HybridHandlerByRequestName(name string) []func(ctx c return qrt.hybridHandlers[name] } +func (qrt *GRPCQueryRouter) ResponseNameByRequestName(requestName string) string { + return qrt.responseByRequestName[requestName] +} + func (qrt *GRPCQueryRouter) registerHybridHandler(sd *grpc.ServiceDesc, method grpc.MethodDesc, handler interface{}) error { // extract message name from method descriptor inputName, err := protocompat.RequestFullNameFromMethodDesc(sd, method) if err != nil { return err } + outputName, err := protocompat.ResponseFullNameFromMethodDesc(sd, method) + if err != nil { + return err + } methodHandler, err := protocompat.MakeHybridHandler(qrt.binaryCodec, sd, method, handler) if err != nil { return err } + // map input name to output name + qrt.responseByRequestName[string(inputName)] = string(outputName) qrt.hybridHandlers[string(inputName)] = append(qrt.hybridHandlers[string(inputName)], methodHandler) return nil } diff --git a/baseapp/grpcserver.go b/baseapp/grpcserver.go index 2d11818a462c..b1befabe9e86 100644 --- a/baseapp/grpcserver.go +++ b/baseapp/grpcserver.go @@ -20,9 +20,6 @@ import ( grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" ) -// GRPCQueryRouter returns the GRPCQueryRouter of a BaseApp. -func (app *BaseApp) GRPCQueryRouter() *GRPCQueryRouter { return app.grpcQueryRouter } - // RegisterGRPCServer registers gRPC services directly with the gRPC server. func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { // Define an interceptor for all gRPC queries: this interceptor will create diff --git a/baseapp/msg_service_router.go b/baseapp/msg_service_router.go index fe4488d2673c..21ba4371e426 100644 --- a/baseapp/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -24,6 +24,9 @@ import ( type MessageRouter interface { Handler(msg sdk.Msg) MsgServiceHandler HandlerByTypeURL(typeURL string) MsgServiceHandler + + ResponseNameByMsgName(msgName string) string + HybridHandlerByMsgName(msgName string) func(ctx context.Context, req, resp protoiface.MessageV1) error } // MsgServiceRouter routes fully-qualified Msg service methods to their handler. @@ -31,7 +34,7 @@ type MsgServiceRouter struct { interfaceRegistry codectypes.InterfaceRegistry routes map[string]MsgServiceHandler hybridHandlers map[string]func(ctx context.Context, req, resp protoiface.MessageV1) error - responseByRequest map[string]string + responseByMsgName map[string]string circuitBreaker CircuitBreaker } @@ -42,7 +45,7 @@ func NewMsgServiceRouter() *MsgServiceRouter { return &MsgServiceRouter{ routes: map[string]MsgServiceHandler{}, hybridHandlers: map[string]func(ctx context.Context, req, resp protoiface.MessageV1) error{}, - responseByRequest: map[string]string{}, + responseByMsgName: map[string]string{}, circuitBreaker: nil, } } @@ -90,8 +93,8 @@ func (msr *MsgServiceRouter) HybridHandlerByMsgName(msgName string) func(ctx con return msr.hybridHandlers[msgName] } -func (msr *MsgServiceRouter) ResponseNameByRequestName(msgName string) string { - return msr.responseByRequest[msgName] +func (msr *MsgServiceRouter) ResponseNameByMsgName(msgName string) string { + return msr.responseByMsgName[msgName] } func (msr *MsgServiceRouter) registerHybridHandler(sd *grpc.ServiceDesc, method grpc.MethodDesc, handler interface{}) error { @@ -109,7 +112,7 @@ func (msr *MsgServiceRouter) registerHybridHandler(sd *grpc.ServiceDesc, method return err } // map input name to output name - msr.responseByRequest[string(inputName)] = string(outputName) + msr.responseByMsgName[string(inputName)] = string(outputName) // if circuit breaker is not nil, then we decorate the hybrid handler with the circuit breaker if msr.circuitBreaker == nil { msr.hybridHandlers[string(inputName)] = hybridHandler diff --git a/baseapp/options.go b/baseapp/options.go index a99762da5e51..5acc6811dbe3 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -385,3 +385,13 @@ func (app *BaseApp) SetStoreMetrics(gatherer metrics.StoreMetrics) { func (app *BaseApp) SetStreamingManager(manager storetypes.StreamingManager) { app.streamingManager = manager } + +// SetMsgServiceRouter sets the MsgServiceRouter of a BaseApp. +func (app *BaseApp) SetMsgServiceRouter(msgServiceRouter *MsgServiceRouter) { + app.msgServiceRouter = msgServiceRouter +} + +// SetGRPCQueryRouter sets the GRPCQueryRouter of the BaseApp. +func (app *BaseApp) SetGRPCQueryRouter(grpcQueryRouter *GRPCQueryRouter) { + app.grpcQueryRouter = grpcQueryRouter +} diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index 7aaf78a85445..a493fc548ff1 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -47,7 +47,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.testClient = testdata.NewQueryClient(queryHelper) kvs := runtime.NewKVStoreService(keys[countertypes.StoreKey]) - counterKeeper := counterkeeper.NewKeeper(kvs, runtime.EventService{}) + counterKeeper := counterkeeper.NewKeeper(runtime.NewEnvironment(kvs, logger)) countertypes.RegisterQueryServer(queryHelper, counterKeeper) s.counterClient = countertypes.NewQueryClient(queryHelper) } diff --git a/client/v2/autocli/testdata/msg-output.golden b/client/v2/autocli/testdata/msg-output.golden index 9d0cead403f9..924f3eeee5d5 100644 --- a/client/v2/autocli/testdata/msg-output.golden +++ b/client/v2/autocli/testdata/msg-output.golden @@ -1 +1 @@ -{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend", "from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk", "to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk", "amount":[{"denom":"foo", "amount":"1"}]}]}, "auth_info":{"fee":{"gas_limit":"200000"}}} +{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}]},"auth_info":{"fee":{"gas_limit":"200000"}}} diff --git a/client/v2/go.mod b/client/v2/go.mod index 571bc45f382a..62468c46493f 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -137,7 +137,7 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/viper v1.18.2 // indirect - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect diff --git a/client/v2/go.sum b/client/v2/go.sum index 9a13c73af234..e8330138e4c2 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -678,8 +678,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -689,8 +690,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/collections/go.mod b/collections/go.mod index c03042f52630..d48f5bec5e5e 100644 --- a/collections/go.mod +++ b/collections/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( cosmossdk.io/core v0.11.0 github.com/cosmos/cosmos-db v1.0.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 pgregory.net/rapid v1.1.0 ) diff --git a/collections/go.sum b/collections/go.sum index 128ded83395d..c1946a7079a3 100644 --- a/collections/go.sum +++ b/collections/go.sum @@ -119,8 +119,8 @@ github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cA github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 8dec182fa0c3..2f556daf6a24 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -42,7 +42,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit. * [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) Add `appmodule.Environment` interface to fetch different services * [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Add `appmodule.Migrations` interface to handle migrations -* [#19617](https://github.com/cosmos/cosmos-sdk/pull/19617) Add DataBaseService to store non-consensus data in a database +* [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Add `router.Service` and add it in `appmodule.Environment` +* [#19617](https://github.com/cosmos/cosmos-sdk/pull/19617) Server/v2 compatible interface: + * Add DataBaseService to store non-consensus data in a database * Create V2 appmodule with v2 api for runtime/v2 * Introduce `Transaction.Tx` for use in runtime/v2 * Introduce `HasUpdateValidators` interface and `ValidatorUpdate` struct for validator updates diff --git a/core/appmodule/v2/environment.go b/core/appmodule/v2/environment.go index 9badbddc2f73..eccc7eb297af 100644 --- a/core/appmodule/v2/environment.go +++ b/core/appmodule/v2/environment.go @@ -5,18 +5,21 @@ import ( "cosmossdk.io/core/event" "cosmossdk.io/core/gas" "cosmossdk.io/core/header" + "cosmossdk.io/core/router" "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 + Logger log.Logger + + BranchService branch.Service + EventService event.Service + GasService gas.Service + HeaderService header.Service + RouterService router.Service + KVStoreService store.KVStoreService MemStoreService store.MemoryStoreService - DataBaseService store.DatabaseService - Logger log.Logger } diff --git a/core/gas/meter.go b/core/gas/service.go similarity index 100% rename from core/gas/meter.go rename to core/gas/service.go diff --git a/core/go.mod b/core/go.mod index e732129de93a..e5ee7dd85038 100644 --- a/core/go.mod +++ b/core/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cosmossdk.io/log v1.3.1 github.com/cosmos/gogoproto v1.4.11 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 ) diff --git a/core/go.sum b/core/go.sum index 57133f587985..ac3b1a6b9989 100644 --- a/core/go.sum +++ b/core/go.sum @@ -37,8 +37,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= 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= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= diff --git a/core/router/service.go b/core/router/service.go new file mode 100644 index 000000000000..d4f13d21b2ce --- /dev/null +++ b/core/router/service.go @@ -0,0 +1,24 @@ +package router + +import ( + "context" + + "google.golang.org/protobuf/runtime/protoiface" +) + +// Service embeds a QueryRouterService and MessageRouterService. +// Each router allows to invoke messages and queries via the corresponding router. +type Service interface { + QueryRouterService() Router + MessageRouterService() Router +} + +// Router is the interface that wraps the basic methods for a router. +type Router interface { + // CanInvoke returns an error if the given request cannot be invoked. + CanInvoke(ctx context.Context, typeURL string) error + // InvokeTyped execute a message or query. It should be used when the called knows the type of the response. + InvokeTyped(ctx context.Context, req, res protoiface.MessageV1) error + // InvokeUntyped execute a message or query. It should be used when the called doesn't know the type of the response. + InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (res protoiface.MessageV1, err error) +} diff --git a/crypto/armor.go b/crypto/armor.go index 13f24c4e082d..47eba69d8a63 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -62,7 +62,7 @@ var BcryptSecurityParameter uint32 = 12 //----------------------------------------------------------------- // add armor -// Armor the InfoBytes +// ArmorInfoBytes armor the InfoBytes func ArmorInfoBytes(bz []byte) string { header := map[string]string{ headerType: "Info", @@ -72,7 +72,7 @@ func ArmorInfoBytes(bz []byte) string { return EncodeArmor(blockTypeKeyInfo, header, bz) } -// Armor the PubKeyBytes +// ArmorPubKeyBytes armor the PubKeyBytes func ArmorPubKeyBytes(bz []byte, algo string) string { header := map[string]string{ headerVersion: "0.0.1", @@ -87,7 +87,7 @@ func ArmorPubKeyBytes(bz []byte, algo string) string { //----------------------------------------------------------------- // remove armor -// Unarmor the InfoBytes +// UnarmorInfoBytes unarmor the InfoBytes func UnarmorInfoBytes(armorStr string) ([]byte, error) { bz, header, err := unarmorBytes(armorStr, blockTypeKeyInfo) if err != nil { @@ -142,7 +142,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri //----------------------------------------------------------------- // encrypt/decrypt with armor -// Encrypt and armor the private key. +// EncryptArmorPrivKey encrypt and armor the private key. func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase, algo string) string { saltBytes, encBytes := encryptPrivKey(privKey, passphrase) header := map[string]string{ diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 8d0bc2018c08..22673e06fa09 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -56,12 +56,12 @@ var ( // Keyring exposes operations over a backend supported by github.com/99designs/keyring. type Keyring interface { - // Get the backend type used in the keyring config: "file", "os", "kwallet", "pass", "test", "memory". + // Backend get the backend type used in the keyring config: "file", "os", "kwallet", "pass", "test", "memory". Backend() string // List all keys. List() ([]*Record, error) - // Supported signing algorithms for Keyring and Ledger respectively. + // SupportedAlgorithms supported signing algorithms for Keyring and Ledger respectively. SupportedAlgorithms() (SigningAlgoList, SigningAlgoList) // Key and KeyByAddress return keys by uid and address respectively. @@ -130,7 +130,7 @@ type Migrator interface { // Exporter is implemented by key stores that support export of public and private keys. type Exporter interface { - // Export public key + // ExportPubKeyArmor export public key ExportPubKeyArmor(uid string) (string, error) ExportPubKeyArmorByAddress(address []byte) (string, error) diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 8de45feb1be2..7bdaad0e5b00 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -13,17 +13,17 @@ import ( // Deprecated: LegacyInfo is the publicly exposed information about a keypair type LegacyInfo interface { - // Human-readable type for key listing + // GetType human-readable type for key listing GetType() KeyType - // Name of the key + // GetName name of the key GetName() string - // Public key + // GetPubKey public key GetPubKey() cryptotypes.PubKey - // Address + // GetAddress address GetAddress() sdk.AccAddress - // Bip44 Path + // GetPath bip44 path GetPath() (*hd.BIP44Params, error) - // Algo + // GetAlgo signing algorithm for the key GetAlgo() hd.PubKeyType } @@ -45,37 +45,37 @@ type legacyLocalInfo struct { func infoKey(name string) string { return fmt.Sprintf("%s.%s", name, infoSuffix) } -// GetType implements Info interface +// GetType returns human-readable type for key listing func (i legacyLocalInfo) GetType() KeyType { return TypeLocal } -// GetType implements Info interface +// GetName returns name of the key func (i legacyLocalInfo) GetName() string { return i.Name } -// GetType implements Info interface +// GetPubKey returns public key func (i legacyLocalInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } -// GetType implements Info interface +// GetAddress returns address func (i legacyLocalInfo) GetAddress() sdk.AccAddress { return i.PubKey.Address().Bytes() } -// GetPrivKeyArmor +// GetPrivKeyArmor returns privkey armor func (i legacyLocalInfo) GetPrivKeyArmor() string { return i.PrivKeyArmor } -// GetType implements Info interface +// GetAlgo returns the signing algorithm for the key func (i legacyLocalInfo) GetAlgo() hd.PubKeyType { return i.Algo } -// GetType implements Info interface +// GetPath returns bip44 path, but not available for this type func (i legacyLocalInfo) GetPath() (*hd.BIP44Params, error) { return nil, fmt.Errorf("BIP44 Paths are not available for this type") } @@ -89,32 +89,32 @@ type legacyLedgerInfo struct { Algo hd.PubKeyType `json:"algo"` } -// GetType implements Info interface +// GetType returns human-readable type for key listing func (i legacyLedgerInfo) GetType() KeyType { return TypeLedger } -// GetName implements Info interface +// GetName returns name of the key func (i legacyLedgerInfo) GetName() string { return i.Name } -// GetPubKey implements Info interface +// GetPubKey returns public key func (i legacyLedgerInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } -// GetAddress implements Info interface +// GetAddress returns address func (i legacyLedgerInfo) GetAddress() sdk.AccAddress { return i.PubKey.Address().Bytes() } -// GetPath implements Info interface +// GetAlgo returns the signing algorithm for the key func (i legacyLedgerInfo) GetAlgo() hd.PubKeyType { return i.Algo } -// GetPath implements Info interface +// GetPath returns bip44 path func (i legacyLedgerInfo) GetPath() (*hd.BIP44Params, error) { tmp := i.Path return &tmp, nil @@ -128,17 +128,17 @@ type legacyOfflineInfo struct { Algo hd.PubKeyType `json:"algo"` } -// GetType implements Info interface +// GetType returns human-readable type for key listing func (i legacyOfflineInfo) GetType() KeyType { return TypeOffline } -// GetName implements Info interface +// GetName returns name of the key func (i legacyOfflineInfo) GetName() string { return i.Name } -// GetPubKey implements Info interface +// GetPubKey returns public key func (i legacyOfflineInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } @@ -148,12 +148,12 @@ func (i legacyOfflineInfo) GetAlgo() hd.PubKeyType { return i.Algo } -// GetAddress implements Info interface +// GetAddress returns address func (i legacyOfflineInfo) GetAddress() sdk.AccAddress { return i.PubKey.Address().Bytes() } -// GetPath implements Info interface +// GetPath returns bip44 path, but not available for this type func (i legacyOfflineInfo) GetPath() (*hd.BIP44Params, error) { return nil, fmt.Errorf("BIP44 Paths are not available for this type") } @@ -167,7 +167,7 @@ type multisigPubKeyInfo struct { Weight uint `json:"weight"` } -// multiInfo is the public information about a multisig key +// LegacyMultiInfo multiInfo is the public information about a multisig key type LegacyMultiInfo struct { Name string `json:"name"` PubKey cryptotypes.PubKey `json:"pubkey"` @@ -186,32 +186,32 @@ func NewLegacyMultiInfo(name string, pub cryptotypes.PubKey) (LegacyInfo, error) }, nil } -// GetType implements Info interface +// GetType returns human-readable type for key listing func (i LegacyMultiInfo) GetType() KeyType { return TypeMulti } -// GetName implements Info interface +// GetName returns name of the key func (i LegacyMultiInfo) GetName() string { return i.Name } -// GetPubKey implements Info interface +// GetPubKey returns public key func (i LegacyMultiInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } -// GetAddress implements Info interface +// GetAddress returns address func (i LegacyMultiInfo) GetAddress() sdk.AccAddress { return i.PubKey.Address().Bytes() } -// GetPath implements Info interface +// GetAlgo returns the signing algorithm for the key func (i LegacyMultiInfo) GetAlgo() hd.PubKeyType { return hd.MultiType } -// GetPath implements Info interface +// GetPath returns bip44 path, but not available for this type func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { return nil, fmt.Errorf("BIP44 Paths are not available for this type") } @@ -223,7 +223,7 @@ func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error return codectypes.UnpackInterfaces(multiPK, unpacker) } -// encoding info +// MarshalInfo encoding info func MarshalInfo(i LegacyInfo) []byte { return legacy.Cdc.MustMarshalLengthPrefixed(i) } diff --git a/crypto/keys/bcrypt/bcrypt.go b/crypto/keys/bcrypt/bcrypt.go index f4f62d500cf7..6441ebce2896 100644 --- a/crypto/keys/bcrypt/bcrypt.go +++ b/crypto/keys/bcrypt/bcrypt.go @@ -32,7 +32,7 @@ var ErrMismatchedHashAndPassword = errors.New("crypto/bcrypt: hashedPassword is // be a bcrypt hash. var ErrHashTooShort = errors.New("crypto/bcrypt: hashedSecret too short to be a bcrypted password") -// The error returned from CompareHashAndPassword when a hash was created with +// HashVersionTooNewError the error returned from CompareHashAndPassword when a hash was created with // a bcrypt algorithm newer than this implementation. type HashVersionTooNewError byte @@ -40,7 +40,7 @@ func (hv HashVersionTooNewError) Error() string { return fmt.Sprintf("crypto/bcrypt: bcrypt algorithm version '%c' requested is newer than current version '%c'", byte(hv), majorVersion) } -// The error returned from CompareHashAndPassword when a hash starts with something other than '$' +// InvalidHashPrefixError the error returned from CompareHashAndPassword when a hash starts with something other than '$' type InvalidHashPrefixError byte func (ih InvalidHashPrefixError) Error() string { @@ -266,7 +266,7 @@ func (p *hashed) decodeVersion(sbytes []byte) (int, error) { return n, nil } -// sbytes should begin where decodeVersion left off. +// decodeCost sbytes should begin where decodeVersion left off. func (p *hashed) decodeCost(sbytes []byte) (int, error) { cost, err := strconv.Atoi(string(sbytes[0:2])) if err != nil { diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index 122be97cb254..b0c28052a8cf 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -22,11 +22,11 @@ import ( const ( PrivKeyName = "tendermint/PrivKeyEd25519" PubKeyName = "tendermint/PubKeyEd25519" - // PubKeySize is is the size, in bytes, of public keys as used in this package. + // PubKeySize is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivKeySize is the size, in bytes, of private keys as used in this package. PrivKeySize = 64 - // Size of an Edwards25519 signature. Namely the size of a compressed + // SignatureSize the size of an Edwards25519 signature. Namely the size of a compressed // Edwards25519 point, and a field element. Both of which are 32 bytes. SignatureSize = 64 // SeedSize is the size, in bytes, of private key seeds. These are the diff --git a/crypto/keys/secp256k1/secp256k1_nocgo.go b/crypto/keys/secp256k1/secp256k1_nocgo.go index fff3ba5e0544..bad10212b63c 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo.go @@ -21,7 +21,7 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { return sig[1:], nil } -// VerifyBytes verifies a signature of the form R || S. +// VerifySignature verifies a signature of the form R || S. // It rejects signatures which are not in lower-S form. func (pubKey *PubKey) VerifySignature(msg, sigStr []byte) bool { if len(sigStr) != 64 { diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index 174fbfb091c0..67dcc73981ab 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -31,11 +31,11 @@ type ( // SECP256K1 reflects an interface a Ledger API must implement for SECP256K1 SECP256K1 interface { Close() error - // Returns an uncompressed pubkey + // GetPublicKeySECP256K1 returns an uncompressed pubkey GetPublicKeySECP256K1([]uint32) ([]byte, error) - // Returns a compressed pubkey and bech32 address (requires user confirmation) + // GetAddressPubKeySECP256K1 returns a compressed pubkey and bech32 address (requires user confirmation) GetAddressPubKeySECP256K1([]uint32, string) ([]byte, string, error) - // Signs a message (requires user confirmation) + // SignSECP256K1 signs a message (requires user confirmation) // The last byte denotes the SIGN_MODE to be used by Ledger: 0 for // LEGACY_AMINO_JSON, 1 for TEXTUAL. It corresponds to the P2 value // in https://github.com/cosmos/ledger-cosmos/blob/main/docs/APDUSPEC.md @@ -71,22 +71,22 @@ func initOptionsDefault() { options.skipDERConversion = false } -// Set the discoverLedger function to use a different Ledger derivation +// SetDiscoverLedger set the discoverLedger function to use a different Ledger derivation func SetDiscoverLedger(fn discoverLedgerFn) { options.discoverLedger = fn } -// Set the createPubkey function to use a different public key +// SetCreatePubkey set the createPubkey function to use a different public key func SetCreatePubkey(fn createPubkeyFn) { options.createPubkey = fn } -// Set the Ledger app name to use a different app name +// SetAppName set the Ledger app name to use a different app name func SetAppName(appName string) { options.appName = appName } -// Set the DER Conversion requirement to true (false by default) +// SetSkipDERConversion set the DER Conversion requirement to true (false by default) func SetSkipDERConversion() { options.skipDERConversion = true } diff --git a/crypto/xsalsa20symmetric/symmetric.go b/crypto/xsalsa20symmetric/symmetric.go index e2ead2e2f58f..2fb58d1ea4fc 100644 --- a/crypto/xsalsa20symmetric/symmetric.go +++ b/crypto/xsalsa20symmetric/symmetric.go @@ -17,7 +17,7 @@ const ( var ErrCiphertextDecrypt = errors.New("ciphertext decryption failed") -// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) +// EncryptSymmetric secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) { if len(secret) != secretLen { @@ -34,7 +34,7 @@ func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) { return ciphertext } -// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) +// DecryptSymmetric secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. func DecryptSymmetric(ciphertext, secret []byte) (plaintext []byte, err error) { if len(secret) != secretLen { diff --git a/depinject/appconfig/module.go b/depinject/appconfig/module.go index fc4f62cbd525..7fc03957d1b5 100644 --- a/depinject/appconfig/module.go +++ b/depinject/appconfig/module.go @@ -10,7 +10,7 @@ import ( var Register = RegisterModule -// Register registers a module with the global module registry. The provided +// RegisterModule registers a module with the global module registry. The provided // protobuf message is used only to uniquely identify the protobuf module config // type. The instance of the protobuf message used in the actual configuration // will be injected into the container and can be requested by a provider diff --git a/depinject/go.mod b/depinject/go.mod index 0e04fe2bcbac..a4633e707978 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.3 github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-proto v1.0.0-beta.4 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb google.golang.org/protobuf v1.32.0 gotest.tools/v3 v3.5.1 diff --git a/depinject/go.sum b/depinject/go.sum index 7646192b0d69..6a8645a1f088 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -38,8 +38,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/errors/go.mod b/errors/go.mod index 93339bc51d10..8fe23f757f23 100644 --- a/errors/go.mod +++ b/errors/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.62.0 ) diff --git a/errors/go.sum b/errors/go.sum index 036012a7b339..02d81a8330cd 100644 --- a/errors/go.sum +++ b/errors/go.sum @@ -22,8 +22,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= diff --git a/go.mod b/go.mod index 24be15a14b4e..567c7107d7c8 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tendermint/go-amino v0.16.0 gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b golang.org/x/crypto v0.20.0 diff --git a/go.sum b/go.sum index 9d0dfeeef4e8..315dd1392a26 100644 --- a/go.sum +++ b/go.sum @@ -678,8 +678,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -692,8 +693,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= diff --git a/log/logger.go b/log/logger.go index 457905fd784e..f17c82eb059a 100644 --- a/log/logger.go +++ b/log/logger.go @@ -141,19 +141,19 @@ func (l zeroLogWrapper) Info(msg string, keyVals ...interface{}) { l.Logger.Info().Fields(keyVals).Msg(msg) } -// Info takes a message and a set of key/value pairs and logs with level INFO. +// Warn takes a message and a set of key/value pairs and logs with level WARN. // The key of the tuple must be a string. func (l zeroLogWrapper) Warn(msg string, keyVals ...interface{}) { l.Logger.Warn().Fields(keyVals).Msg(msg) } -// Error takes a message and a set of key/value pairs and logs with level DEBUG. +// Error takes a message and a set of key/value pairs and logs with level ERROR. // The key of the tuple must be a string. func (l zeroLogWrapper) Error(msg string, keyVals ...interface{}) { l.Logger.Error().Fields(keyVals).Msg(msg) } -// Debug takes a message and a set of key/value pairs and logs with level ERR. +// Debug takes a message and a set of key/value pairs and logs with level DEBUG. // The key of the tuple must be a string. func (l zeroLogWrapper) Debug(msg string, keyVals ...interface{}) { l.Logger.Debug().Fields(keyVals).Msg(msg) diff --git a/math/go.mod b/math/go.mod index 942f928f7a12..53100ea6e7bb 100644 --- a/math/go.mod +++ b/math/go.mod @@ -3,7 +3,7 @@ module cosmossdk.io/math go 1.20 require ( - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20221205204356-47842c84f3db sigs.k8s.io/yaml v1.4.0 ) diff --git a/math/go.sum b/math/go.sum index 3d6bce01e964..a6d9afc96b85 100644 --- a/math/go.sum +++ b/math/go.sum @@ -15,8 +15,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o= golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/orm/go.mod b/orm/go.mod index 3e80e04a875b..818230ebcb1d 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -13,7 +13,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/iancoleman/strcase v0.3.0 github.com/regen-network/gocuke v1.1.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/orm/go.sum b/orm/go.sum index effb8fe59e9b..15ec8faf3350 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -148,8 +148,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/runtime/app.go b/runtime/app.go index a224463fb806..d8474b0041ab 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -49,6 +49,7 @@ type App struct { amino *codec.LegacyAmino baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter + grpcQueryRouter *baseapp.GRPCQueryRouter appConfig *appv1alpha1.Config logger log.Logger // initChainer is the init chainer function defined by the app config. diff --git a/runtime/builder.go b/runtime/builder.go index 805b814a4956..c96af6ecd6ee 100644 --- a/runtime/builder.go +++ b/runtime/builder.go @@ -31,6 +31,7 @@ func (a *AppBuilder) Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...fu bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...) bApp.SetMsgServiceRouter(a.app.msgServiceRouter) + bApp.SetGRPCQueryRouter(a.app.grpcQueryRouter) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(a.app.interfaceRegistry) diff --git a/runtime/environment.go b/runtime/environment.go index 2a592363eb6d..38500ecb6b35 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -4,17 +4,44 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/log" + + "github.com/cosmos/cosmos-sdk/baseapp" ) // NewEnvironment creates a new environment for the application -// if memstoreservice is needed, it can be added to the environment: environment.MemStoreService = memstoreservice -func NewEnvironment(kvService store.KVStoreService, logger log.Logger) appmodule.Environment { - return appmodule.Environment{ +// For setting custom services that aren't set by default, use the EnvOption +// Note: Depinject always provide an environment with all services (mandatory and optional) +func NewEnvironment( + kvService store.KVStoreService, + logger log.Logger, + opts ...EnvOption, +) appmodule.Environment { + env := appmodule.Environment{ + Logger: logger, EventService: EventService{}, HeaderService: HeaderService{}, BranchService: BranchService{}, GasService: GasService{}, KVStoreService: kvService, - Logger: logger, + } + + for _, opt := range opts { + opt(&env) + } + + return env +} + +type EnvOption func(*appmodule.Environment) + +func EnvWithRouterService(queryServiceRouter *baseapp.GRPCQueryRouter, msgServiceRouter *baseapp.MsgServiceRouter) EnvOption { + return func(env *appmodule.Environment) { + env.RouterService = NewRouterService(env.KVStoreService, queryServiceRouter, msgServiceRouter) + } +} + +func EnvWithMemStoreService(memStoreService store.MemoryStoreService) EnvOption { + return func(env *appmodule.Environment) { + env.MemStoreService = memStoreService } } diff --git a/runtime/module.go b/runtime/module.go index e00063df8642..2c0dd6e58671 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -67,7 +67,6 @@ func init() { ProvideMemoryStoreKey, ProvideGenesisTxHandler, ProvideEnvironment, - ProvideMemoryStoreService, ProvideTransientStoreService, ProvideModuleManager, ProvideAppVersionModifier, @@ -82,6 +81,7 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( *codec.LegacyAmino, *AppBuilder, *baseapp.MsgServiceRouter, + *baseapp.GRPCQueryRouter, appmodule.AppModule, protodesc.Resolver, protoregistry.MessageTypeResolver, @@ -104,16 +104,18 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( cdc := codec.NewProtoCodec(interfaceRegistry) msgServiceRouter := baseapp.NewMsgServiceRouter() + grpcQueryRouter := baseapp.NewGRPCQueryRouter() app := &App{ storeKeys: nil, interfaceRegistry: interfaceRegistry, cdc: cdc, amino: amino, msgServiceRouter: msgServiceRouter, + grpcQueryRouter: grpcQueryRouter, } appBuilder := &AppBuilder{app} - return cdc, amino, appBuilder, msgServiceRouter, appModule{app}, protoFiles, protoTypes, nil + return cdc, amino, appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil } type AppInputs struct { @@ -212,15 +214,26 @@ func ProvideGenesisTxHandler(appBuilder *AppBuilder) genesis.TxHandler { return appBuilder.app } -func ProvideEnvironment(config *runtimev1alpha1.Module, key depinject.ModuleKey, app *AppBuilder, logger log.Logger) (store.KVStoreService, appmodule.Environment) { +func ProvideEnvironment( + logger log.Logger, + config *runtimev1alpha1.Module, + key depinject.ModuleKey, + app *AppBuilder, + msgServiceRouter *baseapp.MsgServiceRouter, + queryServiceRouter *baseapp.GRPCQueryRouter, +) (store.KVStoreService, store.MemoryStoreService, appmodule.Environment) { storeKey := ProvideKVStoreKey(config, key, app) kvService := kvStoreService{key: storeKey} - return kvService, NewEnvironment(kvService, logger) -} -func ProvideMemoryStoreService(key depinject.ModuleKey, app *AppBuilder) store.MemoryStoreService { - storeKey := ProvideMemoryStoreKey(key, app) - return memStoreService{key: storeKey} + memStoreKey := ProvideMemoryStoreKey(key, app) + memStoreService := memStoreService{key: memStoreKey} + + return kvService, memStoreService, NewEnvironment( + kvService, + logger, + EnvWithRouterService(queryServiceRouter, msgServiceRouter), + EnvWithMemStoreService(memStoreService), + ) } func ProvideTransientStoreService(key depinject.ModuleKey, app *AppBuilder) store.TransientStoreService { diff --git a/runtime/router.go b/runtime/router.go new file mode 100644 index 000000000000..5e2a8a8e9ba9 --- /dev/null +++ b/runtime/router.go @@ -0,0 +1,175 @@ +package runtime + +import ( + "context" + "fmt" + "reflect" + "strings" + + "github.com/cosmos/gogoproto/proto" + protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoiface" + + "cosmossdk.io/core/router" + "cosmossdk.io/core/store" + + "github.com/cosmos/cosmos-sdk/baseapp" +) + +// NewRouterService creates a router.Service which allows to invoke messages and queries using the msg router. +func NewRouterService(storeService store.KVStoreService, queryRouter *baseapp.GRPCQueryRouter, msgRouter baseapp.MessageRouter) router.Service { + return &routerService{ + queryRouterService: &queryRouterService{ + storeService: storeService, // TODO: this will be used later on as authenticating modules before routing + router: queryRouter, + }, + msgRouterService: &msgRouterService{ + storeService: storeService, // TODO: this will be used later on as authenticating modules before routing + router: msgRouter, + }, + } +} + +var _ router.Service = (*routerService)(nil) + +type routerService struct { + queryRouterService router.Router + msgRouterService router.Router +} + +// MessageRouterService implements router.Service. +func (r *routerService) MessageRouterService() router.Router { + return r.msgRouterService +} + +// QueryRouterService implements router.Service. +func (r *routerService) QueryRouterService() router.Router { + return r.queryRouterService +} + +var _ router.Router = (*msgRouterService)(nil) + +type msgRouterService struct { + storeService store.KVStoreService + router baseapp.MessageRouter +} + +// CanInvoke returns an error if the given message cannot be invoked. +func (m *msgRouterService) CanInvoke(ctx context.Context, typeURL string) error { + if typeURL == "" { + return fmt.Errorf("missing type url") + } + + typeURL = strings.TrimPrefix(typeURL, "/") + + handler := m.router.HybridHandlerByMsgName(typeURL) + if handler == nil { + return fmt.Errorf("unknown message: %s", typeURL) + } + + return nil +} + +// InvokeTyped execute a message and fill-in a response. +// The response must be known and passed as a parameter. +// Use InvokeUntyped if the response type is not known. +func (m *msgRouterService) InvokeTyped(ctx context.Context, msg, resp protoiface.MessageV1) error { + messageName := msgTypeURL(msg) + handler := m.router.HybridHandlerByMsgName(messageName) + if handler == nil { + return fmt.Errorf("unknown message: %s", messageName) + } + + return handler(ctx, msg, resp) +} + +// InvokeUntyped execute a message and returns a response. +func (m *msgRouterService) InvokeUntyped(ctx context.Context, msg protoiface.MessageV1) (protoiface.MessageV1, error) { + messageName := msgTypeURL(msg) + respName := m.router.ResponseNameByMsgName(messageName) + if respName == "" { + return nil, fmt.Errorf("could not find response type for message %s (%T)", messageName, msg) + } + + // get response type + typ := proto.MessageType(respName) + if typ == nil { + return nil, fmt.Errorf("no message type found for %s", respName) + } + msgResp, ok := reflect.New(typ.Elem()).Interface().(protoiface.MessageV1) + if !ok { + return nil, fmt.Errorf("could not create response message %s", respName) + } + + return msgResp, m.InvokeTyped(ctx, msg, msgResp) +} + +var _ router.Router = (*queryRouterService)(nil) + +type queryRouterService struct { + storeService store.KVStoreService + router *baseapp.GRPCQueryRouter +} + +// CanInvoke returns an error if the given request cannot be invoked. +func (m *queryRouterService) CanInvoke(ctx context.Context, typeURL string) error { + if typeURL == "" { + return fmt.Errorf("missing type url") + } + + typeURL = strings.TrimPrefix(typeURL, "/") + + handlers := m.router.HybridHandlerByRequestName(typeURL) + if len(handlers) == 0 { + return fmt.Errorf("unknown request: %s", typeURL) + } else if len(handlers) > 1 { + return fmt.Errorf("ambiguous request, query have multiple handlers: %s", typeURL) + } + + return nil +} + +// InvokeTyped execute a message and fill-in a response. +// The response must be known and passed as a parameter. +// Use InvokeUntyped if the response type is not known. +func (m *queryRouterService) InvokeTyped(ctx context.Context, req, resp protoiface.MessageV1) error { + reqName := msgTypeURL(req) + handlers := m.router.HybridHandlerByRequestName(reqName) + if len(handlers) == 0 { + return fmt.Errorf("unknown request: %s", reqName) + } else if len(handlers) > 1 { + return fmt.Errorf("ambiguous request, query have multiple handlers: %s", reqName) + } + + return handlers[0](ctx, req, resp) +} + +// InvokeUntyped execute a message and returns a response. +func (m *queryRouterService) InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (protoiface.MessageV1, error) { + reqName := msgTypeURL(req) + respName := m.router.ResponseNameByRequestName(reqName) + if respName == "" { + return nil, fmt.Errorf("could not find response type for request %s (%T)", reqName, req) + } + + // get response type + typ := proto.MessageType(respName) + if typ == nil { + return nil, fmt.Errorf("no message type found for %s", respName) + } + reqResp, ok := reflect.New(typ.Elem()).Interface().(protoiface.MessageV1) + if !ok { + return nil, fmt.Errorf("could not create response request %s", respName) + } + + return reqResp, m.InvokeTyped(ctx, req, reqResp) +} + +// msgTypeURL returns the TypeURL of a proto message. +func msgTypeURL(msg proto.Message) string { + if m, ok := msg.(protov2.Message); ok { + return string(m.ProtoReflect().Descriptor().FullName()) + } + + return proto.MessageName(msg) +} diff --git a/runtime/router_test.go b/runtime/router_test.go new file mode 100644 index 000000000000..1c1d3db19edf --- /dev/null +++ b/runtime/router_test.go @@ -0,0 +1,110 @@ +package runtime_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" + counterv1 "cosmossdk.io/api/cosmos/counter/v1" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/cosmos/cosmos-sdk/testutil" + counterkeeper "github.com/cosmos/cosmos-sdk/x/counter/keeper" + countertypes "github.com/cosmos/cosmos-sdk/x/counter/types" +) + +func TestRouterService(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + msgRouter := baseapp.NewMsgServiceRouter() + msgRouter.SetInterfaceRegistry(interfaceRegistry) + queryRouter := baseapp.NewGRPCQueryRouter() + queryRouter.SetInterfaceRegistry(interfaceRegistry) + key := storetypes.NewKVStoreKey(countertypes.StoreKey) + storeService := runtime.NewKVStoreService(key) + counterKeeper := counterkeeper.NewKeeper(runtime.NewEnvironment(storeService, log.NewNopLogger())) + countertypes.RegisterInterfaces(interfaceRegistry) + countertypes.RegisterMsgServer(msgRouter, counterKeeper) + countertypes.RegisterQueryServer(queryRouter, counterKeeper) + + routerService := runtime.NewRouterService(storeService, queryRouter, msgRouter) + testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) + + // Messages + + t.Run("invalid msg", func(t *testing.T) { + _, err := routerService.MessageRouterService().InvokeUntyped(testCtx.Ctx, &bankv1beta1.MsgSend{}) + require.ErrorContains(t, err, "could not find response type for message cosmos.bank.v1beta1.MsgSend") + }) + + t.Run("invoke untyped: valid msg (proto v1)", func(t *testing.T) { + resp, err := routerService.MessageRouterService().InvokeUntyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{ + Signer: "cosmos1", + Count: 42, + }) + require.NoError(t, err) + require.NotNil(t, resp) + }) + + t.Run("invoke typed: valid msg (proto v1)", func(t *testing.T) { + resp := &countertypes.MsgIncreaseCountResponse{} + err := routerService.MessageRouterService().InvokeTyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{ + Signer: "cosmos1", + Count: 42, + }, resp) + require.NoError(t, err) + require.NotNil(t, resp) + }) + + t.Run("invoke typed: valid msg (proto v2)", func(t *testing.T) { + resp := &counterv1.MsgIncreaseCountResponse{} + err := routerService.MessageRouterService().InvokeTyped(testCtx.Ctx, &counterv1.MsgIncreaseCounter{ + Signer: "cosmos1", + Count: 42, + }, resp) + require.NoError(t, err) + require.NotNil(t, resp) + }) + + // Queries + + t.Run("invalid query", func(t *testing.T) { + err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &bankv1beta1.QueryBalanceRequest{}, &bankv1beta1.QueryBalanceResponse{}) + require.ErrorContains(t, err, "unknown request: cosmos.bank.v1beta1.QueryBalanceRequest") + }) + + t.Run("invoke typed: valid query (proto v1)", func(t *testing.T) { + _ = counterKeeper.CountStore.Set(testCtx.Ctx, 42) + + resp := &countertypes.QueryGetCountResponse{} + err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{}, resp) + require.NoError(t, err) + require.NotNil(t, resp) + require.Equal(t, int64(42), resp.TotalCount) + }) + + t.Run("invoke typed: valid query (proto v2)", func(t *testing.T) { + _ = counterKeeper.CountStore.Set(testCtx.Ctx, 42) + + resp := &counterv1.QueryGetCountResponse{} + err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &counterv1.QueryGetCountRequest{}, resp) + require.NoError(t, err) + require.NotNil(t, resp) + require.Equal(t, int64(42), resp.TotalCount) + }) + + t.Run("invoke untyped: valid query (proto v1)", func(t *testing.T) { + _ = counterKeeper.CountStore.Set(testCtx.Ctx, 42) + + resp, err := routerService.QueryRouterService().InvokeUntyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{}) + require.NoError(t, err) + require.NotNil(t, resp) + respVal, ok := resp.(*countertypes.QueryGetCountResponse) + require.True(t, ok) + require.Equal(t, int64(42), respVal.TotalCount) + }) +} diff --git a/simapp/app.go b/simapp/app.go index 2c1e47b95bf5..dce427ef62c0 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -349,7 +349,7 @@ func NewSimApp( app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[circuittypes.StoreKey]), logger), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec()) app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) - app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger), appCodec, app.MsgServiceRouter(), app.AuthKeeper) + app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), appCodec, app.AuthKeeper) groupConfig := group.DefaultConfig() /* @@ -359,7 +359,7 @@ func NewSimApp( config.MaxProposalTitleLen = 255 // example max title length in characters config.MaxProposalSummaryLen = 10200 // example max summary length in characters */ - app.GroupKeeper = groupkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[group.StoreKey]), logger), appCodec, app.MsgServiceRouter(), app.AuthKeeper, groupConfig) + app.GroupKeeper = groupkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[group.StoreKey]), logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), appCodec, app.AuthKeeper, groupConfig) // get skipUpgradeHeights from the app options skipUpgradeHeights := map[int64]bool{} diff --git a/simapp/go.mod b/simapp/go.mod index 6d72d11285eb..c75ac8cdc017 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -29,7 +29,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/protobuf v1.32.0 ) diff --git a/simapp/go.sum b/simapp/go.sum index ef5f1c994b81..2124be9a4581 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -987,8 +987,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1001,8 +1002,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= diff --git a/simapp/gomod2nix.toml b/simapp/gomod2nix.toml index f95900c88bce..8847d6510f38 100644 --- a/simapp/gomod2nix.toml +++ b/simapp/gomod2nix.toml @@ -450,8 +450,8 @@ schema = 3 version = "v1.18.2" hash = "sha256-MXYbK6w1LEaoZ2/L/STF3WU1tbK+7NwGVxUCLKPkwks=" [mod."github.com/stretchr/testify"] - version = "v1.8.4" - hash = "sha256-MoOmRzbz9QgiJ+OOBo5h5/LbilhJfRUryvzHJmXAWjo=" + version = "v1.9.0" + hash = "sha256-uUp/On+1nK+lARkTVtb5RxlW15zxtw2kaAFuIASA+J0=" [mod."github.com/subosito/gotenv"] version = "v1.6.0" hash = "sha256-LspbjTniiq2xAICSXmgqP7carwlNaLqnCTQfw2pa80A=" diff --git a/store/go.mod b/store/go.mod index 733aad58cfd8..1c7eee1772dc 100644 --- a/store/go.mod +++ b/store/go.mod @@ -17,7 +17,7 @@ require ( github.com/linxGnu/grocksdb v1.8.12 github.com/mattn/go-sqlite3 v1.14.22 github.com/spf13/cast v1.6.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 golang.org/x/sync v0.6.0 diff --git a/store/go.sum b/store/go.sum index 85707a574904..628c42dcec16 100644 --- a/store/go.sum +++ b/store/go.sum @@ -222,8 +222,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= diff --git a/tests/go.mod b/tests/go.mod index ae62c99accdb..c285e300effc 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -28,7 +28,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/golang/mock v1.6.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 gotest.tools/v3 v3.5.1 diff --git a/tests/go.sum b/tests/go.sum index fd33ab3213a5..c06556409153 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -969,8 +969,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -981,8 +982,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/tests/integration/staking/keeper/vote_extensions_test.go b/tests/integration/staking/keeper/vote_extensions_test.go index 8e4c1fb0bc2d..506b5b991018 100644 --- a/tests/integration/staking/keeper/vote_extensions_test.go +++ b/tests/integration/staking/keeper/vote_extensions_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "bytes" + "sort" "testing" abci "github.com/cometbft/cometbft/abci/types" @@ -10,6 +11,8 @@ import ( "github.com/cosmos/gogoproto/proto" "gotest.tools/v3/assert" + "cosmossdk.io/core/comet" + "cosmossdk.io/core/header" "cosmossdk.io/math" "cosmossdk.io/x/staking/testutil" stakingtypes "cosmossdk.io/x/staking/types" @@ -21,6 +24,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +const chainID = "chain-id-123" + +// TestValidateVoteExtensions is a unit test function that tests the validation of vote extensions. +// It sets up the necessary fixtures and validators, generates vote extensions for each validator, +// and validates the vote extensions using the baseapp.ValidateVoteExtensions function. func TestValidateVoteExtensions(t *testing.T) { t.Parallel() f := initFixture(t) @@ -28,10 +36,10 @@ func TestValidateVoteExtensions(t *testing.T) { // enable vote extensions cp := simtestutil.DefaultConsensusParams cp.Abci = &cmtproto.ABCIParams{VoteExtensionsEnableHeight: 1} - f.sdkCtx = f.sdkCtx.WithConsensusParams(*cp).WithBlockHeight(2) + f.sdkCtx = f.sdkCtx.WithConsensusParams(*cp).WithHeaderInfo(header.Info{Height: 2, ChainID: chainID}) // setup the validators - numVals := 3 + numVals := 1 privKeys := []cryptotypes.PrivKey{} for i := 0; i < numVals; i++ { privKeys = append(privKeys, ed25519.GenPrivKey()) @@ -61,9 +69,9 @@ func TestValidateVoteExtensions(t *testing.T) { voteExt := []byte("something" + v.OperatorAddress) cve := cmtproto.CanonicalVoteExtension{ Extension: voteExt, - Height: f.sdkCtx.BlockHeight() - 1, // the vote extension was signed in the previous height + Height: f.sdkCtx.HeaderInfo().Height - 1, // the vote extension was signed in the previous height Round: 0, - ChainId: "chain-id-123", + ChainId: chainID, } extSignBytes, err := mashalVoteExt(&cve) @@ -86,7 +94,10 @@ func TestValidateVoteExtensions(t *testing.T) { votes = append(votes, ve) } - err := baseapp.ValidateVoteExtensions(f.sdkCtx, f.stakingKeeper, f.sdkCtx.BlockHeight(), "chain-id-123", abci.ExtendedCommitInfo{Round: 0, Votes: votes}) + eci, ci := extendedCommitToLastCommit(abci.ExtendedCommitInfo{Round: 0, Votes: votes}) + f.sdkCtx = f.sdkCtx.WithCometInfo(ci) + + err := baseapp.ValidateVoteExtensions(f.sdkCtx, f.stakingKeeper, eci) assert.NilError(t, err) } @@ -98,3 +109,44 @@ func mashalVoteExt(msg proto.Message) ([]byte, error) { return buf.Bytes(), nil } + +func extendedCommitToLastCommit(ec abci.ExtendedCommitInfo) (abci.ExtendedCommitInfo, comet.Info) { + // sort the extended commit info + sort.Sort(extendedVoteInfos(ec.Votes)) + + // convert the extended commit info to last commit info + lastCommit := comet.CommitInfo{ + Round: ec.Round, + Votes: make([]comet.VoteInfo, len(ec.Votes)), + } + + for i, vote := range ec.Votes { + lastCommit.Votes[i] = comet.VoteInfo{ + Validator: comet.Validator{ + Address: vote.Validator.Address, + Power: vote.Validator.Power, + }, + } + } + + return ec, comet.Info{ + LastCommit: lastCommit, + } +} + +type extendedVoteInfos []abci.ExtendedVoteInfo + +func (v extendedVoteInfos) Len() int { + return len(v) +} + +func (v extendedVoteInfos) Less(i, j int) bool { + if v[i].Validator.Power == v[j].Validator.Power { + return bytes.Compare(v[i].Validator.Address, v[j].Validator.Address) == -1 + } + return v[i].Validator.Power > v[j].Validator.Power +} + +func (v extendedVoteInfos) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} diff --git a/tests/starship/tests/go.mod b/tests/starship/tests/go.mod index 244e26d1f67a..cc47d40d264e 100644 --- a/tests/starship/tests/go.mod +++ b/tests/starship/tests/go.mod @@ -46,7 +46,7 @@ require ( cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-sdk v0.51.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.62.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/tests/starship/tests/go.sum b/tests/starship/tests/go.sum index f3e4b8e20413..3dc033d4f68b 100644 --- a/tests/starship/tests/go.sum +++ b/tests/starship/tests/go.sum @@ -969,8 +969,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -981,8 +982,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/testutil/integration/router.go b/testutil/integration/router.go index 2784118eb2a2..dafaa7f9d011 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -75,13 +75,13 @@ func NewIntegrationApp( return moduleManager.EndBlock(sdkCtx) }) - router := baseapp.NewMsgServiceRouter() - router.SetInterfaceRegistry(interfaceRegistry) - bApp.SetMsgServiceRouter(router) + msgRouter := baseapp.NewMsgServiceRouter() + msgRouter.SetInterfaceRegistry(interfaceRegistry) + bApp.SetMsgServiceRouter(msgRouter) if keys[consensusparamtypes.StoreKey] != nil { // set baseApp param store - consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String()) + consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(baseapp.NewGRPCQueryRouter(), msgRouter)), authtypes.NewModuleAddress("gov").String()) bApp.SetParamStore(consensusParamsKeeper.ParamsStore) if err := bApp.LoadLatestVersion(); err != nil { diff --git a/tools/confix/go.mod b/tools/confix/go.mod index 4d142fe67e18..f982d683d2e1 100644 --- a/tools/confix/go.mod +++ b/tools/confix/go.mod @@ -129,7 +129,7 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/testify v1.8.4 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect diff --git a/tools/confix/go.sum b/tools/confix/go.sum index 53f232c0b1da..eee7b15df3ba 100644 --- a/tools/confix/go.sum +++ b/tools/confix/go.sum @@ -689,8 +689,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -700,8 +701,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index 66908c7b56fa..9d3a13d476d7 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/x/upgrade v0.1.1 github.com/otiai10/copy v1.14.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 ) require ( diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index c31c1fb0f1fb..671451f96d2b 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -949,8 +949,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -961,8 +962,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index 7586c68106de..5d4c22ce36e0 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -129,7 +129,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.18.2 // indirect - github.com/stretchr/testify v1.8.4 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum index b878d784e67c..9daf81b2ef18 100644 --- a/tools/hubl/go.sum +++ b/tools/hubl/go.sum @@ -689,8 +689,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -700,8 +701,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/types/context.go b/types/context.go index 1eb9d41e4068..2c63445f8709 100644 --- a/types/context.go +++ b/types/context.go @@ -433,16 +433,17 @@ func ToSDKCommitInfo(commit abci.CommitInfo) comet.CommitInfo { func ToSDKExtendedCommitInfo(commit abci.ExtendedCommitInfo) comet.CommitInfo { ci := comet.CommitInfo{ Round: commit.Round, + Votes: make([]comet.VoteInfo, len(commit.Votes)), } - for _, v := range commit.Votes { - ci.Votes = append(ci.Votes, comet.VoteInfo{ + for i, v := range commit.Votes { + ci.Votes[i] = comet.VoteInfo{ Validator: comet.Validator{ Address: v.Validator.Address, Power: v.Validator.Power, }, BlockIDFlag: comet.BlockIDFlag(v.BlockIdFlag), - }) + } } return ci diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 3e7745aba2a5..cdd1d509601e 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -13,7 +13,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 ) diff --git a/x/accounts/go.sum b/x/accounts/go.sum index 823fad196de8..221c87b2767c 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index 463c8664957b..870bce8760ce 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -46,7 +46,7 @@ type QueryRouter interface { // MsgRouter represents a router which can be used to route messages to the correct module. type MsgRouter interface { HybridHandlerByMsgName(msgName string) func(ctx context.Context, req, resp implementation.ProtoMsg) error - ResponseNameByRequestName(name string) string + ResponseNameByMsgName(name string) string } // SignerProvider defines an interface used to get the expected sender from a message. @@ -102,9 +102,9 @@ type Keeper struct { // deps coming from the runtime environment appmodule.Environment addressCodec address.Codec - msgRouter MsgRouter + msgRouter MsgRouter // todo use env signerProvider SignerProvider - queryRouter QueryRouter + queryRouter QueryRouter // todo use env makeSendCoinsMsg coinsTransferMsgFunc accounts map[string]implementation.Implementation @@ -344,7 +344,7 @@ func (k Keeper) sendAnyMessages(ctx context.Context, sender []byte, anyMessages func (k Keeper) sendModuleMessageUntyped(ctx context.Context, sender []byte, msg implementation.ProtoMsg) (implementation.ProtoMsg, error) { // we need to fetch the response type from the request message type. // this is because the response type is not known. - respName := k.msgRouter.ResponseNameByRequestName(implementation.MessageName(msg)) + respName := k.msgRouter.ResponseNameByMsgName(implementation.MessageName(msg)) if respName == "" { return nil, fmt.Errorf("could not find response type for message %T", msg) } diff --git a/x/accounts/utils_test.go b/x/accounts/utils_test.go index dc7ac535052c..5ee67365b6ec 100644 --- a/x/accounts/utils_test.go +++ b/x/accounts/utils_test.go @@ -89,6 +89,6 @@ func (m mockExec) HybridHandlerByMsgName(_ string) func(ctx context.Context, req } } -func (m mockExec) ResponseNameByRequestName(name string) string { +func (m mockExec) ResponseNameByMsgName(name string) string { return name + "Response" } diff --git a/x/auth/go.mod b/x/auth/go.mod index fa4698cafb13..333c2616d5e4 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -25,7 +25,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 diff --git a/x/auth/go.sum b/x/auth/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/authz/CHANGELOG.md b/x/authz/CHANGELOG.md index 4954a50128b5..0e4e5795d1c1 100644 --- a/x/authz/CHANGELOG.md +++ b/x/authz/CHANGELOG.md @@ -25,20 +25,17 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -### Consens Breaking Changes - -* [#19188](https://github.com/cosmos/cosmos-sdk/pull/19188) Remove creation of `BaseAccount` when sending a message to an account that does not exist - ### Features * [#18737](https://github.com/cosmos/cosmos-sdk/pull/18737) Added a limit of 200 grants pruned per `BeginBlock` and the `PruneExpiredGrants` message that prunes 75 expired grants on every run. -### Improvements - ### API Breaking Changes -* [#19490](https://github.com/cosmos/cosmos-sdk/pull/19490) `appmodule.Environment` is received on the Keeper to get access to different application services +* [#19637](https://github.com/cosmos/cosmos-sdk/pull/19637) `NewKeeper` doesn't take a message router anymore. Set the message router in the `appmodule.Environment` instead. +* [#19490](https://github.com/cosmos/cosmos-sdk/pull/19490) `appmodule.Environment` is received on the Keeper to get access to different application services. * [#18737](https://github.com/cosmos/cosmos-sdk/pull/18737) Update the keeper method `DequeueAndDeleteExpiredGrants` to take a limit argument for the number of grants to prune. * [#16509](https://github.com/cosmos/cosmos-sdk/pull/16509) `AcceptResponse` has been moved to sdk/types/authz and the `Updated` field is now of the type `sdk.Msg` instead of `authz.Authorization`. -### Bug Fixes +### Consensus Breaking Changes + +* [#19188](https://github.com/cosmos/cosmos-sdk/pull/19188) Remove creation of `BaseAccount` when sending a message to an account that does not exist. diff --git a/x/authz/go.mod b/x/authz/go.mod index a48bb4fe90f3..399282648ac1 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -25,7 +25,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/authz/go.sum b/x/authz/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index e3ced43a0eb5..8ae9811c019c 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -47,7 +47,6 @@ func (suite *GenesisTestSuite) SetupTest() { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) @@ -68,8 +67,9 @@ func (suite *GenesisTestSuite) SetupTest() { msr := suite.baseApp.MsgServiceRouter() msr.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry) + env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(nil, msr)) - suite.keeper = keeper.NewKeeper(env, suite.encCfg.Codec, msr, suite.accountKeeper) + suite.keeper = keeper.NewKeeper(env, suite.encCfg.Codec, suite.accountKeeper) } func (suite *GenesisTestSuite) TestImportExportGenesis() { diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 05546384281f..2613e4085327 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -4,19 +4,16 @@ import ( "bytes" "context" "fmt" - "strconv" "time" "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/event" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/authz" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -32,16 +29,14 @@ const gasCostPerIteration = uint64(20) type Keeper struct { environment appmodule.Environment cdc codec.Codec - router baseapp.MessageRouter authKeeper authz.AccountKeeper } // NewKeeper constructs a message authorization Keeper -func NewKeeper(env appmodule.Environment, cdc codec.Codec, router baseapp.MessageRouter, ak authz.AccountKeeper) Keeper { +func NewKeeper(env appmodule.Environment, cdc codec.Codec, ak authz.AccountKeeper) Keeper { return Keeper{ environment: env, cdc: cdc, - router: router, authKeeper: ak, } } @@ -151,29 +146,11 @@ func (k Keeper) DispatchActions(ctx context.Context, grantee sdk.AccAddress, msg } } - handler := k.router.Handler(msg) - if handler == nil { - return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(msg)) - } - - msgResp, err := handler(sdkCtx, msg) + // no need to use the branch service here, as if the transaction fails, the transaction will be reverted + _, err = k.environment.RouterService.MessageRouterService().InvokeUntyped(ctx, msg) if err != nil { - return nil, errorsmod.Wrapf(err, "failed to execute message; message %v", msg) + return nil, fmt.Errorf("failed to execute message %d; message %v: %w", i, msg, err) } - - results[i] = msgResp.Data - - // emit the events from the dispatched actions - for i = range msgResp.Events { - err := k.environment.EventService.EventManager(ctx).EmitKV( - "dispatch actions", - event.NewAttribute("authz_msg_index", strconv.Itoa(i)), - ) - if err != nil { - return nil, err - } - } - } return results, nil diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index b984aeac2a1a..444787fcdf7d 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -52,7 +52,6 @@ func (s *TestSuite) SetupTest() { testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now().Round(0).UTC()}) s.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) s.baseApp = baseapp.NewBaseApp( "authz", @@ -75,7 +74,8 @@ func (s *TestSuite) SetupTest() { banktypes.RegisterInterfaces(s.encCfg.InterfaceRegistry) banktypes.RegisterMsgServer(s.baseApp.MsgServiceRouter(), s.bankKeeper) - s.authzKeeper = authzkeeper.NewKeeper(env, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper) + env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(s.baseApp.GRPCQueryRouter(), s.baseApp.MsgServiceRouter())) + s.authzKeeper = authzkeeper.NewKeeper(env, s.encCfg.Codec, s.accountKeeper) queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.encCfg.InterfaceRegistry) authz.RegisterQueryServer(queryHelper, s.authzKeeper) diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index 1a3e5f29f047..fe14037cd328 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -40,8 +40,8 @@ func (k Keeper) Grant(ctx context.Context, msg *authz.MsgGrant) (*authz.MsgGrant } t := authorization.MsgTypeURL() - if k.router.HandlerByTypeURL(t) == nil { - return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist.", t) + if err := k.environment.RouterService.MessageRouterService().CanInvoke(ctx, t); err != nil { + return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist", t) } err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration) diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index f0494f267c84..f45f7e004974 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -32,7 +32,6 @@ func TestExpiredGrantsQueue(t *testing.T) { testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) ctx := testCtx.Ctx - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) baseApp := baseapp.NewBaseApp( "authz", @@ -66,7 +65,8 @@ func TestExpiredGrantsQueue(t *testing.T) { accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() - authzKeeper := keeper.NewKeeper(env, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper) + env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(baseApp.GRPCQueryRouter(), baseApp.MsgServiceRouter())) + authzKeeper := keeper.NewKeeper(env, encCfg.Codec, accountKeeper) save := func(grantee sdk.AccAddress, exp *time.Time) { err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp) diff --git a/x/authz/module/depinject.go b/x/authz/module/depinject.go index e3b11f50fe5c..849471f8fa27 100644 --- a/x/authz/module/depinject.go +++ b/x/authz/module/depinject.go @@ -8,7 +8,6 @@ import ( "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -28,12 +27,11 @@ func init() { type ModuleInputs struct { depinject.In - Cdc codec.Codec - AccountKeeper authz.AccountKeeper - BankKeeper authz.BankKeeper - Registry cdctypes.InterfaceRegistry - MsgServiceRouter baseapp.MessageRouter - Environment appmodule.Environment + Cdc codec.Codec + AccountKeeper authz.AccountKeeper + BankKeeper authz.BankKeeper + Registry cdctypes.InterfaceRegistry + Environment appmodule.Environment } type ModuleOutputs struct { @@ -44,7 +42,7 @@ type ModuleOutputs struct { } func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.Environment, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) + k := keeper.NewKeeper(in.Environment, in.Cdc, in.AccountKeeper) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) return ModuleOutputs{AuthzKeeper: k, Module: m} } diff --git a/x/bank/go.mod b/x/bank/go.mod index 9ebf12bdc141..e95cc944132f 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -22,7 +22,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 gotest.tools/v3 v3.5.1 diff --git a/x/bank/go.sum b/x/bank/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 7a6982c45da9..b504ba0fc3c2 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -16,7 +16,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 ) diff --git a/x/circuit/go.sum b/x/circuit/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/counter/depinject.go b/x/counter/depinject.go index a1297170602b..4cbe20acf4a2 100644 --- a/x/counter/depinject.go +++ b/x/counter/depinject.go @@ -3,8 +3,6 @@ package counter import ( modulev1 "cosmossdk.io/api/cosmos/counter/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" @@ -26,9 +24,8 @@ func init() { type ModuleInputs struct { depinject.In - Config *modulev1.Module - StoreService storetypes.KVStoreService - EventManager event.Service + Config *modulev1.Module + Environment appmodule.Environment } type ModuleOutputs struct { @@ -39,7 +36,7 @@ type ModuleOutputs struct { } func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.StoreService, in.EventManager) + k := keeper.NewKeeper(in.Environment) m := NewAppModule(k) return ModuleOutputs{ diff --git a/x/counter/keeper/keeper.go b/x/counter/keeper/keeper.go index 6d7fd422e8c3..f03b978ad1e4 100644 --- a/x/counter/keeper/keeper.go +++ b/x/counter/keeper/keeper.go @@ -9,8 +9,8 @@ import ( "google.golang.org/grpc/status" "cosmossdk.io/collections" + "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/x/counter/types" ) @@ -18,15 +18,15 @@ import ( var StoreKey = "Counter" type Keeper struct { - event event.Service + env appmodule.Environment CountStore collections.Item[int64] } -func NewKeeper(storeService storetypes.KVStoreService, em event.Service) Keeper { - sb := collections.NewSchemaBuilder(storeService) +func NewKeeper(env appmodule.Environment) Keeper { + sb := collections.NewSchemaBuilder(env.KVStoreService) return Keeper{ - event: em, + env: env, CountStore: collections.NewItem(sb, collections.NewPrefix(0), "count", collections.Int64Value), } } @@ -67,7 +67,7 @@ func (k Keeper) IncreaseCount(ctx context.Context, msg *types.MsgIncreaseCounter return nil, err } - if err := k.event.EventManager(ctx).EmitKV( + if err := k.env.EventService.EventManager(ctx).EmitKV( "increase_counter", event.NewAttribute("signer", msg.Signer), event.NewAttribute("new count", fmt.Sprint(num+msg.Count))); err != nil { diff --git a/x/distribution/go.mod b/x/distribution/go.mod index a915abd43b1a..f813a9090a77 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -24,7 +24,7 @@ require ( github.com/hashicorp/go-metrics v0.5.3 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 gotest.tools/v3 v3.5.1 diff --git a/x/distribution/go.sum b/x/distribution/go.sum index ba69099d417b..65b95dc785bc 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -672,8 +672,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -683,8 +684,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 12969d169dcf..f7f9b31ad892 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -19,7 +19,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/evidence/go.sum b/x/evidence/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index d8717b76e520..8d5d1158fb68 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -23,7 +23,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index e2036bb174a4..b83119ac3074 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -680,8 +680,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -691,8 +692,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/gov/go.mod b/x/gov/go.mod index 41fbd2a48f52..df879c528788 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -29,7 +29,7 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 diff --git a/x/gov/go.sum b/x/gov/go.sum index e2036bb174a4..b83119ac3074 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -680,8 +680,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -691,8 +692,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/group/CHANGELOG.md b/x/group/CHANGELOG.md index c21c3df8009b..9e67e2a664d1 100644 --- a/x/group/CHANGELOG.md +++ b/x/group/CHANGELOG.md @@ -30,9 +30,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18448](https://github.com/cosmos/cosmos-sdk/pull/18448) Extend group config * [18286](https://github.com/cosmos/cosmos-sdk/pull/18286) Move prefix store creation down after error checks. -### Features - ### API Breaking Changes +* [#19638](https://github.com/cosmos/cosmos-sdk/pull/19638) Migrate module to use `appmodule.Environment` router service so no `baseapp.MessageRouter` is required is `NewKeeper` anymore. * [#19489](https://github.com/cosmos/cosmos-sdk/pull/19489) `appmodule.Environment` is received on the Keeper to get access to different application services. * [#19410](https://github.com/cosmos/cosmos-sdk/pull/19410) Migrate to Store Service. diff --git a/x/group/go.mod b/x/group/go.mod index 8332fc32b959..033bc332babf 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -27,7 +27,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/manifoldco/promptui v0.9.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 diff --git a/x/group/go.sum b/x/group/go.sum index a7481d6bf0bf..8820e64701dd 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -680,8 +680,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -691,8 +692,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/group/keeper/genesis_test.go b/x/group/keeper/genesis_test.go index 412f5db64cb3..00e66b436069 100644 --- a/x/group/keeper/genesis_test.go +++ b/x/group/keeper/genesis_test.go @@ -53,7 +53,6 @@ func (s *GenesisTestSuite) SetupTest() { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) ctrl := gomock.NewController(s.T()) accountKeeper := grouptestutil.NewMockAccountKeeper(ctrl) @@ -74,7 +73,8 @@ func (s *GenesisTestSuite) SetupTest() { s.cdc = codec.NewProtoCodec(encCfg.InterfaceRegistry) s.ctx = s.sdkCtx - s.keeper = keeper.NewKeeper(env, s.cdc, bApp.MsgServiceRouter(), accountKeeper, group.DefaultConfig()) + env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter())) + s.keeper = keeper.NewKeeper(env, s.cdc, accountKeeper, group.DefaultConfig()) } func (s *GenesisTestSuite) TestInitExportGenesis() { diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index 4754d73e5703..95ddd1e200ea 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -43,7 +43,6 @@ func initKeeper(t *testing.T) *fixture { ) key := storetypes.NewKVStoreKey(group.StoreKey) - storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) @@ -69,9 +68,9 @@ func initKeeper(t *testing.T) *fixture { accountKeeper.EXPECT().NewAccount(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() accountKeeper.EXPECT().SetAccount(gomock.Any(), gomock.Any()).AnyTimes() - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter())) - groupKeeper = groupkeeper.NewKeeper(env, encCfg.Codec, bApp.MsgServiceRouter(), accountKeeper, group.DefaultConfig()) + groupKeeper = groupkeeper.NewKeeper(env, encCfg.Codec, accountKeeper, group.DefaultConfig()) queryHelper := baseapp.NewQueryServerTestHelper(ctx, interfaceRegistry) group.RegisterQueryServer(queryHelper, groupKeeper) queryClient := group.NewQueryClient(queryHelper) diff --git a/x/group/keeper/keeper.go b/x/group/keeper/keeper.go index ede804f85283..622f5703ecda 100644 --- a/x/group/keeper/keeper.go +++ b/x/group/keeper/keeper.go @@ -12,7 +12,6 @@ import ( "cosmossdk.io/x/group/errors" "cosmossdk.io/x/group/internal/orm" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -75,18 +74,15 @@ type Keeper struct { voteByProposalIndex orm.Index voteByVoterIndex orm.Index - router baseapp.MessageRouter - config group.Config cdc codec.Codec } // NewKeeper creates a new group keeper. -func NewKeeper(env appmodule.Environment, cdc codec.Codec, router baseapp.MessageRouter, accKeeper group.AccountKeeper, config group.Config) Keeper { +func NewKeeper(env appmodule.Environment, cdc codec.Codec, accKeeper group.AccountKeeper, config group.Config) Keeper { k := Keeper{ environment: env, - router: router, accKeeper: accKeeper, cdc: cdc, } diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 7fde6bd60109..1c19479bcf43 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -52,14 +52,11 @@ type TestSuite struct { func (s *TestSuite) SetupTest() { s.blockTime = time.Now().Round(0).UTC() key := storetypes.NewKVStoreKey(group.StoreKey) - storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}, bank.AppModule{}) s.addrs = simtestutil.CreateIncrementalAccounts(6) - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) - // setup gomock and initialize some globally expected executions ctrl := gomock.NewController(s.T()) s.accountKeeper = grouptestutil.NewMockAccountKeeper(ctrl) @@ -79,8 +76,9 @@ func (s *TestSuite) SetupTest() { bApp.SetInterfaceRegistry(encCfg.InterfaceRegistry) banktypes.RegisterMsgServer(bApp.MsgServiceRouter(), s.bankKeeper) + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter())) config := group.DefaultConfig() - s.groupKeeper = keeper.NewKeeper(env, encCfg.Codec, bApp.MsgServiceRouter(), s.accountKeeper, config) + s.groupKeeper = keeper.NewKeeper(env, encCfg.Codec, s.accountKeeper, config) s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: s.blockTime}) s.sdkCtx = sdk.UnwrapSDKContext(s.ctx) diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index b51b794e8019..34bb77a7a511 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -850,27 +850,21 @@ func (k Keeper) Exec(goCtx context.Context, msg *group.MsgExec) (*group.MsgExecR // Execute proposal payload. var logs string if proposal.Status == group.PROPOSAL_STATUS_ACCEPTED && proposal.ExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { - // Caching context so that we don't update the store in case of failure. - cacheCtx, flush := ctx.CacheContext() - addr, err := k.accKeeper.AddressCodec().StringToBytes(policyInfo.Address) if err != nil { return nil, err } decisionPolicy := policyInfo.DecisionPolicy.GetCachedValue().(group.DecisionPolicy) - if results, err := k.doExecuteMsgs(cacheCtx, k.router, proposal, addr, decisionPolicy); err != nil { + + if err := k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + return k.doExecuteMsgs(ctx, proposal, addr, decisionPolicy) + }); err != nil { proposal.ExecutorResult = group.PROPOSAL_EXECUTOR_RESULT_FAILURE logs = fmt.Sprintf("proposal execution failed on proposal %d, because of error %s", proposal.Id, err.Error()) k.Logger().Info("proposal execution failed", "cause", err, "proposalID", proposal.Id) } else { proposal.ExecutorResult = group.PROPOSAL_EXECUTOR_RESULT_SUCCESS - flush() - - for _, res := range results { - // NOTE: The sdk msg handler creates a new EventManager, so events must be correctly propagated back to the current context - ctx.EventManager().EmitEvents(res.GetEvents()) - } } } diff --git a/x/group/keeper/proposal_executor.go b/x/group/keeper/proposal_executor.go index 88ca0491637b..148de9c741eb 100644 --- a/x/group/keeper/proposal_executor.go +++ b/x/group/keeper/proposal_executor.go @@ -2,13 +2,12 @@ package keeper import ( "bytes" - "fmt" + "context" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/group" "cosmossdk.io/x/group/errors" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -16,12 +15,13 @@ import ( // doExecuteMsgs routes the messages to the registered handlers. Messages are limited to those that require no authZ or // by the account of group policy only. Otherwise this gives access to other peoples accounts as the sdk middlewares are bypassed -// TODO: use context.Context and env bundler service once baseapp's MsgServiceHandler is migrated to use context.Context -func (s Keeper) doExecuteMsgs(ctx sdk.Context, router baseapp.MessageRouter, proposal group.Proposal, groupPolicyAcc sdk.AccAddress, decisionPolicy group.DecisionPolicy) ([]sdk.Result, error) { +func (k Keeper) doExecuteMsgs(ctx context.Context, proposal group.Proposal, groupPolicyAcc sdk.AccAddress, decisionPolicy group.DecisionPolicy) error { + currentTime := k.environment.HeaderService.GetHeaderInfo(ctx).Time + // Ensure it's not too early to execute the messages. minExecutionDate := proposal.SubmitTime.Add(decisionPolicy.GetMinExecutionPeriod()) - if ctx.HeaderInfo().Time.Before(minExecutionDate) { - return nil, errors.ErrInvalid.Wrapf("must wait until %s to execute proposal %d", minExecutionDate, proposal.Id) + if currentTime.Before(minExecutionDate) { + return errors.ErrInvalid.Wrapf("must wait until %s to execute proposal %d", minExecutionDate, proposal.Id) } // Ensure it's not too late to execute the messages. @@ -29,37 +29,26 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router baseapp.MessageRouter, pro // be pruned automatically, so this function should not even be called, as // the proposal doesn't exist in state. For sanity check, we can still keep // this simple and cheap check. - expiryDate := proposal.VotingPeriodEnd.Add(s.config.MaxExecutionPeriod) - if expiryDate.Before(ctx.HeaderInfo().Time) { - return nil, errors.ErrExpired.Wrapf("proposal expired on %s", expiryDate) + expiryDate := proposal.VotingPeriodEnd.Add(k.config.MaxExecutionPeriod) + if expiryDate.Before(currentTime) { + return errors.ErrExpired.Wrapf("proposal expired on %s", expiryDate) } msgs, err := proposal.GetMsgs() if err != nil { - return nil, err + return err } - results := make([]sdk.Result, len(msgs)) - if err := ensureMsgAuthZ(msgs, groupPolicyAcc, s.cdc); err != nil { - return nil, err + if err := ensureMsgAuthZ(msgs, groupPolicyAcc, k.cdc); err != nil { + return err } + for i, msg := range msgs { - handler := s.router.Handler(msg) - if handler == nil { - return nil, errorsmod.Wrapf(errors.ErrInvalid, "no message handler found for %q", sdk.MsgTypeURL(msg)) - } - r, err := handler(ctx, msg) - if err != nil { - return nil, errorsmod.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i) + if _, err := k.environment.RouterService.MessageRouterService().InvokeUntyped(ctx, msg); err != nil { + return errorsmod.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i) } - // Handler should always return non-nil sdk.Result. - if r == nil { - return nil, fmt.Errorf("got nil sdk.Result for message %q at position %d", msg, i) - } - - results[i] = *r } - return results, nil + return nil } // ensureMsgAuthZ checks that if a message requires signers that all of them diff --git a/x/group/module/depinject.go b/x/group/module/depinject.go index 3810847332f4..88d98478dc21 100644 --- a/x/group/module/depinject.go +++ b/x/group/module/depinject.go @@ -8,7 +8,6 @@ import ( "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -28,13 +27,12 @@ func init() { type GroupInputs struct { depinject.In - Config *modulev1.Module - Environment appmodule.Environment - Cdc codec.Codec - AccountKeeper group.AccountKeeper - BankKeeper group.BankKeeper - Registry cdctypes.InterfaceRegistry - MsgServiceRouter baseapp.MessageRouter + Config *modulev1.Module + Environment appmodule.Environment + Cdc codec.Codec + AccountKeeper group.AccountKeeper + BankKeeper group.BankKeeper + Registry cdctypes.InterfaceRegistry } type GroupOutputs struct { @@ -47,7 +45,6 @@ type GroupOutputs struct { func ProvideModule(in GroupInputs) GroupOutputs { k := keeper.NewKeeper(in.Environment, in.Cdc, - in.MsgServiceRouter, in.AccountKeeper, group.Config{ MaxExecutionPeriod: in.Config.MaxExecutionPeriod.AsDuration(), diff --git a/x/mint/go.mod b/x/mint/go.mod index b3ec0d3713ba..124544a7abe3 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -19,7 +19,7 @@ require ( github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 gotest.tools/v3 v3.5.1 diff --git a/x/mint/go.sum b/x/mint/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/nft/go.mod b/x/nft/go.mod index c45f2500f1c3..394d05a7be95 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -16,7 +16,7 @@ require ( github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 ) diff --git a/x/nft/go.sum b/x/nft/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/params/go.mod b/x/params/go.mod index 16377d64e512..386be5f463d5 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -20,7 +20,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 ) diff --git a/x/params/go.sum b/x/params/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index 6644b1071294..2401090e1a1e 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -18,7 +18,7 @@ require ( github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 37239d2a5af0..793d3e43b6f1 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -22,7 +22,7 @@ require ( github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/slashing/go.sum b/x/slashing/go.sum index e4427810a9e4..ffa9d4eee03a 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -672,8 +672,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -683,8 +684,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/staking/go.mod b/x/staking/go.mod index 7bf6ec71d2d2..0ed29e490e8e 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -22,7 +22,7 @@ require ( github.com/hashicorp/go-metrics v0.5.3 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 diff --git a/x/staking/go.sum b/x/staking/go.sum index 884ec3416ac7..a82e64689883 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -670,8 +670,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -681,8 +682,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index c5dea74ea009..fc1061df8e83 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -850,7 +850,7 @@ func (k Keeper) Unbond( } valAddr, err1 := k.validatorAddressCodec.StringToBytes(delegation.GetValidatorAddr()) - if err != nil { + if err1 != nil { return amount, err1 } diff --git a/x/tx/go.mod b/x/tx/go.mod index 5f2790a8512b..969b7b360261 100644 --- a/x/tx/go.mod +++ b/x/tx/go.mod @@ -13,7 +13,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/iancoleman/strcase v0.3.0 github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tendermint/go-amino v0.16.0 google.golang.org/protobuf v1.32.0 gotest.tools/v3 v3.5.1 diff --git a/x/tx/go.sum b/x/tx/go.sum index effdc7a95e68..5065aad27c35 100644 --- a/x/tx/go.sum +++ b/x/tx/go.sum @@ -39,8 +39,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index e0cd8b69260e..775ede36bb9e 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -24,7 +24,7 @@ require ( github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index a9e0f3cc3350..e5a75f8a242f 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -967,8 +967,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -979,8 +980,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=