From 2174fef2c59a9982a81de443be0b4dcdbde9aa24 Mon Sep 17 00:00:00 2001 From: Arnab Mitra Date: Tue, 1 Feb 2022 16:35:06 -0700 Subject: [PATCH] feat: V0.45 rc prep (#27) * Updated and fixed Rosetta * add changelog * added prs to changelog * update release notes * feat: Add msg service router interface (#2) * convert message router to interface * Add setter for msg service interface * Adding a custom fee charging handler, so that if provenance want's they can charge fees for certain msg types. * refactored variable name. * Fixing comments on changed files. * Return transaction context from runTx * emitting events from AdditionalMsgFeeHandler, since authz and wasm calls need the event too. * test: Fix comppile issues on existing tests * handling error on failure to charge additional fee. * fixing err while deliverTx. * Update return values to have err at end * Fix tests * Refactor to remove pio specific stuff Co-authored-by: arnabmitra * fixed @arnabmitra cr request * go mod vendor * cleanup * fmt * adding msg fee work to the changelog under unreleased section. * fixed tests * updated changelog to reflect provenance releases * remove unused db copy cmd * updated release notes * updating comment. * updating comment based on code review. * adding anteevents which were missed in the merge. * update release notes wording * baseapp changes the way they propagate antehandler events, this commit takes care of the order of ante and base events, since ante events are charged before all events and fee events are charged at the end. * Error from fee invoker is not getting propagated properly. * merging. * updating release notes. * Add missing iavl config size value to config parser Co-authored-by: fkneeland Co-authored-by: fkneeland-figure <86616427+fkneeland-figure@users.noreply.github.com> Co-authored-by: Carlton Hanna <73041609+channa-figure@users.noreply.github.com> Co-authored-by: Carlton Hanna --- CHANGELOG.md | 11 ++++ RELEASE_NOTES.md | 5 ++ baseapp/abci.go | 6 +- baseapp/baseapp.go | 60 +++++++++++++++---- baseapp/baseapp_test.go | 4 +- baseapp/msg_service_router.go | 7 +++ baseapp/options.go | 9 +++ baseapp/test_helpers.go | 10 ++-- client/grpc_query_test.go | 1 + client/keys/add_ledger_test.go | 3 +- client/keys/add_test.go | 3 +- client/query_test.go | 1 + contrib/images/simd-env/Dockerfile | 1 - cosmovisor/process_test.go | 1 + cosmovisor/upgrade_test.go | 1 + crypto/keyring/keyring_ledger_test.go | 3 +- .../internal/ecdsa/privkey_internal_test.go | 5 +- crypto/keys/secp256k1/secp256k1_cgo.go | 1 + crypto/keys/secp256k1/secp256k1_cgo_test.go | 1 + crypto/keys/secp256k1/secp256k1_nocgo_test.go | 1 + crypto/ledger/ledger_real.go | 1 + server/config/config.go | 1 + server/grpc/server_test.go | 1 + server/rosetta/lib/errors/errors_test.go | 3 +- simapp/params/amino.go | 1 + simapp/simd/cmd/genaccounts_test.go | 3 +- simapp/simd/cmd/root.go | 3 +- simapp/simd/cmd/testnet_test.go | 7 ++- simapp/test_helpers.go | 2 +- store/cachemulti/store_test.go | 3 +- testutil/network/network_test.go | 1 + types/fee_handler.go | 4 ++ types/handler_test.go | 2 +- x/auth/client/testutil/cli_test.go | 1 + x/auth/tx/service.go | 4 +- x/auth/vesting/client/testutil/cli_test.go | 1 + x/authz/client/rest/grpc_query_test.go | 1 + x/authz/client/testutil/cli_test.go | 1 + x/authz/keeper/keeper.go | 4 +- x/bank/client/rest/grpc_query_test.go | 1 + x/bank/client/rest/query_test.go | 1 + x/bank/client/rest/tx_test.go | 1 + x/bank/client/testutil/cli_test.go | 1 + x/crisis/client/testsuite/cli_test.go | 1 + x/distribution/client/testutil/cli_test.go | 1 + x/evidence/client/testutil/cli_test.go | 1 + x/feegrant/client/testutil/cli_test.go | 1 + x/genutil/client/testutil/cli_test.go | 1 + x/gov/client/rest/grpc_query_test.go | 1 + x/gov/client/rest/rest_test.go | 1 + x/gov/client/testutil/cli_test.go | 1 + x/gov/client/testutil/deposits.go | 5 +- x/mint/client/rest/grpc_query_test.go | 1 + x/mint/client/testutil/cli_test.go | 1 + x/params/client/testutil/cli_test.go | 1 + x/slashing/client/testutil/cli_test.go | 1 + x/staking/client/rest/grpc_query_test.go | 1 + x/staking/client/rest/rest_test.go | 1 + x/staking/client/testutil/cli_test.go | 1 + x/upgrade/client/testutil/cli_test.go | 6 +- x/upgrade/client/testutil/suite.go | 5 +- 61 files changed, 165 insertions(+), 48 deletions(-) create mode 100644 types/fee_handler.go diff --git a/CHANGELOG.md b/CHANGELOG.md index cbebe05b561..9b90ad1c850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,17 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +# Provenance Specific releases + +## [v0.45-pio-1](https://github.com/provenance-io/cosmos-sdk/releases/tag/v0.45-pio-1.8.rc1) + +* Updated baseapp and added custom fee handler to support provenance message fee module [354](https://github.com/provenance-io/provenance/issues/354), for upstream cosmos-sdk release [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) + +## [v0.44.3-rosetta-fix](https://github.com/provenance-io/cosmos-sdk/tag/v0.44.3-rosetta-fix) + +* Upgraded Rosetta to v0.7.2 which includes the following prs to cosmos upstream: [10432](https://github.com/cosmos/cosmos-sdk/pull/10432) and [10707](https://github.com/cosmos/cosmos-sdk/pull/10707) + + ## [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) - 2022-01-18 ### State Machine Breaking diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index fb3c2acaff0..6deb9fb8667 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,7 @@ +# Cosmos SDK v0.44.5 Release Notes + +This release adds the updates from cosmos-sdk upstream v0.44.4 and v0.44.5 to the msg fee and rosetta fixes added into the Provenanced fork at v0.45 + # Cosmos SDK v0.45.0 Release Notes Cosmos SDK v0.45.0 is a logical continuation of the v0.44.\* series, but brings a couple of state- and API-breaking changes requested by the community. @@ -29,3 +33,4 @@ Finally, when using the `SetOrder*` functions in simapp, e.g. `SetOrderBeginBloc - Copied and updated `server.GenerateCoinKey` and `server.GenerateServerCoinKey` functions to the `testutil` package. These functions in `server` package are marked deprecated and will be removed in the next release. In the `testutil.GenerateServerCoinKey` version we added support for custom mnemonics in in-process testing network. See our [CHANGELOG](./CHANGELOG.md) for the exhaustive list of all changes, or a full [commit diff](https://github.com/cosmos/cosmos-sdk/compare/v0.44.5...v0.45.0). + diff --git a/baseapp/abci.go b/baseapp/abci.go index 80d0011dca3..2d6597cab33 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -241,7 +241,7 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.Type)) } - gInfo, result, anteEvents, err := app.runTx(mode, req.Tx) + gInfo, result, anteEvents, _, err := app.runTx(mode, req.Tx) if err != nil { return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace) } @@ -273,7 +273,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted") }() - gInfo, result, anteEvents, err := app.runTx(runTxModeDeliver, req.Tx) + gInfo, result, anteEvents, _, err := app.runTx(runTxModeDeliver, req.Tx) if err != nil { resultStr = "failed" return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace) @@ -745,7 +745,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res case "simulate": txBytes := req.Data - gInfo, res, err := app.Simulate(txBytes) + gInfo, res, _, err := app.Simulate(txBytes) if err != nil { return sdkerrors.QueryResult(sdkerrors.Wrap(err, "failed to simulate tx")) } diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 3a73f6ef20d..0bed1280268 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -55,7 +55,7 @@ type BaseApp struct { // nolint: maligned router sdk.Router // handle any kind of message queryRouter sdk.QueryRouter // router for redirecting query calls grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls - msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages + msgServiceRouter IMsgServiceRouter // router for redirecting Msg service messages interfaceRegistry types.InterfaceRegistry txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx @@ -133,6 +133,8 @@ type BaseApp struct { // nolint: maligned // indexEvents defines the set of events in the form {eventType}.{attributeKey}, // which informs Tendermint what to index. If empty, all events will be indexed. indexEvents map[string]struct{} + + feeHandler sdk.FeeHandler } // NewBaseApp returns a reference to an initialized BaseApp. It accepts a @@ -195,8 +197,13 @@ func (app *BaseApp) Trace() bool { return app.trace } +// sets MsgServiceRouter of the BaseApp. +func (app *BaseApp) SetMsgServiceRouter(msgServiceRouter IMsgServiceRouter) { + app.msgServiceRouter = msgServiceRouter +} + // MsgServiceRouter returns the MsgServiceRouter of a BaseApp. -func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter } +func (app *BaseApp) MsgServiceRouter() IMsgServiceRouter { return app.msgServiceRouter } // MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp // multistore. @@ -572,7 +579,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context // Note, gas execution info is always returned. A reference to a Result is // returned if the tx does not run out of gas and if all the messages are valid // and execute successfully. An error is returned otherwise. -func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) { +func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, txCtx sdk.Context, err error) { // NOTE: GasWanted should be returned by the AnteHandler. GasUsed is // determined by the GasMeter. We need access to the context to get the gas // meter so we initialize upfront. @@ -583,7 +590,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re // only run the tx if there is block gas remaining if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() { - return gInfo, nil, nil, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx") + return gInfo, nil, nil, ctx, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx") } defer func() { @@ -618,12 +625,12 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re tx, err := app.txDecoder(txBytes) if err != nil { - return sdk.GasInfo{}, nil, nil, err + return sdk.GasInfo{}, nil, nil, ctx, err } msgs := tx.GetMsgs() if err := validateBasicTxMsgs(msgs); err != nil { - return sdk.GasInfo{}, nil, nil, err + return sdk.GasInfo{}, nil, nil, ctx, err } if app.anteHandler != nil { @@ -659,7 +666,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re gasWanted = ctx.GasMeter().Limit() if err != nil { - return gInfo, nil, nil, err + return gInfo, nil, nil, ctx, err } msCache.Write() @@ -677,17 +684,44 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re result, err = app.runMsgs(runMsgCtx, msgs, mode) if err == nil && mode == runTxModeDeliver { // When block gas exceeds, it'll panic and won't commit the cached store. + // this should be called before we charge additional fee( otherwise would + // defy the whole point of charging additional fee at the end) consumeBlockGas() - msCache.Write() - - if len(anteEvents) > 0 { - // append the events in the order of occurrence - result.Events = append(anteEvents, result.Events...) + // apply fee logic calls + feeEvents, errFromFeeInvoker := FeeInvoke(mode, app, runMsgCtx) + // if err from FeeInvoke then don't write to cache + if errFromFeeInvoker == nil { + msCache.Write() + // these are the ante events propagated only on success, that now means that fee charging has happened successfully. + if len(anteEvents) > 0 { + // append the events in the order of occurrence + result.Events = append(anteEvents, result.Events...) + } + // additional fee events + if len(feeEvents) > 0 { + // append the fee events at the end of the other events, since they get charged at the end of the Tx + result.Events = append(result.Events, feeEvents.ToABCIEvents()...) + } + } else { + err = errFromFeeInvoker } } - return gInfo, result, anteEvents, err + return gInfo, result, anteEvents, ctx, err +} + +// FeeInvoke apply fee logic and append events +func FeeInvoke(mode runTxMode, app *BaseApp, runMsgCtx sdk.Context) (sdk.Events, error) { + if app.feeHandler != nil { + // call the msgFee + _, eventsFromFeeHandler, err := app.feeHandler(runMsgCtx, mode == runTxModeSimulate) + if err != nil { + return nil, err + } + return eventsFromFeeHandler, nil + } + return nil, nil } // runMsgs iterates through a list of messages and executes them with the provided diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index df891e13693..6c5497e0bae 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -1131,13 +1131,13 @@ func TestSimulateTx(t *testing.T) { require.Nil(t, err) // simulate a message, check gas reported - gInfo, result, err := app.Simulate(txBytes) + gInfo, result, _, err := app.Simulate(txBytes) require.NoError(t, err) require.NotNil(t, result) require.Equal(t, gasConsumed, gInfo.GasUsed) // simulate again, same result - gInfo, result, err = app.Simulate(txBytes) + gInfo, result, _, err = app.Simulate(txBytes) require.NoError(t, err) require.NotNil(t, result) require.Equal(t, gasConsumed, gInfo.GasUsed) diff --git a/baseapp/msg_service_router.go b/baseapp/msg_service_router.go index 1b7f8f89bf7..9dba81f74b2 100644 --- a/baseapp/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -31,6 +31,13 @@ func NewMsgServiceRouter() *MsgServiceRouter { // MsgServiceHandler defines a function type which handles Msg service message. type MsgServiceHandler = func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) +type IMsgServiceRouter interface { + Handler(msg sdk.Msg) MsgServiceHandler + HandlerByTypeURL(typeURL string) MsgServiceHandler + RegisterService(sd *grpc.ServiceDesc, handler interface{}) + SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry) +} + // Handler returns the MsgServiceHandler for a given msg or nil if not found. func (msr *MsgServiceRouter) Handler(msg sdk.Msg) MsgServiceHandler { return msr.routes[sdk.MsgTypeURL(msg)] diff --git a/baseapp/options.go b/baseapp/options.go index 5d336cb1bf1..c01a3b79532 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -242,3 +242,12 @@ func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) { app.grpcQueryRouter.SetInterfaceRegistry(registry) app.msgServiceRouter.SetInterfaceRegistry(registry) } + +// SetFeeHandler sets the FeeHandler which if set will change the behavior of fee handling +func (app *BaseApp) SetFeeHandler(feeHandler sdk.FeeHandler) { + if app.sealed { + panic("SetKeeperHandler() on sealed BaseApp") + } + + app.feeHandler = feeHandler +} diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 4d5ef1b75bc..af6abddc1f4 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -15,13 +15,13 @@ func (app *BaseApp) Check(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk if err != nil { return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - gasInfo, result, _, err := app.runTx(runTxModeCheck, bz) + gasInfo, result, _, _, err := app.runTx(runTxModeCheck, bz) return gasInfo, result, err } -func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) { - gasInfo, result, _, err := app.runTx(runTxModeSimulate, txBytes) - return gasInfo, result, err +func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, sdk.Context, error) { + gasInfo, result, _, ctx, err := app.runTx(runTxModeSimulate, txBytes) + return gasInfo, result, ctx, err } func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { @@ -30,7 +30,7 @@ func (app *BaseApp) Deliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *s if err != nil { return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - gasInfo, result, _, err := app.runTx(runTxModeDeliver, bz) + gasInfo, result, _, _, err := app.runTx(runTxModeDeliver, bz) return gasInfo, result, err } diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index c4d2f024a07..db7c487276e 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package client_test diff --git a/client/keys/add_ledger_test.go b/client/keys/add_ledger_test.go index 69ccb32a428..cfa63eed8d8 100644 --- a/client/keys/add_ledger_test.go +++ b/client/keys/add_ledger_test.go @@ -1,4 +1,5 @@ -//+build ledger test_ledger_mock +//go:build ledger || test_ledger_mock +// +build ledger test_ledger_mock package keys diff --git a/client/keys/add_test.go b/client/keys/add_test.go index f59848a8d1c..2d67c8818bf 100644 --- a/client/keys/add_test.go +++ b/client/keys/add_test.go @@ -11,6 +11,8 @@ import ( "github.com/tendermint/tendermint/libs/cli" + bip39 "github.com/cosmos/go-bip39" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -19,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - bip39 "github.com/cosmos/go-bip39" ) func Test_runAddCmdBasic(t *testing.T) { diff --git a/client/query_test.go b/client/query_test.go index 14cc25ba9d9..7e22d3f3445 100644 --- a/client/query_test.go +++ b/client/query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package client_test diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index b4443cdc8a8..dd5d2761c26 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -2,7 +2,6 @@ FROM golang:1.17-alpine AS build RUN apk add build-base git linux-headers WORKDIR /work COPY go.mod go.sum /work/ -COPY db/go.mod db/go.sum /work/db/ RUN go mod download COPY ./ /work RUN LEDGER_ENABLED=false make clean build diff --git a/cosmovisor/process_test.go b/cosmovisor/process_test.go index 6dc964f21ee..3b9a553ed63 100644 --- a/cosmovisor/process_test.go +++ b/cosmovisor/process_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package cosmovisor_test diff --git a/cosmovisor/upgrade_test.go b/cosmovisor/upgrade_test.go index 2123df8e403..371db1ef3c9 100644 --- a/cosmovisor/upgrade_test.go +++ b/cosmovisor/upgrade_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package cosmovisor_test diff --git a/crypto/keyring/keyring_ledger_test.go b/crypto/keyring/keyring_ledger_test.go index cccfa20452b..9b3f3c00a34 100644 --- a/crypto/keyring/keyring_ledger_test.go +++ b/crypto/keyring/keyring_ledger_test.go @@ -1,4 +1,5 @@ -//+build ledger test_ledger_mock +//go:build ledger || test_ledger_mock +// +build ledger test_ledger_mock package keyring diff --git a/crypto/keys/internal/ecdsa/privkey_internal_test.go b/crypto/keys/internal/ecdsa/privkey_internal_test.go index 1eae718f698..9d26680c79e 100644 --- a/crypto/keys/internal/ecdsa/privkey_internal_test.go +++ b/crypto/keys/internal/ecdsa/privkey_internal_test.go @@ -4,10 +4,11 @@ import ( "crypto/ecdsa" "crypto/elliptic" "crypto/sha256" - "github.com/tendermint/tendermint/crypto" "math/big" "testing" + "github.com/tendermint/tendermint/crypto" + "github.com/stretchr/testify/suite" ) @@ -80,7 +81,7 @@ func (suite *SKSuite) TestSign() { // leave r untouched! high_s := new(big.Int).Mod(new(big.Int).Neg(low_s), elliptic.P256().Params().N) - require.False(suite.pk.VerifySignature(msg, signatureRaw(r,high_s))) + require.False(suite.pk.VerifySignature(msg, signatureRaw(r, high_s))) // Valid signature using low_s, but too long sigCpy = make([]byte, len(sig)+2) diff --git a/crypto/keys/secp256k1/secp256k1_cgo.go b/crypto/keys/secp256k1/secp256k1_cgo.go index 42088483d3f..1d104364617 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo.go +++ b/crypto/keys/secp256k1/secp256k1_cgo.go @@ -1,3 +1,4 @@ +//go:build libsecp256k1 // +build libsecp256k1 package secp256k1 diff --git a/crypto/keys/secp256k1/secp256k1_cgo_test.go b/crypto/keys/secp256k1/secp256k1_cgo_test.go index bfaa76caf9d..20ae3e12780 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo_test.go +++ b/crypto/keys/secp256k1/secp256k1_cgo_test.go @@ -1,3 +1,4 @@ +//go:build libsecp256k1 // +build libsecp256k1 package secp256k1 diff --git a/crypto/keys/secp256k1/secp256k1_nocgo_test.go b/crypto/keys/secp256k1/secp256k1_nocgo_test.go index 4c2c856e13c..878a06bfe6a 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo_test.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo_test.go @@ -1,3 +1,4 @@ +//go:build !libsecp256k1 // +build !libsecp256k1 package secp256k1 diff --git a/crypto/ledger/ledger_real.go b/crypto/ledger/ledger_real.go index 07f8a8e3ed6..48c87aff768 100644 --- a/crypto/ledger/ledger_real.go +++ b/crypto/ledger/ledger_real.go @@ -1,3 +1,4 @@ +//go:build cgo && ledger && !test_ledger_mock // +build cgo,ledger,!test_ledger_mock package ledger diff --git a/server/config/config.go b/server/config/config.go index f5a395dce8e..803808b19a7 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -271,6 +271,7 @@ func GetConfig(v *viper.Viper) Config { HaltTime: v.GetUint64("halt-time"), IndexEvents: v.GetStringSlice("index-events"), MinRetainBlocks: v.GetUint64("min-retain-blocks"), + IAVLCacheSize: v.GetUint64("iavl-cache-size"), }, Telemetry: telemetry.Config{ ServiceName: v.GetString("telemetry.service-name"), diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index 2c18754e03c..c96e4981d92 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package grpc_test diff --git a/server/rosetta/lib/errors/errors_test.go b/server/rosetta/lib/errors/errors_test.go index 5502f09f7e3..6efe446f5b2 100644 --- a/server/rosetta/lib/errors/errors_test.go +++ b/server/rosetta/lib/errors/errors_test.go @@ -1,8 +1,9 @@ package errors import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestRegisterError(t *testing.T) { diff --git a/simapp/params/amino.go b/simapp/params/amino.go index 440c29f817e..0d43dd1eb8f 100644 --- a/simapp/params/amino.go +++ b/simapp/params/amino.go @@ -1,3 +1,4 @@ +//go:build test_amino // +build test_amino package params diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index 8ed82d0918a..0b44a0e6d55 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -3,10 +3,11 @@ package cmd_test import ( "context" "fmt" + "testing" + "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "testing" "github.com/spf13/viper" "github.com/stretchr/testify/require" diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 679723c0bc6..79802ed2c23 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -6,13 +6,14 @@ import ( "os" "path/filepath" - serverconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/spf13/cast" "github.com/spf13/cobra" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" + serverconfig "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" diff --git a/simapp/simd/cmd/testnet_test.go b/simapp/simd/cmd/testnet_test.go index da58fd454d8..da46913eae0 100644 --- a/simapp/simd/cmd/testnet_test.go +++ b/simapp/simd/cmd/testnet_test.go @@ -5,6 +5,10 @@ import ( "fmt" "testing" + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -12,9 +16,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" ) func Test_TestnetCmd(t *testing.T) { diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 4f45b23eacd..3b07d7f45af 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -341,7 +341,7 @@ func SignCheckDeliver( require.Nil(t, err) // Must simulate now as CheckTx doesn't run Msgs anymore - _, res, err := app.Simulate(txBytes) + _, res, _, err := app.Simulate(txBytes) if expSimPass { require.NoError(t, err) diff --git a/store/cachemulti/store_test.go b/store/cachemulti/store_test.go index 8747df9ef96..ef5bd5eaebb 100644 --- a/store/cachemulti/store_test.go +++ b/store/cachemulti/store_test.go @@ -4,8 +4,9 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/store/types" ) func TestStoreGetKVStore(t *testing.T) { diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go index 3e45309f2f1..e53fc743f7a 100644 --- a/testutil/network/network_test.go +++ b/testutil/network/network_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package network_test diff --git a/types/fee_handler.go b/types/fee_handler.go new file mode 100644 index 00000000000..7f1a61363e9 --- /dev/null +++ b/types/fee_handler.go @@ -0,0 +1,4 @@ +package types + +// FeeHandler optional custom fee handling implementations +type FeeHandler func(ctx Context, simulate bool) (coins Coins, events Events, err error) diff --git a/types/handler_test.go b/types/handler_test.go index 449d1b602f5..c7fc961a560 100644 --- a/types/handler_test.go +++ b/types/handler_test.go @@ -36,7 +36,7 @@ func (s *handlerTestSuite) TestChainAnteDecorators() { mockAnteDecorator2 := mocks.NewMockAnteDecorator(mockCtrl) // NOTE: we can't check that mockAnteDecorator2 is passed as the last argument because // ChainAnteDecorators wraps the decorators into closures, so each decorator is - // receving a closure. + // receiving a closure. mockAnteDecorator1.EXPECT().AnteHandle(gomock.Eq(ctx), gomock.Eq(tx), true, gomock.Any()).Times(1) mockAnteDecorator2.EXPECT().AnteHandle(gomock.Eq(ctx), gomock.Eq(tx), true, gomock.Any()).Times(1) diff --git a/x/auth/client/testutil/cli_test.go b/x/auth/client/testutil/cli_test.go index 0a7a5cc2587..f23e88847c3 100644 --- a/x/auth/client/testutil/cli_test.go +++ b/x/auth/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index a0deedae6aa..2c5e617793d 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -19,7 +19,7 @@ import ( ) // baseAppSimulateFn is the signature of the Baseapp#Simulate function. -type baseAppSimulateFn func(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) +type baseAppSimulateFn func(txBytes []byte) (sdk.GasInfo, *sdk.Result, sdk.Context, error) // txServer is the server for the protobuf Tx service. type txServer struct { @@ -114,7 +114,7 @@ func (s txServer) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (* return nil, status.Errorf(codes.InvalidArgument, "empty txBytes is not allowed") } - gasInfo, result, err := s.simulate(txBytes) + gasInfo, result, _, err := s.simulate(txBytes) if err != nil { return nil, err } diff --git a/x/auth/vesting/client/testutil/cli_test.go b/x/auth/vesting/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/auth/vesting/client/testutil/cli_test.go +++ b/x/auth/vesting/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/authz/client/rest/grpc_query_test.go b/x/authz/client/rest/grpc_query_test.go index 614e283a15e..b81dc5eaddd 100644 --- a/x/authz/client/rest/grpc_query_test.go +++ b/x/authz/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/authz/client/testutil/cli_test.go b/x/authz/client/testutil/cli_test.go index 3c083e69472..5b3ef61c5a4 100644 --- a/x/authz/client/testutil/cli_test.go +++ b/x/authz/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index ce4e421c125..ea6d2fc2de5 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -19,11 +19,11 @@ import ( type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec - router *baseapp.MsgServiceRouter + router baseapp.IMsgServiceRouter } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, router *baseapp.MsgServiceRouter) Keeper { +func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, router baseapp.IMsgServiceRouter) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, diff --git a/x/bank/client/rest/grpc_query_test.go b/x/bank/client/rest/grpc_query_test.go index 857aa58e4b8..c5d3d74dada 100644 --- a/x/bank/client/rest/grpc_query_test.go +++ b/x/bank/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/bank/client/rest/query_test.go b/x/bank/client/rest/query_test.go index a9e43a53db8..4dd304396c4 100644 --- a/x/bank/client/rest/query_test.go +++ b/x/bank/client/rest/query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/bank/client/rest/tx_test.go b/x/bank/client/rest/tx_test.go index 8406a2c2abd..faeda7a0d48 100644 --- a/x/bank/client/rest/tx_test.go +++ b/x/bank/client/rest/tx_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/bank/client/testutil/cli_test.go b/x/bank/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/bank/client/testutil/cli_test.go +++ b/x/bank/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/crisis/client/testsuite/cli_test.go b/x/crisis/client/testsuite/cli_test.go index 3c083e69472..5b3ef61c5a4 100644 --- a/x/crisis/client/testsuite/cli_test.go +++ b/x/crisis/client/testsuite/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/distribution/client/testutil/cli_test.go b/x/distribution/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/distribution/client/testutil/cli_test.go +++ b/x/distribution/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/evidence/client/testutil/cli_test.go b/x/evidence/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/evidence/client/testutil/cli_test.go +++ b/x/evidence/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/feegrant/client/testutil/cli_test.go b/x/feegrant/client/testutil/cli_test.go index bdbfb78d0bd..9814e9573b3 100644 --- a/x/feegrant/client/testutil/cli_test.go +++ b/x/feegrant/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/genutil/client/testutil/cli_test.go b/x/genutil/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/genutil/client/testutil/cli_test.go +++ b/x/genutil/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/gov/client/rest/grpc_query_test.go b/x/gov/client/rest/grpc_query_test.go index 12247aeb9a9..64aaf15c10b 100644 --- a/x/gov/client/rest/grpc_query_test.go +++ b/x/gov/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/gov/client/rest/rest_test.go b/x/gov/client/rest/rest_test.go index 9049bd26401..d39b65ad0f2 100644 --- a/x/gov/client/rest/rest_test.go +++ b/x/gov/client/rest/rest_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/gov/client/testutil/cli_test.go b/x/gov/client/testutil/cli_test.go index 713c33f1218..c7bc27ace35 100644 --- a/x/gov/client/testutil/cli_test.go +++ b/x/gov/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/gov/client/testutil/deposits.go b/x/gov/client/testutil/deposits.go index 57c3c936333..a5f02cfc836 100644 --- a/x/gov/client/testutil/deposits.go +++ b/x/gov/client/testutil/deposits.go @@ -4,13 +4,14 @@ import ( "fmt" "time" + "github.com/stretchr/testify/suite" + tmcli "github.com/tendermint/tendermint/libs/cli" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/client/cli" "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/stretchr/testify/suite" - tmcli "github.com/tendermint/tendermint/libs/cli" ) type DepositTestSuite struct { diff --git a/x/mint/client/rest/grpc_query_test.go b/x/mint/client/rest/grpc_query_test.go index fdbb4ff7599..2520f8df4aa 100644 --- a/x/mint/client/rest/grpc_query_test.go +++ b/x/mint/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/mint/client/testutil/cli_test.go +++ b/x/mint/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/params/client/testutil/cli_test.go b/x/params/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/params/client/testutil/cli_test.go +++ b/x/params/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/slashing/client/testutil/cli_test.go b/x/slashing/client/testutil/cli_test.go index dd36a6af2d3..1035ca75026 100644 --- a/x/slashing/client/testutil/cli_test.go +++ b/x/slashing/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/staking/client/rest/grpc_query_test.go b/x/staking/client/rest/grpc_query_test.go index 55a10194f60..c53635128ae 100644 --- a/x/staking/client/rest/grpc_query_test.go +++ b/x/staking/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/staking/client/rest/rest_test.go b/x/staking/client/rest/rest_test.go index 43b9afdb6dd..78a46f82f1f 100644 --- a/x/staking/client/rest/rest_test.go +++ b/x/staking/client/rest/rest_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test diff --git a/x/staking/client/testutil/cli_test.go b/x/staking/client/testutil/cli_test.go index 0a7a5cc2587..f23e88847c3 100644 --- a/x/staking/client/testutil/cli_test.go +++ b/x/staking/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/upgrade/client/testutil/cli_test.go b/x/upgrade/client/testutil/cli_test.go index d4ca6406773..7f92bbeeff5 100644 --- a/x/upgrade/client/testutil/cli_test.go +++ b/x/upgrade/client/testutil/cli_test.go @@ -1,9 +1,11 @@ package testutil import ( - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/stretchr/testify/suite" "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/testutil/network" ) func TestIntegrationTestSuite(t *testing.T) { diff --git a/x/upgrade/client/testutil/suite.go b/x/upgrade/client/testutil/suite.go index 6b559e823c7..4af91221671 100644 --- a/x/upgrade/client/testutil/suite.go +++ b/x/upgrade/client/testutil/suite.go @@ -3,14 +3,15 @@ package testutil import ( "fmt" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/simapp" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/upgrade/client/cli" "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {