diff --git a/.circleci/config.yml b/.circleci/config.yml index 45fb8d2bda..55547e0640 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ orbs: executors: golang: docker: - - image: cimg/go:1.20 + - image: cimg/go:1.21 commands: make: @@ -101,7 +101,7 @@ jobs: test-system: executor: golang parallelism: 1 - resource_class: large + resource_class: xlarge steps: - attach_workspace: at: /tmp/workspace @@ -135,7 +135,7 @@ jobs: simulations: executor: golang parallelism: 1 - resource_class: large + resource_class: xlarge steps: - checkout - run: diff --git a/.mergify.yml b/.mergify.yml index 59bc41bdd0..32ea628b42 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -6,7 +6,7 @@ queue_rules: pull_request_rules: - name: backport patches to main branch conditions: - - base=releases/v0.40.x + - base=releases/v0.4x - label=backport/main actions: backport: @@ -20,11 +20,11 @@ pull_request_rules: backport: branches: - releases/v0.3x - - name: backport patches to v0.40.x release branch + - name: backport patches to sdk47 release branch conditions: - base=main - - label=backport/v0.40.x + - label=backport/v0.4x actions: backport: branches: - - releases/v0.40.x + - releases/v0.4x diff --git a/Dockerfile b/Dockerfile index 18e80d3976..68814b32b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # docker build . -t cosmwasm/wasmd:latest # docker run --rm -it cosmwasm/wasmd:latest /bin/sh -FROM golang:1.19-alpine3.15 AS go-builder +FROM golang:1.21-alpine3.17 AS go-builder ARG arch=x86_64 # this comes from standard alpine nightly file @@ -29,7 +29,7 @@ RUN echo "Ensuring binary is statically linked ..." \ && (file /code/build/wasmd | grep "statically linked") # -------------------------------------------------------- -FROM alpine:3.15 +FROM alpine:3.17 COPY --from=go-builder /code/build/wasmd /usr/bin/wasmd diff --git a/Makefile b/Makefile index 0ef07eca21..06ad540ddf 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,7 @@ format: format-tools ############################################################################### ### Protobuf ### ############################################################################### -protoVer=0.13.1 +protoVer=0.14.0 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) diff --git a/app/ante.go b/app/ante.go index 79a73822fa..43f1b5edcf 100644 --- a/app/ante.go +++ b/app/ante.go @@ -1,14 +1,16 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - "github.com/cosmos/ibc-go/v7/modules/core/keeper" + "errors" - errorsmod "cosmossdk.io/errors" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + "github.com/cosmos/ibc-go/v8/modules/core/keeper" + + corestoretypes "cosmossdk.io/core/store" + circuitante "cosmossdk.io/x/circuit/ante" + circuitkeeper "cosmossdk.io/x/circuit/keeper" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -20,34 +22,39 @@ import ( type HandlerOptions struct { ante.HandlerOptions - IBCKeeper *keeper.Keeper - WasmKeeper *wasmkeeper.Keeper - WasmConfig *wasmTypes.WasmConfig - TXCounterStoreKey storetypes.StoreKey + IBCKeeper *keeper.Keeper + WasmConfig *wasmTypes.WasmConfig + WasmKeeper *wasmkeeper.Keeper + TXCounterStoreService corestoretypes.KVStoreService + CircuitKeeper *circuitkeeper.Keeper } func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { if options.AccountKeeper == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler") + return nil, errors.New("account keeper is required for ante builder") } if options.BankKeeper == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler") + return nil, errors.New("bank keeper is required for ante builder") } if options.SignModeHandler == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") + return nil, errors.New("sign mode handler is required for ante builder") } if options.WasmConfig == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder") + return nil, errors.New("wasm config is required for ante builder") + } + if options.TXCounterStoreService == nil { + return nil, errors.New("wasm store service is required for ante builder") } - if options.TXCounterStoreKey == nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder") + if options.CircuitKeeper == nil { + return nil, errors.New("circuit keeper is required for ante builder") } anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early - wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey), + wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService), wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), + circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), diff --git a/app/app.go b/app/app.go index aa1e321f15..c630550c08 100644 --- a/app/app.go +++ b/app/app.go @@ -6,46 +6,67 @@ import ( "io" "os" "path/filepath" + "sort" "strings" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - tmos "github.com/cometbft/cometbft/libs/os" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" - icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller" - icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper" - icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" - ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" - ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" - ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" - transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" + icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" + ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" + ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/circuit" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + circuittypes "cosmossdk.io/x/circuit/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" + "cosmossdk.io/x/nft" + nftkeeper "cosmossdk.io/x/nft/keeper" + nftmodule "cosmossdk.io/x/nft/module" + "cosmossdk.io/x/tx/signing" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -53,13 +74,14 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/store/streaming" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" @@ -73,9 +95,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -85,12 +104,6 @@ import ( distr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -104,9 +117,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/mint" mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/x/nft" - nftkeeper "github.com/cosmos/cosmos-sdk/x/nft/keeper" - nftmodule "github.com/cosmos/cosmos-sdk/x/nft/module" "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" @@ -118,10 +128,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -157,62 +163,21 @@ var ( Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic ) -var ( - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic( - []govclient.ProposalHandler{ - paramsclient.ProposalHandler, - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, - }, - ), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - groupmodule.AppModuleBasic{}, - vesting.AppModuleBasic{}, - nftmodule.AppModuleBasic{}, - consensus.AppModuleBasic{}, - // non sdk modules - wasm.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ibctm.AppModuleBasic{}, - transfer.AppModuleBasic{}, - ica.AppModuleBasic{}, - ibcfee.AppModuleBasic{}, - ) - - // module account permissions - maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - nft.ModuleName: nil, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - ibcfeetypes.ModuleName: nil, - icatypes.ModuleName: nil, - wasmtypes.ModuleName: {authtypes.Burner}, - } -) +// module account permissions +var maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + nft.ModuleName: nil, + // non sdk modules + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, + icatypes.ModuleName: nil, + wasmtypes.ModuleName: {authtypes.Burner}, +} var ( _ runtime.AppI = (*WasmApp)(nil) @@ -234,7 +199,7 @@ type WasmApp struct { // keepers AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper + BankKeeper bankkeeper.BaseKeeper CapabilityKeeper *capabilitykeeper.Keeper StakingKeeper *stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper @@ -250,6 +215,7 @@ type WasmApp struct { GroupKeeper groupkeeper.Keeper NFTKeeper nftkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper + CircuitKeeper circuitkeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly IBCFeeKeeper ibcfeekeeper.Keeper @@ -266,7 +232,8 @@ type WasmApp struct { ScopedWasmKeeper capabilitykeeper.ScopedKeeper // the module manager - ModuleManager *module.Manager + ModuleManager *module.Manager + BasicModuleManager module.BasicManager // simulation manager sm *module.SimulationManager @@ -285,11 +252,59 @@ func NewWasmApp( wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *WasmApp { - encodingConfig := MakeEncodingConfig() + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + if err != nil { + panic(err) + } + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) - appCodec, legacyAmino := encodingConfig.Codec, encodingConfig.Amino - interfaceRegistry := encodingConfig.InterfaceRegistry - txConfig := encodingConfig.TxConfig + std.RegisterLegacyAminoCodec(legacyAmino) + std.RegisterInterfaces(interfaceRegistry) + + // Below we could construct and set an application specific mempool and + // ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are + // already set in the SDK's BaseApp, this shows an example of how to override + // them. + // + // Example: + // + // bApp := baseapp.NewBaseApp(...) + // nonceMempool := mempool.NewSenderNonceMempool() + // abciPropHandler := NewDefaultProposalHandler(nonceMempool, bApp) + // + // bApp.SetMempool(nonceMempool) + // bApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) + // bApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler()) + // + // Alternatively, you can construct BaseApp options, append those to + // baseAppOptions and pass them to NewBaseApp. + // + // Example: + // + // prepareOpt = func(app *baseapp.BaseApp) { + // abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app) + // app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) + // } + // baseAppOptions = append(baseAppOptions, prepareOpt) + + // create and set dummy vote extension handler + // voteExtOp := func(bApp *baseapp.BaseApp) { + // voteExtHandler := NewVoteExtensionHandler() + // voteExtHandler.SetHandlers(bApp) + // } + // baseAppOptions = append(baseAppOptions, voteExtOp) bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -297,25 +312,24 @@ func NewWasmApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, capabilitytypes.StoreKey, + evidencetypes.StoreKey, circuittypes.StoreKey, authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, // non sdk store keys - ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, + capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, wasmtypes.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - // load state streaming if enabled - if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, logger, keys); err != nil { - logger.Error("failed to load state streaming", "err", err) - os.Exit(1) + // register streaming services + if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { + panic(err) } app := &WasmApp{ @@ -337,8 +351,13 @@ func NewWasmApp( ) // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + runtime.EventService{}, + ) + bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( @@ -355,41 +374,47 @@ func NewWasmApp( app.CapabilityKeeper.Seal() // add keepers + app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - Bech32Prefix, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, BlockedAddresses(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, ) + app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) - app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -400,7 +425,7 @@ func NewWasmApp( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -408,14 +433,15 @@ func NewWasmApp( invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), ) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks @@ -423,14 +449,34 @@ func NewWasmApp( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) - app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) + app.CircuitKeeper = circuitkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[circuittypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), + ) + app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) + + app.AuthzKeeper = authzkeeper.NewKeeper( + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + ) groupConfig := group.DefaultConfig() /* Example of setting group params: groupConfig.MaxMetadataLen = 1000 */ - app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, groupConfig) + app.GroupKeeper = groupkeeper.NewKeeper( + keys[group.StoreKey], + // runtime.NewKVStoreService(keys[group.StoreKey]), + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + groupConfig, + ) // get skipUpgradeHeights from the app options skipUpgradeHeights := map[int64]bool{} @@ -441,7 +487,7 @@ func NewWasmApp( // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -455,6 +501,7 @@ func NewWasmApp( app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Register the proposal types @@ -463,9 +510,8 @@ func NewWasmApp( // See: https://docs.cosmos.network/main/modules/gov#proposal-messages govRouter := govv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). // This should be removed. It is still in place to avoid failures of modules that have not yet been upgraded. - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + // This should be removed. It is still in place to avoid failures of modules that have not yet been upgraded. + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) govConfig := govtypes.DefaultConfig() /* @@ -474,10 +520,11 @@ func NewWasmApp( */ govKeeper := govkeeper.NewKeeper( appCodec, - keys[govtypes.StoreKey], + runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, + app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -490,7 +537,7 @@ func NewWasmApp( ) app.NFTKeeper = nftkeeper.NewKeeper( - keys[nftkeeper.StoreKey], + runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), appCodec, app.AccountKeeper, app.BankKeeper, @@ -499,9 +546,11 @@ func NewWasmApp( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), app.StakingKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper @@ -525,6 +574,7 @@ func NewWasmApp( app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.ICAHostKeeper = icahostkeeper.NewKeeper( @@ -537,6 +587,7 @@ func NewWasmApp( app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( appCodec, @@ -547,6 +598,7 @@ func NewWasmApp( &app.IBCKeeper.PortKeeper, scopedICAControllerKeeper, app.MsgServiceRouter(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) wasmDir := filepath.Join(homePath, "wasm") @@ -560,7 +612,7 @@ func NewWasmApp( availableCapabilities := strings.Join(AllCapabilities(), ",") app.WasmKeeper = wasmkeeper.NewKeeper( appCodec, - keys[wasmtypes.StoreKey], + runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -635,46 +687,75 @@ func NewWasmApp( genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, - app.BaseApp.DeliverTx, - encodingConfig.TxConfig, + app, + txConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), - capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(app.UpgradeKeeper), + upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuit.NewAppModule(appCodec, app.CircuitKeeper), + // non sdk modules + capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), ibc.NewAppModule(app.IBCKeeper), transfer.NewAppModule(app.TransferKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), + ibctm.AppModuleBasic{}, + // sdk crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them ) + // BasicModuleManager defines the module BasicManager is in charge of setting up basic, + // non-dependant module elements, such as codec registration and genesis verification. + // By default it is composed of all the module from the module manager. + // Additionally, app module basics can be overwritten by passing them as argument. + app.BasicModuleManager = module.NewBasicManagerFromManager( + app.ModuleManager, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + }, + ), + ibctm.ModuleName: ibctm.AppModuleBasic{}, + }) + app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) + app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) + + // NOTE: upgrade module is required to be prioritized + app.ModuleManager.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.ModuleManager.SetOrderBeginBlockers( - upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, - evidencetypes.ModuleName, stakingtypes.ModuleName, - authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, - authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, - paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, + minttypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, // additional non simd modules + capabilitytypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, icatypes.ModuleName, @@ -683,13 +764,14 @@ func NewWasmApp( ) app.ModuleManager.SetOrderEndBlockers( - crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, - slashingtypes.ModuleName, minttypes.ModuleName, - genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, nft.ModuleName, group.ModuleName, - paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, + crisistypes.ModuleName, + govtypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + group.ModuleName, // additional non simd modules + capabilitytypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, icatypes.ModuleName, @@ -706,11 +788,13 @@ func NewWasmApp( // NOTE: wasm module should be at the end as it can call other module functionality direct or via message dispatching during // genesis phase. For example bank transfer, auth account check, staking, ... genesisModuleOrder := []string{ - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, + capabilitytypes.ModuleName, + // simd modules + authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, - vestingtypes.ModuleName, consensusparamtypes.ModuleName, + vestingtypes.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName, // additional non simd modules ibctransfertypes.ModuleName, ibcexported.ModuleName, @@ -727,7 +811,10 @@ func NewWasmApp( app.ModuleManager.RegisterInvariants(app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.ModuleManager.RegisterServices(app.configurator) + err = app.ModuleManager.RegisterServices(app.configurator) + if err != nil { + panic(err) + } // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. @@ -764,7 +851,7 @@ func NewWasmApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.setAnteHandler(encodingConfig.TxConfig, wasmConfig, keys[wasmtypes.StoreKey]) + app.setAnteHandler(txConfig, wasmConfig, keys[wasmtypes.StoreKey]) // must be before Loading version // requires the snapshot store to be created and registered as a BaseAppOption @@ -804,23 +891,35 @@ func NewWasmApp( // upgrade. app.setPostHandler() + // At startup, after all modules have been registered, check that all proto + // annotations are correct. + protoFiles, err := proto.MergedRegistry() + if err != nil { + panic(err) + } + err = msgservice.ValidateProtoAnnotations(protoFiles) + if err != nil { + // Once we switch to using protoreflect-based antehandlers, we might + // want to panic here instead of logging a warning. + _, _ = fmt.Fprintln(os.Stderr, err.Error()) + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { - logger.Error("error on loading last version", "err", err) - os.Exit(1) + panic(fmt.Errorf("error loading last version: %w", err)) } ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) // Initialize pinned codes in wasmvm as they are not persisted there if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil { - tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) + panic(fmt.Sprintf("failed initialize pinned codes %s", err)) } } return app } -func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey storetypes.StoreKey) { +func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey *storetypes.KVStoreKey) { anteHandler, err := NewAnteHandler( HandlerOptions{ HandlerOptions: ante.HandlerOptions{ @@ -830,10 +929,11 @@ func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtype FeegrantKeeper: app.FeeGrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - IBCKeeper: app.IBCKeeper, - WasmConfig: &wasmConfig, - TXCounterStoreKey: txCounterStoreKey, - WasmKeeper: &app.WasmKeeper, + IBCKeeper: app.IBCKeeper, + WasmConfig: &wasmConfig, + WasmKeeper: &app.WasmKeeper, + TXCounterStoreService: runtime.NewKVStoreService(txCounterStoreKey), + CircuitKeeper: &app.CircuitKeeper, }, ) if err != nil { @@ -857,27 +957,31 @@ func (app *WasmApp) setPostHandler() { func (app *WasmApp) Name() string { return app.BaseApp.Name() } // BeginBlocker application updates every begin block -func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.ModuleManager.BeginBlock(ctx, req) +func (app *WasmApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.ModuleManager.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *WasmApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.ModuleManager.EndBlock(ctx, req) +func (app *WasmApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.ModuleManager.EndBlock(ctx) } -func (app *WasmApp) Configurator() module.Configurator { - return app.configurator +func (a *WasmApp) Configurator() module.Configurator { + return a.configurator } // InitChainer application update at chain initialization -func (app *WasmApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *WasmApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) - return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) + err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + if err != nil { + panic(err) + } + response, err := app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) + return response, err } // LoadHeight loads a particular height @@ -911,9 +1015,30 @@ func (app *WasmApp) TxConfig() client.TxConfig { return app.txConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *WasmApp) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.ModuleManager.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.ModuleManager.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. -func (app *WasmApp) DefaultGenesis() map[string]json.RawMessage { - return ModuleBasics.DefaultGenesis(app.appCodec) +func (a *WasmApp) DefaultGenesis() map[string]json.RawMessage { + return a.BasicModuleManager.DefaultGenesis(a.appCodec) } // GetKey returns the KVStoreKey for the provided store key. @@ -923,6 +1048,18 @@ func (app *WasmApp) GetKey(storeKey string) *storetypes.KVStoreKey { return app.keys[storeKey] } +// GetStoreKeys returns all the stored store keys. +func (app *WasmApp) GetStoreKeys() []storetypes.StoreKey { + keys := make([]storetypes.StoreKey, 0, len(app.keys)) + for _, key := range app.keys { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return keys[i].Name() < keys[j].Name() + }) + return keys +} + // GetTKey returns the TransientStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. @@ -957,14 +1094,14 @@ func (app *WasmApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICo // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register new CometBFT queries routes from grpc-gateway. + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register node gRPC service for grpc-gateway. nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc-gateway routes for all modules. - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil { @@ -979,16 +1116,17 @@ func (app *WasmApp) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *WasmApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService( + cmtApp := server.NewCometABCIWrapper(app) + cmtservice.RegisterTendermintService( clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, - app.Query, + cmtApp.Query, ) } -func (app *WasmApp) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *WasmApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // GetMaccPerms returns a copy of the module account permissions diff --git a/app/app_test.go b/app/app_test.go index 6dfc76942d..c363a847f8 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -1,15 +1,18 @@ package app import ( - "os" "testing" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" + abci "github.com/cometbft/cometbft/abci/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" + "cosmossdk.io/log" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) @@ -18,16 +21,25 @@ var emptyWasmOpts []wasmkeeper.Option func TestWasmdExport(t *testing.T) { db := dbm.NewMemDB() + logger := log.NewTestLogger(t) gapp := NewWasmAppWithCustomOptions(t, false, SetupOptions{ - Logger: log.NewTMLogger(log.NewSyncWriter(os.Stdout)), + Logger: logger.With("instance", "first"), DB: db, AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), }) - gapp.Commit() + + // finalize block so we have CheckTx state set + _, err := gapp.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: 1, + }) + require.NoError(t, err) + + _, err = gapp.Commit() + require.NoError(t, err) // Making a new app object with the db, so that initchain hasn't been called - newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts) - _, err := newGapp.ExportAppStateAndValidators(false, []string{}, nil) + newGapp := NewWasmApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts) + _, err = newGapp.ExportAppStateAndValidators(false, []string{}, nil) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } @@ -52,3 +64,18 @@ func TestGetMaccPerms(t *testing.T) { dup := GetMaccPerms() require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions") } + +// TestMergedRegistry tests that fetching the gogo/protov2 merged registry +// doesn't fail after loading all file descriptors. +func TestMergedRegistry(t *testing.T) { + r, err := proto.MergedRegistry() + require.NoError(t, err) + require.Greater(t, r.NumFiles(), 0) +} + +func TestProtoAnnotations(t *testing.T) { + r, err := proto.MergedRegistry() + require.NoError(t, err) + err = msgservice.ValidateProtoAnnotations(r) + require.NoError(t, err) +} diff --git a/app/encoding.go b/app/encoding.go index 5416f77a97..3bf0c656c0 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,17 +1,33 @@ package app import ( - "github.com/cosmos/cosmos-sdk/std" + "testing" + + dbm "github.com/cosmos/cosmos-db" + + "cosmossdk.io/log" + + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/CosmWasm/wasmd/app/params" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) -// MakeEncodingConfig creates a new EncodingConfig with all modules registered -func MakeEncodingConfig() params.EncodingConfig { - encodingConfig := params.MakeEncodingConfig() - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) +// MakeEncodingConfig creates a new EncodingConfig with all modules registered. For testing only +func MakeEncodingConfig(t testing.TB) params.EncodingConfig { + t.Helper() + // we "pre"-instantiate the application for getting the injected/configured encoding configuration + // note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go) + tempApp := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), []wasmkeeper.Option{}) + return makeEncodingConfig(tempApp) +} + +func makeEncodingConfig(tempApp *WasmApp) params.EncodingConfig { + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: tempApp.InterfaceRegistry(), + Codec: tempApp.AppCodec(), + TxConfig: tempApp.TxConfig(), + Amino: tempApp.LegacyAmino(), + } return encodingConfig } diff --git a/app/export.go b/app/export.go index f7232cc2bd..8209597c8c 100644 --- a/app/export.go +++ b/app/export.go @@ -5,7 +5,9 @@ import ( "fmt" "log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + + storetypes "cosmossdk.io/store/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,17 +20,21 @@ import ( // file. func (app *WasmApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which - // Tendermint will start InitChain. + // CometBFT will start InitChain. height := app.LastBlockHeight() + 1 if forZeroHeight { height = 0 app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + genState, err := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + if err != nil { + return servertypes.ExportedApp{}, err + } + appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err @@ -71,13 +77,24 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ /* Handle fee distribution state. */ // withdraw all validator commission - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } + _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) return false }) + if err != nil { + panic(err) + } // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) + dels, err := app.StakingKeeper.GetAllDelegations(ctx) + if err != nil { + panic(err) + } + for _, delegation := range dels { valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) if err != nil { @@ -102,18 +119,33 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) + scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) + if err != nil { + panic(err) + } + feePool, err := app.DistrKeeper.FeePool.Get(ctx) + if err != nil { + panic(err) + } feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) + if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { + panic(err) + } - if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil { + if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil { panic(err) } return false }) + if err != nil { + panic(err) + } // reinitialize all delegations for _, del := range dels { @@ -140,33 +172,44 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ /* Handle staking state. */ // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } - app.StakingKeeper.SetRedelegation(ctx, red) + err = app.StakingKeeper.SetRedelegation(ctx, red) + if err != nil { + panic(err) + } return false }) + if err != nil { + panic(err) + } // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } - app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + if err != nil { + panic(err) + } return false }) + if err != nil { + panic(err) + } // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) - counter := int16(0) + iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key())) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { + validator, err := app.StakingKeeper.GetValidator(ctx, addr) + if err != nil { panic("expected validator, not found") } @@ -175,8 +218,10 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ validator.Jailed = true } - app.StakingKeeper.SetValidator(ctx, validator) - counter++ + err = app.StakingKeeper.SetValidator(ctx, validator) + if err != nil { + panic(err) + } } if err := iter.Close(); err != nil { @@ -184,7 +229,7 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ return } - _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) + _, err = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) if err != nil { log.Fatal(err) } @@ -192,12 +237,17 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ /* Handle slashing state. */ // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( + err = app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + if err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info); err != nil { + panic(err) + } return false }, ) + if err != nil { + panic(err) + } } diff --git a/app/genesis.go b/app/genesis.go index 2900679c12..1aa0f67001 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -2,8 +2,15 @@ package app import ( "encoding/json" + "testing" - "github.com/cosmos/cosmos-sdk/codec" + dbm "github.com/cosmos/cosmos-db" + + "cosmossdk.io/log" + + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) // GenesisState of the blockchain is represented here as a map of raw json @@ -16,6 +23,11 @@ import ( type GenesisState map[string]json.RawMessage // NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { - return ModuleBasics.DefaultGenesis(cdc) +// Deprecated: use wasmApp.DefaultGenesis() instead +func NewDefaultGenesisState(t *testing.T) GenesisState { + t.Helper() + // we "pre"-instantiate the application for getting the injected/configured encoding configuration + // note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go) + tempApp := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), []wasmkeeper.Option{}) + return tempApp.DefaultGenesis() } diff --git a/app/params/proto.go b/app/params/proto.go index 1855c43538..b7045084b8 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -1,21 +1,41 @@ package params import ( + "github.com/cosmos/gogoproto/proto" + + "cosmossdk.io/x/tx/signing" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/tx" ) // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. func MakeEncodingConfig() EncodingConfig { amino := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() - codec := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(codec, tx.DefaultSignModes) + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + if err != nil { + panic(err) + } + + marshaler := codec.NewProtoCodec(interfaceRegistry) + txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Codec: codec, + Codec: marshaler, TxConfig: txCfg, Amino: amino, } diff --git a/app/sim_test.go b/app/sim_test.go index 259bef1481..94fa34e66e 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -2,35 +2,31 @@ package app import ( "encoding/json" + "flag" "fmt" "os" "runtime/debug" "strings" "testing" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/log" + "cosmossdk.io/store" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/feegrant" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/simulation" simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -42,15 +38,12 @@ import ( // SimAppChainID hardcoded chainID for simulation const SimAppChainID = "simulation-app" +var FlagEnableStreamingValue bool + // Get flags every time the simulator is run func init() { simcli.GetSimulatorFlags() -} - -type StoreKeysPrefixes struct { - A storetypes.StoreKey - B storetypes.StoreKey - Prefixes [][]byte + flag.BoolVar(&FlagEnableStreamingValue, "EnableStreaming", false, "Enable streaming service") } // fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of @@ -133,58 +126,70 @@ func TestAppImportExport(t *testing.T) { newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "WasmApp", newApp.Name()) - var genesisState GenesisState - err = json.Unmarshal(exported.AppState, &genesisState) - require.NoError(t, err) + initReq := &abci.RequestInitChain{ + AppStateBytes: exported.AppState, + } - defer func() { - if r := recover(); r != nil { - err := fmt.Sprintf("%v", r) - if !strings.Contains(err, "validator set is empty after InitGenesis") { - panic(r) - } + ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) + ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) + _, err = newApp.InitChainer(ctxB, initReq) + + if err != nil { + if strings.Contains(err.Error(), "validator set is empty after InitGenesis") { t.Log("Skipping simulation as all validators have been unbonded") t.Logf("err: %s stacktrace: %s\n", err, string(debug.Stack())) + return } - }() + } - ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) - ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) - newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState) - newApp.StoreConsensusParams(ctxB, exported.ConsensusParams) + require.NoError(t, err) + err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams) + require.NoError(t, err) t.Log("comparing stores...") - storeKeysPrefixes := []StoreKeysPrefixes{ - {app.GetKey(wasmtypes.StoreKey), newApp.GetKey(wasmtypes.StoreKey), [][]byte{wasmtypes.TXCounterPrefix}}, - {app.GetKey(authtypes.StoreKey), newApp.GetKey(authtypes.StoreKey), [][]byte{}}, - { - app.GetKey(stakingtypes.StoreKey), newApp.GetKey(stakingtypes.StoreKey), - [][]byte{ - stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, - stakingtypes.HistoricalInfoKey, stakingtypes.UnbondingIDKey, stakingtypes.UnbondingIndexKey, stakingtypes.UnbondingTypeKey, stakingtypes.ValidatorUpdatesKey, - }, - }, // ordering may change but it doesn't matter - {app.GetKey(slashingtypes.StoreKey), newApp.GetKey(slashingtypes.StoreKey), [][]byte{}}, - {app.GetKey(minttypes.StoreKey), newApp.GetKey(minttypes.StoreKey), [][]byte{}}, - {app.GetKey(distrtypes.StoreKey), newApp.GetKey(distrtypes.StoreKey), [][]byte{}}, - {app.GetKey(banktypes.StoreKey), newApp.GetKey(banktypes.StoreKey), [][]byte{banktypes.BalancesPrefix}}, - {app.GetKey(paramtypes.StoreKey), newApp.GetKey(paramtypes.StoreKey), [][]byte{}}, - {app.GetKey(govtypes.StoreKey), newApp.GetKey(govtypes.StoreKey), [][]byte{}}, - {app.GetKey(evidencetypes.StoreKey), newApp.GetKey(evidencetypes.StoreKey), [][]byte{}}, - {app.GetKey(capabilitytypes.StoreKey), newApp.GetKey(capabilitytypes.StoreKey), [][]byte{}}, - {app.GetKey(authzkeeper.StoreKey), newApp.GetKey(authzkeeper.StoreKey), [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}}, + // skip certain prefixes + skipPrefixes := map[string][][]byte{ + stakingtypes.StoreKey: { + stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, + stakingtypes.HistoricalInfoKey, stakingtypes.UnbondingIDKey, stakingtypes.UnbondingIndexKey, + stakingtypes.UnbondingTypeKey, stakingtypes.ValidatorUpdatesKey, + }, + authzkeeper.StoreKey: {authzkeeper.GrantQueuePrefix}, + feegrant.StoreKey: {feegrant.FeeAllowanceQueueKeyPrefix}, + slashingtypes.StoreKey: {slashingtypes.ValidatorMissedBlockBitmapKeyPrefix}, + wasmtypes.StoreKey: {wasmtypes.TXCounterPrefix}, } - for _, skp := range storeKeysPrefixes { - storeA := ctxA.KVStore(skp.A) - storeB := ctxB.KVStore(skp.B) - require.NotNil(t, storeA) - require.NotNil(t, storeB) - failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes) - require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare") + storeKeys := app.GetStoreKeys() + require.NotEmpty(t, storeKeys) + + for _, appKeyA := range storeKeys { + // only compare kvstores + if _, ok := appKeyA.(*storetypes.KVStoreKey); !ok { + continue + } - t.Logf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B) - require.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) + keyName := appKeyA.Name() + appKeyB := newApp.GetKey(keyName) + + storeA := ctxA.KVStore(appKeyA) + storeB := ctxB.KVStore(appKeyB) + + failedKVAs, failedKVBs := simtestutil.DiffKVStores(storeA, storeB, skipPrefixes[keyName]) + if !assert.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare in %q", keyName) { + for _, v := range failedKVBs { + t.Logf("store missmatch: %q\n", v) + } + t.FailNow() + } + + t.Logf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), appKeyA, appKeyB) + if !assert.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(keyName, app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) { + for _, v := range failedKVAs { + t.Logf("store missmatch: %q\n", v) + } + t.FailNow() + } } } @@ -236,10 +241,11 @@ func TestAppSimulationAfterImport(t *testing.T) { newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "WasmApp", newApp.Name()) - newApp.InitChain(abci.RequestInitChain{ + _, err = newApp.InitChain(&abci.RequestInitChain{ ChainId: SimAppChainID, AppStateBytes: exported.AppState, }) + require.NoError(t, err) _, _, err = simulation.SimulateFromSeed( t, @@ -256,7 +262,6 @@ func TestAppSimulationAfterImport(t *testing.T) { } func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simtestutil.AppOptionsMap, *WasmApp) { - t.Helper() config := simcli.NewConfigFromFlags() config.ChainID = SimAppChainID @@ -295,20 +300,33 @@ func TestAppStateDeterminism(t *testing.T) { config.ChainID = SimAppChainID numSeeds := 3 - numTimesToRunPerSeed := 5 + numTimesToRunPerSeed := 3 // This used to be set to 5, but we've temporarily reduced it to 3 for the sake of faster CI. appHashList := make([]json.RawMessage, numTimesToRunPerSeed) - appOptions := make(simtestutil.AppOptionsMap, 0) - appOptions[flags.FlagHome] = t.TempDir() // ensure a unique folder - appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue + // We will be overriding the random seed and just run a single simulation on the provided seed value + if config.Seed != simcli.DefaultSeedValue { + numSeeds = 1 + } + + appOptions := viper.New() + if FlagEnableStreamingValue { + m := make(map[string]interface{}) + m["streaming.abci.keys"] = []string{"*"} + m["streaming.abci.plugin"] = "abci_v1" + m["streaming.abci.stop-node-on-err"] = true + for key, value := range m { + appOptions.SetDefault(key, value) + } + } + appOptions.SetDefault(flags.FlagHome, t.TempDir()) // ensure a unique folder + appOptions.SetDefault(server.FlagInvCheckPeriod, simcli.FlagPeriodValue) for i := 0; i < numSeeds; i++ { config.Seed += int64(i) - for j := 0; j < numTimesToRunPerSeed; j++ { var logger log.Logger if simcli.FlagVerboseValue { - logger = log.TestingLogger() + logger = log.NewTestLogger(t) } else { logger = log.NewNopLogger() } diff --git a/app/test_helpers.go b/app/test_helpers.go index 5963ee378d..ca61d3d3e4 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -9,15 +9,17 @@ import ( "testing" "time" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtjson "github.com/cometbft/cometbft/libs/json" + cmttypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - "cosmossdk.io/math" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + pruningtypes "cosmossdk.io/store/pruning/types" + "cosmossdk.io/store/snapshots" + snapshottypes "cosmossdk.io/store/snapshots/types" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -29,9 +31,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/snapshots" - snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" - pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "github.com/cosmos/cosmos-sdk/testutil/mock" "github.com/cosmos/cosmos-sdk/testutil/network" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -54,24 +53,23 @@ type SetupOptions struct { WasmOpts []wasmkeeper.Option } -func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*WasmApp, GenesisState) { - tb.Helper() +func setup(t testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*WasmApp, GenesisState) { db := dbm.NewMemDB() - nodeHome := tb.TempDir() + nodeHome := t.TempDir() snapshotDir := filepath.Join(nodeHome, "data", "snapshots") snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir) - require.NoError(tb, err) - tb.Cleanup(func() { snapshotDB.Close() }) + require.NoError(t, err) + t.Cleanup(func() { snapshotDB.Close() }) snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) - require.NoError(tb, err) + require.NoError(t, err) appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = nodeHome // ensure unique folder appOptions[server.FlagInvCheckPeriod] = invCheckPeriod app := NewWasmApp(log.NewNopLogger(), db, nil, true, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2})) if withGenesis { - return app, NewDefaultGenesisState(app.AppCodec()) + return app, app.DefaultGenesis() } return app, GenesisState{} } @@ -84,35 +82,35 @@ func NewWasmAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOpti pubKey, err := privVal.GetPubKey() require.NoError(t, err) // create validator set with single validator - validator := tmtypes.NewValidator(pubKey, 1) - valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + validator := cmttypes.NewValidator(pubKey, 1) + valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator}) // generate genesis account senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := NewWasmApp(options.Logger, options.DB, nil, true, options.AppOpts, options.WasmOpts) - genesisState := NewDefaultGenesisState(app.appCodec) + genesisState := app.DefaultGenesis() genesisState, err = GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) require.NoError(t, err) if !isCheckTx { // init chain must be called to stop deliverState from being nil - stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") + stateBytes, err := cmtjson.MarshalIndent(genesisState, "", " ") require.NoError(t, err) // Initialize the chain - app.InitChain( - abci.RequestInitChain{ + _, err = app.InitChain( + &abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: simtestutil.DefaultConsensusParams, AppStateBytes: stateBytes, - }, - ) + }) + require.NoError(t, err) } return app @@ -127,15 +125,15 @@ func Setup(t *testing.T, opts ...wasmkeeper.Option) *WasmApp { require.NoError(t, err) // create validator set with single validator - validator := tmtypes.NewValidator(pubKey, 1) - valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + validator := cmttypes.NewValidator(pubKey, 1) + valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator}) // generate genesis account senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } chainID := "testing" app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, chainID, opts, balance) @@ -147,7 +145,14 @@ func Setup(t *testing.T, opts ...wasmkeeper.Option) *WasmApp { // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit in the default token of the WasmApp from first genesis // account. A Nop logger is set in WasmApp. -func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) *WasmApp { +func SetupWithGenesisValSet( + t *testing.T, + valSet *cmttypes.ValidatorSet, + genAccs []authtypes.GenesisAccount, + chainID string, + opts []wasmkeeper.Option, + balances ...banktypes.Balance, +) *WasmApp { t.Helper() app, genesisState := setup(t, chainID, true, 5, opts...) @@ -160,47 +165,36 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs // init chain will set the validator set and initialize the genesis accounts consensusParams := simtestutil.DefaultConsensusParams consensusParams.Block.MaxGas = 100 * simtestutil.DefaultGenTxGas - app.InitChain( - abci.RequestInitChain{ - ChainId: chainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: consensusParams, - AppStateBytes: stateBytes, - }, - ) - // commit genesis changes - app.Commit() + _, err = app.InitChain(&abci.RequestInitChain{ + ChainId: chainID, + Time: time.Now().UTC(), + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: consensusParams, + InitialHeight: app.LastBlockHeight() + 1, + AppStateBytes: stateBytes, + }) + require.NoError(t, err) votes := make([]abci.VoteInfo, len(valSet.Validators)) for i, v := range valSet.Validators { votes[i] = abci.VoteInfo{ - Validator: abci.Validator{Address: v.Address, Power: v.VotingPower}, - SignedLastBlock: true, + Validator: abci.Validator{Address: v.Address, Power: v.VotingPower}, } } - app.BeginBlock(abci.RequestBeginBlock{ - Header: tmproto.Header{ - ChainID: chainID, - Height: app.LastBlockHeight() + 1, - AppHash: app.LastCommitID().Hash, - Time: time.Now().UTC(), - ValidatorsHash: valSet.Hash(), - NextValidatorsHash: valSet.Hash(), - }, - LastCommitInfo: abci.CommitInfo{ - Votes: votes, - }, + _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: app.LastBlockHeight() + 1, + Hash: app.LastCommitID().Hash, + NextValidatorsHash: valSet.Hash(), }) + require.NoError(t, err) return app } // SetupWithEmptyStore set up a wasmd app instance with empty DB -func SetupWithEmptyStore(tb testing.TB) *WasmApp { - tb.Helper() - - app, _ := setup(tb, "testing", false, 0) +func SetupWithEmptyStore(t testing.TB) *WasmApp { + app, _ := setup(t, "testing", false, 0) return app } @@ -214,8 +208,8 @@ func GenesisStateWithSingleValidator(t *testing.T, app *WasmApp) GenesisState { require.NoError(t, err) // create validator set with single validator - validator := tmtypes.NewValidator(pubKey, 1) - valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + validator := cmttypes.NewValidator(pubKey, 1) + valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator}) // generate genesis account senderPrivKey := secp256k1.GenPrivKey() @@ -223,11 +217,11 @@ func GenesisStateWithSingleValidator(t *testing.T, app *WasmApp) GenesisState { balances := []banktypes.Balance{ { Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), }, } - genesisState := NewDefaultGenesisState(app.appCodec) + genesisState := app.DefaultGenesis() genesisState, err = GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) require.NoError(t, err) @@ -236,14 +230,18 @@ func GenesisStateWithSingleValidator(t *testing.T, app *WasmApp) GenesisState { // AddTestAddrsIncremental constructs and returns accNum amount of accounts with an // initial balance of accAmt in random order -func AddTestAddrsIncremental(app *WasmApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress { +func AddTestAddrsIncremental(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int) []sdk.AccAddress { return addTestAddrs(app, ctx, accNum, accAmt, simtestutil.CreateIncrementalAccounts) } -func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt math.Int, strategy simtestutil.GenerateAccountStrategy) []sdk.AccAddress { +func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int, strategy simtestutil.GenerateAccountStrategy) []sdk.AccAddress { testAddrs := strategy(accNum) - initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt)) + denom, err := app.StakingKeeper.BondDenom(ctx) + if err != nil { + panic(err) + } + initCoins := sdk.NewCoins(sdk.NewCoin(denom, accAmt)) for _, addr := range testAddrs { initAccountWithCoins(app, ctx, addr, initCoins) @@ -295,7 +293,7 @@ func NewTestNetworkFixture() network.TestFixture { return network.TestFixture{ AppConstructor: appCtr, - GenesisState: NewDefaultGenesisState(app.AppCodec()), + GenesisState: app.DefaultGenesis(), EncodingConfig: testutil.TestEncodingConfig{ InterfaceRegistry: app.InterfaceRegistry(), Codec: app.AppCodec(), @@ -306,11 +304,7 @@ func NewTestNetworkFixture() network.TestFixture { } // SignAndDeliverWithoutCommit signs and delivers a transaction. No commit -func SignAndDeliverWithoutCommit( - t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, fees sdk.Coins, - chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey, -) (sdk.GasInfo, *sdk.Result, error) { - t.Helper() +func SignAndDeliverWithoutCommit(t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, fees sdk.Coins, chainID string, accNums, accSeqs []uint64, blockTime time.Time, priv ...cryptotypes.PrivKey) (*abci.ResponseFinalizeBlock, error) { tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), txCfg, @@ -324,13 +318,14 @@ func SignAndDeliverWithoutCommit( ) require.NoError(t, err) - // Simulate a sending a transaction and committing a block - // app.BeginBlock(abci.RequestBeginBlock{Header: header}) - gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx) - // app.EndBlock(abci.RequestEndBlock{}) - // app.Commit() + bz, err := txCfg.TxEncoder()(tx) + require.NoError(t, err) - return gInfo, res, err + return app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: app.LastBlockHeight() + 1, + Time: blockTime, + Txs: [][]byte{bz}, + }) } // GenesisStateWithValSet returns a new genesis state with the validator set @@ -338,7 +333,7 @@ func SignAndDeliverWithoutCommit( func GenesisStateWithValSet( codec codec.Codec, genesisState map[string]json.RawMessage, - valSet *tmtypes.ValidatorSet, + valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance, ) (map[string]json.RawMessage, error) { @@ -352,7 +347,7 @@ func GenesisStateWithValSet( bondAmt := sdk.DefaultPowerReduction for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey) if err != nil { return nil, fmt.Errorf("failed to convert pubkey: %w", err) } @@ -368,15 +363,16 @@ func GenesisStateWithValSet( Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: math.LegacyOneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()), - MinSelfDelegation: math.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), math.LegacyOneDec())) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), sdkmath.LegacyOneDec())) + } // set validators and delegations diff --git a/app/test_support.go b/app/test_support.go index ac9cd2865b..33bbffadc2 100644 --- a/app/test_support.go +++ b/app/test_support.go @@ -1,12 +1,12 @@ package app import ( - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" "github.com/cosmos/cosmos-sdk/baseapp" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" diff --git a/app/upgrades.go b/app/upgrades.go index 775e28bf45..992621cae0 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -1,91 +1,26 @@ package app import ( - icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "context" - "github.com/cosmos/cosmos-sdk/baseapp" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/types/module" ) // UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade -// from v046 to v047. +// from v047 to v050. // // NOTE: This upgrade defines a reference implementation of what an upgrade // could look like when an application is migrating from Cosmos SDK version -// v0.46.x to v0.47.x. -const UpgradeName = "v046-to-v047" +// v0.47.x to v0.50.x. +const UpgradeName = "v047-to-v050" func (app WasmApp) RegisterUpgradeHandlers() { - // Set param key table for params module migration - for _, subspace := range app.ParamsKeeper.GetSubspaces() { - subspace := subspace - - var keyTable paramstypes.KeyTable - switch subspace.Name() { - case authtypes.ModuleName: - keyTable = authtypes.ParamKeyTable() //nolint:staticcheck - case banktypes.ModuleName: - keyTable = banktypes.ParamKeyTable() //nolint:staticcheck - case stakingtypes.ModuleName: - keyTable = stakingtypes.ParamKeyTable() - case minttypes.ModuleName: - keyTable = minttypes.ParamKeyTable() //nolint:staticcheck - case distrtypes.ModuleName: - keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck - case slashingtypes.ModuleName: - keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck - case govtypes.ModuleName: - keyTable = govv1.ParamKeyTable() //nolint:staticcheck - case crisistypes.ModuleName: - keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck - // ibc types - case ibctransfertypes.ModuleName: - keyTable = ibctransfertypes.ParamKeyTable() - case icahosttypes.SubModuleName: - keyTable = icahosttypes.ParamKeyTable() - case icacontrollertypes.SubModuleName: - keyTable = icacontrollertypes.ParamKeyTable() - // wasm - case wasmtypes.ModuleName: - keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck - default: - continue - } - - if !subspace.HasKeyTable() { - subspace.WithKeyTable(keyTable) - } - } - - baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - app.UpgradeKeeper.SetUpgradeHandler( UpgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. - baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) - - // Note: this migration is optional, - // You can include x/gov proposal migration documented in [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md) - + func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) }, ) @@ -96,12 +31,7 @@ func (app WasmApp) RegisterUpgradeHandlers() { } if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{ - consensustypes.ModuleName, - crisistypes.ModuleName, - }, - } + storeUpgrades := storetypes.StoreUpgrades{} // configure store loader that checks if version == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 4d3e2b87df..a5bb6ac557 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -7,13 +7,15 @@ import ( "testing" "time" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -32,31 +34,32 @@ import ( ) func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*app.WasmApp, app.GenesisState) { //nolint:unparam - wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.EmptyAppOptions{}, nil) + + logLevel := log.LevelOption(zerolog.InfoLevel) + + wasmApp := app.NewWasmApp(log.NewLogger(os.Stdout, logLevel), db, nil, true, simtestutil.EmptyAppOptions{}, nil) if withGenesis { - return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec()) + return wasmApp, wasmApp.DefaultGenesis() } return wasmApp, app.GenesisState{} } // SetupWithGenesisAccountsAndValSet initializes a new WasmApp with the provided genesis // accounts and possible balances. -func SetupWithGenesisAccountsAndValSet(tb testing.TB, db dbm.DB, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *app.WasmApp { - tb.Helper() - +func SetupWithGenesisAccountsAndValSet(b testing.TB, db dbm.DB, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *app.WasmApp { wasmApp, genesisState := setup(db, true, 0) authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) appCodec := wasmApp.AppCodec() privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() - require.NoError(tb, err) + require.NoError(b, err) genesisState[authtypes.ModuleName] = appCodec.MustMarshalJSON(authGenesis) - validator := tmtypes.NewValidator(pubKey, 1) - valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + validator := cmtypes.NewValidator(pubKey, 1) + valSet := cmtypes.NewValidatorSet([]*cmtypes.Validator{validator}) validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) @@ -64,7 +67,7 @@ func SetupWithGenesisAccountsAndValSet(tb testing.TB, db dbm.DB, genAccs []autht bondAmt := sdk.DefaultPowerReduction for _, val := range valSet.Validators { - pk, _ := cryptocodec.FromTmPubKeyInterface(val.PubKey) + pk, _ := cryptocodec.FromCmtPubKeyInterface(val.PubKey) pkAny, _ := codectypes.NewAnyWithValue(pk) validator := stakingtypes.Validator{ OperatorAddress: sdk.ValAddress(val.Address).String(), @@ -72,17 +75,17 @@ func SetupWithGenesisAccountsAndValSet(tb testing.TB, db dbm.DB, genAccs []autht Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), sdkmath.LegacyOneDec())) } + // set validators and delegations stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) genesisState[stakingtypes.ModuleName] = appCodec.MustMarshalJSON(stakingGenesis) @@ -110,16 +113,16 @@ func SetupWithGenesisAccountsAndValSet(tb testing.TB, db dbm.DB, genAccs []autht consensusParams := simtestutil.DefaultConsensusParams consensusParams.Block.MaxGas = 100 * simtestutil.DefaultGenTxGas - wasmApp.InitChain( - abci.RequestInitChain{ + _, err = wasmApp.InitChain( + &abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: consensusParams, AppStateBytes: stateBytes, }, ) - - wasmApp.Commit() - wasmApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: wasmApp.LastBlockHeight() + 1}}) + require.NoError(b, err) + _, err = wasmApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: wasmApp.LastBlockHeight() + 1}) + require.NoError(b, err) return wasmApp } @@ -135,9 +138,7 @@ type AppInfo struct { TxConfig client.TxConfig } -func InitializeWasmApp(tb testing.TB, db dbm.DB, numAccounts int) AppInfo { - tb.Helper() - +func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo { // constants minter := secp256k1.GenPrivKey() addr := sdk.AccAddress(minter.PubKey().Address()) @@ -166,25 +167,26 @@ func InitializeWasmApp(tb testing.TB, db dbm.DB, numAccounts int) AppInfo { Coins: sdk.NewCoins(sdk.NewInt64Coin(denom, 100000000000)), } } - wasmApp := SetupWithGenesisAccountsAndValSet(tb, db, genAccs, bals...) + wasmApp := SetupWithGenesisAccountsAndValSet(b, db, genAccs, bals...) // add wasm contract - height := int64(2) + height := int64(1) txGen := moduletestutil.MakeTestEncodingConfig().TxConfig - wasmApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height, Time: time.Now()}}) + _, err := wasmApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: height, Time: time.Now()}) + require.NoError(b, err) // upload the code cw20Code, err := os.ReadFile("./testdata/cw20_base.wasm") - require.NoError(tb, err) + require.NoError(b, err) storeMsg := wasmtypes.MsgStoreCode{ Sender: addr.String(), WASMByteCode: cw20Code, } r := rand.New(rand.NewSource(time.Now().UnixNano())) storeTx, err := simtestutil.GenSignedMockTx(r, txGen, []sdk.Msg{&storeMsg}, nil, 55123123, "", []uint64{0}, []uint64{0}, minter) - require.NoError(tb, err) + require.NoError(b, err) _, _, err = wasmApp.SimDeliver(txGen.TxEncoder(), storeTx) - require.NoError(tb, err) + require.NoError(b, err) codeID := uint64(1) // instantiate the contract @@ -206,7 +208,7 @@ func InitializeWasmApp(tb testing.TB, db dbm.DB, numAccounts int) AppInfo { InitialBalances: initialBalances, } initBz, err := json.Marshal(init) - require.NoError(tb, err) + require.NoError(b, err) initMsg := wasmtypes.MsgInstantiateContract{ Sender: addr.String(), Admin: addr.String(), @@ -216,17 +218,18 @@ func InitializeWasmApp(tb testing.TB, db dbm.DB, numAccounts int) AppInfo { } gasWanted := 500000 + 10000*uint64(numAccounts) initTx, err := simtestutil.GenSignedMockTx(r, txGen, []sdk.Msg{&initMsg}, nil, gasWanted, "", []uint64{0}, []uint64{1}, minter) - require.NoError(tb, err) + require.NoError(b, err) _, res, err := wasmApp.SimDeliver(txGen.TxEncoder(), initTx) - require.NoError(tb, err) + require.NoError(b, err) // TODO: parse contract address better evt := res.Events[len(res.Events)-1] attr := evt.Attributes[0] contractAddr := attr.Value - - wasmApp.EndBlock(abci.RequestEndBlock{Height: height}) - wasmApp.Commit() + _, err = wasmApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: height}) + require.NoError(b, err) + _, err = wasmApp.Commit() + require.NoError(b, err) return AppInfo{ App: wasmApp, @@ -240,16 +243,14 @@ func InitializeWasmApp(tb testing.TB, db dbm.DB, numAccounts int) AppInfo { } } -func GenSequenceOfTxs(tb testing.TB, info *AppInfo, msgGen func(*AppInfo) ([]sdk.Msg, error), numToGenerate int) []sdk.Tx { - tb.Helper() - +func GenSequenceOfTxs(b testing.TB, info *AppInfo, msgGen func(*AppInfo) ([]sdk.Msg, error), numToGenerate int) []sdk.Tx { fees := sdk.Coins{sdk.NewInt64Coin(info.Denom, 0)} txs := make([]sdk.Tx, numToGenerate) r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < numToGenerate; i++ { msgs, err := msgGen(info) - require.NoError(tb, err) + require.NoError(b, err) txs[i], err = simtestutil.GenSignedMockTx( r, info.TxConfig, @@ -261,7 +262,7 @@ func GenSequenceOfTxs(tb testing.TB, info *AppInfo, msgGen func(*AppInfo) ([]sdk []uint64{info.SeqNum}, info.MinterKey, ) - require.NoError(tb, err) + require.NoError(b, err) info.SeqNum++ } diff --git a/benchmarks/bench_test.go b/benchmarks/bench_test.go index 003fd11bdd..49aec11da7 100644 --- a/benchmarks/bench_test.go +++ b/benchmarks/bench_test.go @@ -5,9 +5,8 @@ import ( "testing" "time" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" "github.com/syndtr/goleveldb/leveldb/opt" @@ -96,28 +95,24 @@ func BenchmarkTxSending(b *testing.B) { // number of Tx per block for the benchmarks blockSize := tc.blockSize - height := int64(3) + height := int64(2) txEncoder := appInfo.TxConfig.TxEncoder() b.ResetTimer() for i := 0; i < b.N/blockSize; i++ { - appInfo.App.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height, Time: time.Now()}}) - + xxx := make([][]byte, blockSize) for j := 0; j < blockSize; j++ { idx := i*blockSize + j bz, err := txEncoder(txs[idx]) require.NoError(b, err) - rsp := appInfo.App.CheckTx(abci.RequestCheckTx{ - Tx: bz, - Type: abci.CheckTxType_New, - }) - require.True(b, rsp.IsOK()) - dRsp := appInfo.App.DeliverTx(abci.RequestDeliverTx{Tx: bz}) - require.True(b, dRsp.IsOK()) + xxx[j] = bz } - appInfo.App.EndBlock(abci.RequestEndBlock{Height: height}) - appInfo.App.Commit() + _, err := appInfo.App.FinalizeBlock(&abci.RequestFinalizeBlock{Txs: xxx, Height: height, Time: time.Now()}) + require.NoError(b, err) + + _, err = appInfo.App.Commit() + require.NoError(b, err) height++ } }) @@ -153,7 +148,6 @@ func cw20TransferMsg(info *AppInfo) ([]sdk.Msg, error) { func buildTxFromMsg(builder func(info *AppInfo) ([]sdk.Msg, error)) func(b *testing.B, info *AppInfo) []sdk.Tx { return func(b *testing.B, info *AppInfo) []sdk.Tx { - b.Helper() return GenSequenceOfTxs(b, info, builder, b.N) } } @@ -163,7 +157,6 @@ func buildMemDB(_ *testing.B) dbm.DB { } func buildLevelDB(b *testing.B) dbm.DB { - b.Helper() levelDB, err := dbm.NewGoLevelDBWithOpts("testing", b.TempDir(), &opt.Options{BlockCacher: opt.NoCacher}) require.NoError(b, err) return levelDB diff --git a/cmd/wasmd/commands.go b/cmd/wasmd/commands.go new file mode 100644 index 0000000000..ba97b85db1 --- /dev/null +++ b/cmd/wasmd/commands.go @@ -0,0 +1,266 @@ +package main + +import ( + "errors" + "io" + "os" + + cmtcfg "github.com/cometbft/cometbft/config" + dbm "github.com/cosmos/cosmos-db" + "github.com/prometheus/client_golang/prometheus" + "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "cosmossdk.io/log" + confixcmd "cosmossdk.io/tools/confix/cmd" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/debug" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/keys" + "github.com/cosmos/cosmos-sdk/client/pruning" + "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/client/snapshot" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/server" + serverconfig "github.com/cosmos/cosmos-sdk/server/config" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/crisis" + genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + + "github.com/CosmWasm/wasmd/app" + "github.com/CosmWasm/wasmd/x/wasm" + wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" +) + +// initCometBFTConfig helps to override default CometBFT Config values. +// return cmtcfg.DefaultConfig if no custom configuration is required for the application. +func initCometBFTConfig() *cmtcfg.Config { + cfg := cmtcfg.DefaultConfig() + + // these values put a higher strain on node memory + // cfg.P2P.MaxNumInboundPeers = 100 + // cfg.P2P.MaxNumOutboundPeers = 40 + + return cfg +} + +// initAppConfig helps to override default appConfig template and configs. +// return "", nil if no custom configuration is required for the application. +func initAppConfig() (string, interface{}) { + // The following code snippet is just for reference. + + type CustomAppConfig struct { + serverconfig.Config + + Wasm wasmtypes.WasmConfig `mapstructure:"wasm"` + } + + // Optionally allow the chain developer to overwrite the SDK's default + // server config. + srvCfg := serverconfig.DefaultConfig() + // The SDK's default minimum gas price is set to "" (empty value) inside + // app.toml. If left empty by validators, the node will halt on startup. + // However, the chain developer can set a default app.toml value for their + // validators here. + // + // In summary: + // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their + // own app.toml config, + // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their + // own app.toml to override, or use this default value. + // + // In simapp, we set the min gas prices to 0. + srvCfg.MinGasPrices = "0stake" + // srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default + + customAppConfig := CustomAppConfig{ + Config: *srvCfg, + Wasm: wasmtypes.DefaultWasmConfig(), + } + + customAppTemplate := serverconfig.DefaultConfigTemplate + + wasmtypes.DefaultConfigTemplate() + + return customAppTemplate, customAppConfig +} + +func initRootCmd( + rootCmd *cobra.Command, + txConfig client.TxConfig, + interfaceRegistry codectypes.InterfaceRegistry, + appCodec codec.Codec, + basicManager module.BasicManager, +) { + cfg := sdk.GetConfig() + cfg.Seal() + + rootCmd.AddCommand( + genutilcli.InitCmd(basicManager, app.DefaultNodeHome), + NewTestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), + debug.Cmd(), + confixcmd.ConfigCommand(), + pruning.Cmd(newApp, app.DefaultNodeHome), + snapshot.Cmd(newApp), + ) + + server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) + wasmcli.ExtendUnsafeResetAllCmd(rootCmd) + + // add keybase, auxiliary RPC, query, genesis, and tx child commands + rootCmd.AddCommand( + server.StatusCommand(), + genesisCommand(txConfig, basicManager), + queryCommand(), + txCommand(), + keys.Commands(), + ) +} + +func addModuleInitFlags(startCmd *cobra.Command) { + crisis.AddModuleInitFlags(startCmd) + wasm.AddModuleInitFlags(startCmd) +} + +// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter +func genesisCommand(txConfig client.TxConfig, basicManager module.BasicManager, cmds ...*cobra.Command) *cobra.Command { + cmd := genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome) + + for _, subCmd := range cmds { + cmd.AddCommand(subCmd) + } + return cmd +} + +func queryCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "query", + Aliases: []string{"q"}, + Short: "Querying subcommands", + DisableFlagParsing: false, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + rpc.QueryEventForTxCmd(), + server.QueryBlockCmd(), + authcmd.QueryTxsByEventsCmd(), + server.QueryBlocksCmd(), + authcmd.QueryTxCmd(), + server.QueryBlockResultsCmd(), + ) + + return cmd +} + +func txCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "tx", + Short: "Transactions subcommands", + DisableFlagParsing: false, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + authcmd.GetSignCommand(), + authcmd.GetSignBatchCommand(), + authcmd.GetMultiSignCommand(), + authcmd.GetMultiSignBatchCmd(), + authcmd.GetValidateSignaturesCommand(), + authcmd.GetBroadcastCommand(), + authcmd.GetEncodeCommand(), + authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), + ) + + return cmd +} + +// newApp creates the application +func newApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + appOpts servertypes.AppOptions, +) servertypes.Application { + baseappOptions := server.DefaultBaseappOptions(appOpts) + + var wasmOpts []wasmkeeper.Option + if cast.ToBool(appOpts.Get("telemetry.enabled")) { + wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) + } + + return app.NewWasmApp( + logger, db, traceStore, true, + appOpts, + wasmOpts, + baseappOptions..., + ) +} + +// appExport creates a new wasm app (optionally at a given height) and exports state. +func appExport( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + height int64, + forZeroHeight bool, + jailAllowedAddrs []string, + appOpts servertypes.AppOptions, + modulesToExport []string, +) (servertypes.ExportedApp, error) { + var wasmApp *app.WasmApp + // this check is necessary as we use the flag in x/upgrade. + // we can exit more gracefully by checking the flag here. + homePath, ok := appOpts.Get(flags.FlagHome).(string) + if !ok || homePath == "" { + return servertypes.ExportedApp{}, errors.New("application home is not set") + } + + viperAppOpts, ok := appOpts.(*viper.Viper) + if !ok { + return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper") + } + + // overwrite the FlagInvCheckPeriod + viperAppOpts.Set(server.FlagInvCheckPeriod, 1) + appOpts = viperAppOpts + + var emptyWasmOpts []wasmkeeper.Option + wasmApp = app.NewWasmApp( + logger, + db, + traceStore, + height == -1, + appOpts, + emptyWasmOpts, + ) + + if height != -1 { + if err := wasmApp.LoadHeight(height); err != nil { + return servertypes.ExportedApp{}, err + } + } + + return wasmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) +} + +var tempDir = func() string { + dir, err := os.MkdirTemp("", "wasmd") + if err != nil { + panic("failed to create temp dir: " + err.Error()) + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/cmd/wasmd/main.go b/cmd/wasmd/main.go index 3a7719e6cf..af4366beda 100644 --- a/cmd/wasmd/main.go +++ b/cmd/wasmd/main.go @@ -3,22 +3,18 @@ package main import ( "os" - "github.com/cosmos/cosmos-sdk/server" + "cosmossdk.io/log" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/CosmWasm/wasmd/app" ) func main() { - rootCmd, _ := NewRootCmd() + rootCmd := NewRootCmd() if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - - default: - os.Exit(1) - } + log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err) + os.Exit(1) } } diff --git a/cmd/wasmd/root.go b/cmd/wasmd/root.go index b95922095f..7ef9136f93 100644 --- a/cmd/wasmd/root.go +++ b/cmd/wasmd/root.go @@ -1,62 +1,53 @@ package main import ( - "errors" - "io" "os" - dbm "github.com/cometbft/cometbft-db" - tmcfg "github.com/cometbft/cometbft/config" - "github.com/cometbft/cometbft/libs/log" - "github.com/prometheus/client_golang/prometheus" - "github.com/spf13/cast" + dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cobra" - "github.com/spf13/viper" - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" - "github.com/cosmos/cosmos-sdk/client/debug" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/cosmos/cosmos-sdk/client/pruning" - "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" - serverconfig "github.com/cosmos/cosmos-sdk/server/config" - servertypes "github.com/cosmos/cosmos-sdk/server/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/version" - authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/crisis" - genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" "github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/app/params" - "github.com/CosmWasm/wasmd/x/wasm" - wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) // NewRootCmd creates a new root command for wasmd. It is called once in the // main function. -func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeEncodingConfig() - +func NewRootCmd() *cobra.Command { cfg := sdk.GetConfig() cfg.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) cfg.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub) cfg.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub) cfg.SetAddressVerifier(wasmtypes.VerifyAddressLen()) cfg.Seal() + // we "pre"-instantiate the application for getting the injected/configured encoding configuration + // note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go) + tempApp := app.NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir()), []wasmkeeper.Option{}) + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: tempApp.InterfaceRegistry(), + Codec: tempApp.AppCodec(), + TxConfig: tempApp.TxConfig(), + Amino: tempApp.LegacyAmino(), + } initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). @@ -71,6 +62,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { cmd.SetOut(cmd.OutOrStdout()) cmd.SetErr(cmd.ErrOrStderr()) + initClientCtx = initClientCtx.WithCmdContext(cmd.Context()) initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) if err != nil { return err @@ -81,225 +73,42 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfigWithTextual, err := tx.NewTxConfigWithOptions( + codec.NewProtoCodec(encodingConfig.InterfaceRegistry), + txConfigOpts, + ) + if err != nil { + return err + } + initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual) + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } customAppTemplate, customAppConfig := initAppConfig() - customTMConfig := initTendermintConfig() + customCMTConfig := initCometBFTConfig() - return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) + return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customCMTConfig) }, } - initRootCmd(rootCmd, encodingConfig) - - return rootCmd, encodingConfig -} - -// initTendermintConfig helps to override default Tendermint Config values. -// return tmcfg.DefaultConfig if no custom configuration is required for the application. -func initTendermintConfig() *tmcfg.Config { - cfg := tmcfg.DefaultConfig() - - // these values put a higher strain on node memory - // cfg.P2P.MaxNumInboundPeers = 100 - // cfg.P2P.MaxNumOutboundPeers = 40 - - return cfg -} - -// initAppConfig helps to override default appConfig template and configs. -// return "", nil if no custom configuration is required for the application. -func initAppConfig() (string, interface{}) { - // The following code snippet is just for reference. - - type CustomAppConfig struct { - serverconfig.Config - - Wasm wasmtypes.WasmConfig `mapstructure:"wasm"` - } - - // Optionally allow the chain developer to overwrite the SDK's default - // server config. - srvCfg := serverconfig.DefaultConfig() - // The SDK's default minimum gas price is set to "" (empty value) inside - // app.toml. If left empty by validators, the node will halt on startup. - // However, the chain developer can set a default app.toml value for their - // validators here. - // - // In summary: - // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their - // own app.toml config, - // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their - // own app.toml to override, or use this default value. - // - // In simapp, we set the min gas prices to 0. - srvCfg.MinGasPrices = "0stake" - // srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default - - customAppConfig := CustomAppConfig{ - Config: *srvCfg, - Wasm: wasmtypes.DefaultWasmConfig(), - } - - customAppTemplate := serverconfig.DefaultConfigTemplate + - wasmtypes.DefaultConfigTemplate() - - return customAppTemplate, customAppConfig -} - -func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { - rootCmd.AddCommand( - genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), - NewTestnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), - debug.Cmd(), - config.Cmd(), - pruning.PruningCmd(newApp), - ) - - server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) - wasmcli.ExtendUnsafeResetAllCmd(rootCmd) - - // add keybase, auxiliary RPC, query, and tx child commands - rootCmd.AddCommand( - rpc.StatusCommand(), - genesisCommand(encodingConfig), - queryCommand(), - txCommand(), - keys.Commands(app.DefaultNodeHome), - ) - // add rosetta - rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) -} - -func addModuleInitFlags(startCmd *cobra.Command) { - crisis.AddModuleInitFlags(startCmd) - wasm.AddModuleInitFlags(startCmd) -} - -// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter -func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command { - cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, app.ModuleBasics, app.DefaultNodeHome) - - for _, subCmd := range cmds { - cmd.AddCommand(subCmd) - } - return cmd -} - -func queryCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "query", - Aliases: []string{"q"}, - Short: "Querying subcommands", - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand( - authcmd.GetAccountCmd(), - rpc.ValidatorCommand(), - rpc.BlockCommand(), - authcmd.QueryTxsByEventsCmd(), - authcmd.QueryTxCmd(), - ) - - app.ModuleBasics.AddQueryCommands(cmd) - - return cmd -} - -func txCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "tx", - Short: "Transactions subcommands", - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand( - authcmd.GetSignCommand(), - authcmd.GetSignBatchCommand(), - authcmd.GetMultiSignCommand(), - authcmd.GetMultiSignBatchCmd(), - authcmd.GetValidateSignaturesCommand(), - authcmd.GetBroadcastCommand(), - authcmd.GetEncodeCommand(), - authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), - ) - - app.ModuleBasics.AddTxCommands(cmd) - - return cmd -} - -// newApp creates the application -func newApp( - logger log.Logger, - db dbm.DB, - traceStore io.Writer, - appOpts servertypes.AppOptions, -) servertypes.Application { - baseappOptions := server.DefaultBaseappOptions(appOpts) - - var wasmOpts []wasmkeeper.Option - if cast.ToBool(appOpts.Get("telemetry.enabled")) { - wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) - } - - return app.NewWasmApp( - logger, db, traceStore, true, - appOpts, - wasmOpts, - baseappOptions..., - ) -} - -// appExport creates a new wasm app (optionally at a given height) and exports state. -func appExport( - logger log.Logger, - db dbm.DB, - traceStore io.Writer, - height int64, - forZeroHeight bool, - jailAllowedAddrs []string, - appOpts servertypes.AppOptions, - modulesToExport []string, -) (servertypes.ExportedApp, error) { - var wasmApp *app.WasmApp - homePath, ok := appOpts.Get(flags.FlagHome).(string) - if !ok || homePath == "" { - return servertypes.ExportedApp{}, errors.New("application home is not set") - } - - viperAppOpts, ok := appOpts.(*viper.Viper) - if !ok { - return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper") - } - - // overwrite the FlagInvCheckPeriod - viperAppOpts.Set(server.FlagInvCheckPeriod, 1) - appOpts = viperAppOpts + initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, encodingConfig.Codec, tempApp.BasicModuleManager) - var emptyWasmOpts []wasmkeeper.Option - wasmApp = app.NewWasmApp( - logger, - db, - traceStore, - height == -1, - appOpts, - emptyWasmOpts, - ) + // add keyring to autocli opts + autoCliOpts := tempApp.AutoCliOpts() + initClientCtx, _ = config.ReadFromClientConfig(initClientCtx) + autoCliOpts.Keyring = initClientCtx.Keyring - if height != -1 { - if err := wasmApp.LoadHeight(height); err != nil { - return servertypes.ExportedApp{}, err - } + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) } - return wasmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) + return rootCmd } diff --git a/cmd/wasmd/testnet.go b/cmd/wasmd/testnet.go index c1d8dfd0fc..cdfe205a64 100644 --- a/cmd/wasmd/testnet.go +++ b/cmd/wasmd/testnet.go @@ -11,14 +11,13 @@ import ( "path/filepath" "time" - tmconfig "github.com/cometbft/cometbft/config" - tmrand "github.com/cometbft/cometbft/libs/rand" - "github.com/cometbft/cometbft/types" - tmtime "github.com/cometbft/cometbft/types/time" + cmtconfig "github.com/cometbft/cometbft/config" + cmttime "github.com/cometbft/cometbft/types/time" "github.com/spf13/cobra" "github.com/spf13/pflag" "cosmossdk.io/math" + "cosmossdk.io/math/unsafe" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -26,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/testutil" @@ -93,7 +93,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) { // support old flags name for backwards compatibility cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { - if name == "algo" { + if name == flags.FlagKeyAlgorithm { name = flags.FlagKeyType } @@ -118,7 +118,7 @@ func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBala return testnetCmd } -// testnetInitFilesCmd returns a cmd to initialize all files for tendermint testnet and application +// testnetInitFilesCmd returns a cmd to initialize all files for CometBFT testnet and application func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { cmd := &cobra.Command{ Use: "init-files", @@ -160,7 +160,7 @@ Example: return err } - return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, args) + return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, clientCtx.TxConfig.SigningContext().ValidatorAddressCodec(), args) }, } @@ -205,7 +205,7 @@ Example: } addTestnetFlagsToCmd(cmd) - cmd.Flags().Bool(flagEnableLogging, false, "Enable INFO logging of tendermint validator nodes") + cmd.Flags().Bool(flagEnableLogging, false, "Enable INFO logging of CometBFT validator nodes") cmd.Flags().String(flagRPCAddress, "tcp://0.0.0.0:26657", "the RPC address to listen on") cmd.Flags().String(flagAPIAddress, "tcp://0.0.0.0:1317", "the address to listen on for REST API") cmd.Flags().String(flagGRPCAddress, "0.0.0.0:9090", "the gRPC server address to listen on") @@ -219,13 +219,14 @@ const nodeDirPerm = 0o755 func initTestnetFiles( clientCtx client.Context, cmd *cobra.Command, - nodeConfig *tmconfig.Config, + nodeConfig *cmtconfig.Config, mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator, + valAddrCodec runtime.ValidatorAddressCodec, args initArgs, ) error { if args.chainID == "" { - args.chainID = "chain-" + tmrand.Str(6) + args.chainID = "chain-" + unsafe.Str(6) } nodeIDs := make([]string, args.numValidators) valPubKeys := make([]cryptotypes.PubKey, args.numValidators) @@ -244,10 +245,9 @@ func initTestnetFiles( genFiles []string ) const ( - rpcPort = 26657 - apiPort = 1317 - grpcPort = 9090 - grpcWebPort = 8090 + rpcPort = 26657 + apiPort = 1317 + grpcPort = 9090 ) p2pPortStart := 26656 @@ -273,7 +273,7 @@ func initTestnetFiles( appConfig.API.Address = fmt.Sprintf("tcp://0.0.0.0:%d", apiPort+portOffset) appConfig.GRPC.Address = fmt.Sprintf("0.0.0.0:%d", grpcPort+portOffset) - appConfig.GRPCWeb.Address = fmt.Sprintf("0.0.0.0:%d", grpcWebPort+portOffset) + appConfig.GRPCWeb.Enable = true if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil { _ = os.RemoveAll(args.outputDir) @@ -334,9 +334,13 @@ func initTestnetFiles( genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) + valStr, err := valAddrCodec.BytesToString(sdk.ValAddress(addr)) + if err != nil { + return err + } valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction) createValMsg, err := stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(addr), + valStr, valPubKeys[i], sdk.NewCoin(sdk.DefaultBondDenom, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), @@ -361,7 +365,7 @@ func initTestnetFiles( WithKeybase(kb). WithTxConfig(clientCtx.TxConfig) - if err := tx.Sign(txFactory, nodeDirName, txBuilder, true); err != nil { + if err := tx.Sign(cmd.Context(), txFactory, nodeDirName, txBuilder, true); err != nil { return err } @@ -374,6 +378,7 @@ func initTestnetFiles( return err } + srvconfig.SetConfigTemplate(srvconfig.DefaultConfigTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), appConfig) } @@ -383,7 +388,7 @@ func initTestnetFiles( err := collectGenFiles( clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators, - args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator, + args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator, valAddrCodec, rpcPort, p2pPortStart, args.singleMachine, ) if err != nil { @@ -428,15 +433,10 @@ func initGenFiles( return err } - genDoc := types.GenesisDoc{ - ChainID: chainID, - AppState: appGenStateJSON, - Validators: nil, - } - + appGenesis := genutiltypes.NewAppGenesisWithVersion(chainID, appGenStateJSON) // generate empty genesis files for each validator and save for i := 0; i < numValidators; i++ { - if err := genDoc.SaveAs(genFiles[i]); err != nil { + if err := appGenesis.SaveAs(genFiles[i]); err != nil { return err } } @@ -444,14 +444,14 @@ func initGenFiles( } func collectGenFiles( - clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string, + clientCtx client.Context, nodeConfig *cmtconfig.Config, chainID string, nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, - outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, + outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, valAddrCodec runtime.ValidatorAddressCodec, rpcPortStart, p2pPortStart int, singleMachine bool, ) error { var appState json.RawMessage - genTime := tmtime.Now() + genTime := cmttime.Now() for i := 0; i < numValidators; i++ { var portOffset int @@ -471,12 +471,13 @@ func collectGenFiles( nodeID, valPubKey := nodeIDs[i], valPubKeys[i] initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey) - genDoc, err := types.GenesisDocFromFile(nodeConfig.GenesisFile()) + appGenesis, err := genutiltypes.AppGenesisFromFile(nodeConfig.GenesisFile()) if err != nil { return err } - nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator, genutiltypes.DefaultMessageValidator) + nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, appGenesis, genBalIterator, genutiltypes.DefaultMessageValidator, + valAddrCodec) if err != nil { return err } @@ -528,7 +529,7 @@ func writeFile(name, dir string, contents []byte) error { return fmt.Errorf("could not create directory %q: %w", dir, err) } - if err := os.WriteFile(file, contents, 0o644); err != nil { //nolint: gosec + if err := os.WriteFile(file, contents, 0o600); err != nil { return err } @@ -547,7 +548,7 @@ func startTestnet(cmd *cobra.Command, args startArgs) error { networkConfig.SigningAlgo = args.algo networkConfig.MinGasPrices = args.minGasPrices networkConfig.NumValidators = args.numValidators - networkConfig.EnableTMLogging = args.enableLogging + networkConfig.EnableLogging = args.enableLogging networkConfig.RPCAddress = args.rpcAddress networkConfig.APIAddress = args.apiAddress networkConfig.GRPCAddress = args.grpcAddress diff --git a/go.mod b/go.mod index 49b7be519f..250b9ed9c1 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,14 @@ module github.com/CosmWasm/wasmd -go 1.20 +go 1.21 require ( github.com/CosmWasm/wasmvm v1.4.0 - github.com/cosmos/cosmos-proto v1.0.0-beta.2 - github.com/cosmos/cosmos-sdk v0.47.5 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 + github.com/cosmos/cosmos-sdk v0.50.0-rc.0.0.20230921092356-3d9ce99e4eee github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/iavl v0.20.1 - github.com/cosmos/ibc-go/v7 v7.3.0 + github.com/cosmos/gogoproto v1.4.11 + github.com/cosmos/iavl v1.0.0-rc.1 github.com/cosmos/ics23/go v0.10.0 // indirect github.com/docker/distribution v2.8.2+incompatible github.com/dvsekhvalnov/jose2go v1.5.0 // indirect @@ -19,77 +18,93 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.16.0 - github.com/rakyll/statik v0.1.7 // indirect github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d - google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/grpc v1.56.2 + google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/grpc v1.58.1 gopkg.in/yaml.v2 v2.4.0 ) require ( - cosmossdk.io/api v0.3.1 - cosmossdk.io/core v0.5.1 + cosmossdk.io/api v0.7.1 + cosmossdk.io/client/v2 v2.0.0-20230818115413-c402c51a1508 + cosmossdk.io/collections v0.4.0 + cosmossdk.io/core v0.11.0 cosmossdk.io/errors v1.0.0 + cosmossdk.io/log v1.2.1 cosmossdk.io/math v1.1.2 - cosmossdk.io/tools/rosetta v0.2.1 - github.com/cometbft/cometbft v0.37.2 - github.com/cometbft/cometbft-db v0.8.0 + cosmossdk.io/store v1.0.0-rc.0 + cosmossdk.io/tools/confix v0.0.0-20230818115413-c402c51a1508 + cosmossdk.io/x/circuit v0.0.0-20230818115413-c402c51a1508 + cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 + cosmossdk.io/x/feegrant v0.0.0-20230818115413-c402c51a1508 + cosmossdk.io/x/nft v0.0.0-20230630152705-9f4a4e416f85 + cosmossdk.io/x/tx v0.10.0 + cosmossdk.io/x/upgrade v0.0.0-20230915171831-2196edacb99d + github.com/cometbft/cometbft v0.38.0 + github.com/cosmos/cosmos-db v1.0.0 + github.com/cosmos/ibc-go/modules/capability v1.0.0-rc5 + github.com/cosmos/ibc-go/v8 v8.0.0-beta.0 + github.com/rs/zerolog v1.30.0 github.com/spf13/viper v1.16.0 - google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 + google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e ) require ( - cloud.google.com/go v0.110.4 // indirect - cloud.google.com/go/compute v1.20.1 // indirect + cloud.google.com/go v0.110.6 // indirect + cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.0 // indirect + cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.44.203 // indirect + github.com/DataDog/zstd v1.5.5 // indirect + github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect + github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v0.0.0-20230817233644-564b068800e0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect - github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect - github.com/confio/ics23/go v0.9.0 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft-db v0.8.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.1 // indirect - github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect - github.com/creachadair/taskgroup v0.4.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect + github.com/creachadair/atomicfile v0.3.1 // indirect + github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/emicklei/dot v1.5.0 // indirect + github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/getsentry/sentry-go v0.23.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect + github.com/gobwas/httphead v0.1.0 // indirect + github.com/gobwas/pool v0.2.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -106,51 +121,55 @@ require ( github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-metrics v0.5.1 // indirect + github.com/hashicorp/go-plugin v1.4.10 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.16.3 // indirect + github.com/klauspost/compress v1.16.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/linxGnu/grocksdb v1.7.16 // indirect + github.com/linxGnu/grocksdb v1.8.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce // indirect + github.com/oklog/run v1.1.0 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/pelletier/go-toml/v2 v2.0.9 // indirect + github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.30.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -162,22 +181,24 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gotest.tools/v3 v3.5.0 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v0.5.5 // indirect + pgregory.net/rapid v1.1.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index d068da97c7..333a7f2bb3 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= -cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.6 h1:8uYAkj3YHTP/1iwReuHPxLSbdcyc+dSBbzFMrVwDR6Q= +cloud.google.com/go v0.110.6/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -70,8 +70,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg= -cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -111,8 +111,8 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v1.1.0 h1:67gSqaPukx7O8WLLHMa0PNs3EBGd2eE4d+psbO/CO94= -cloud.google.com/go/iam v1.1.0/go.mod h1:nxdHjaKfCr7fNYx/HJMM8LgiMugmveWlkatear5gVyk= +cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= +cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= @@ -187,10 +187,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= -cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= -cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI= -cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE= +cosmossdk.io/api v0.7.1 h1:PNQ1xN8+/0hj/sSD0ANqjkgfXFys+bZ5L8Hg7uzoUTU= +cosmossdk.io/api v0.7.1/go.mod h1:ure9edhcROIHsngavM6mBLilMGFnfjhV/AaYhEMUkdo= +cosmossdk.io/client/v2 v2.0.0-20230818115413-c402c51a1508 h1:tt5OMwdouv7dkwkWJYxb8I9h322bOxnC9RmK2qGvWMs= +cosmossdk.io/client/v2 v2.0.0-20230818115413-c402c51a1508/go.mod h1:iHeSk2AT6O8RNGlfcEQq6Yty6Z/6gydQsXXBh5I715Q= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= +cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= @@ -199,24 +203,41 @@ cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= -cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= +cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= +cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= +cosmossdk.io/tools/confix v0.0.0-20230818115413-c402c51a1508 h1:axKhxRa3M9QW2GdKJUsSyzo44gxcwSOTGeomtkbQClM= +cosmossdk.io/tools/confix v0.0.0-20230818115413-c402c51a1508/go.mod h1:qcJ1zwLIMefpDHZuYSa73yBe/k5HyQ5H1Jg9PWv30Ts= +cosmossdk.io/x/circuit v0.0.0-20230818115413-c402c51a1508 h1:9HRBpMbGgk+W4BIp4ezYH2EjbpuVl2fBlwyJ2GZgrS0= +cosmossdk.io/x/circuit v0.0.0-20230818115413-c402c51a1508/go.mod h1:BhFX0kD6lkctNQO3ZGYY3p6h0/wPLVbFhrOt3uQxEIM= +cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 h1:R9H1lDpcPSkrLOnt6IDE38o0Wp8xE/+BAxocb0oyX4I= +cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508/go.mod h1:yjIo3J0QKDo9CJawK1QoTA1hBx0llafVJdPqI0+ry74= +cosmossdk.io/x/feegrant v0.0.0-20230818115413-c402c51a1508 h1:TKqjhhTfLchU8nSo1WZRgaH7xZWzYUQXVRj9CePcbaw= +cosmossdk.io/x/feegrant v0.0.0-20230818115413-c402c51a1508/go.mod h1:kOr8Rr10RoMeGGk/pfW5yo1R7GQTGu4KdRgKphVvjz4= +cosmossdk.io/x/nft v0.0.0-20230630152705-9f4a4e416f85 h1:fk1yplfM4UUTQmBJOb6cwk09ssRwaBbLR4rsfuBEhBg= +cosmossdk.io/x/nft v0.0.0-20230630152705-9f4a4e416f85/go.mod h1:arLtdZiIFmnqTNWSk2tFtSodGDKTmr+Q0fGmF5wpn2c= +cosmossdk.io/x/tx v0.10.0 h1:LxWF/hksVDbeQmFj4voLM5ZCHyVZ1cCNIqKenfH9plc= +cosmossdk.io/x/tx v0.10.0/go.mod h1:MKo9/b5wsoL8dd9y9pvD2yOP1CMvzHIWYxi1l2oLPFo= +cosmossdk.io/x/upgrade v0.0.0-20230915171831-2196edacb99d h1:LH8NPa2+yoMFdCTxCFyQUX5zVDip4YDgtg7e0EecDqo= +cosmossdk.io/x/upgrade v0.0.0-20230915171831-2196edacb99d/go.mod h1:+5jCm6Lk/CrQhQvtJFy/tmuLfhQKNMn/U0vwrRz/dxQ= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/CosmWasm/wasmvm v1.4.0 h1:84I3MlvvzcOo2z+ed0ztPi7eeDNk6/sYuK76uyXP1nI= github.com/CosmWasm/wasmvm v1.4.0/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -224,6 +245,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -236,16 +258,15 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U= -github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= +github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -255,11 +276,16 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= +github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= +github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -298,22 +324,25 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= -github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230817233644-564b068800e0 h1:M4A5LioEhkZ/s+m0g0pWgiLBQr83p0jWnQUo320Qy+A= +github.com/cockroachdb/pebble v0.0.0-20230817233644-564b068800e0/go.mod h1:EDjiaAXc0FXiRmxDzcu1wIEJ093ohHMUWxrI6iku0XA= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= -github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.38.0 h1:ogKnpiPX7gxCvqTEF4ly25/wAxUqf181t30P3vqdpdc= +github.com/cometbft/cometbft v0.38.0/go.mod h1:5Jz0Z8YsHSf0ZaAqGvi/ifioSdVFPtEGrm8Y9T/993k= github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= -github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= -github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -322,35 +351,38 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-proto v1.0.0-beta.2 h1:X3OKvWgK9Gsejo0F1qs5l8Qn6xJV/AzgIWR2wZ8Nua8= -github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0= -github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= -github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= +github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk v0.50.0-rc.0.0.20230921092356-3d9ce99e4eee h1:YyOREOZSN9dVc+hlmf+iswdEN0nS7pXAegh0x2qjQCw= +github.com/cosmos/cosmos-sdk v0.50.0-rc.0.0.20230921092356-3d9ce99e4eee/go.mod h1:8rNGga/Gg9/NIFvpqO4URts+8Cz/XVB0wTr5ZDm22UM= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= -github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= -github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/v7 v7.3.0 h1:QtGeVMi/3JeLWuvEuC60sBHpAF40Oenx/y+bP8+wRRw= -github.com/cosmos/ibc-go/v7 v7.3.0/go.mod h1:mUmaHFXpXrEdcxfdXyau+utZf14pGKVUiXwYftRZZfQ= +github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= +github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= +github.com/cosmos/iavl v1.0.0-rc.1 h1:5+73BEWW1gZOIUJKlk/1fpD4lOqqeFBA8KuV+NpkCpU= +github.com/cosmos/iavl v1.0.0-rc.1/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= +github.com/cosmos/ibc-go/modules/capability v1.0.0-rc5 h1:OwYsRIM2gwe3ifuvi2sriEvDBd3t43vTF2GEi1SOchM= +github.com/cosmos/ibc-go/modules/capability v1.0.0-rc5/go.mod h1:YriReKrNl7ZKBW6FSmgV7v4BhrN84tm672YjU0Y2C2I= +github.com/cosmos/ibc-go/v8 v8.0.0-beta.0 h1:Rppw2d8W40OR0hiLOLPm9fCniuLRKMEGFa/qohEKj+4= +github.com/cosmos/ibc-go/v8 v8.0.0-beta.0/go.mod h1:PdH5J3hN9G13jVTQUP6YKHsFx7duUhFX9CrZetZcRsw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= -github.com/cosmos/ledger-cosmos-go v0.12.1 h1:sMBxza5p/rNK/06nBSNmsI/WDqI0pVJFVNihy1Y984w= -github.com/cosmos/ledger-cosmos-go v0.12.1/go.mod h1:dhO6kj+Y+AHIOgAe4L9HL/6NDdyyth4q238I9yFpD2g= -github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= -github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= +github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s= +github.com/cosmos/ledger-cosmos-go v0.13.0/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8= -github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= +github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= +github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= +github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= +github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -358,9 +390,10 @@ github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -374,7 +407,9 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -385,6 +420,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/emicklei/dot v1.5.0 h1:tc9eKdCBTgoR68vJ6OcgMtI0SdrGDwLPPVaPA6XhX50= +github.com/emicklei/dot v1.5.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -397,13 +434,18 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -416,6 +458,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -424,6 +467,7 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -438,16 +482,21 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= +github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= +github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= +github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= +github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -535,6 +584,7 @@ github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIG github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -591,19 +641,14 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -613,11 +658,17 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= +github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= +github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -625,22 +676,25 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -649,6 +703,8 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -657,7 +713,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.2 h1:7YppbATX94jEt9KLAc5hICx4h6Yt3SaavhQRsIUEHP0= +github.com/jhump/protoreflect v1.15.2/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -687,8 +744,8 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= -github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -710,8 +767,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.7.16 h1:Q2co1xrpdkr5Hx3Fp+f+f7fRGhQFQhvi/+226dtLmA8= -github.com/linxGnu/grocksdb v1.7.16/go.mod h1:JkS7pl5qWpGpuVb3bPqTz8nC12X3YtPZT+Xq7+QfQo4= +github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= +github.com/linxGnu/grocksdb v1.8.0/go.mod h1:09CeBborffXhXdNpEcOeZrLKEnRtrZFEpFdPNI9Zjjg= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -719,11 +776,13 @@ github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3v github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= @@ -734,9 +793,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -775,23 +831,32 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce h1:/pEpMk55wH0X+E5zedGEMOdLuWmV8P4+4W3+LZaM6kg= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -801,6 +866,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -808,15 +874,16 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0= +github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761 h1:W04oB3d0J01W5jgYRGKsV8LCM6g9EkCvPkZcmFuy0OE= +github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -841,26 +908,24 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= -github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -892,6 +957,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa h1:YJfZp12Z3AFhSBeXOlv4BO55RMwPn2NoQeDsrdWnBtY= @@ -936,9 +1002,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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.1/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/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= @@ -992,11 +1058,15 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1005,7 +1075,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1013,8 +1082,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1026,8 +1095,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1054,7 +1123,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1116,8 +1186,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1143,8 +1213,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1159,7 +1229,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1191,6 +1262,7 @@ golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1213,6 +1285,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1234,6 +1307,7 @@ golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1257,13 +1331,13 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1275,8 +1349,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1302,6 +1376,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1333,6 +1408,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1343,7 +1419,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1521,12 +1598,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIYWHqOUZ1pva5qK/rwbIhoXEUB9Lu8= -google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= -google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= -google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1568,8 +1645,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58= +google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1620,8 +1697,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1632,8 +1709,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= -pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= +pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/proto/cosmwasm/wasm/v1/authz.proto b/proto/cosmwasm/wasm/v1/authz.proto index 713369fb5c..151ccc04c9 100644 --- a/proto/cosmwasm/wasm/v1/authz.proto +++ b/proto/cosmwasm/wasm/v1/authz.proto @@ -63,7 +63,7 @@ message CodeGrant { // Since: wasmd 0.30 message ContractGrant { // Contract is the bech32 address of the smart contract - string contract = 1; + string contract = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Limit defines execution limits that are enforced and updated when the grant // is applied. When the limit lapsed the grant is removed. diff --git a/proto/cosmwasm/wasm/v1/genesis.proto b/proto/cosmwasm/wasm/v1/genesis.proto index 68e8b18e63..9082c8b8b2 100644 --- a/proto/cosmwasm/wasm/v1/genesis.proto +++ b/proto/cosmwasm/wasm/v1/genesis.proto @@ -4,6 +4,7 @@ package cosmwasm.wasm.v1; import "gogoproto/gogo.proto"; import "cosmwasm/wasm/v1/types.proto"; import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "github.com/CosmWasm/wasmd/x/wasm/types"; @@ -40,7 +41,8 @@ message Code { // Contract struct encompasses ContractAddress, ContractInfo, and ContractState message Contract { - string contract_address = 1; + string contract_address = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; ContractInfo contract_info = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; repeated Model contract_state = 3 diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index eedbb9b399..8bb872e2a8 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -26,7 +26,7 @@ message StoreCodeProposal { // Description is a human readable text string description = 2; // RunAs is the address that is passed to the contract's environment as sender - string run_as = 3; + string run_as = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // WASMByteCode can be raw or gzip compressed bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ]; // Used in v1beta1 @@ -59,9 +59,9 @@ message InstantiateContractProposal { // Description is a human readable text string description = 2; // RunAs is the address that is passed to the contract's environment as sender - string run_as = 3; + string run_as = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Admin is an optional address that can execute migrations - string admin = 4; + string admin = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID is the reference to the stored WASM code uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ]; // Label is optional metadata to be stored with a constract instance. @@ -90,9 +90,9 @@ message InstantiateContract2Proposal { // Description is a human readable text string description = 2; // RunAs is the address that is passed to the contract's enviroment as sender - string run_as = 3; + string run_as = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Admin is an optional address that can execute migrations - string admin = 4; + string admin = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID is the reference to the stored WASM code uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ]; // Label is optional metadata to be stored with a constract instance. @@ -128,7 +128,7 @@ message MigrateContractProposal { // Note: skipping 3 as this was previously used for unneeded run_as // Contract is the address of the smart contract - string contract = 4; + string contract = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID references the new WASM code uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ]; // Msg json encoded message to be passed to the contract on migration @@ -149,7 +149,7 @@ message SudoContractProposal { // Description is a human readable text string description = 2; // Contract is the address of the smart contract - string contract = 3; + string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Msg json encoded message to be passed to the contract as sudo bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ]; } @@ -168,9 +168,9 @@ message ExecuteContractProposal { // Description is a human readable text string description = 2; // RunAs is the address that is passed to the contract's environment as sender - string run_as = 3; + string run_as = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 4; + string contract = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Msg json encoded message to be passed to the contract as execute bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ]; // Funds coins that are transferred to the contract on instantiation @@ -195,9 +195,12 @@ message UpdateAdminProposal { // Description is a human readable text string description = 2; // NewAdmin address to be set - string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; + string new_admin = 3 [ + (gogoproto.moretags) = "yaml:\"new_admin\"", + (cosmos_proto.scalar) = "cosmos.AddressString" + ]; // Contract is the address of the smart contract - string contract = 4; + string contract = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for @@ -214,7 +217,7 @@ message ClearAdminProposal { // Description is a human readable text string description = 2; // Contract is the address of the smart contract - string contract = 3; + string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for @@ -227,9 +230,9 @@ message PinCodesProposal { option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary - string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string title = 1; // Description is a human readable text - string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + string description = 2; // CodeIDs references the new WASM codes repeated uint64 code_ids = 3 [ (gogoproto.customname) = "CodeIDs", @@ -247,9 +250,9 @@ message UnpinCodesProposal { option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary - string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string title = 1; // Description is a human readable text - string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + string description = 2; // CodeIDs references the WASM codes repeated uint64 code_ids = 3 [ (gogoproto.customname) = "CodeIDs", @@ -300,7 +303,7 @@ message StoreAndInstantiateContractProposal { // Description is a human readable text string description = 2; // RunAs is the address that is passed to the contract's environment as sender - string run_as = 3; + string run_as = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // WASMByteCode can be raw or gzip compressed bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ]; // InstantiatePermission to apply on contract creation, optional diff --git a/proto/cosmwasm/wasm/v1/query.proto b/proto/cosmwasm/wasm/v1/query.proto index d14f315924..16840585a3 100644 --- a/proto/cosmwasm/wasm/v1/query.proto +++ b/proto/cosmwasm/wasm/v1/query.proto @@ -6,6 +6,7 @@ import "cosmwasm/wasm/v1/types.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "github.com/CosmWasm/wasmd/x/wasm/types"; option (gogoproto.goproto_getters_all) = false; @@ -77,7 +78,7 @@ service Query { // method message QueryContractInfoRequest { // address is the address of the contract to query - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // QueryContractInfoResponse is the response type for the Query/ContractInfo RPC // method @@ -85,7 +86,7 @@ message QueryContractInfoResponse { option (gogoproto.equal) = true; // address is the address of the contract - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; ContractInfo contract_info = 2 [ (gogoproto.embed) = true, (gogoproto.nullable) = false, @@ -98,7 +99,7 @@ message QueryContractInfoResponse { // RPC method message QueryContractHistoryRequest { // address is the address of the contract to query - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 2; } @@ -124,7 +125,8 @@ message QueryContractsByCodeRequest { // Query/ContractsByCode RPC method message QueryContractsByCodeResponse { // contracts are a set of contract addresses - repeated string contracts = 1; + repeated string contracts = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -134,7 +136,7 @@ message QueryContractsByCodeResponse { // Query/AllContractState RPC method message QueryAllContractStateRequest { // address is the address of the contract - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 2; } @@ -152,7 +154,7 @@ message QueryAllContractStateResponse { // Query/RawContractState RPC method message QueryRawContractStateRequest { // address is the address of the contract - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bytes query_data = 2; } @@ -167,7 +169,7 @@ message QueryRawContractStateResponse { // Query/SmartContractState RPC method message QuerySmartContractStateRequest { // address is the address of the contract - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // QueryData contains the query data passed to the contract bytes query_data = 2 [ (gogoproto.casttype) = "RawContractMessage" ]; } @@ -192,7 +194,7 @@ message CodeInfoResponse { (gogoproto.customname) = "CodeID", (gogoproto.jsontag) = "id" ]; // id for legacy support - string creator = 2; + string creator = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bytes data_hash = 3 [ (gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes" ]; @@ -253,7 +255,7 @@ message QueryParamsResponse { // Query/ContractsByCreator RPC method. message QueryContractsByCreatorRequest { // CreatorAddress is the address of contract creator - string creator_address = 1; + string creator_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 2; } @@ -262,7 +264,8 @@ message QueryContractsByCreatorRequest { // Query/ContractsByCreator RPC method. message QueryContractsByCreatorResponse { // ContractAddresses result set - repeated string contract_addresses = 1; + repeated string contract_addresses = 1 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } \ No newline at end of file diff --git a/proto/cosmwasm/wasm/v1/tx.proto b/proto/cosmwasm/wasm/v1/tx.proto index 7203b8a817..98798fe321 100644 --- a/proto/cosmwasm/wasm/v1/tx.proto +++ b/proto/cosmwasm/wasm/v1/tx.proto @@ -13,6 +13,8 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the wasm Msg service. service Msg { + option (cosmos.msg.v1.service) = true; + // StoreCode to submit Wasm code to the system rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse); // InstantiateContract creates a new smart contract instance for the given @@ -84,7 +86,7 @@ message MsgStoreCode { option (cosmos.msg.v1.signer) = "sender"; // Sender is the actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // WASMByteCode can be raw or gzip compressed bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ]; // Used in v1beta1 @@ -108,9 +110,9 @@ message MsgInstantiateContract { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Admin is an optional address that can execute migrations - string admin = 2; + string admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID is the reference to the stored WASM code uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; // Label is optional metadata to be stored with a contract instance. @@ -128,7 +130,7 @@ message MsgInstantiateContract { // MsgInstantiateContractResponse return instantiation result data message MsgInstantiateContractResponse { // Address is the bech32 address of the new contract instance. - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Data contains bytes to returned from the contract bytes data = 2; } @@ -140,9 +142,9 @@ message MsgInstantiateContract2 { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Admin is an optional address that can execute migrations - string admin = 2; + string admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID is the reference to the stored WASM code uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; // Label is optional metadata to be stored with a contract instance. @@ -165,7 +167,7 @@ message MsgInstantiateContract2 { // MsgInstantiateContract2Response return instantiation result data message MsgInstantiateContract2Response { // Address is the bech32 address of the new contract instance. - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Data contains bytes to returned from the contract bytes data = 2; } @@ -176,9 +178,9 @@ message MsgExecuteContract { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 2; + string contract = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Msg json encoded message to be passed to the contract bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ]; // Funds coins that are transferred to the contract on execution @@ -201,9 +203,9 @@ message MsgMigrateContract { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 2; + string contract = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID references the new WASM code uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; // Msg json encoded message to be passed to the contract on migration @@ -223,11 +225,11 @@ message MsgUpdateAdmin { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // NewAdmin address to be set - string new_admin = 2; + string new_admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 3; + string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // MsgUpdateAdminResponse returns empty data @@ -239,9 +241,9 @@ message MsgClearAdmin { option (cosmos.msg.v1.signer) = "sender"; // Sender is the actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 3; + string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // MsgClearAdminResponse returns empty data @@ -253,7 +255,7 @@ message MsgUpdateInstantiateConfig { option (cosmos.msg.v1.signer) = "sender"; // Sender is the that actor that signed the messages - string sender = 1; + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // CodeID references the stored WASM code uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ]; // NewInstantiatePermission is the new access control @@ -297,7 +299,7 @@ message MsgSudoContract { string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Contract is the address of the smart contract - string contract = 2; + string contract = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Msg json encoded message to be passed to the contract as sudo bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ]; } @@ -373,7 +375,7 @@ message MsgStoreAndInstantiateContract { // pinned to cache. bool unpin_code = 5; // Admin is an optional address that can execute migrations - string admin = 6; + string admin = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Label is optional metadata to be stored with a constract instance. string label = 7; // Msg json encoded message to be passed to the contract on instantiation @@ -401,7 +403,8 @@ message MsgStoreAndInstantiateContract { // Since: 0.40 message MsgStoreAndInstantiateContractResponse { // Address is the bech32 address of the new contract instance. - string address = 1; + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // Data contains bytes to returned from the contract bytes data = 2; } diff --git a/proto/cosmwasm/wasm/v1/types.proto b/proto/cosmwasm/wasm/v1/types.proto index 614e27b975..5790585c8c 100644 --- a/proto/cosmwasm/wasm/v1/types.proto +++ b/proto/cosmwasm/wasm/v1/types.proto @@ -44,7 +44,8 @@ message AccessConfig { reserved 2; // was address - repeated string addresses = 3 [ (gogoproto.moretags) = "yaml:\"addresses\"" ]; + repeated string addresses = 3 + [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // Params defines the set of wasm parameters. @@ -64,7 +65,7 @@ message CodeInfo { // CodeHash is the unique identifier created by wasmvm bytes code_hash = 1; // Creator address who initially stored the code - string creator = 2; + string creator = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Used in v1beta1 reserved 3, 4; // InstantiateConfig access control to apply on contract creation, optional @@ -79,9 +80,9 @@ message ContractInfo { // CodeID is the reference to the stored Wasm code uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; // Creator address who initially instantiated the contract - string creator = 2; + string creator = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Admin is an optional address that can execute migrations - string admin = 3; + string admin = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Label is optional metadata to be stored with a contract instance. string label = 4; // Created Tx position when the contract was instantiated. diff --git a/tests/e2e/gov_test.go b/tests/e2e/gov_test.go index 33b7fd34a4..f57e6b1051 100644 --- a/tests/e2e/gov_test.go +++ b/tests/e2e/gov_test.go @@ -8,6 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -27,7 +29,7 @@ func TestGovVoteByContract(t *testing.T) { coord := ibctesting.NewCoordinator(t, 1) chain := coord.GetChain(ibctesting.GetChainID(1)) contractAddr := e2e.InstantiateReflectContract(t, chain) - chain.Fund(contractAddr, sdk.NewIntFromUint64(1_000_000_000)) + chain.Fund(contractAddr, sdkmath.NewIntFromUint64(1_000_000_000)) // a contract with a high delegation amount delegateMsg := wasmvmtypes.CosmosMsg{ Staking: &wasmvmtypes.StakingMsg{ @@ -48,7 +50,9 @@ func TestGovVoteByContract(t *testing.T) { communityPoolBalance := chain.Balance(accountKeeper.GetModuleAccount(chain.GetContext(), distributiontypes.ModuleName).GetAddress(), sdk.DefaultBondDenom) require.False(t, communityPoolBalance.IsZero()) - initialDeposit := govKeeper.GetParams(chain.GetContext()).MinDeposit + gParams, err := govKeeper.Params.Get(chain.GetContext()) + require.NoError(t, err) + initialDeposit := gParams.MinDeposit govAcctAddr := govKeeper.GetGovernanceAccount(chain.GetContext()).GetAddress() specs := map[string]struct { @@ -88,7 +92,7 @@ func TestGovVoteByContract(t *testing.T) { payloadMsg := &distributiontypes.MsgCommunityPoolSpend{ Authority: govAcctAddr.String(), Recipient: recipientAddr.String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), } msg, err := v1.NewMsgSubmitProposal( []sdk.Msg{payloadMsg}, @@ -97,13 +101,14 @@ func TestGovVoteByContract(t *testing.T) { "", "my proposal", "testing", + false, ) require.NoError(t, err) rsp, gotErr := chain.SendMsgs(msg) require.NoError(t, gotErr) - require.Len(t, rsp.MsgResponses, 1) - got, ok := rsp.MsgResponses[0].GetCachedValue().(*v1.MsgSubmitProposalResponse) - require.True(t, ok) + var got v1.MsgSubmitProposalResponse + chain.UnwrapExecTXResult(rsp, &got) + propID := got.ProposalId // with other delegators voted yes @@ -120,8 +125,8 @@ func TestGovVoteByContract(t *testing.T) { e2e.MustExecViaReflectContract(t, chain, contractAddr, voteMsg) // then proposal executed after voting period - proposal, ok := govKeeper.GetProposal(chain.GetContext(), propID) - require.True(t, ok) + proposal, err := govKeeper.Proposals.Get(chain.GetContext(), propID) + require.NoError(t, err) coord.IncrementTimeBy(proposal.VotingEndTime.Sub(chain.GetContext().BlockTime()) + time.Minute) coord.CommitBlock(chain) @@ -131,7 +136,7 @@ func TestGovVoteByContract(t *testing.T) { assert.True(t, recipientBalance.IsZero()) return } - expBalanceAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) + expBalanceAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt()) assert.Equal(t, expBalanceAmount.String(), recipientBalance.String()) }) } diff --git a/tests/e2e/grants_test.go b/tests/e2e/grants_test.go index f7102d4133..82748be8b2 100644 --- a/tests/e2e/grants_test.go +++ b/tests/e2e/grants_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -43,11 +44,11 @@ func TestGrants(t *testing.T) { otherPrivKey := secp256k1.GenPrivKey() otherAddr := sdk.AccAddress(otherPrivKey.PubKey().Address().Bytes()) - chain.Fund(granteeAddr, sdk.NewInt(1_000_000)) - chain.Fund(otherAddr, sdk.NewInt(1_000_000)) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + chain.Fund(granteeAddr, sdkmath.NewInt(1_000_000)) + chain.Fund(otherAddr, sdkmath.NewInt(1_000_000)) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) - myAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2_000_000)) + myAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2_000_000)) specs := map[string]struct { limit types.ContractAuthzLimitX @@ -65,14 +66,14 @@ func TestGrants(t *testing.T) { "exceed limits": { limit: types.NewMaxFundsLimit(myAmount), filter: types.NewAllowAllMessagesFilter(), - transferAmount: myAmount.Add(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), + transferAmount: myAmount.Add(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), senderKey: granteePrivKey, expErr: sdkerrors.ErrUnauthorized, }, "not match filter": { limit: types.NewMaxFundsLimit(myAmount), filter: types.NewAcceptedMessageKeysFilter("foo"), - transferAmount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()), + transferAmount: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt()), senderKey: granteePrivKey, expErr: sdkerrors.ErrUnauthorized, }, @@ -110,13 +111,13 @@ func TestGrants(t *testing.T) { // then if spec.expErr != nil { - require.True(t, spec.expErr.Is(gotErr)) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + require.ErrorContains(t, gotErr, fmt.Sprintf("%s/%d:", spec.expErr.Codespace(), spec.expErr.ABCICode())) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) assert.Equal(t, granterStartBalance, chain.Balance(granterAddr, sdk.DefaultBondDenom).Amount) return } require.NoError(t, gotErr) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) assert.Equal(t, granterStartBalance.Sub(spec.transferAmount.Amount), chain.Balance(granterAddr, sdk.DefaultBondDenom).Amount) }) } @@ -138,9 +139,9 @@ func TestStoreCodeGrant(t *testing.T) { otherPrivKey := secp256k1.GenPrivKey() otherAddr := sdk.AccAddress(otherPrivKey.PubKey().Address().Bytes()) - chain.Fund(granteeAddr, sdk.NewInt(1_000_000)) - chain.Fund(otherAddr, sdk.NewInt(1_000_000)) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + chain.Fund(granteeAddr, sdkmath.NewInt(1_000_000)) + chain.Fund(otherAddr, sdkmath.NewInt(1_000_000)) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) specs := map[string]struct { codeHash []byte @@ -180,7 +181,7 @@ func TestStoreCodeGrant(t *testing.T) { for name, spec := range specs { t.Run(name, func(t *testing.T) { // setup grant - grant, err := types.NewCodeGrant(spec.codeHash, &spec.instantiatePermission) + grant, err := types.NewCodeGrant(spec.codeHash, &spec.instantiatePermission) //nolint:gosec require.NoError(t, err) authorization := types.NewStoreCodeAuthorization(*grant) expiry := time.Now().Add(time.Hour) @@ -199,7 +200,7 @@ func TestStoreCodeGrant(t *testing.T) { // then if spec.expErr != nil { - require.True(t, spec.expErr.Is(gotErr)) + assert.ErrorContains(t, gotErr, fmt.Sprintf("%s/%d:", spec.expErr.Codespace(), spec.expErr.ABCICode())) return } require.NoError(t, gotErr) @@ -226,9 +227,9 @@ func TestGzipStoreCodeGrant(t *testing.T) { otherPrivKey := secp256k1.GenPrivKey() otherAddr := sdk.AccAddress(otherPrivKey.PubKey().Address().Bytes()) - chain.Fund(granteeAddr, sdk.NewInt(1_000_000)) - chain.Fund(otherAddr, sdk.NewInt(1_000_000)) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + chain.Fund(granteeAddr, sdkmath.NewInt(1_000_000)) + chain.Fund(otherAddr, sdkmath.NewInt(1_000_000)) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) specs := map[string]struct { codeHash []byte @@ -268,7 +269,7 @@ func TestGzipStoreCodeGrant(t *testing.T) { for name, spec := range specs { t.Run(name, func(t *testing.T) { // setup grant - grant, err := types.NewCodeGrant(spec.codeHash, &spec.instantiatePermission) + grant, err := types.NewCodeGrant(spec.codeHash, &spec.instantiatePermission) //nolint:gosec require.NoError(t, err) authorization := types.NewStoreCodeAuthorization(*grant) expiry := time.Now().Add(time.Hour) @@ -287,7 +288,7 @@ func TestGzipStoreCodeGrant(t *testing.T) { // then if spec.expErr != nil { - require.True(t, spec.expErr.Is(gotErr)) + assert.ErrorContains(t, gotErr, fmt.Sprintf("%s/%d:", spec.expErr.Codespace(), spec.expErr.ABCICode())) return } require.NoError(t, gotErr) @@ -308,9 +309,9 @@ func TestBrokenGzipStoreCodeGrant(t *testing.T) { otherPrivKey := secp256k1.GenPrivKey() otherAddr := sdk.AccAddress(otherPrivKey.PubKey().Address().Bytes()) - chain.Fund(granteeAddr, sdk.NewInt(1_000_000)) - chain.Fund(otherAddr, sdk.NewInt(1_000_000)) - assert.Equal(t, sdk.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) + chain.Fund(granteeAddr, sdkmath.NewInt(1_000_000)) + chain.Fund(otherAddr, sdkmath.NewInt(1_000_000)) + assert.Equal(t, sdkmath.NewInt(1_000_000), chain.Balance(granteeAddr, sdk.DefaultBondDenom).Amount) codeHash := []byte("*") instantiatePermission := types.AllowEverybody diff --git a/tests/e2e/group_test.go b/tests/e2e/group_test.go index 8708c12639..9852d9793a 100644 --- a/tests/e2e/group_test.go +++ b/tests/e2e/group_test.go @@ -8,6 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -26,7 +28,7 @@ func TestGroupWithContract(t *testing.T) { coord := ibctesting.NewCoordinator(t, 1) chain := coord.GetChain(ibctesting.GetChainID(1)) contractAddr := e2e.InstantiateReflectContract(t, chain) - chain.Fund(contractAddr, sdk.NewIntFromUint64(1_000_000_000)) + chain.Fund(contractAddr, sdkmath.NewIntFromUint64(1_000_000_000)) members := []group.MemberRequest{ { @@ -47,25 +49,28 @@ func TestGroupWithContract(t *testing.T) { rsp, err := chain.SendMsgs(msg) require.NoError(t, err) - createRsp := rsp.MsgResponses[0].GetCachedValue().(*group.MsgCreateGroupWithPolicyResponse) + var createRsp group.MsgCreateGroupWithPolicyResponse + chain.UnwrapExecTXResult(rsp, &createRsp) groupID, policyAddr := createRsp.GroupId, sdk.MustAccAddressFromBech32(createRsp.GroupPolicyAddress) require.NotEmpty(t, groupID) - chain.Fund(policyAddr, sdk.NewIntFromUint64(1_000_000_000)) + chain.Fund(policyAddr, sdkmath.NewIntFromUint64(1_000_000_000)) // and a proposal submitted recipientAddr := sdk.AccAddress(rand.Bytes(address.Len)) - payload := []sdk.Msg{banktypes.NewMsgSend(policyAddr, recipientAddr, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())))} + payload := []sdk.Msg{banktypes.NewMsgSend(policyAddr, recipientAddr, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())))} propMsg, err := group.NewMsgSubmitProposal(policyAddr.String(), []string{contractAddr.String()}, payload, "my proposal", group.Exec_EXEC_TRY, "my title", "my description") require.NoError(t, err) rsp = e2e.MustExecViaStargateReflectContract(t, chain, contractAddr, propMsg) - bz := rsp.MsgResponses[0].GetCachedValue().(*types.MsgExecuteContractResponse).Data + var execRsp types.MsgExecuteContractResponse + chain.UnwrapExecTXResult(rsp, &execRsp) + var groupRsp group.MsgSubmitProposalResponse - require.NoError(t, chain.Codec.Unmarshal(bz, &groupRsp)) + require.NoError(t, chain.Codec.Unmarshal(execRsp.Data, &groupRsp)) // require.NotEmpty(t, groupRsp.ProposalId) // and coins received recipientBalance := chain.Balance(recipientAddr, sdk.DefaultBondDenom) - expBalanceAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) + expBalanceAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt()) assert.Equal(t, expBalanceAmount.String(), recipientBalance.String()) } diff --git a/tests/e2e/ibc_fees_test.go b/tests/e2e/ibc_fees_test.go index ea6c72fe69..f08467cc16 100644 --- a/tests/e2e/ibc_fees_test.go +++ b/tests/e2e/ibc_fees_test.go @@ -7,14 +7,16 @@ import ( "testing" "time" - ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" @@ -29,7 +31,7 @@ func TestIBCFeesTransfer(t *testing.T) { // with an ics-20 channel established // when an ics-29 fee is attached to an ibc package // then the relayer's payee is receiving the fee(s) on success - codec := app.MakeEncodingConfig().Codec + marshaler := app.MakeEncodingConfig(t).Codec coord := wasmibctesting.NewCoordinator(t, 2) chainA := coord.GetChain(wasmibctesting.GetChainID(1)) chainB := coord.GetChain(wasmibctesting.GetChainID(2)) @@ -38,17 +40,17 @@ func TestIBCFeesTransfer(t *testing.T) { actorChainB := sdk.AccAddress(chainB.SenderPrivKey.PubKey().Address()) receiver := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) payee := sdk.AccAddress(bytes.Repeat([]byte{2}, address.Len)) - oneToken := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))) + oneToken := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))) path := wasmibctesting.NewPath(chainA, chainB) path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ PortID: ibctransfertypes.PortID, - Version: string(codec.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), + Version: string(marshaler.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), Order: channeltypes.UNORDERED, } path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ PortID: ibctransfertypes.PortID, - Version: string(codec.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), + Version: string(marshaler.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), Order: channeltypes.UNORDERED, } // with an ics-20 transfer channel setup between both chains @@ -62,7 +64,7 @@ func TestIBCFeesTransfer(t *testing.T) { require.NoError(t, err) // when a transfer package is sent - transferCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + transferCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)) ibcPayloadMsg := ibctransfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, transferCoin, actorChainA.String(), receiver.String(), clienttypes.Height{}, uint64(time.Now().Add(time.Minute).UnixNano()), "testing") ibcPackageFee := ibcfee.NewFee(oneToken, oneToken, sdk.Coins{}) feeMsg := ibcfee.NewMsgPayPacketFee(ibcPackageFee, ibctransfertypes.PortID, path.EndpointA.ChannelID, actorChainA.String(), nil) @@ -105,7 +107,7 @@ func TestIBCFeesTransfer(t *testing.T) { gotBalance = chainA.Balance(receiver, expBalance.Denom) assert.Equal(t, expBalance.String(), gotBalance.String()) payeeBalance = chainB.AllBalances(payee) - assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2)).String(), payeeBalance.String()) + assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2)).String(), payeeBalance.String()) } func TestIBCFeesWasm(t *testing.T) { @@ -114,7 +116,7 @@ func TestIBCFeesWasm(t *testing.T) { // and an ibc channel established // when an ics-29 fee is attached to an ibc package // then the relayer's payee is receiving the fee(s) on success - codec := app.MakeEncodingConfig().Codec + marshaler := app.MakeEncodingConfig(t).Codec coord := wasmibctesting.NewCoordinator(t, 2) chainA := coord.GetChain(wasmibctesting.GetChainID(1)) chainB := coord.GetChain(ibctesting.GetChainID(2)) @@ -133,17 +135,17 @@ func TestIBCFeesWasm(t *testing.T) { ibcContractPortID := chainA.ContractInfo(ibcContractAddr).IBCPortID payee := sdk.AccAddress(bytes.Repeat([]byte{2}, address.Len)) - oneToken := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))) + oneToken := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))) path := wasmibctesting.NewPath(chainA, chainB) path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ PortID: ibcContractPortID, - Version: string(codec.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), + Version: string(marshaler.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), Order: channeltypes.UNORDERED, } path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ PortID: ibctransfertypes.PortID, - Version: string(codec.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), + Version: string(marshaler.MustMarshalJSON(&ibcfee.Metadata{FeeVersion: ibcfee.Version, AppVersion: ibctransfertypes.Version})), Order: channeltypes.UNORDERED, } // with an ics-29 fee enabled channel setup between both chains @@ -182,11 +184,11 @@ func TestIBCFeesWasm(t *testing.T) { require.NoError(t, err) assert.JSONEq(t, `{"balance":"99999900"}`, string(gotCW20Balance)) payeeBalance := chainA.AllBalances(payee) - assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2)).String(), payeeBalance.String()) + assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2)).String(), payeeBalance.String()) // and on chain B pendingIncentivisedPackages = appA.IBCFeeKeeper.GetIdentifiedPacketFeesForChannel(chainA.GetContext(), ibcContractPortID, path.EndpointA.ChannelID) assert.Len(t, pendingIncentivisedPackages, 0) - expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, "cw20:"+cw20ContractAddr.String(), sdk.NewInt(100)) + expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, "cw20:"+cw20ContractAddr.String(), sdkmath.NewInt(100)) gotBalance := chainB.Balance(actorChainB, expBalance.Denom) assert.Equal(t, expBalance.String(), gotBalance.String(), chainB.AllBalances(actorChainB)) @@ -215,5 +217,5 @@ func TestIBCFeesWasm(t *testing.T) { assert.JSONEq(t, `{"balance":"100000000"}`, string(gotCW20Balance)) // and on chain B payeeBalance = chainB.AllBalances(payee) - assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2)).String(), payeeBalance.String()) + assert.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2)).String(), payeeBalance.String()) } diff --git a/tests/e2e/ica_test.go b/tests/e2e/ica_test.go index d72617b2ff..489da9a4ed 100644 --- a/tests/e2e/ica_test.go +++ b/tests/e2e/ica_test.go @@ -1,19 +1,23 @@ package e2e import ( - "bytes" "testing" "time" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/libs/rand" "github.com/cosmos/gogoproto/proto" - icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - hosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" + hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -40,62 +44,89 @@ func TestICA(t *testing.T) { path := wasmibctesting.NewPath(controllerChain, hostChain) coord.SetupConnections(path) - ownerAddr := sdk.AccAddress(controllerChain.SenderPrivKey.PubKey().Address()) - msg := icacontrollertypes.NewMsgRegisterInterchainAccount(path.EndpointA.ConnectionID, ownerAddr.String(), "") - res, err := controllerChain.SendMsgs(msg) - require.NoError(t, err) - chanID, portID, version := parseIBCChannelEvents(t, res) - - // next open channels on both sides - path.EndpointA.ChannelID = chanID - path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ - PortID: portID, - Version: version, - Order: channeltypes.ORDERED, - } - path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ - PortID: icatypes.HostPortID, - Version: icatypes.Version, - Order: channeltypes.ORDERED, - } - coord.CreateChannels(path) - - // assert ICA exists on controller - contApp := controllerChain.App.(*app.WasmApp) - icaRsp, err := contApp.ICAControllerKeeper.InterchainAccount(sdk.WrapSDKContext(controllerChain.GetContext()), &icacontrollertypes.QueryInterchainAccountRequest{ - Owner: ownerAddr.String(), - ConnectionId: path.EndpointA.ConnectionID, - }) - require.NoError(t, err) - icaAddr := sdk.MustAccAddressFromBech32(icaRsp.GetAddress()) - hostChain.Fund(icaAddr, sdk.NewInt(1_000)) - - // submit a tx - targetAddr := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) - sendCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - payloadMsg := banktypes.NewMsgSend(icaAddr, targetAddr, sdk.NewCoins(sendCoin)) - rawPayloadData, err := icatypes.SerializeCosmosTx(controllerChain.Codec, []proto.Message{payloadMsg}) - require.NoError(t, err) - payloadPacket := icatypes.InterchainAccountPacketData{ - Type: icatypes.EXECUTE_TX, - Data: rawPayloadData, - Memo: "testing", + specs := map[string]struct { + icaVersion string + encoding string + }{ + "proto": { + icaVersion: "", // empty string defaults to the proto3 encoding type + encoding: icatypes.EncodingProtobuf, + }, + "json": { + icaVersion: string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{ + Version: icatypes.Version, + ControllerConnectionId: path.EndpointA.ConnectionID, + HostConnectionId: path.EndpointB.ConnectionID, + Encoding: icatypes.EncodingProto3JSON, // use proto3json + TxType: icatypes.TxTypeSDKMultiMsg, + })), + encoding: icatypes.EncodingProto3JSON, + }, } - relativeTimeout := uint64(time.Minute.Nanoseconds()) // note this is in nanoseconds - msgSendTx := icacontrollertypes.NewMsgSendTx(ownerAddr.String(), path.EndpointA.ConnectionID, relativeTimeout, payloadPacket) - _, err = controllerChain.SendMsgs(msgSendTx) - require.NoError(t, err) + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + icaControllerKey := secp256k1.GenPrivKey() + icaControllerAddr := sdk.AccAddress(icaControllerKey.PubKey().Address().Bytes()) + controllerChain.Fund(icaControllerAddr, sdkmath.NewInt(1_000)) + + msg := icacontrollertypes.NewMsgRegisterInterchainAccount(path.EndpointA.ConnectionID, icaControllerAddr.String(), spec.icaVersion) + res, err := controllerChain.SendNonDefaultSenderMsgs(icaControllerKey, msg) + require.NoError(t, err) + chanID, portID, version := parseIBCChannelEvents(t, res) + + // next open channels on both sides + path.EndpointA.ChannelID = chanID + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: portID, + Version: version, + Order: channeltypes.ORDERED, + } + path.EndpointB.ChannelID = "" + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: icatypes.HostPortID, + Version: icatypes.Version, + Order: channeltypes.ORDERED, + } + coord.CreateChannels(path) - assert.Equal(t, 1, len(controllerChain.PendingSendPackets)) - require.NoError(t, coord.RelayAndAckPendingPackets(path)) + // assert ICA exists on controller + contApp := controllerChain.App.(*app.WasmApp) + icaRsp, err := contApp.ICAControllerKeeper.InterchainAccount(controllerChain.GetContext(), &icacontrollertypes.QueryInterchainAccountRequest{ + Owner: icaControllerAddr.String(), + ConnectionId: path.EndpointA.ConnectionID, + }) + require.NoError(t, err) + icaAddr := sdk.MustAccAddressFromBech32(icaRsp.GetAddress()) + hostChain.Fund(icaAddr, sdkmath.NewInt(1_000)) - gotBalance := hostChain.Balance(targetAddr, sdk.DefaultBondDenom) - assert.Equal(t, sendCoin.String(), gotBalance.String()) + // submit a tx + targetAddr := sdk.AccAddress(rand.Bytes(address.Len)) + sendCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) + payloadMsg := banktypes.NewMsgSend(icaAddr, targetAddr, sdk.NewCoins(sendCoin)) + rawPayloadData, err := icatypes.SerializeCosmosTx(controllerChain.Codec, []proto.Message{payloadMsg}, spec.encoding) + require.NoError(t, err) + payloadPacket := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: rawPayloadData, + Memo: "testing", + } + relativeTimeout := uint64(time.Minute.Nanoseconds()) // note this is in nanoseconds + msgSendTx := icacontrollertypes.NewMsgSendTx(icaControllerAddr.String(), path.EndpointA.ConnectionID, relativeTimeout, payloadPacket) + _, err = controllerChain.SendNonDefaultSenderMsgs(icaControllerKey, msgSendTx) + require.NoError(t, err) + + assert.Equal(t, 1, len(controllerChain.PendingSendPackets)) + require.NoError(t, coord.RelayAndAckPendingPackets(path)) + + gotBalance := hostChain.Balance(targetAddr, sdk.DefaultBondDenom) + assert.Equal(t, sendCoin.String(), gotBalance.String()) + }) + } } -func parseIBCChannelEvents(t *testing.T, res *sdk.Result) (string, string, string) { +func parseIBCChannelEvents(t *testing.T, res *abci.ExecTxResult) (string, string, string) { t.Helper() - chanID, err := ibctesting.ParseChannelIDFromEvents(res.GetEvents()) + chanID, err := wasmibctesting.ParseChannelIDFromEvents(res.GetEvents()) require.NoError(t, err) portID, err := wasmibctesting.ParsePortIDFromEvents(res.GetEvents()) require.NoError(t, err) diff --git a/tests/e2e/reflect_helper.go b/tests/e2e/reflect_helper.go index 26cb2798cd..2d8a4c4d79 100644 --- a/tests/e2e/reflect_helper.go +++ b/tests/e2e/reflect_helper.go @@ -5,9 +5,10 @@ import ( "testing" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/ibctesting" @@ -17,7 +18,6 @@ import ( // InstantiateReflectContract store and instantiate a reflect contract instance func InstantiateReflectContract(t *testing.T, chain *ibctesting.TestChain) sdk.AccAddress { - t.Helper() codeID := chain.StoreCodeFile("../../x/wasm/keeper/testdata/reflect_1_1.wasm").CodeID contractAddr := chain.InstantiateContract(codeID, []byte(`{}`)) require.NotEmpty(t, contractAddr) @@ -25,20 +25,18 @@ func InstantiateReflectContract(t *testing.T, chain *ibctesting.TestChain) sdk.A } // MustExecViaReflectContract submit execute message to send payload to reflect contract -func MustExecViaReflectContract(t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs ...wasmvmtypes.CosmosMsg) *sdk.Result { - t.Helper() +func MustExecViaReflectContract(t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs ...wasmvmtypes.CosmosMsg) *abci.ExecTxResult { rsp, err := ExecViaReflectContract(t, chain, contractAddr, msgs) require.NoError(t, err) return rsp } type sdkMessageType interface { - codec.ProtoMarshaler + proto.Message sdk.Msg } -func MustExecViaStargateReflectContract[T sdkMessageType](t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs ...T) *sdk.Result { - t.Helper() +func MustExecViaStargateReflectContract[T sdkMessageType](t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs ...T) *abci.ExecTxResult { vmMsgs := make([]wasmvmtypes.CosmosMsg, len(msgs)) for i, m := range msgs { bz, err := chain.Codec.Marshal(m) @@ -56,8 +54,7 @@ func MustExecViaStargateReflectContract[T sdkMessageType](t *testing.T, chain *i } // ExecViaReflectContract submit execute message to send payload to reflect contract -func ExecViaReflectContract(t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs []wasmvmtypes.CosmosMsg) (*sdk.Result, error) { - t.Helper() +func ExecViaReflectContract(t *testing.T, chain *ibctesting.TestChain, contractAddr sdk.AccAddress, msgs []wasmvmtypes.CosmosMsg) (*abci.ExecTxResult, error) { require.NotEmpty(t, msgs) reflectSend := testdata.ReflectHandleMsg{ Reflect: &testdata.ReflectPayload{Msgs: msgs}, diff --git a/tests/system/cli.go b/tests/system/cli.go index 7aeddb38ab..2e8f462eef 100644 --- a/tests/system/cli.go +++ b/tests/system/cli.go @@ -308,7 +308,7 @@ func (c WasmdCli) WasmStore(file string, args ...string) int { rsp := c.CustomCommand(cmd...) RequireTxSuccess(c.t, rsp) - codeID := gjson.Get(rsp, "logs.#.events.#.attributes.#(key=code_id).value").Array()[0].Array()[0].Int() + codeID := gjson.Get(rsp, "events.#.attributes.#(key=code_id).value").Array()[0].Array()[0].Int() require.NotEmpty(c.t, codeID) return int(codeID) } @@ -321,7 +321,7 @@ func (c WasmdCli) WasmInstantiate(codeID int, initMsg string, args ...string) st cmd := append([]string{"tx", "wasm", "instantiate", strconv.Itoa(codeID), initMsg}, args...) rsp := c.CustomCommand(cmd...) RequireTxSuccess(c.t, rsp) - addr := gjson.Get(rsp, "logs.#.events.#.attributes.#(key=_contract_address).value").Array()[0].Array()[0].String() + addr := gjson.Get(rsp, "events.#.attributes.#(key=_contract_address).value").Array()[0].Array()[0].String() require.NotEmpty(c.t, addr) return addr } @@ -341,21 +341,21 @@ func (c WasmdCli) QueryBalances(addr string) string { // QueryBalance returns balance amount for given denom. // 0 when not found func (c WasmdCli) QueryBalance(addr, denom string) int64 { - raw := c.CustomQuery("q", "bank", "balances", addr, "--denom="+denom) + raw := c.CustomQuery("q", "bank", "balance", addr, denom) require.Contains(c.t, raw, "amount", raw) - return gjson.Get(raw, "amount").Int() + return gjson.Get(raw, "balance.amount").Int() } // QueryTotalSupply returns total amount of tokens for a given denom. // 0 when not found func (c WasmdCli) QueryTotalSupply(denom string) int64 { - raw := c.CustomQuery("q", "bank", "total", "--denom="+denom) + raw := c.CustomQuery("q", "bank", "total-supply") require.Contains(c.t, raw, "amount", raw) - return gjson.Get(raw, "amount").Int() + return gjson.Get(raw, fmt.Sprintf("supply.#(denom==%q).amount", denom)).Int() } func (c WasmdCli) GetTendermintValidatorSet() rpc.ResultValidatorsOutput { - args := []string{"q", "tendermint-validator-set"} + args := []string{"q", "comet-validator-set"} got := c.CustomQuery(args...) // still using amino here as the SDK diff --git a/tests/system/cli_test.go b/tests/system/cli_test.go index 02b486aadd..fd001dc6bf 100644 --- a/tests/system/cli_test.go +++ b/tests/system/cli_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" @@ -29,7 +30,7 @@ func TestUnsafeResetAll(t *testing.T) { require.NoError(t, err) // when - sut.ForEachNodeExecAndWait(t, []string{"tendermint", "unsafe-reset-all"}) + sut.ForEachNodeExecAndWait(t, []string{"comet", "unsafe-reset-all"}) // then sut.withEachNodeHome(func(i int, home string) { @@ -94,7 +95,7 @@ func TestVestingAccounts(t *testing.T) { assert.Equal(t, myStartTimestamp, accounts[0].Get("start_time").Int()) // check accounts have some balances - assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100000000))), GetGenesisBalance([]byte(raw), vest1Addr)) - assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100000001))), GetGenesisBalance([]byte(raw), vest2Addr)) - assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(200000002))), GetGenesisBalance([]byte(raw), vest3Addr)) + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100000000))), GetGenesisBalance([]byte(raw), vest1Addr)) + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100000001))), GetGenesisBalance([]byte(raw), vest2Addr)) + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(200000002))), GetGenesisBalance([]byte(raw), vest3Addr)) } diff --git a/tests/system/genesis_io.go b/tests/system/genesis_io.go index 23e54f09e8..4b286304d2 100644 --- a/tests/system/genesis_io.go +++ b/tests/system/genesis_io.go @@ -4,17 +4,20 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/tidwall/gjson" "github.com/tidwall/sjson" + + sdkmath "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // SetConsensusMaxGas max gas that can be consumed in a block func SetConsensusMaxGas(t *testing.T, max int) GenesisMutator { return func(genesis []byte) []byte { t.Helper() - state, err := sjson.SetRawBytes(genesis, "consensus_params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, max))) + state, err := sjson.SetRawBytes(genesis, "consensus.params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, max))) require.NoError(t, err) return state } @@ -26,7 +29,7 @@ func GetGenesisBalance(rawGenesis []byte, addr string) sdk.Coins { balances := gjson.GetBytes(rawGenesis, fmt.Sprintf(`app_state.bank.balances.#[address==%q]#.coins`, addr)).Array() for _, coins := range balances { for _, coin := range coins.Array() { - r = append(r, sdk.NewCoin(coin.Get("denom").String(), sdk.NewInt(coin.Get("amount").Int()))) + r = append(r, sdk.NewCoin(coin.Get("denom").String(), sdkmath.NewInt(coin.Get("amount").Int()))) } } return r diff --git a/tests/system/staking_test.go b/tests/system/staking_test.go index 2cb25d9778..32c80b5f23 100644 --- a/tests/system/staking_test.go +++ b/tests/system/staking_test.go @@ -38,17 +38,17 @@ func TestStakeUnstake(t *testing.T) { assert.Equal(t, int64(99989999), cli.QueryBalance(account1Addr, "stake")) rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr) - assert.Equal(t, "10000", gjson.Get(rsp, "balance.amount").String()) - assert.Equal(t, "stake", gjson.Get(rsp, "balance.denom").String()) + assert.Equal(t, "10000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp) + assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp) // unstake tokens rsp = cli.CustomCommand("tx", "staking", "unbond", valAddr, "5000stake", "--from="+account1Addr, "--fees=1stake") RequireTxSuccess(t, rsp) rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr) - assert.Equal(t, "5000", gjson.Get(rsp, "balance.amount").String()) - assert.Equal(t, "stake", gjson.Get(rsp, "balance.denom").String()) + assert.Equal(t, "5000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp) + assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp) rsp = cli.CustomQuery("q", "staking", "unbonding-delegation", account1Addr, valAddr) - assert.Equal(t, "5000", gjson.Get(rsp, "entries.#.balance").Array()[0].String()) + assert.Equal(t, "5000", gjson.Get(rsp, "unbond.entries.#.balance").Array()[0].String(), rsp) } diff --git a/tests/system/system.go b/tests/system/system.go index 89b5ca0543..e05451a5da 100644 --- a/tests/system/system.go +++ b/tests/system/system.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -89,7 +88,7 @@ func (s *SystemUnderTest) SetupChain() { "--starting-ip-address", "", // empty to use host systems "--single-host", } - fmt.Printf("+++ %s %s", s.execBinary, strings.Join(args, " ")) + fmt.Printf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")) cmd := exec.Command( //nolint:gosec locateExecutable(s.execBinary), args..., @@ -104,12 +103,12 @@ func (s *SystemUnderTest) SetupChain() { // modify genesis with system test defaults src := filepath.Join(workDir, s.nodePath(0), "config", "genesis.json") - genesisBz, err := ioutil.ReadFile(src) + genesisBz, err := os.ReadFile(src) if err != nil { panic(fmt.Sprintf("failed to load genesis: %s", err)) } - genesisBz, err = sjson.SetRawBytes(genesisBz, "consensus_params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, 10_000_000))) + genesisBz, err = sjson.SetRawBytes(genesisBz, "consensus.params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, 10_000_000))) if err != nil { panic(fmt.Sprintf("failed set block max gas: %s", err)) } @@ -812,7 +811,7 @@ func copyFilesInDir(src, dest string) error { if err != nil { return fmt.Errorf("mkdirs: %s", err) } - fs, err := ioutil.ReadDir(src) + fs, err := os.ReadDir(src) if err != nil { return fmt.Errorf("read dir: %s", err) } @@ -828,7 +827,7 @@ func copyFilesInDir(src, dest string) error { } func storeTempFile(t *testing.T, content []byte) *os.File { - out, err := ioutil.TempFile(t.TempDir(), "genesis") + out, err := os.CreateTemp(t.TempDir(), "genesis") require.NoError(t, err) _, err = io.Copy(out, bytes.NewReader(content)) require.NoError(t, err) diff --git a/x/wasm/alias.go b/x/wasm/alias.go index 931cc837a6..1cf0293ead 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -45,8 +45,6 @@ var ( // Deprecated: Do not use. ValidateGenesis = types.ValidateGenesis // Deprecated: Do not use. - ConvertToProposals = types.ConvertToProposals - // Deprecated: Do not use. GetCodeKey = types.GetCodeKey // Deprecated: Do not use. GetContractAddressKey = types.GetContractAddressKey @@ -111,8 +109,6 @@ var ( // variable aliases // Deprecated: Do not use. - ModuleCdc = types.ModuleCdc - // Deprecated: Do not use. DefaultCodespace = types.DefaultCodespace // Deprecated: Do not use. ErrCreateFailed = types.ErrCreateFailed diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 928dee6b69..7f22f958f6 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -62,7 +62,7 @@ func ProposalStoreCodeCmd() *cobra.Command { Short: "Submit a wasm binary proposal", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -80,13 +80,10 @@ func ProposalStoreCodeCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -154,7 +151,7 @@ func ProposalInstantiateContractCmd() *cobra.Command { Short: "Submit an instantiate wasm contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -173,13 +170,10 @@ func ProposalInstantiateContractCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -201,7 +195,7 @@ func ProposalInstantiateContract2Cmd() *cobra.Command { Short: "Submit an instantiate wasm contract proposal with predictable address", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -220,13 +214,10 @@ func ProposalInstantiateContract2Cmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -250,7 +241,7 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command { Short: "Submit a store and instantiate wasm contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -341,12 +332,12 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command { Msg: []byte(args[1]), Funds: amount, } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -375,7 +366,7 @@ func ProposalMigrateContractCmd() *cobra.Command { Short: "Submit a migrate wasm contract to a new code version proposal", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -394,13 +385,10 @@ func ProposalMigrateContractCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -417,7 +405,7 @@ func ProposalExecuteContractCmd() *cobra.Command { Short: "Submit a execute wasm contract proposal (run by any address)", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -448,12 +436,12 @@ func ProposalExecuteContractCmd() *cobra.Command { Msg: execMsg, Funds: funds, } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -474,7 +462,7 @@ func ProposalSudoContractCmd() *cobra.Command { Short: "Submit a sudo wasm contract proposal (to call privileged commands)", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -493,12 +481,12 @@ func ProposalSudoContractCmd() *cobra.Command { Contract: args[0], Msg: []byte(args[1]), } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -517,7 +505,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command { Short: "Submit a new admin for a contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -531,13 +519,13 @@ func ProposalUpdateContractAdminCmd() *cobra.Command { return errors.New("authority address is required") } - src := parseUpdateContractAdminArgs(args, authority) - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + src, err := parseUpdateContractAdminArgs(args, authority) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -556,7 +544,7 @@ func ProposalClearContractAdminCmd() *cobra.Command { Short: "Submit a clear admin for a contract to prevent further migrations proposal", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -574,12 +562,12 @@ func ProposalClearContractAdminCmd() *cobra.Command { Sender: authority, Contract: args[0], } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -598,7 +586,7 @@ func ProposalPinCodesCmd() *cobra.Command { Short: "Submit a pin code proposal for pinning a code to cache", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -621,12 +609,12 @@ func ProposalPinCodesCmd() *cobra.Command { Authority: authority, CodeIDs: codeIds, } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -657,7 +645,7 @@ func ProposalUnpinCodesCmd() *cobra.Command { Short: "Submit a unpin code proposal for unpinning a code to cache", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -679,12 +667,12 @@ func ProposalUnpinCodesCmd() *cobra.Command { Authority: authority, CodeIDs: codeIds, } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) - if err != nil { + if err = msg.ValidateBasic(); err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) + if err != nil { return err } @@ -763,7 +751,7 @@ Example: $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm,%s1vx8knpllrj7n963p9ttd80w47kpacrhuts497x `, version.AppName, bech32Prefix, bech32Prefix)), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -785,20 +773,21 @@ $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1 msgs := make([]sdk.Msg, len(updates)) for i, update := range updates { permission := update.InstantiatePermission - msgs[i] = &types.MsgUpdateInstantiateConfig{ + msg := &types.MsgUpdateInstantiateConfig{ Sender: authority, CodeID: update.CodeID, NewInstantiatePermission: &permission, } + if err = msg.ValidateBasic(); err != nil { + return err + } + msgs[i] = msg } - proposalMsg, err := v1.NewMsgSubmitProposal(msgs, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal(msgs, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -815,7 +804,7 @@ func ProposalAddCodeUploadParamsAddresses() *cobra.Command { Short: "Submit an add code upload params addresses proposal to add addresses to code upload config params", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -834,13 +823,10 @@ func ProposalAddCodeUploadParamsAddresses() *cobra.Command { Addresses: args, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -857,7 +843,7 @@ func ProposalRemoveCodeUploadParamsAddresses() *cobra.Command { Short: "Submit a remove code upload params addresses proposal to remove addresses from code upload config params", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -876,13 +862,10 @@ func ProposalRemoveCodeUploadParamsAddresses() *cobra.Command { Addresses: args, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, @@ -899,35 +882,41 @@ func addCommonProposalFlags(cmd *cobra.Command) { cmd.Flags().String(cli.FlagSummary, "", "Summary of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") cmd.Flags().String(flagAuthority, DefaultGovAuthority.String(), "The address of the governance account. Default is the sdk gov module account") + cmd.Flags().Bool(flagExpedite, false, "Expedite proposals have shorter voting period but require higher voting threshold") } -func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, error) { +func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, bool, error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { - return client.Context{}, "", "", nil, err + return client.Context{}, "", "", nil, false, err } proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) if err != nil { - return clientCtx, proposalTitle, "", nil, err + return clientCtx, proposalTitle, "", nil, false, err } summary, err := cmd.Flags().GetString(cli.FlagSummary) if err != nil { - return client.Context{}, proposalTitle, summary, nil, err + return client.Context{}, proposalTitle, summary, nil, false, err } depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) if err != nil { - return client.Context{}, proposalTitle, summary, nil, err + return client.Context{}, proposalTitle, summary, nil, false, err } deposit, err := sdk.ParseCoinsNormalized(depositArg) if err != nil { - return client.Context{}, proposalTitle, summary, deposit, err + return client.Context{}, proposalTitle, summary, deposit, false, err } - return clientCtx, proposalTitle, summary, deposit, nil + expedite, err := cmd.Flags().GetBool(flagExpedite) + if err != nil { + return client.Context{}, proposalTitle, summary, deposit, false, err + } + + return clientCtx, proposalTitle, summary, deposit, expedite, nil } func ProposalStoreAndMigrateContractCmd() *cobra.Command { @@ -936,7 +925,7 @@ func ProposalStoreAndMigrateContractCmd() *cobra.Command { Short: "Submit a store and migrate wasm contract proposal", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -963,13 +952,10 @@ func ProposalStoreAndMigrateContractCmd() *cobra.Command { Contract: args[1], } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) }, diff --git a/x/wasm/client/cli/new_tx.go b/x/wasm/client/cli/new_tx.go index 2a76fb828f..18b5e3517c 100644 --- a/x/wasm/client/cli/new_tx.go +++ b/x/wasm/client/cli/new_tx.go @@ -31,9 +31,6 @@ func MigrateContractCmd() *cobra.Command { if err != nil { return err } - if err := msg.ValidateBasic(); err != nil { - return nil - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, SilenceUsage: true, @@ -57,7 +54,7 @@ func parseMigrateContractArgs(args []string, sender string) (types.MsgMigrateCon CodeID: codeID, Msg: []byte(migrateMsg), } - return msg, nil + return msg, msg.ValidateBasic() } // UpdateContractAdminCmd sets an new admin for a contract @@ -73,8 +70,8 @@ func UpdateContractAdminCmd() *cobra.Command { return err } - msg := parseUpdateContractAdminArgs(args, clientCtx.GetFromAddress().String()) - if err := msg.ValidateBasic(); err != nil { + msg, err := parseUpdateContractAdminArgs(args, clientCtx.GetFromAddress().String()) + if err != nil { return err } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) @@ -85,13 +82,13 @@ func UpdateContractAdminCmd() *cobra.Command { return cmd } -func parseUpdateContractAdminArgs(args []string, sender string) types.MsgUpdateAdmin { +func parseUpdateContractAdminArgs(args []string, sender string) (types.MsgUpdateAdmin, error) { msg := types.MsgUpdateAdmin{ Sender: sender, Contract: args[0], NewAdmin: args[1], } - return msg + return msg, msg.ValidateBasic() } // ClearContractAdminCmd clears an admin for a contract diff --git a/x/wasm/client/cli/tx.go b/x/wasm/client/cli/tx.go index 863730e9f2..ec8bd5f569 100644 --- a/x/wasm/client/cli/tx.go +++ b/x/wasm/client/cli/tx.go @@ -47,6 +47,7 @@ const ( flagAllowAllMsgs = "allow-all-messages" flagNoTokenTransfer = "no-token-transfer" flagAuthority = "authority" + flagExpedite = "expedite" ) // GetTxCmd returns the transaction commands for this module @@ -90,9 +91,6 @@ func StoreCodeCmd() *cobra.Command { if err != nil { return err } - if err = msg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, SilenceUsage: true, @@ -131,7 +129,7 @@ func parseStoreCodeArgs(file, sender string, flags *flag.FlagSet) (types.MsgStor WASMByteCode: wasm, InstantiatePermission: perm, } - return msg, nil + return msg, msg.ValidateBasic() } func parseAccessConfigFlags(flags *flag.FlagSet) (*types.AccessConfig, error) { @@ -217,9 +215,6 @@ $ %s tx wasm instantiate 1 '{"foo":"bar"}' --admin="$(%s keys show mykey -a)" \ if err != nil { return err } - if err := msg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, SilenceUsage: true, @@ -278,9 +273,6 @@ $ %s tx wasm instantiate2 1 '{"foo":"bar"}' $(echo -n "testing" | xxd -ps) --adm Salt: salt, FixMsg: fixMsg, } - if err := msg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, SilenceUsage: true, @@ -362,7 +354,7 @@ func parseInstantiateArgs(rawCodeID, initMsg string, kr keyring.Keyring, sender Msg: []byte(initMsg), Admin: adminStr, } - return &msg, nil + return &msg, msg.ValidateBasic() } // ExecuteContractCmd will instantiate a contract from previously uploaded code. @@ -382,9 +374,6 @@ func ExecuteContractCmd() *cobra.Command { if err != nil { return err } - if err := msg.ValidateBasic(); err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, SilenceUsage: true, diff --git a/x/wasm/client/cli/utils.go b/x/wasm/client/cli/utils.go index f6c0c6bf88..97adca5635 100644 --- a/x/wasm/client/cli/utils.go +++ b/x/wasm/client/cli/utils.go @@ -14,7 +14,7 @@ import ( func ExtendUnsafeResetAllCmd(rootCmd *cobra.Command) { unsafeResetCmd := tmcmd.ResetAllCmd.Use for _, branchCmd := range rootCmd.Commands() { - if branchCmd.Use != "tendermint" { + if branchCmd.Use != "comet" { continue } for _, cmd := range branchCmd.Commands() { diff --git a/x/wasm/common_test.go b/x/wasm/common_test.go index 202770aa60..aa507ee429 100644 --- a/x/wasm/common_test.go +++ b/x/wasm/common_test.go @@ -14,7 +14,6 @@ const firstCodeID = 1 // ensure store code returns the expected response func assertStoreCodeResponse(t *testing.T, data []byte, expected uint64) { - t.Helper() var pStoreResp types.MsgStoreCodeResponse require.NoError(t, pStoreResp.Unmarshal(data)) require.Equal(t, pStoreResp.CodeID, expected) @@ -22,7 +21,6 @@ func assertStoreCodeResponse(t *testing.T, data []byte, expected uint64) { // ensure execution returns the expected data func assertExecuteResponse(t *testing.T, data, expected []byte) { - t.Helper() var pExecResp types.MsgExecuteContractResponse require.NoError(t, pExecResp.Unmarshal(data)) require.Equal(t, pExecResp.Data, expected) @@ -30,7 +28,6 @@ func assertExecuteResponse(t *testing.T, data, expected []byte) { // ensures this returns a valid bech32 address and returns it func parseInitResponse(t *testing.T, data []byte) string { - t.Helper() var pInstResp types.MsgInstantiateContractResponse require.NoError(t, pInstResp.Unmarshal(data)) require.NotEmpty(t, pInstResp.Address) diff --git a/x/wasm/ibc.go b/x/wasm/ibc.go index 4cd6f8fd21..347a3c2eaa 100644 --- a/x/wasm/ibc.go +++ b/x/wasm/ibc.go @@ -4,15 +4,15 @@ import ( "math" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/CosmWasm/wasmd/x/wasm/types" diff --git a/x/wasm/ibc_integration_test.go b/x/wasm/ibc_integration_test.go index c5403759dd..689c12b3f9 100644 --- a/x/wasm/ibc_integration_test.go +++ b/x/wasm/ibc_integration_test.go @@ -1,13 +1,14 @@ package wasm_test import ( + "encoding/json" "testing" wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -57,10 +58,9 @@ func TestOnChanOpenInitVersion(t *testing.T) { appA = chainA.App.(*app.WasmApp) contractInfo = appA.WasmKeeper.GetContractInfo(chainA.GetContext(), myContractAddr) ) - path := wasmibctesting.NewPath(chainA, chainB) - coordinator.SetupConnections(path) - + coordinator.SetupClients(path) + coordinator.CreateConnections(path) path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ PortID: contractInfo.IBCPortID, Version: startVersion, @@ -174,7 +174,8 @@ func TestOnIBCPacketReceive(t *testing.T) { // setup chain B contracts reflectID := chainB.StoreCodeFile("./keeper/testdata/reflect.wasm").CodeID - initMsg := wasmkeeper.IBCReflectInitMsg{ReflectCodeID: reflectID}.GetBytes(t) + initMsg, err := json.Marshal(wasmkeeper.IBCReflectInitMsg{ReflectCodeID: reflectID}) + require.NoError(t, err) codeID := chainB.StoreCodeFile("./keeper/testdata/ibc_reflect.wasm").CodeID ibcReflectContractAddr := chainB.InstantiateContract(codeID, initMsg) @@ -204,7 +205,7 @@ func TestOnIBCPacketReceive(t *testing.T) { require.Equal(t, 1, len(chainA.PendingSendPackets)) require.Equal(t, 0, len(chainB.PendingSendPackets)) - err := coord.RelayAndAckPendingPackets(path) + err = coord.RelayAndAckPendingPackets(path) // then if spec.expPacketNotHandled { diff --git a/x/wasm/ibc_reflect_test.go b/x/wasm/ibc_reflect_test.go index 7151b27150..f0d3ced634 100644 --- a/x/wasm/ibc_reflect_test.go +++ b/x/wasm/ibc_reflect_test.go @@ -4,8 +4,8 @@ import ( "testing" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/wasm/ibc_test.go b/x/wasm/ibc_test.go index f25622c8ee..d3f18e4e14 100644 --- a/x/wasm/ibc_test.go +++ b/x/wasm/ibc_test.go @@ -6,9 +6,9 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/rand" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/wasm/ibctesting/chain.go b/x/wasm/ibctesting/chain.go index 504e82f283..1f9aee077b 100644 --- a/x/wasm/ibctesting/chain.go +++ b/x/wasm/ibctesting/chain.go @@ -1,44 +1,46 @@ package ibctesting import ( + "context" "fmt" "testing" "time" + // simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" - tmtypes "github.com/cometbft/cometbft/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" + cmttypes "github.com/cometbft/cometbft/types" tmversion "github.com/cometbft/cometbft/version" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - "github.com/cosmos/ibc-go/v7/modules/core/types" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v7/testing" - "github.com/cosmos/ibc-go/v7/testing/mock" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + "github.com/cosmos/ibc-go/v8/modules/core/types" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -51,14 +53,16 @@ var MaxAccounts = 10 type SenderAccount struct { SenderPrivKey cryptotypes.PrivKey - SenderAccount authtypes.AccountI + SenderAccount sdk.AccountI } // ChainApp Abstract chain app definition used for testing type ChainApp interface { - abci.Application + servertypes.ABCI AppCodec() codec.Codec - NewContext(isCheckTx bool, header tmproto.Header) sdk.Context + GetContextForFinalizeBlock(txBytes []byte) sdk.Context + NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context + NewUncachedContext(isCheckTx bool, header cmtproto.Header) sdk.Context LastBlockHeight() int64 LastCommitID() storetypes.CommitID GetBaseApp() *baseapp.BaseApp @@ -72,7 +76,7 @@ type ChainApp interface { GetWasmKeeper() wasmkeeper.Keeper } -// TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI +// TestChain is a testing struct that wraps a simapp with the last CMT header, the current ABCI // header and the validators of the TestChain. It also contains a field called ChainID. This // is the clientID that *other* chains use to refer to this TestChain. The SenderAccount // is used for delivering transactions through the application state. @@ -83,25 +87,25 @@ type TestChain struct { Coordinator *Coordinator App ChainApp ChainID string - LastHeader *ibctm.Header // header for last block height committed - CurrentHeader tmproto.Header // header for current block height + LastHeader *ibctm.Header // header for last block height committed + CurrentHeader cmtproto.Header // header for current block height QueryServer types.QueryServer TxConfig client.TxConfig - Codec codec.BinaryCodec + Codec codec.Codec - Vals *tmtypes.ValidatorSet - NextVals *tmtypes.ValidatorSet + Vals *cmttypes.ValidatorSet + NextVals *cmttypes.ValidatorSet // Signers is a map from validator address to the PrivValidator // The map is converted into an array that is the same order as the validators right before signing commit // This ensures that signers will always be in correct order even as validator powers change. // If a test adds a new validator after chain creation, then the signer map must be updated to include // the new PrivValidator entry. - Signers map[string]tmtypes.PrivValidator + Signers map[string]cmttypes.PrivValidator // autogenerated sender private key SenderPrivKey cryptotypes.PrivKey - SenderAccount authtypes.AccountI + SenderAccount sdk.AccountI SenderAccounts []SenderAccount PendingSendPackets []channeltypes.Packet @@ -114,44 +118,41 @@ type PacketAck struct { } // ChainAppFactory abstract factory method that usually implemented by app.SetupWithGenesisValSet -type ChainAppFactory func(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp +type ChainAppFactory func(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp // DefaultWasmAppFactory instantiates and sets up the default wasmd app -func DefaultWasmAppFactory(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp { - t.Helper() +func DefaultWasmAppFactory(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp { return app.SetupWithGenesisValSet(t, valSet, genAccs, chainID, opts, balances...) } // NewDefaultTestChain initializes a new test chain with a default of 4 validators // Use this function if the tests do not need custom control over the validator set func NewDefaultTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasmkeeper.Option) *TestChain { - t.Helper() return NewTestChain(t, coord, DefaultWasmAppFactory, chainID, opts...) } // NewTestChain initializes a new test chain with a default of 4 validators // Use this function if the tests do not need custom control over the validator set func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, opts ...wasmkeeper.Option) *TestChain { - t.Helper() // generate validators private/public key var ( validatorsPerChain = 4 - validators = make([]*tmtypes.Validator, 0, validatorsPerChain) - signersByAddress = make(map[string]tmtypes.PrivValidator, validatorsPerChain) + validators = make([]*cmttypes.Validator, 0, validatorsPerChain) + signersByAddress = make(map[string]cmttypes.PrivValidator, validatorsPerChain) ) for i := 0; i < validatorsPerChain; i++ { - privVal := mock.NewPV() + _, privVal := cmttypes.RandValidator(false, 100) pubKey, err := privVal.GetPubKey() require.NoError(t, err) - validators = append(validators, tmtypes.NewValidator(pubKey, 1)) + validators = append(validators, cmttypes.NewValidator(pubKey, 1)) signersByAddress[pubKey.Address().String()] = privVal } // construct validator set; // Note that the validators are sorted by voting power // or, if equal, by address lexical order - valSet := tmtypes.NewValidatorSet(validators) + valSet := cmttypes.NewValidatorSet(validators) return NewTestChainWithValSet(t, coord, appFactory, chainID, valSet, signersByAddress, opts...) } @@ -171,8 +172,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, // // CONTRACT: Validator array must be provided in the order expected by Tendermint. // i.e. sorted first by power and then lexicographically by address. -func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, valSet *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator, opts ...wasmkeeper.Option) *TestChain { - t.Helper() +func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator, opts ...wasmkeeper.Option) *TestChain { genAccs := []authtypes.GenesisAccount{} genBals := []banktypes.Balance{} senderAccs := []SenderAccount{} @@ -181,7 +181,7 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAp for i := 0; i < MaxAccounts; i++ { senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), uint64(i), 0) - amount, ok := sdk.NewIntFromString("10000000000000000000") + amount, ok := sdkmath.NewIntFromString("10000000000000000000") require.True(t, ok) // add sender account @@ -204,7 +204,7 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAp wasmApp := appFactory(t, valSet, genAccs, chainID, opts, genBals...) // create current header and call begin block - header := tmproto.Header{ + header := cmtproto.Header{ ChainID: chainID, Height: 1, Time: coord.CurrentTime.UTC(), @@ -228,7 +228,7 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAp SenderPrivKey: senderAccs[0].SenderPrivKey, SenderAccount: senderAccs[0].SenderAccount, SenderAccounts: senderAccs, - DefaultMsgFees: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.ZeroInt())), + DefaultMsgFees: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.ZeroInt())), } coord.CommitBlock(chain) @@ -238,7 +238,7 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAp // GetContext returns the current context for the application. func (chain *TestChain) GetContext() sdk.Context { - return chain.App.NewContext(false, chain.CurrentHeader) + return chain.App.NewUncachedContext(false, chain.CurrentHeader) } // QueryProof performs an abci query with the given key and returns the proto encoded merkle proof @@ -257,12 +257,13 @@ func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, cl // QueryProofForStore performs an abci query with the given key and returns the proto encoded merkle proof // for the query and the height at which the proof will succeed on a tendermint verifier. func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height int64) ([]byte, clienttypes.Height) { - res := chain.App.Query(abci.RequestQuery{ + res, err := chain.App.Query(context.TODO(), &abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", storeKey), Height: height - 1, Data: key, Prove: true, }) + require.NoError(chain.t, err) merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) require.NoError(chain.t, err) @@ -281,12 +282,13 @@ func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height i // QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof // for the query and the height at which the proof will succeed on a tendermint verifier. func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height) { - res := chain.App.Query(abci.RequestQuery{ + res, err := chain.App.Query(context.TODO(), &abci.RequestQuery{ Path: "store/upgrade/key", Height: int64(height - 1), Data: key, Prove: true, }) + require.NoError(chain.t, err) merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) require.NoError(chain.t, err) @@ -316,18 +318,27 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien // NextBlock sets the last header to the current header and increments the current header to be // at the next block height. It does not update the time as that is handled by the Coordinator. -// It will call Endblock and Commit and apply the validator set changes to the next validators -// of the next block being created. This follows the Tendermint protocol of applying valset changes +// It will call FinalizeBlock and Commit and apply the validator set changes to the next validators +// of the next block being created. This follows the CometBFT protocol of applying valset changes // returned on block `n` to the validators of block `n+2`. -// It calls BeginBlock with the new block created before returning. -func (chain *TestChain) NextBlock() abci.ResponseEndBlock { - res := chain.App.EndBlock(abci.RequestEndBlock{Height: chain.CurrentHeader.Height}) - chain.App.Commit() - chain.CaptureIBCEvents(res.Events) +// It updates the current header with the new block created before returning. +func (chain *TestChain) NextBlock() { + res, err := chain.App.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: chain.CurrentHeader.Height, + Time: chain.CurrentHeader.GetTime(), // todo (Alex): is this the correct time + NextValidatorsHash: chain.NextVals.Hash(), + }) + require.NoError(chain.t, err) + chain.commitBlock(res) +} + +func (chain *TestChain) commitBlock(res *abci.ResponseFinalizeBlock) { + _, err := chain.App.Commit() + require.NoError(chain.t, err) // set the last header to the current header // use nil trusted fields - chain.LastHeader = chain.CurrentTMClientHeader() + chain.LastHeader = chain.CurrentCmtClientHeader() // val set changes returned from previous block get applied to the next validators // of this block. See tendermint spec for details. @@ -335,7 +346,7 @@ func (chain *TestChain) NextBlock() abci.ResponseEndBlock { chain.NextVals = ibctesting.ApplyValSetChanges(chain.t, chain.Vals, res.ValidatorUpdates) // increment the current header - chain.CurrentHeader = tmproto.Header{ + chain.CurrentHeader = cmtproto.Header{ ChainID: chain.ChainID, Height: chain.App.LastBlockHeight() + 1, AppHash: chain.App.LastCommitID().Hash, @@ -346,21 +357,6 @@ func (chain *TestChain) NextBlock() abci.ResponseEndBlock { NextValidatorsHash: chain.NextVals.Hash(), ProposerAddress: chain.CurrentHeader.ProposerAddress, } - - votes := make([]abci.VoteInfo, len(chain.Vals.Validators)) - for i, v := range chain.Vals.Validators { - votes[i] = abci.VoteInfo{ - Validator: abci.Validator{Address: v.Address, Power: v.VotingPower}, - SignedLastBlock: true, - } - } - chain.App.BeginBlock(abci.RequestBeginBlock{ - Header: chain.CurrentHeader, - LastCommitInfo: abci.CommitInfo{ - Votes: votes, - }, - }) - return res } // sendMsgs delivers a transaction through the application without returning the result. @@ -372,39 +368,62 @@ func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { // SendMsgs delivers a transaction through the application. It updates the senders sequence // number and updates the TestChain's headers. It returns the result and error if one // occurred. -func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { +func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { + rsp, gotErr := chain.sendWithSigner(chain.SenderPrivKey, chain.SenderAccount, msgs...) + require.NoError(chain.t, chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence()+1)) + return rsp, gotErr +} + +// SendNonDefaultSenderMsgs is the same as SendMsgs but with a custom signer/account +func (chain *TestChain) SendNonDefaultSenderMsgs(senderPrivKey cryptotypes.PrivKey, msgs ...sdk.Msg) (*abci.ExecTxResult, error) { + require.NotEqual(chain.t, chain.SenderPrivKey, senderPrivKey, "use SendMsgs method") + + addr := sdk.AccAddress(senderPrivKey.PubKey().Address().Bytes()) + account := chain.App.GetAccountKeeper().GetAccount(chain.GetContext(), addr) + require.NotNil(chain.t, account) + return chain.sendWithSigner(senderPrivKey, account, msgs...) +} + +// sendWithSigner is a generic helper to send messages +func (chain *TestChain) sendWithSigner( + senderPrivKey cryptotypes.PrivKey, + senderAccount sdk.AccountI, + msgs ...sdk.Msg, +) (*abci.ExecTxResult, error) { // ensure the chain has the latest time chain.Coordinator.UpdateTimeForChain(chain) - _, r, gotErr := app.SignAndDeliverWithoutCommit( + + blockResp, gotErr := app.SignAndDeliverWithoutCommit( chain.t, chain.TxConfig, chain.App.GetBaseApp(), msgs, chain.DefaultMsgFees, chain.ChainID, - []uint64{chain.SenderAccount.GetAccountNumber()}, - []uint64{chain.SenderAccount.GetSequence()}, - chain.SenderPrivKey, + []uint64{senderAccount.GetAccountNumber()}, + []uint64{senderAccount.GetSequence()}, + chain.CurrentHeader.GetTime(), + senderPrivKey, ) - - // NextBlock calls app.Commit() - chain.NextBlock() - - // increment sequence for successful and failed transaction execution - require.NoError(chain.t, chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence()+1)) - chain.Coordinator.IncrementTime() - if gotErr != nil { return nil, gotErr } - chain.CaptureIBCEvents(r.Events) + chain.commitBlock(blockResp) + chain.Coordinator.IncrementTime() + + require.Len(chain.t, blockResp.TxResults, 1) + txResult := blockResp.TxResults[0] + if txResult.Code != 0 { + return txResult, fmt.Errorf("%s/%d: %q", txResult.Codespace, txResult.Code, txResult.Log) + } - return r, nil + chain.CaptureIBCEvents(txResult) + return txResult, nil } -func (chain *TestChain) CaptureIBCEvents(evts []abci.Event) { - toSend := GetSendPackets(evts) +func (chain *TestChain) CaptureIBCEvents(r *abci.ExecTxResult) { + toSend := GetSendPackets(r.Events) if len(toSend) > 0 { // Keep a queue on the chain that we can relay in tests chain.PendingSendPackets = append(chain.PendingSendPackets, toSend...) @@ -428,19 +447,28 @@ func (chain *TestChain) GetConsensusState(clientID string, height exported.Heigh // GetValsAtHeight will return the validator set of the chain at a given height. It will return // a success boolean depending on if the validator set exists or not at that height. -func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bool) { - histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) - if !ok { +func (chain *TestChain) GetValsAtHeight(height int64) (*cmttypes.ValidatorSet, bool) { + // if the current uncommitted header equals the requested height, then we can return + // the current validator set as this validator set will be stored in the historical info + // when the block height is executed + if height == chain.CurrentHeader.Height { + return chain.Vals, true + } + + histInfo, err := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) + if err != nil { return nil, false } - valSet := stakingtypes.Validators(histInfo.Valset) + valSet := stakingtypes.Validators{ + Validators: histInfo.Valset, + } - tmValidators, err := testutil.ToTmValidators(valSet, sdk.DefaultPowerReduction) + cmtValidators, err := testutil.ToCmtValidators(valSet, sdk.DefaultPowerReduction) if err != nil { panic(err) } - return tmtypes.NewValidatorSet(tmValidators), true + return cmttypes.NewValidatorSet(cmtValidators), true } // GetAcknowledgement retrieves an acknowledgement for the provided packet. If the @@ -460,32 +488,32 @@ func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix { // ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the // light client on the source chain. func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty *TestChain, clientID string) (*ibctm.Header, error) { - return chain.ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty, clientID, clienttypes.ZeroHeight()) + return chain.ConstructUpdateCMTClientHeaderWithTrustedHeight(counterparty, clientID, clienttypes.ZeroHeight()) } -// ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the +// ConstructUpdateCMTClientHeaderWithTrustedHeight will construct a valid 07-tendermint Header to update the // light client on the source chain. -func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty *TestChain, clientID string, trustedHeight clienttypes.Height) (*ibctm.Header, error) { +func (chain *TestChain) ConstructUpdateCMTClientHeaderWithTrustedHeight(counterparty *TestChain, clientID string, trustedHeight clienttypes.Height) (*ibctm.Header, error) { header := counterparty.LastHeader // Relayer must query for LatestHeight on client to get TrustedHeight if the trusted height is not set if trustedHeight.IsZero() { trustedHeight = chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height) } var ( - tmTrustedVals *tmtypes.ValidatorSet - ok bool + cmtTrustedVals *cmttypes.ValidatorSet + ok bool ) // Once we get TrustedHeight from client, we must query the validators from the counterparty chain // If the LatestHeight == LastHeader.Height, then TrustedValidators are current validators // If LatestHeight < LastHeader.Height, we can query the historical validator set from HistoricalInfo if trustedHeight == counterparty.LastHeader.GetHeight() { - tmTrustedVals = counterparty.Vals + cmtTrustedVals = counterparty.Vals } else { // NOTE: We need to get validators from counterparty at height: trustedHeight+1 // since the last trusted validators for a header at height h // is the NextValidators at h+1 committed to in header h by // NextValidatorsHash - tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) + cmtTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) if !ok { return nil, errorsmod.Wrapf(ibctm.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) } @@ -494,7 +522,7 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa // for now assume revision number is 0 header.TrustedHeight = trustedHeight - trustedVals, err := tmTrustedVals.ToProto() + trustedVals, err := cmtTrustedVals.ToProto() if err != nil { return nil, err } @@ -509,26 +537,35 @@ func (chain *TestChain) ExpireClient(amount time.Duration) { chain.Coordinator.IncrementTimeBy(amount) } -// CurrentTMClientHeader creates a TM header using the current header parameters +// CurrentCmtClientHeader creates a CMT header using the current header parameters // on the chain. The trusted fields in the header are set to nil. -func (chain *TestChain) CurrentTMClientHeader() *ibctm.Header { - return chain.CreateTMClientHeader(chain.ChainID, chain.CurrentHeader.Height, clienttypes.Height{}, chain.CurrentHeader.Time, chain.Vals, chain.NextVals, nil, chain.Signers) +func (chain *TestChain) CurrentCmtClientHeader() *ibctm.Header { + return chain.CreateCmtClientHeader( + chain.ChainID, + chain.CurrentHeader.Height, + clienttypes.Height{}, + chain.CurrentHeader.Time, + chain.Vals, + chain.NextVals, + nil, + chain.Signers, + ) } -// CreateTMClientHeader creates a TM header to update the TM client. Args are passed in to allow +// CreateCmtClientHeader creates a CMT header to update the CMT client. Args are passed in to allow // caller flexibility to use params that differ from the chain. -func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, nextVals, tmTrustedVals *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator) *ibctm.Header { +func (chain *TestChain) CreateCmtClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, cmtValSet, nextVals, cmtTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header { var ( - valSet *tmproto.ValidatorSet - trustedVals *tmproto.ValidatorSet + valSet *cmtproto.ValidatorSet + trustedVals *cmtproto.ValidatorSet ) - require.NotNil(chain.t, tmValSet) + require.NotNil(chain.t, cmtValSet) - vsetHash := tmValSet.Hash() + vsetHash := cmtValSet.Hash() nextValHash := nextVals.Hash() - tmHeader := tmtypes.Header{ - Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2}, + cmtHeader := cmttypes.Header{ + Version: cmtprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2}, ChainID: chainID, Height: blockHeight, Time: timestamp, @@ -541,35 +578,34 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, AppHash: chain.CurrentHeader.AppHash, LastResultsHash: tmhash.Sum([]byte("last_results_hash")), EvidenceHash: tmhash.Sum([]byte("evidence_hash")), - ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck // SA5011: possible nil pointer dereference + ProposerAddress: cmtValSet.Proposer.Address, //nolint:staticcheck // SA5011: possible nil pointer dereference } - hhash := tmHeader.Hash() + hhash := cmtHeader.Hash() blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chainID, blockHeight, 1, tmproto.PrecommitType, tmValSet) + voteSet := cmttypes.NewExtendedVoteSet(chainID, blockHeight, 1, cmtproto.PrecommitType, cmtValSet) // MakeCommit expects a signer array in the same order as the validator array. // Thus we iterate over the ordered validator set and construct a signer array // from the signer map in the same order. - signerArr := make([]tmtypes.PrivValidator, len(tmValSet.Validators)) //nolint:staticcheck - for i, v := range tmValSet.Validators { //nolint:staticcheck + signerArr := make([]cmttypes.PrivValidator, len(cmtValSet.Validators)) //nolint:staticcheck + for i, v := range cmtValSet.Validators { //nolint:staticcheck signerArr[i] = signers[v.Address.String()] } - - commit, err := tmtypes.MakeCommit(blockID, blockHeight, 1, voteSet, signerArr, timestamp) + extCommit, err := cmttypes.MakeExtCommit(blockID, blockHeight, 1, voteSet, signerArr, timestamp, true) require.NoError(chain.t, err) - signedHeader := &tmproto.SignedHeader{ - Header: tmHeader.ToProto(), - Commit: commit.ToProto(), + signedHeader := &cmtproto.SignedHeader{ + Header: cmtHeader.ToProto(), + Commit: extCommit.ToCommit().ToProto(), } - if tmValSet != nil { //nolint:staticcheck - valSet, err = tmValSet.ToProto() + if cmtValSet != nil { //nolint:staticcheck + valSet, err = cmtValSet.ToProto() require.NoError(chain.t, err) } - if tmTrustedVals != nil { - trustedVals, err = tmTrustedVals.ToProto() + if cmtTrustedVals != nil { + trustedVals, err = cmtTrustedVals.ToProto() require.NoError(chain.t, err) } @@ -583,11 +619,11 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, } } -// MakeBlockID copied unimported test functions from tmtypes to use them here -func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID { - return tmtypes.BlockID{ +// MakeBlockID copied unimported test functions from cmttypes to use them here +func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) cmttypes.BlockID { + return cmttypes.BlockID{ Hash: hash, - PartSetHeader: tmtypes.PartSetHeader{ + PartSetHeader: cmttypes.PartSetHeader{ Total: partSetSize, Hash: partSetHash, }, @@ -611,7 +647,7 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope require.NoError(chain.t, err) } - chain.NextBlock() + chain.Coordinator.CommitBlock(chain) } // GetPortCapability returns the port capability for the given portID. The capability must @@ -637,7 +673,7 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc require.NoError(chain.t, err) } - chain.NextBlock() + chain.Coordinator.CommitBlock(chain) } // GetChannelCapability returns the channel capability for the given portID and channelID. diff --git a/x/wasm/ibctesting/coordinator.go b/x/wasm/ibctesting/coordinator.go index b5000d733b..3ac37577c4 100644 --- a/x/wasm/ibctesting/coordinator.go +++ b/x/wasm/ibctesting/coordinator.go @@ -5,10 +5,9 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -81,7 +80,6 @@ func (coord *Coordinator) UpdateTime() { // UpdateTimeForChain updates the clock for a specific chain. func (coord *Coordinator) UpdateTimeForChain(chain *TestChain) { chain.CurrentHeader.Time = coord.CurrentTime.UTC() - chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) } // Setup constructs a TM client, connection, and channel on both chains provided. It will diff --git a/x/wasm/ibctesting/endpoint.go b/x/wasm/ibctesting/endpoint.go index 2e22ec802b..54a20bd04e 100644 --- a/x/wasm/ibctesting/endpoint.go +++ b/x/wasm/ibctesting/endpoint.go @@ -4,18 +4,18 @@ import ( "fmt" "strings" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + abci "github.com/cometbft/cometbft/abci/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" ) // Endpoint is a which represents a channel endpoint and its associated @@ -122,7 +122,7 @@ func (endpoint *Endpoint) CreateClient() (err error) { return err } - endpoint.ClientID, err = ibctesting.ParseClientIDFromEvents(res.GetEvents()) + endpoint.ClientID, err = ParseClientIDFromEvents(res.GetEvents()) require.NoError(endpoint.Chain.t, err) return nil @@ -185,7 +185,7 @@ func (endpoint *Endpoint) UpgradeChain() error { baseapp.SetChainID(newChainID)(endpoint.Chain.App.GetBaseApp()) endpoint.Chain.ChainID = newChainID endpoint.Chain.CurrentHeader.ChainID = newChainID - endpoint.Chain.NextBlock() // commit changes + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) // update counterparty client manually clientState.ChainId = newChainID @@ -201,13 +201,9 @@ func (endpoint *Endpoint) UpgradeChain() error { // ensure the next update isn't identical to the one set in state endpoint.Chain.Coordinator.IncrementTime() - endpoint.Chain.NextBlock() - - if err = endpoint.Counterparty.UpdateClient(); err != nil { - return err - } + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) - return nil + return endpoint.Counterparty.UpdateClient() } // ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint. @@ -223,7 +219,7 @@ func (endpoint *Endpoint) ConnOpenInit() error { return err } - endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents()) + endpoint.ConnectionID, err = ParseConnectionIDFromEvents(res.GetEvents()) require.NoError(endpoint.Chain.t, err) return nil @@ -249,7 +245,7 @@ func (endpoint *Endpoint) ConnOpenTry() error { } if endpoint.ConnectionID == "" { - endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents()) + endpoint.ConnectionID, err = ParseConnectionIDFromEvents(res.GetEvents()) require.NoError(endpoint.Chain.t, err) } @@ -331,7 +327,7 @@ func (endpoint *Endpoint) ChanOpenInit() error { return err } - endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents()) + endpoint.ChannelID, err = ParseChannelIDFromEvents(res.GetEvents()) require.NoError(endpoint.Chain.t, err) // update version to selected app version @@ -362,7 +358,7 @@ func (endpoint *Endpoint) ChanOpenTry() error { } if endpoint.ChannelID == "" { - endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents()) + endpoint.ChannelID, err = ParseChannelIDFromEvents(res.GetEvents()) require.NoError(endpoint.Chain.t, err) } @@ -476,7 +472,7 @@ func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error { // RecvPacketWithResult receives a packet on the associated endpoint and the result // of the transaction is returned. The counterparty client is updated. -func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*sdk.Result, error) { +func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*abci.ExecTxResult, error) { // get proof of packet commitment on source packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := endpoint.Counterparty.Chain.QueryProof(packetKey) diff --git a/x/wasm/ibctesting/event_utils.go b/x/wasm/ibctesting/event_utils.go index 71df2784a5..b383fc07b2 100644 --- a/x/wasm/ibctesting/event_utils.go +++ b/x/wasm/ibctesting/event_utils.go @@ -7,10 +7,8 @@ import ( "strings" abci "github.com/cometbft/cometbft/abci/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - - sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) func GetSendPackets(evts []abci.Event) []channeltypes.Packet { @@ -91,7 +89,7 @@ func parseTimeoutHeight(raw string) clienttypes.Height { } } -func ParsePortIDFromEvents(events sdk.Events) (string, error) { +func ParsePortIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { for _, attr := range ev.Attributes { @@ -104,7 +102,7 @@ func ParsePortIDFromEvents(events sdk.Events) (string, error) { return "", fmt.Errorf("port id event attribute not found") } -func ParseChannelVersionFromEvents(events sdk.Events) (string, error) { +func ParseChannelVersionFromEvents(events []abci.Event) (string, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { for _, attr := range ev.Attributes { diff --git a/x/wasm/ibctesting/events.go b/x/wasm/ibctesting/events.go new file mode 100644 index 0000000000..4bd939d72c --- /dev/null +++ b/x/wasm/ibctesting/events.go @@ -0,0 +1,172 @@ +package ibctesting + +import ( + "encoding/hex" + "fmt" + "strconv" + + abci "github.com/cometbft/cometbft/abci/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + "github.com/stretchr/testify/suite" +) + +type EventsMap map[string]map[string]string + +// ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the +// client identifier. +func ParseClientIDFromEvents(events []abci.Event) (string, error) { + for _, ev := range events { + if ev.Type == clienttypes.EventTypeCreateClient { + for _, attr := range ev.Attributes { + if attr.Key == clienttypes.AttributeKeyClientID { + return attr.Value, nil + } + } + } + } + return "", fmt.Errorf("client identifier event attribute not found") +} + +// ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or +// MsgConnectionOpenTry and returns the connection identifier. +func ParseConnectionIDFromEvents(events []abci.Event) (string, error) { + for _, ev := range events { + if ev.Type == connectiontypes.EventTypeConnectionOpenInit || + ev.Type == connectiontypes.EventTypeConnectionOpenTry { + for _, attr := range ev.Attributes { + if attr.Key == connectiontypes.AttributeKeyConnectionID { + return attr.Value, nil + } + } + } + } + return "", fmt.Errorf("connection identifier event attribute not found") +} + +// ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or +// MsgChannelOpenTry and returns the channel identifier. +func ParseChannelIDFromEvents(events []abci.Event) (string, error) { + for _, ev := range events { + if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { + for _, attr := range ev.Attributes { + if attr.Key == channeltypes.AttributeKeyChannelID { + return attr.Value, nil + } + } + } + } + return "", fmt.Errorf("channel identifier event attribute not found") +} + +// ParsePacketFromEvents parses events emitted from a MsgRecvPacket and returns the +// acknowledgement. +func ParsePacketFromEvents(events []abci.Event) (channeltypes.Packet, error) { + for _, ev := range events { + if ev.Type == channeltypes.EventTypeSendPacket { + packet := channeltypes.Packet{} + for _, attr := range ev.Attributes { + switch attr.Key { + case channeltypes.AttributeKeyDataHex: + bz, err := hex.DecodeString(attr.Value) + if err != nil { + panic(err) + } + packet.Data = bz + + case channeltypes.AttributeKeySequence: + seq, err := strconv.ParseUint(attr.Value, 10, 64) + if err != nil { + return channeltypes.Packet{}, err + } + + packet.Sequence = seq + + case channeltypes.AttributeKeySrcPort: + packet.SourcePort = attr.Value + + case channeltypes.AttributeKeySrcChannel: + packet.SourceChannel = attr.Value + + case channeltypes.AttributeKeyDstPort: + packet.DestinationPort = attr.Value + + case channeltypes.AttributeKeyDstChannel: + packet.DestinationChannel = attr.Value + + case channeltypes.AttributeKeyTimeoutHeight: + height, err := clienttypes.ParseHeight(attr.Value) + if err != nil { + return channeltypes.Packet{}, err + } + + packet.TimeoutHeight = height + + case channeltypes.AttributeKeyTimeoutTimestamp: + timestamp, err := strconv.ParseUint(attr.Value, 10, 64) + if err != nil { + return channeltypes.Packet{}, err + } + + packet.TimeoutTimestamp = timestamp + + default: + continue + } + } + + return packet, nil + } + } + return channeltypes.Packet{}, fmt.Errorf("acknowledgement event attribute not found") +} + +// ParseAckFromEvents parses events emitted from a MsgRecvPacket and returns the +// acknowledgement. +func ParseAckFromEvents(events []abci.Event) ([]byte, error) { + for _, ev := range events { + if ev.Type == channeltypes.EventTypeWriteAck { + for _, attr := range ev.Attributes { + if attr.Key == channeltypes.AttributeKeyAckHex { + bz, err := hex.DecodeString(attr.Value) + if err != nil { + panic(err) + } + return bz, nil + } + } + } + } + return nil, fmt.Errorf("acknowledgement event attribute not found") +} + +// AssertEvents asserts that expected events are present in the actual events. +// Expected map needs to be a subset of actual events to pass. +func AssertEvents( + suite *suite.Suite, + expected EventsMap, + actual []abci.Event, +) { + hasEvents := make(map[string]bool) + for eventType := range expected { + hasEvents[eventType] = false + } + + for _, event := range actual { + expEvent, eventFound := expected[event.Type] + if eventFound { + hasEvents[event.Type] = true + suite.Require().Len(event.Attributes, len(expEvent)) + for _, attr := range event.Attributes { + expValue, found := expEvent[attr.Key] + suite.Require().True(found) + suite.Require().Equal(expValue, attr.Value) + } + } + } + + for eventName, hasEvent := range hasEvents { + suite.Require().True(hasEvent, "event: %s was not found in events", eventName) + } +} diff --git a/x/wasm/ibctesting/faucet.go b/x/wasm/ibctesting/faucet.go index 559149906f..38565465e8 100644 --- a/x/wasm/ibctesting/faucet.go +++ b/x/wasm/ibctesting/faucet.go @@ -5,11 +5,8 @@ import ( "cosmossdk.io/math" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/CosmWasm/wasmd/app" ) // Fund an address with the given amount in default denom @@ -20,36 +17,3 @@ func (chain *TestChain) Fund(addr sdk.AccAddress, amount math.Int) { Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)), })) } - -// SendNonDefaultSenderMsgs delivers a transaction through the application. It returns the result and error if one -// occurred. -func (chain *TestChain) SendNonDefaultSenderMsgs(senderPrivKey cryptotypes.PrivKey, msgs ...sdk.Msg) (*sdk.Result, error) { - require.NotEqual(chain.t, chain.SenderPrivKey, senderPrivKey, "use SendMsgs method") - - // ensure the chain has the latest time - chain.Coordinator.UpdateTimeForChain(chain) - - addr := sdk.AccAddress(senderPrivKey.PubKey().Address().Bytes()) - account := chain.App.GetAccountKeeper().GetAccount(chain.GetContext(), addr) - require.NotNil(chain.t, account) - _, r, err := app.SignAndDeliverWithoutCommit( - chain.t, - chain.TxConfig, - chain.App.GetBaseApp(), - msgs, - chain.DefaultMsgFees, - chain.ChainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - senderPrivKey, - ) - - // SignAndDeliverWithoutCommit calls app.Commit() - chain.NextBlock() - chain.Coordinator.IncrementTime() - if err != nil { - return r, err - } - chain.CaptureIBCEvents(r.Events) - return r, nil -} diff --git a/x/wasm/ibctesting/path.go b/x/wasm/ibctesting/path.go index fe0ace44f4..0bc4943056 100644 --- a/x/wasm/ibctesting/path.go +++ b/x/wasm/ibctesting/path.go @@ -4,8 +4,7 @@ import ( "bytes" "fmt" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -55,7 +54,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, _ []byte) error { return err } - ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + ack, err := ParseAckFromEvents(res.GetEvents()) if err != nil { return err } @@ -78,7 +77,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, _ []byte) error { return err } - ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + ack, err := ParseAckFromEvents(res.GetEvents()) if err != nil { return err } diff --git a/x/wasm/ibctesting/wasm.go b/x/wasm/ibctesting/wasm.go index b01611a8b5..48343926da 100644 --- a/x/wasm/ibctesting/wasm.go +++ b/x/wasm/ibctesting/wasm.go @@ -3,6 +3,7 @@ package ibctesting import ( "bytes" "compress/gzip" + "context" "encoding/json" "fmt" "os" @@ -11,7 +12,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/rand" "github.com/cosmos/gogoproto/proto" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -56,13 +57,23 @@ func (chain *TestChain) StoreCode(byteCode []byte) types.MsgStoreCodeResponse { } r, err := chain.SendMsgs(storeMsg) require.NoError(chain.t, err) - // unmarshal protobuf response from data - require.Len(chain.t, r.MsgResponses, 1) - require.NotEmpty(chain.t, r.MsgResponses[0].GetCachedValue()) - pInstResp := r.MsgResponses[0].GetCachedValue().(*types.MsgStoreCodeResponse) + + var pInstResp types.MsgStoreCodeResponse + chain.UnwrapExecTXResult(r, &pInstResp) + require.NotEmpty(chain.t, pInstResp.CodeID) require.NotEmpty(chain.t, pInstResp.Checksum) - return *pInstResp + return pInstResp +} + +// UnwrapExecTXResult is a helper to unpack execution result from proto any type +func (chain *TestChain) UnwrapExecTXResult(r *abci.ExecTxResult, target proto.Message) { + var wrappedRsp sdk.TxMsgData + require.NoError(chain.t, chain.Codec.Unmarshal(r.Data, &wrappedRsp)) + + // unmarshal protobuf response from data + require.Len(chain.t, wrappedRsp.MsgResponses, 1) + require.NoError(chain.t, proto.Unmarshal(wrappedRsp.MsgResponses[0].Value, target)) } func (chain *TestChain) InstantiateContract(codeID uint64, initMsg []byte) sdk.AccAddress { @@ -77,9 +88,10 @@ func (chain *TestChain) InstantiateContract(codeID uint64, initMsg []byte) sdk.A r, err := chain.SendMsgs(instantiateMsg) require.NoError(chain.t, err) - require.Len(chain.t, r.MsgResponses, 1) - require.NotEmpty(chain.t, r.MsgResponses[0].GetCachedValue()) - pExecResp := r.MsgResponses[0].GetCachedValue().(*types.MsgInstantiateContractResponse) + + var pExecResp types.MsgInstantiateContractResponse + chain.UnwrapExecTXResult(r, &pExecResp) + a, err := sdk.AccAddressFromBech32(pExecResp.Address) require.NoError(chain.t, err) return a @@ -95,10 +107,11 @@ func (chain *TestChain) RawQuery(contractAddr string, queryData []byte) ([]byte, return nil, err } - res := chain.App.Query(abci.RequestQuery{ + res, err := chain.App.Query(context.TODO(), &abci.RequestQuery{ Path: "/cosmwasm.wasm.v1.Query/RawContractState", Data: reqBin, }) + require.NoError(chain.t, err) if res.Code != 0 { return nil, fmt.Errorf("raw query failed: (%d) %s", res.Code, res.Log) @@ -132,11 +145,11 @@ func (chain *TestChain) SmartQuery(contractAddr string, queryMsg, response inter return err } - // TODO: what is the query? - res := chain.App.Query(abci.RequestQuery{ + res, err := chain.App.Query(context.TODO(), &abci.RequestQuery{ Path: "/cosmwasm.wasm.v1.Query/SmartContractState", Data: reqBin, }) + require.NoError(chain.t, err) if res.Code != 0 { return fmt.Errorf("smart query failed: (%d) %s", res.Code, res.Log) diff --git a/x/wasm/keeper/addresses.go b/x/wasm/keeper/addresses.go index 9df74f40da..77ecaa1d4e 100644 --- a/x/wasm/keeper/addresses.go +++ b/x/wasm/keeper/addresses.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "encoding/binary" "fmt" @@ -11,19 +12,19 @@ import ( ) // AddressGenerator abstract address generator to be used for a single contract address -type AddressGenerator func(ctx sdk.Context, codeID uint64, checksum []byte) sdk.AccAddress +type AddressGenerator func(ctx context.Context, codeID uint64, checksum []byte) sdk.AccAddress // ClassicAddressGenerator generates a contract address using codeID and instanceID sequence func (k Keeper) ClassicAddressGenerator() AddressGenerator { - return func(ctx sdk.Context, codeID uint64, _ []byte) sdk.AccAddress { - instanceID := k.autoIncrementID(ctx, types.KeySequenceInstanceID) + return func(ctx context.Context, codeID uint64, _ []byte) sdk.AccAddress { + instanceID := k.mustAutoIncrementID(ctx, types.KeySequenceInstanceID) return BuildContractAddressClassic(codeID, instanceID) } } // PredicableAddressGenerator generates a predictable contract address func PredicableAddressGenerator(creator sdk.AccAddress, salt, msg []byte, fixMsg bool) AddressGenerator { - return func(ctx sdk.Context, _ uint64, checksum []byte) sdk.AccAddress { + return func(_ context.Context, _ uint64, checksum []byte) sdk.AccAddress { if !fixMsg { // clear msg to not be included in the address generation msg = []byte{} } diff --git a/x/wasm/keeper/ante.go b/x/wasm/keeper/ante.go index 1718c1ce11..96bf474caf 100644 --- a/x/wasm/keeper/ante.go +++ b/x/wasm/keeper/ante.go @@ -3,7 +3,10 @@ package keeper import ( "encoding/binary" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + corestoretypes "cosmossdk.io/core/store" + errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -11,12 +14,12 @@ import ( // CountTXDecorator ante handler to count the tx position in a block. type CountTXDecorator struct { - storeKey storetypes.StoreKey + storeService corestoretypes.KVStoreService } // NewCountTXDecorator constructor -func NewCountTXDecorator(storeKey storetypes.StoreKey) *CountTXDecorator { - return &CountTXDecorator{storeKey: storeKey} +func NewCountTXDecorator(s corestoretypes.KVStoreService) *CountTXDecorator { + return &CountTXDecorator{storeService: s} } // AnteHandle handler stores a tx counter with current height encoded in the store to let the app handle @@ -27,12 +30,16 @@ func (a CountTXDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, if simulate { return next(ctx, tx, simulate) } - store := ctx.KVStore(a.storeKey) + store := a.storeService.OpenKVStore(ctx) currentHeight := ctx.BlockHeight() var txCounter uint32 // start with 0 // load counter when exists - if bz := store.Get(types.TXCounterPrefix); bz != nil { + bz, err := store.Get(types.TXCounterPrefix) + if err != nil { + return ctx, errorsmod.Wrap(err, "read tx counter") + } + if bz != nil { lastHeight, val := decodeHeightCounter(bz) if currentHeight == lastHeight { // then use stored counter @@ -40,8 +47,10 @@ func (a CountTXDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, } // else use `0` from above to start with } // store next counter value for current height - store.Set(types.TXCounterPrefix, encodeHeightCounter(currentHeight, txCounter+1)) - + err = store.Set(types.TXCounterPrefix, encodeHeightCounter(currentHeight, txCounter+1)) + if err != nil { + return ctx, errorsmod.Wrap(err, "store tx counter") + } return next(types.WithTXCounter(ctx, txCounter), tx, simulate) } @@ -57,11 +66,11 @@ func decodeHeightCounter(bz []byte) (int64, uint32) { // LimitSimulationGasDecorator ante decorator to limit gas in simulation calls type LimitSimulationGasDecorator struct { - gasLimit *sdk.Gas + gasLimit *storetypes.Gas } // NewLimitSimulationGasDecorator constructor accepts nil value to fallback to block gas limit. -func NewLimitSimulationGasDecorator(gasLimit *sdk.Gas) *LimitSimulationGasDecorator { +func NewLimitSimulationGasDecorator(gasLimit *storetypes.Gas) *LimitSimulationGasDecorator { if gasLimit != nil && *gasLimit == 0 { panic("gas limit must not be zero") } @@ -86,12 +95,13 @@ func (d LimitSimulationGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu // apply custom node gas limit if d.gasLimit != nil { - return next(ctx.WithGasMeter(sdk.NewGasMeter(*d.gasLimit)), tx, simulate) + return next(ctx.WithGasMeter(storetypes.NewGasMeter(*d.gasLimit)), tx, simulate) } // default to max block gas when set, to be on the safe side - if maxGas := ctx.ConsensusParams().GetBlock().MaxGas; maxGas > 0 { - return next(ctx.WithGasMeter(sdk.NewGasMeter(sdk.Gas(maxGas))), tx, simulate) + params := ctx.ConsensusParams() + if maxGas := params.GetBlock().MaxGas; maxGas > 0 { + return next(ctx.WithGasMeter(storetypes.NewGasMeter(storetypes.Gas(maxGas))), tx, simulate) } return next(ctx, tx, simulate) } diff --git a/x/wasm/keeper/ante_test.go b/x/wasm/keeper/ante_test.go index c1e59c4aa2..5334964615 100644 --- a/x/wasm/keeper/ante_test.go +++ b/x/wasm/keeper/ante_test.go @@ -4,14 +4,17 @@ import ( "testing" "time" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "cosmossdk.io/log" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -20,9 +23,9 @@ import ( ) func TestCountTxDecorator(t *testing.T) { - keyWasm := sdk.NewKVStoreKey(types.StoreKey) + keyWasm := storetypes.NewKVStoreKey(types.StoreKey) db := dbm.NewMemDB() - ms := store.NewCommitMultiStore(db) + ms := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) ms.MountStoreWithDB(keyWasm, storetypes.StoreTypeIAVL, db) require.NoError(t, ms.LoadLatestVersion()) const myCurrentBlockHeight = 100 @@ -33,9 +36,7 @@ func TestCountTxDecorator(t *testing.T) { nextAssertAnte func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) }{ "no initial counter set": { - setupDB: func(t *testing.T, ctx sdk.Context) { - t.Helper() - }, + setupDB: func(t *testing.T, ctx sdk.Context) {}, nextAssertAnte: func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { gotCounter, ok := types.TXCounter(ctx) require.True(t, ok) @@ -48,7 +49,6 @@ func TestCountTxDecorator(t *testing.T) { }, "persistent counter incremented - big endian": { setupDB: func(t *testing.T, ctx sdk.Context) { - t.Helper() bz := []byte{0, 0, 0, 0, 0, 0, 0, myCurrentBlockHeight, 1, 0, 0, 2} ctx.MultiStore().GetKVStore(keyWasm).Set(types.TXCounterPrefix, bz) }, @@ -64,7 +64,6 @@ func TestCountTxDecorator(t *testing.T) { }, "old height counter replaced": { setupDB: func(t *testing.T, ctx sdk.Context) { - t.Helper() previousHeight := byte(myCurrentBlockHeight - 1) bz := []byte{0, 0, 0, 0, 0, 0, 0, previousHeight, 0, 0, 0, 1} ctx.MultiStore().GetKVStore(keyWasm).Set(types.TXCounterPrefix, bz) @@ -81,7 +80,6 @@ func TestCountTxDecorator(t *testing.T) { }, "simulation not persisted": { setupDB: func(t *testing.T, ctx sdk.Context) { - t.Helper() }, simulate: true, nextAssertAnte: func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { @@ -96,7 +94,7 @@ func TestCountTxDecorator(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - ctx := sdk.NewContext(ms.CacheMultiStore(), tmproto.Header{ + ctx := sdk.NewContext(ms.CacheMultiStore(), cmtproto.Header{ Height: myCurrentBlockHeight, Time: time.Date(2021, time.September, 27, 12, 0, 0, 0, time.UTC), }, false, log.NewNopLogger()) @@ -105,7 +103,7 @@ func TestCountTxDecorator(t *testing.T) { var anyTx sdk.Tx // when - ante := keeper.NewCountTXDecorator(keyWasm) + ante := keeper.NewCountTXDecorator(runtime.NewKVStoreService(keyWasm)) _, gotErr := ante.AnteHandle(ctx, anyTx, spec.simulate, spec.nextAssertAnte) require.NoError(t, gotErr) }) @@ -114,12 +112,12 @@ func TestCountTxDecorator(t *testing.T) { func TestLimitSimulationGasDecorator(t *testing.T) { var ( - hundred sdk.Gas = 100 - zero sdk.Gas = 0 + hundred storetypes.Gas = 100 + zero storetypes.Gas = 0 ) specs := map[string]struct { - customLimit *sdk.Gas - consumeGas sdk.Gas + customLimit *storetypes.Gas + consumeGas storetypes.Gas maxBlockGas int64 simulation bool expErr interface{} @@ -129,13 +127,13 @@ func TestLimitSimulationGasDecorator(t *testing.T) { consumeGas: hundred + 1, maxBlockGas: -1, simulation: true, - expErr: sdk.ErrorOutOfGas{Descriptor: "testing"}, + expErr: storetypes.ErrorOutOfGas{Descriptor: "testing"}, }, "block limit set": { maxBlockGas: 100, consumeGas: hundred + 1, simulation: true, - expErr: sdk.ErrorOutOfGas{Descriptor: "testing"}, + expErr: storetypes.ErrorOutOfGas{Descriptor: "testing"}, }, "no limits set": { maxBlockGas: -1, @@ -163,9 +161,9 @@ func TestLimitSimulationGasDecorator(t *testing.T) { t.Run(name, func(t *testing.T) { nextAnte := consumeGasAnteHandler(spec.consumeGas) ctx := sdk.Context{}. - WithGasMeter(sdk.NewInfiniteGasMeter()). - WithConsensusParams(&tmproto.ConsensusParams{ - Block: &tmproto.BlockParams{MaxGas: spec.maxBlockGas}, + WithGasMeter(storetypes.NewInfiniteGasMeter()). + WithConsensusParams(cmtproto.ConsensusParams{ + Block: &cmtproto.BlockParams{MaxGas: spec.maxBlockGas}, }) // when if spec.expErr != nil { @@ -183,7 +181,7 @@ func TestLimitSimulationGasDecorator(t *testing.T) { } } -func consumeGasAnteHandler(gasToConsume sdk.Gas) sdk.AnteHandler { +func consumeGasAnteHandler(gasToConsume storetypes.Gas) sdk.AnteHandler { return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { ctx.GasMeter().ConsumeGas(gasToConsume, "testing") return ctx, nil @@ -192,7 +190,7 @@ func consumeGasAnteHandler(gasToConsume sdk.Gas) sdk.AnteHandler { func TestGasRegisterDecorator(t *testing.T) { db := dbm.NewMemDB() - ms := store.NewCommitMultiStore(db) + ms := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) specs := map[string]struct { simulate bool @@ -219,7 +217,7 @@ func TestGasRegisterDecorator(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - ctx := sdk.NewContext(ms, tmproto.Header{ + ctx := sdk.NewContext(ms, cmtproto.Header{ Height: 100, Time: time.Now(), }, false, log.NewNopLogger()) diff --git a/x/wasm/keeper/bench_test.go b/x/wasm/keeper/bench_test.go index 500d97cc54..19bb7de44d 100644 --- a/x/wasm/keeper/bench_test.go +++ b/x/wasm/keeper/bench_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" diff --git a/x/wasm/keeper/contract_keeper.go b/x/wasm/keeper/contract_keeper.go index 2cd482970e..3faf459bdf 100644 --- a/x/wasm/keeper/contract_keeper.go +++ b/x/wasm/keeper/contract_keeper.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -10,10 +12,10 @@ var _ types.ContractOpsKeeper = PermissionedKeeper{} // decoratedKeeper contains a subset of the wasm keeper that are already or can be guarded by an authorization policy in the future type decoratedKeeper interface { - create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ types.AuthorizationPolicy) (codeID uint64, checksum []byte, err error) + create(ctx context.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ types.AuthorizationPolicy) (codeID uint64, checksum []byte, err error) instantiate( - ctx sdk.Context, + ctx context.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, @@ -23,14 +25,14 @@ type decoratedKeeper interface { authZ types.AuthorizationPolicy, ) (sdk.AccAddress, []byte, error) - migrate(ctx sdk.Context, contractAddress, caller sdk.AccAddress, newCodeID uint64, msg []byte, authZ types.AuthorizationPolicy) ([]byte, error) - setContractAdmin(ctx sdk.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ types.AuthorizationPolicy) error - pinCode(ctx sdk.Context, codeID uint64) error - unpinCode(ctx sdk.Context, codeID uint64) error - execute(ctx sdk.Context, contractAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) - Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) - setContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error - setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, autz types.AuthorizationPolicy) error + migrate(ctx context.Context, contractAddress, caller sdk.AccAddress, newCodeID uint64, msg []byte, authZ types.AuthorizationPolicy) ([]byte, error) + setContractAdmin(ctx context.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ types.AuthorizationPolicy) error + pinCode(ctx context.Context, codeID uint64) error + unpinCode(ctx context.Context, codeID uint64) error + execute(ctx context.Context, contractAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) + Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) + setContractInfoExtension(ctx context.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error + setAccessConfig(ctx context.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, autz types.AuthorizationPolicy) error ClassicAddressGenerator() AddressGenerator } @@ -55,7 +57,7 @@ func (p PermissionedKeeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasm return p.nested.create(ctx, creator, wasmCode, instantiateAccess, p.authZPolicy) } -// AuthZActionInstantiate creates an instance of a WASM contract using the classic sequence based address generator +// Instantiate creates an instance of a WASM contract using the classic sequence based address generator func (p PermissionedKeeper) Instantiate( ctx sdk.Context, codeID uint64, diff --git a/x/wasm/keeper/contract_keeper_test.go b/x/wasm/keeper/contract_keeper_test.go index e816ac096b..e917367d20 100644 --- a/x/wasm/keeper/contract_keeper_test.go +++ b/x/wasm/keeper/contract_keeper_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" @@ -18,7 +20,7 @@ import ( func TestInstantiate2(t *testing.T) { parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities) - parentCtx = parentCtx.WithGasMeter(sdk.NewInfiniteGasMeter()) + parentCtx = parentCtx.WithGasMeter(storetypes.NewInfiniteGasMeter()) example := StoreHackatomExampleContract(t, parentCtx, keepers) otherExample := StoreReflectContract(t, parentCtx, keepers) @@ -37,7 +39,6 @@ func TestInstantiate2(t *testing.T) { ) // create instances for duplicate checks exampleContract := func(t *testing.T, ctx sdk.Context, fixMsg bool) { - t.Helper() _, _, err := keepers.ContractKeeper.Instantiate2( ctx, example.CodeID, @@ -52,11 +53,9 @@ func TestInstantiate2(t *testing.T) { require.NoError(t, err) } exampleWithFixMsg := func(t *testing.T, ctx sdk.Context) { - t.Helper() exampleContract(t, ctx, true) } exampleWithoutFixMsg := func(t *testing.T, ctx sdk.Context) { - t.Helper() exampleContract(t, ctx, false) } specs := map[string]struct { diff --git a/x/wasm/keeper/genesis.go b/x/wasm/keeper/genesis.go index 6df469c16e..bfee46927e 100644 --- a/x/wasm/keeper/genesis.go +++ b/x/wasm/keeper/genesis.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + abci "github.com/cometbft/cometbft/abci/types" errorsmod "cosmossdk.io/errors" @@ -12,7 +14,7 @@ import ( // ValidatorSetSource is a subset of the staking keeper type ValidatorSetSource interface { - ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate, err error) + ApplyAndReturnValidatorSetUpdates(context.Context) (updates []abci.ValidatorUpdate, err error) } // InitGenesis sets supply information for genesis. @@ -60,13 +62,19 @@ func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState) ([]ab } // sanity check seq values - seqVal := keeper.PeekAutoIncrementID(ctx, types.KeySequenceCodeID) + seqVal, err := keeper.PeekAutoIncrementID(ctx, types.KeySequenceCodeID) + if err != nil { + return nil, err + } if seqVal <= maxCodeID { return nil, errorsmod.Wrapf(types.ErrInvalid, "seq %s with value: %d must be greater than: %d ", string(types.KeySequenceCodeID), seqVal, maxCodeID) } // ensure next classic address is unused so that we know the sequence is good rCtx, _ := ctx.CacheContext() - seqVal = keeper.PeekAutoIncrementID(rCtx, types.KeySequenceInstanceID) + seqVal, err = keeper.PeekAutoIncrementID(rCtx, types.KeySequenceInstanceID) + if err != nil { + return nil, err + } addr := keeper.ClassicAddressGenerator()(rCtx, seqVal, nil) if keeper.HasContractInfo(ctx, addr) { return nil, errorsmod.Wrapf(types.ErrInvalid, "value: %d for seq %s was used already", seqVal, string(types.KeySequenceInstanceID)) @@ -113,9 +121,13 @@ func ExportGenesis(ctx sdk.Context, keeper *Keeper) *types.GenesisState { }) for _, k := range [][]byte{types.KeySequenceCodeID, types.KeySequenceInstanceID} { + id, err := keeper.PeekAutoIncrementID(ctx, k) + if err != nil { + panic(err) + } genState.Sequences = append(genState.Sequences, types.Sequence{ IDKey: k, - Value: keeper.PeekAutoIncrementID(ctx, k), + Value: id, }) } diff --git a/x/wasm/keeper/genesis_test.go b/x/wasm/keeper/genesis_test.go index 2ad87f7e5f..913b373d26 100644 --- a/x/wasm/keeper/genesis_test.go +++ b/x/wasm/keeper/genesis_test.go @@ -10,17 +10,20 @@ import ( "time" wasmvm "github.com/CosmWasm/wasmvm" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/log" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -83,8 +86,8 @@ func TestGenesisExportImport(t *testing.T) { contract.CodeID = codeID contractAddr := wasmKeeper.ClassicAddressGenerator()(srcCtx, codeID, nil) - wasmKeeper.storeContractInfo(srcCtx, contractAddr, &contract) - wasmKeeper.appendToContractHistory(srcCtx, contractAddr, history...) + wasmKeeper.mustStoreContractInfo(srcCtx, contractAddr, &contract) + require.NoError(t, wasmKeeper.appendToContractHistory(srcCtx, contractAddr, history...)) err = wasmKeeper.importContractState(srcCtx, contractAddr, stateModels) require.NoError(t, err) } @@ -116,8 +119,10 @@ func TestGenesisExportImport(t *testing.T) { creatorAddress := sdk.MustAccAddressFromBech32(info.Creator) history := wasmKeeper.GetContractHistory(srcCtx, address) - wasmKeeper.addToContractCodeSecondaryIndex(srcCtx, address, history[len(history)-1]) - wasmKeeper.addToContractCreatorSecondaryIndex(srcCtx, creatorAddress, history[0].Updated, address) + err = wasmKeeper.addToContractCodeSecondaryIndex(srcCtx, address, history[len(history)-1]) + require.NoError(t, err) + err = wasmKeeper.addToContractCreatorSecondaryIndex(srcCtx, creatorAddress, history[0].Updated, address) + require.NoError(t, err) return false }) @@ -133,8 +138,10 @@ func TestGenesisExportImport(t *testing.T) { // compare whole DB - srcIT := srcCtx.KVStore(wasmKeeper.storeKey).Iterator(nil, nil) - dstIT := dstCtx.KVStore(dstKeeper.storeKey).Iterator(nil, nil) + srcIT, err := wasmKeeper.storeService.OpenKVStore(srcCtx).Iterator(nil, nil) + require.NoError(t, err) + dstIT, err := dstKeeper.storeService.OpenKVStore(dstCtx).Iterator(nil, nil) + require.NoError(t, err) t.Cleanup(func() { types.MaxWasmSize = originalMaxWasmSize @@ -143,9 +150,9 @@ func TestGenesisExportImport(t *testing.T) { }) for i := 0; srcIT.Valid(); i++ { - require.True(t, dstIT.Valid(), "[%s] destination DB has less elements than source. Missing: %x", wasmKeeper.storeKey.Name(), srcIT.Key()) + require.True(t, dstIT.Valid(), "[%s] destination DB has less elements than source. Missing", srcIT.Key()) require.Equal(t, srcIT.Key(), dstIT.Key(), i) - require.Equal(t, srcIT.Value(), dstIT.Value(), "[%s] element (%d): %X", wasmKeeper.storeKey.Name(), i, srcIT.Key()) + require.Equal(t, srcIT.Value(), dstIT.Value(), "[%s] element: %X", i, srcIT.Key()) dstIT.Next() srcIT.Next() } @@ -578,7 +585,7 @@ func TestImportContractWithCodeHistoryPreserved(t *testing.T) { require.NoError(t, err) require.NoError(t, importState.ValidateBasic(), genesisStr) - ctx = ctx.WithBlockHeight(0).WithGasMeter(sdk.NewInfiniteGasMeter()) + ctx = ctx.WithBlockHeight(0).WithGasMeter(storetypes.NewInfiniteGasMeter()) // when _, err = InitGenesis(ctx, keeper, importState) @@ -640,8 +647,12 @@ func TestImportContractWithCodeHistoryPreserved(t *testing.T) { }, } assert.Equal(t, expHistory, keeper.GetContractHistory(ctx, contractAddr)) - assert.Equal(t, uint64(2), keeper.PeekAutoIncrementID(ctx, types.KeySequenceCodeID)) - assert.Equal(t, uint64(3), keeper.PeekAutoIncrementID(ctx, types.KeySequenceInstanceID)) + id, err := keeper.PeekAutoIncrementID(ctx, types.KeySequenceCodeID) + require.NoError(t, err) + assert.Equal(t, uint64(2), id) + id, err = keeper.PeekAutoIncrementID(ctx, types.KeySequenceInstanceID) + require.NoError(t, err) + assert.Equal(t, uint64(3), id) } func setupKeeper(t *testing.T) (*Keeper, sdk.Context) { @@ -650,14 +661,14 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context) { require.NoError(t, err) t.Cleanup(func() { os.RemoveAll(tempDir) }) - keyWasm := sdk.NewKVStoreKey(types.StoreKey) + keyWasm := storetypes.NewKVStoreKey(types.StoreKey) db := dbm.NewMemDB() - ms := store.NewCommitMultiStore(db) + ms := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) ms.MountStoreWithDB(keyWasm, storetypes.StoreTypeIAVL, db) require.NoError(t, ms.LoadLatestVersion()) - ctx := sdk.NewContext(ms, tmproto.Header{ + ctx := sdk.NewContext(ms, cmtproto.Header{ Height: 1234567, Time: time.Date(2020, time.April, 22, 12, 0, 0, 0, time.UTC), }, false, log.NewNopLogger()) @@ -675,7 +686,7 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context) { srcKeeper := NewKeeper( encodingConfig.Codec, - keyWasm, + runtime.NewKVStoreService(keyWasm), authkeeper.AccountKeeper{}, &bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, diff --git a/x/wasm/keeper/handler_plugin.go b/x/wasm/keeper/handler_plugin.go index e812411c51..74dea048a7 100644 --- a/x/wasm/keeper/handler_plugin.go +++ b/x/wasm/keeper/handler_plugin.go @@ -5,13 +5,13 @@ import ( "fmt" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -33,6 +33,7 @@ type MessageRouter interface { type SDKMessageHandler struct { router MessageRouter encoders msgEncoder + cdc codec.Codec } // NewDefaultMessageHandler constructor @@ -42,23 +43,24 @@ func NewDefaultMessageHandler( channelKeeper types.ChannelKeeper, capabilityKeeper types.CapabilityKeeper, bankKeeper types.Burner, - unpacker codectypes.AnyUnpacker, + cdc codec.Codec, portSource types.ICS20TransferPortSource, customEncoders ...*MessageEncoders, ) Messenger { - encoders := DefaultEncoders(unpacker, portSource) + encoders := DefaultEncoders(cdc, portSource) for _, e := range customEncoders { encoders = encoders.Merge(e) } return NewMessageHandlerChain( - NewSDKMessageHandler(router, encoders), + NewSDKMessageHandler(cdc, router, encoders), NewIBCRawPacketHandler(ics4Wrapper, channelKeeper, capabilityKeeper), NewBurnCoinMessageHandler(bankKeeper), ) } -func NewSDKMessageHandler(router MessageRouter, encoders msgEncoder) SDKMessageHandler { +func NewSDKMessageHandler(cdc codec.Codec, router MessageRouter, encoders msgEncoder) SDKMessageHandler { return SDKMessageHandler{ + cdc: cdc, router: router, encoders: encoders, } @@ -87,15 +89,24 @@ func (h SDKMessageHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddr } func (h SDKMessageHandler) handleSdkMessage(ctx sdk.Context, contractAddr sdk.Address, msg sdk.Msg) (*sdk.Result, error) { - if err := msg.ValidateBasic(); err != nil { - return nil, err + // todo: this block needs proper review from sdk team + if m, ok := msg.(sdk.HasValidateBasic); ok { + if err := m.ValidateBasic(); err != nil { + return nil, err + } } + // make sure this account can send it - for _, acct := range msg.GetSigners() { - if !acct.Equals(contractAddr) { + signers, _, err := h.cdc.GetMsgV1Signers(msg) + if err != nil { + return nil, err + } + for _, acct := range signers { + if !contractAddr.Equals(sdk.AccAddress(acct)) { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "contract doesn't have permission") } } + // --- end block // find the handler and execute it if handler := h.router.Handler(msg); handler != nil { diff --git a/x/wasm/keeper/handler_plugin_encoders.go b/x/wasm/keeper/handler_plugin_encoders.go index 5e07ac7e69..0b0783e082 100644 --- a/x/wasm/keeper/handler_plugin_encoders.go +++ b/x/wasm/keeper/handler_plugin_encoders.go @@ -5,11 +5,12 @@ import ( "fmt" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -336,7 +337,7 @@ func EncodeGovMsg(sender sdk.AccAddress, msg *wasmvmtypes.GovMsg) ([]sdk.Msg, er case msg.VoteWeighted != nil: opts := make([]*v1.WeightedVoteOption, len(msg.VoteWeighted.Options)) for i, v := range msg.VoteWeighted.Options { - weight, err := sdk.NewDecFromStr(v.Weight) + weight, err := sdkmath.LegacyNewDecFromStr(v.Weight) if err != nil { return nil, errorsmod.Wrapf(err, "weight for vote %d", i+1) } @@ -394,7 +395,7 @@ func ConvertWasmCoinsToSdkCoins(coins []wasmvmtypes.Coin) (sdk.Coins, error) { // ConvertWasmCoinToSdkCoin converts a wasm vm type coin to sdk type coin func ConvertWasmCoinToSdkCoin(coin wasmvmtypes.Coin) (sdk.Coin, error) { - amount, ok := sdk.NewIntFromString(coin.Amount) + amount, ok := sdkmath.NewIntFromString(coin.Amount) if !ok { return sdk.Coin{}, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, coin.Amount+coin.Denom) } diff --git a/x/wasm/keeper/handler_plugin_encoders_test.go b/x/wasm/keeper/handler_plugin_encoders_test.go index 334f78526d..acd4e544d6 100644 --- a/x/wasm/keeper/handler_plugin_encoders_test.go +++ b/x/wasm/keeper/handler_plugin_encoders_test.go @@ -5,18 +5,19 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cosmos/gogoproto/proto" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" @@ -45,16 +46,11 @@ func TestEncoding(t *testing.T) { sdk.NewInt64Coin("utgd", 54321), }, } - bankMsgBin, err := proto.Marshal(bankMsg) - require.NoError(t, err) - - content, err := codectypes.NewAnyWithValue(types.StoreCodeProposalFixture()) - require.NoError(t, err) - - proposalMsg := &v1beta1.MsgSubmitProposal{ + bankMsgBin := must(proto.Marshal(bankMsg)) + proposalMsg := &govv1.MsgSubmitProposal{ Proposer: addr1.String(), + Messages: []*codectypes.Any{must(codectypes.NewAnyWithValue(types.MsgStoreCodeFixture()))}, InitialDeposit: sdk.NewCoins(sdk.NewInt64Coin("uatom", 12345)), - Content: content, } proposalMsgBin, err := proto.Marshal(proposalMsg) require.NoError(t, err) @@ -68,8 +64,6 @@ func TestEncoding(t *testing.T) { output []sdk.Msg // set if expect mapping fails expError bool - // set if sdk validate basic should fail - expInvalid bool }{ "simple send": { sender: addr1, @@ -133,8 +127,7 @@ func TestEncoding(t *testing.T) { }, }, }, - expError: false, // addresses are checked in the handler - expInvalid: true, + expError: false, // addresses are checked in the handler output: []sdk.Msg{ &banktypes.MsgSend{ FromAddress: addr1.String(), @@ -294,7 +287,7 @@ func TestEncoding(t *testing.T) { }, }, }, - "staking delegate to non-validator": { + "staking delegate to non-validator - invalid": { sender: addr1, srcMsg: wasmvmtypes.CosmosMsg{ Staking: &wasmvmtypes.StakingMsg{ @@ -304,8 +297,7 @@ func TestEncoding(t *testing.T) { }, }, }, - expError: false, // fails in the handler - expInvalid: true, + expError: false, // fails in the handler output: []sdk.Msg{ &stakingtypes.MsgDelegate{ DelegatorAddress: addr1.String(), @@ -420,7 +412,7 @@ func TestEncoding(t *testing.T) { sender: addr2, srcMsg: wasmvmtypes.CosmosMsg{ Stargate: &wasmvmtypes.StargateMsg{ - TypeURL: "/cosmos.gov.v1beta1.MsgSubmitProposal", + TypeURL: "/cosmos.gov.v1.MsgSubmitProposal", Value: proposalMsgBin, }, }, @@ -463,7 +455,7 @@ func TestEncoding(t *testing.T) { SourceChannel: "myChanID", Token: sdk.Coin{ Denom: "ALX", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }, Sender: addr1.String(), Receiver: addr2.String(), @@ -496,7 +488,7 @@ func TestEncoding(t *testing.T) { SourceChannel: "myChanID", Token: sdk.Coin{ Denom: "ALX", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }, Sender: addr1.String(), Receiver: addr2.String(), @@ -529,7 +521,7 @@ func TestEncoding(t *testing.T) { SourceChannel: "myChanID", Token: sdk.Coin{ Denom: "ALX", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }, Sender: addr1.String(), Receiver: addr2.String(), @@ -569,16 +561,6 @@ func TestEncoding(t *testing.T) { } require.NoError(t, err) assert.Equal(t, tc.output, res) - - // and valid sdk message - for _, v := range res { - gotErr := v.ValidateBasic() - if tc.expInvalid { - assert.Error(t, gotErr) - } else { - assert.NoError(t, gotErr) - } - } }) } } @@ -594,8 +576,6 @@ func TestEncodeGovMsg(t *testing.T) { output []sdk.Msg // set if expect mapping fails expError bool - // set if sdk validate basic should fail - expInvalid bool }{ "Gov vote: yes": { sender: myAddr, @@ -605,10 +585,10 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVote{ + &govv1.MsgVote{ ProposalId: 1, Voter: myAddr.String(), - Option: v1.OptionYes, + Option: govv1.OptionYes, }, }, }, @@ -620,10 +600,10 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVote{ + &govv1.MsgVote{ ProposalId: 1, Voter: myAddr.String(), - Option: v1.OptionNo, + Option: govv1.OptionNo, }, }, }, @@ -635,10 +615,10 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVote{ + &govv1.MsgVote{ ProposalId: 10, Voter: myAddr.String(), - Option: v1.OptionAbstain, + Option: govv1.OptionAbstain, }, }, }, @@ -650,10 +630,10 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVote{ + &govv1.MsgVote{ ProposalId: 1, Voter: myAddr.String(), - Option: v1.OptionNoWithVeto, + Option: govv1.OptionNoWithVeto, }, }, }, @@ -679,11 +659,11 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVoteWeighted{ + &govv1.MsgVoteWeighted{ ProposalId: 1, Voter: myAddr.String(), - Options: []*v1.WeightedVoteOption{ - {Option: v1.OptionYes, Weight: sdk.NewDec(1).String()}, + Options: []*govv1.WeightedVoteOption{ + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDec(1).String()}, }, }, }, @@ -704,19 +684,19 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVoteWeighted{ + &govv1.MsgVoteWeighted{ ProposalId: 1, Voter: myAddr.String(), - Options: []*v1.WeightedVoteOption{ - {Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(23, 2).String()}, - {Option: v1.OptionNo, Weight: sdk.NewDecWithPrec(24, 2).String()}, - {Option: v1.OptionAbstain, Weight: sdk.NewDecWithPrec(26, 2).String()}, - {Option: v1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(27, 2).String()}, + Options: []*govv1.WeightedVoteOption{ + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDecWithPrec(23, 2).String()}, + {Option: govv1.OptionNo, Weight: sdkmath.LegacyNewDecWithPrec(24, 2).String()}, + {Option: govv1.OptionAbstain, Weight: sdkmath.LegacyNewDecWithPrec(26, 2).String()}, + {Option: govv1.OptionNoWithVeto, Weight: sdkmath.LegacyNewDecWithPrec(27, 2).String()}, }, }, }, }, - "Gov weighted vote: duplicate option": { + "Gov weighted vote: duplicate option - invalid": { sender: myAddr, srcMsg: wasmvmtypes.CosmosMsg{ Gov: &wasmvmtypes.GovMsg{ @@ -730,18 +710,17 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVoteWeighted{ + &govv1.MsgVoteWeighted{ ProposalId: 1, Voter: myAddr.String(), - Options: []*v1.WeightedVoteOption{ - {Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(5, 1).String()}, - {Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(5, 1).String()}, + Options: []*govv1.WeightedVoteOption{ + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDecWithPrec(5, 1).String()}, + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDecWithPrec(5, 1).String()}, }, }, }, - expInvalid: true, }, - "Gov weighted vote: weight sum exceeds 1": { + "Gov weighted vote: weight sum exceeds 1- invalid": { sender: myAddr, srcMsg: wasmvmtypes.CosmosMsg{ Gov: &wasmvmtypes.GovMsg{ @@ -755,18 +734,17 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVoteWeighted{ + &govv1.MsgVoteWeighted{ ProposalId: 1, Voter: myAddr.String(), - Options: []*v1.WeightedVoteOption{ - {Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(51, 2).String()}, - {Option: v1.OptionNo, Weight: sdk.NewDecWithPrec(5, 1).String()}, + Options: []*govv1.WeightedVoteOption{ + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDecWithPrec(51, 2).String()}, + {Option: govv1.OptionNo, Weight: sdkmath.LegacyNewDecWithPrec(5, 1).String()}, }, }, }, - expInvalid: true, }, - "Gov weighted vote: weight sum less than 1": { + "Gov weighted vote: weight sum less than 1 - invalid": { sender: myAddr, srcMsg: wasmvmtypes.CosmosMsg{ Gov: &wasmvmtypes.GovMsg{ @@ -780,16 +758,15 @@ func TestEncodeGovMsg(t *testing.T) { }, }, output: []sdk.Msg{ - &v1.MsgVoteWeighted{ + &govv1.MsgVoteWeighted{ ProposalId: 1, Voter: myAddr.String(), - Options: []*v1.WeightedVoteOption{ - {Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(49, 2).String()}, - {Option: v1.OptionNo, Weight: sdk.NewDecWithPrec(5, 1).String()}, + Options: []*govv1.WeightedVoteOption{ + {Option: govv1.OptionYes, Weight: sdkmath.LegacyNewDecWithPrec(49, 2).String()}, + {Option: govv1.OptionNo, Weight: sdkmath.LegacyNewDecWithPrec(5, 1).String()}, }, }, }, - expInvalid: true, }, } encodingConfig := MakeEncodingConfig(t) @@ -804,16 +781,6 @@ func TestEncodeGovMsg(t *testing.T) { } require.NoError(t, gotEncErr) assert.Equal(t, tc.output, res) - - // and valid sdk message - for _, v := range res { - gotErr := v.ValidateBasic() - if tc.expInvalid { - assert.Error(t, gotErr) - } else { - assert.NoError(t, gotErr) - } - } }) } } @@ -829,7 +796,7 @@ func TestConvertWasmCoinToSdkCoin(t *testing.T) { Denom: "foo", Amount: "1", }, - expVal: sdk.NewCoin("foo", sdk.NewIntFromUint64(1)), + expVal: sdk.NewCoin("foo", sdkmath.NewIntFromUint64(1)), }, "negative amount": { src: wasmvmtypes.Coin{ @@ -885,7 +852,7 @@ func TestConvertWasmCoinsToSdkCoins(t *testing.T) { }, "single coin": { src: []wasmvmtypes.Coin{{Denom: "foo", Amount: "1"}}, - exp: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1))), + exp: sdk.NewCoins(sdk.NewCoin("foo", sdkmath.NewInt(1))), }, "multiple coins": { src: []wasmvmtypes.Coin{ @@ -893,8 +860,8 @@ func TestConvertWasmCoinsToSdkCoins(t *testing.T) { {Denom: "bar", Amount: "2"}, }, exp: sdk.NewCoins( - sdk.NewCoin("bar", sdk.NewInt(2)), - sdk.NewCoin("foo", sdk.NewInt(1)), + sdk.NewCoin("bar", sdkmath.NewInt(2)), + sdk.NewCoin("foo", sdkmath.NewInt(1)), ), }, "sorted": { @@ -904,9 +871,9 @@ func TestConvertWasmCoinsToSdkCoins(t *testing.T) { {Denom: "bar", Amount: "1"}, }, exp: []sdk.Coin{ - sdk.NewCoin("bar", sdk.NewInt(1)), - sdk.NewCoin("foo", sdk.NewInt(1)), - sdk.NewCoin("other", sdk.NewInt(1)), + sdk.NewCoin("bar", sdkmath.NewInt(1)), + sdk.NewCoin("foo", sdkmath.NewInt(1)), + sdk.NewCoin("other", sdkmath.NewInt(1)), }, }, "zero amounts dropped": { @@ -915,7 +882,7 @@ func TestConvertWasmCoinsToSdkCoins(t *testing.T) { {Denom: "bar", Amount: "0"}, }, exp: sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(1)), + sdk.NewCoin("foo", sdkmath.NewInt(1)), ), }, "duplicate denoms merged": { @@ -923,14 +890,14 @@ func TestConvertWasmCoinsToSdkCoins(t *testing.T) { {Denom: "foo", Amount: "1"}, {Denom: "foo", Amount: "1"}, }, - exp: []sdk.Coin{sdk.NewCoin("foo", sdk.NewInt(2))}, + exp: []sdk.Coin{sdk.NewCoin("foo", sdkmath.NewInt(2))}, }, "duplicate denoms with one 0 amount does not fail": { src: []wasmvmtypes.Coin{ {Denom: "foo", Amount: "0"}, {Denom: "foo", Amount: "1"}, }, - exp: []sdk.Coin{sdk.NewCoin("foo", sdk.NewInt(1))}, + exp: []sdk.Coin{sdk.NewCoin("foo", sdkmath.NewInt(1))}, }, "empty denom rejected": { src: []wasmvmtypes.Coin{{Denom: "", Amount: "1"}}, diff --git a/x/wasm/keeper/handler_plugin_test.go b/x/wasm/keeper/handler_plugin_test.go index 9fc666b101..6d0e01d2cb 100644 --- a/x/wasm/keeper/handler_plugin_test.go +++ b/x/wasm/keeper/handler_plugin_test.go @@ -6,19 +6,20 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cometbft/cometbft/libs/log" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -206,7 +207,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { // when ctx := sdk.Context{} - h := NewSDKMessageHandler(spec.srcRoute, MessageEncoders{Custom: spec.srcEncoder}) + h := NewSDKMessageHandler(MakeTestCodec(t), spec.srcRoute, MessageEncoders{Custom: spec.srcEncoder}) gotEvents, gotData, gotErr := h.DispatchMsg(ctx, myContractAddr, "myPort", myContractMessage) // then @@ -226,7 +227,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { func TestIBCRawPacketHandler(t *testing.T) { ibcPort := "contractsIBCPort" - ctx := sdk.Context{}.WithLogger(log.TestingLogger()) + ctx := sdk.Context{}.WithLogger(log.NewTestLogger(t)) type CapturedPacket struct { sourcePort string @@ -335,12 +336,12 @@ func TestBurnCoinMessageHandlerIntegration(t *testing.T) { // picks the message in the default handler chain ctx, keepers := CreateDefaultTestInput(t) // set some supply - keepers.Faucet.NewFundedRandomAccount(ctx, sdk.NewCoin("denom", sdk.NewInt(10_000_000))) + keepers.Faucet.NewFundedRandomAccount(ctx, sdk.NewCoin("denom", sdkmath.NewInt(10_000_000))) k := keepers.WasmKeeper example := InstantiateHackatomExampleContract(t, ctx, keepers) // with deposit of 100 stake - before, err := keepers.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &banktypes.QueryTotalSupplyRequest{}) + before, err := keepers.BankKeeper.TotalSupply(ctx, &banktypes.QueryTotalSupplyRequest{}) require.NoError(t, err) specs := map[string]struct { @@ -406,10 +407,10 @@ func TestBurnCoinMessageHandlerIntegration(t *testing.T) { require.NoError(t, err) // and total supply reduced by burned amount - after, err := keepers.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &banktypes.QueryTotalSupplyRequest{}) + after, err := keepers.BankKeeper.TotalSupply(ctx, &banktypes.QueryTotalSupplyRequest{}) require.NoError(t, err) diff := before.Supply.Sub(after.Supply...) - assert.Equal(t, sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(100))), diff) + assert.Equal(t, sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(100))), diff) }) } diff --git a/x/wasm/keeper/ibc.go b/x/wasm/keeper/ibc.go index ac31dfac66..b0e1d05e1f 100644 --- a/x/wasm/keeper/ibc.go +++ b/x/wasm/keeper/ibc.go @@ -3,12 +3,12 @@ package keeper import ( "strings" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/keeper/ibc_test.go b/x/wasm/keeper/ibc_test.go index 01ed35b3fa..99627a6beb 100644 --- a/x/wasm/keeper/ibc_test.go +++ b/x/wasm/keeper/ibc_test.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/json" "fmt" "testing" @@ -24,9 +25,10 @@ func TestBindingPortForIBCContractOnInstantiate(t *testing.T) { require.NoError(t, err) require.Equal(t, "wasm", owner) - initMsgBz := IBCReflectInitMsg{ + initMsgBz, err := json.Marshal(IBCReflectInitMsg{ ReflectCodeID: example.ReflectCodeID, - }.GetBytes(t) + }) + require.NoError(t, err) // create a second contract should give yet another portID (and different address) creator := RandomAccountAddress(t) diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 6862773b73..43c72ad9f0 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "bytes" + "context" "encoding/binary" "encoding/hex" "fmt" @@ -13,13 +14,16 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/collections" + corestoretypes "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -56,7 +60,7 @@ type AccountPruner interface { // CleanupExistingAccount handles the cleanup process for balances and data of the given account. The persisted account // type is already reset to base account at this stage. // The method returns true when the account address can be reused. Unsupported account types are rejected by returning false - CleanupExistingAccount(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) + CleanupExistingAccount(ctx sdk.Context, existingAccount sdk.AccountI) (handled bool, err error) } // WasmVMResponseHandler is an extension point to handles the response data returned by a contract call. @@ -79,7 +83,8 @@ var defaultAcceptedAccountTypes = map[reflect.Type]struct{}{ // Keeper will have a reference to Wasm Engine with it's own data directory. type Keeper struct { - storeKey storetypes.StoreKey + // The (unexposed) keys used to access the stores from the Context. + storeService corestoretypes.KVStoreService cdc codec.Codec accountKeeper types.AccountKeeper bank CoinTransferrer @@ -95,6 +100,7 @@ type Keeper struct { maxQueryStackSize uint32 acceptedAccountTypes map[reflect.Type]struct{} accountPruner AccountPruner + params collections.Item[types.Params] // propagate gov authZ to sub-messages propagateGovAuthorization map[types.AuthorizationPolicyAction]struct{} @@ -103,41 +109,26 @@ type Keeper struct { authority string } -func (k Keeper) getUploadAccessConfig(ctx sdk.Context) types.AccessConfig { +func (k Keeper) getUploadAccessConfig(ctx context.Context) types.AccessConfig { return k.GetParams(ctx).CodeUploadAccess } -func (k Keeper) getInstantiateAccessConfig(ctx sdk.Context) types.AccessType { +func (k Keeper) getInstantiateAccessConfig(ctx context.Context) types.AccessType { return k.GetParams(ctx).InstantiateDefaultPermission } // GetParams returns the total set of wasm parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - var params types.Params - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return params +func (k Keeper) GetParams(ctx context.Context) types.Params { + p, err := k.params.Get(ctx) + if err != nil { + panic(err) } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params + return p } // SetParams sets all wasm parameters. -func (k Keeper) SetParams(ctx sdk.Context, ps types.Params) error { - if err := ps.ValidateBasic(); err != nil { - return err - } - - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(&ps) - if err != nil { - return err - } - store.Set(types.ParamsKey, bz) - - return nil +func (k Keeper) SetParams(ctx context.Context, ps types.Params) error { + return k.params.Set(ctx, ps) } // GetAuthority returns the x/wasm module's authority. @@ -150,19 +141,19 @@ func (k Keeper) GetGasRegister() types.GasRegister { return k.gasRegister } -func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ types.AuthorizationPolicy) (codeID uint64, checksum []byte, err error) { +func (k Keeper) create(ctx context.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ types.AuthorizationPolicy) (codeID uint64, checksum []byte, err error) { if creator == nil { return 0, checksum, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "cannot be nil") } - + sdkCtx := sdk.UnwrapSDKContext(ctx) // figure out proper instantiate access - defaultAccessConfig := k.getInstantiateAccessConfig(ctx).With(creator) + defaultAccessConfig := k.getInstantiateAccessConfig(sdkCtx).With(creator) if instantiateAccess == nil { instantiateAccess = &defaultAccessConfig } chainConfigs := types.ChainAccessConfigs{ Instantiate: defaultAccessConfig, - Upload: k.getUploadAccessConfig(ctx), + Upload: k.getUploadAccessConfig(sdkCtx), } if !authZ.CanCreateCode(chainConfigs, creator, *instantiateAccess) { @@ -170,14 +161,14 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, } if ioutils.IsGzip(wasmCode) { - ctx.GasMeter().ConsumeGas(k.gasRegister.UncompressCosts(len(wasmCode)), "Uncompress gzip bytecode") + sdkCtx.GasMeter().ConsumeGas(k.gasRegister.UncompressCosts(len(wasmCode)), "Uncompress gzip bytecode") wasmCode, err = ioutils.Uncompress(wasmCode, int64(types.MaxWasmSize)) if err != nil { return 0, checksum, types.ErrCreateFailed.Wrap(errorsmod.Wrap(err, "uncompress wasm archive").Error()) } } - ctx.GasMeter().ConsumeGas(k.gasRegister.CompileCosts(len(wasmCode)), "Compiling wasm bytecode") + sdkCtx.GasMeter().ConsumeGas(k.gasRegister.CompileCosts(len(wasmCode)), "Compiling wasm bytecode") checksum, err = k.wasmVM.StoreCode(wasmCode) if err != nil { return 0, checksum, errorsmod.Wrap(types.ErrCreateFailed, err.Error()) @@ -186,10 +177,10 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, if err != nil { return 0, checksum, errorsmod.Wrap(types.ErrCreateFailed, err.Error()) } - codeID = k.autoIncrementID(ctx, types.KeySequenceCodeID) - k.Logger(ctx).Debug("storing new contract", "capabilities", report.RequiredCapabilities, "code_id", codeID) + codeID = k.mustAutoIncrementID(sdkCtx, types.KeySequenceCodeID) + k.Logger(sdkCtx).Debug("storing new contract", "capabilities", report.RequiredCapabilities, "code_id", codeID) codeInfo := types.NewCodeInfo(checksum, creator, *instantiateAccess) - k.storeCodeInfo(ctx, codeID, codeInfo) + k.mustStoreCodeInfo(sdkCtx, codeID, codeInfo) evt := sdk.NewEvent( types.EventTypeStoreCode, @@ -199,18 +190,21 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, for _, f := range strings.Split(report.RequiredCapabilities, ",") { evt.AppendAttributes(sdk.NewAttribute(types.AttributeKeyRequiredCapability, strings.TrimSpace(f))) } - ctx.EventManager().EmitEvent(evt) + sdkCtx.EventManager().EmitEvent(evt) return codeID, checksum, nil } -func (k Keeper) storeCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) mustStoreCodeInfo(ctx context.Context, codeID uint64, codeInfo types.CodeInfo) { + store := k.storeService.OpenKVStore(ctx) // 0x01 | codeID (uint64) -> ContractInfo - store.Set(types.GetCodeKey(codeID), k.cdc.MustMarshal(&codeInfo)) + err := store.Set(types.GetCodeKey(codeID), k.cdc.MustMarshal(&codeInfo)) + if err != nil { + panic(err) + } } -func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo, wasmCode []byte) error { +func (k Keeper) importCode(ctx context.Context, codeID uint64, codeInfo types.CodeInfo, wasmCode []byte) error { if ioutils.IsGzip(wasmCode) { var err error wasmCode, err = ioutils.Uncompress(wasmCode, math.MaxInt64) @@ -226,18 +220,21 @@ func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeIn return errorsmod.Wrap(types.ErrInvalid, "code hashes not same") } - store := ctx.KVStore(k.storeKey) + store := k.storeService.OpenKVStore(ctx) key := types.GetCodeKey(codeID) - if store.Has(key) { + ok, err := store.Has(key) + if err != nil { + return errorsmod.Wrap(err, "has code-id key") + } + if ok { return errorsmod.Wrapf(types.ErrDuplicate, "duplicate code: %d", codeID) } // 0x01 | codeID (uint64) -> ContractInfo - store.Set(key, k.cdc.MustMarshal(&codeInfo)) - return nil + return store.Set(key, k.cdc.MustMarshal(&codeInfo)) } func (k Keeper) instantiate( - ctx sdk.Context, + ctx context.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, @@ -251,8 +248,9 @@ func (k Keeper) instantiate( if creator == nil { return nil, nil, types.ErrEmpty.Wrap("creator") } - instanceCosts := k.gasRegister.NewContractInstanceCosts(k.IsPinnedCode(ctx, codeID), len(initMsg)) - ctx.GasMeter().ConsumeGas(instanceCosts, "Loading CosmWasm module: instantiate") + sdkCtx := sdk.UnwrapSDKContext(ctx) + instanceCosts := k.gasRegister.NewContractInstanceCosts(k.IsPinnedCode(sdkCtx, codeID), len(initMsg)) + sdkCtx.GasMeter().ConsumeGas(instanceCosts, "Loading CosmWasm module: instantiate") codeInfo := k.GetCodeInfo(ctx, codeID) if codeInfo == nil { @@ -272,21 +270,21 @@ func (k Keeper) instantiate( // But not all account types of other modules are known or may make sense for contracts, therefore we kept this // decision logic also very flexible and extendable. We provide new options to overwrite the default settings via WithAcceptedAccountTypesOnContractInstantiation and // WithPruneAccountTypesOnContractInstantiation as constructor arguments - existingAcct := k.accountKeeper.GetAccount(ctx, contractAddress) + existingAcct := k.accountKeeper.GetAccount(sdkCtx, contractAddress) if existingAcct != nil { if existingAcct.GetSequence() != 0 || existingAcct.GetPubKey() != nil { return nil, nil, types.ErrAccountExists.Wrap("address is claimed by external account") } if _, accept := k.acceptedAccountTypes[reflect.TypeOf(existingAcct)]; accept { // keep account and balance as it is - k.Logger(ctx).Info("instantiate contract with existing account", "address", contractAddress.String()) + k.Logger(sdkCtx).Info("instantiate contract with existing account", "address", contractAddress.String()) } else { // consider an account in the wasmd namespace spam and overwrite it. - k.Logger(ctx).Info("pruning existing account for contract instantiation", "address", contractAddress.String()) - contractAccount := k.accountKeeper.NewAccountWithAddress(ctx, contractAddress) - k.accountKeeper.SetAccount(ctx, contractAccount) + k.Logger(sdkCtx).Info("pruning existing account for contract instantiation", "address", contractAddress.String()) + contractAccount := k.accountKeeper.NewAccountWithAddress(sdkCtx, contractAddress) + k.accountKeeper.SetAccount(sdkCtx, contractAccount) // also handle balance to not open cases where these accounts are abused and become liquid - switch handled, err := k.accountPruner.CleanupExistingAccount(ctx, existingAcct); { + switch handled, err := k.accountPruner.CleanupExistingAccount(sdkCtx, existingAcct); { case err != nil: return nil, nil, errorsmod.Wrap(err, "prune balance") case !handled: @@ -295,38 +293,38 @@ func (k Keeper) instantiate( } } else { // create an empty account (so we don't have issues later) - contractAccount := k.accountKeeper.NewAccountWithAddress(ctx, contractAddress) - k.accountKeeper.SetAccount(ctx, contractAccount) + contractAccount := k.accountKeeper.NewAccountWithAddress(sdkCtx, contractAddress) + k.accountKeeper.SetAccount(sdkCtx, contractAccount) } // deposit initial contract funds if !deposit.IsZero() { - if err := k.bank.TransferCoins(ctx, creator, contractAddress, deposit); err != nil { + if err := k.bank.TransferCoins(sdkCtx, creator, contractAddress, deposit); err != nil { return nil, nil, err } } // prepare params for contract instantiate call - env := types.NewEnv(ctx, contractAddress) + env := types.NewEnv(sdkCtx, contractAddress) info := types.NewInfo(creator, deposit) // create prefixed data store // 0x03 | BuildContractAddressClassic (sdk.AccAddress) prefixStoreKey := types.GetContractStorePrefix(contractAddress) - vmStore := types.NewStoreAdapter(prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey)) + vmStore := types.NewStoreAdapter(prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(sdkCtx)), prefixStoreKey)) // prepare querier - querier := k.newQueryHandler(ctx, contractAddress) + querier := k.newQueryHandler(sdkCtx, contractAddress) // instantiate wasm contract - gas := k.runtimeGasForContract(ctx) - res, gasUsed, err := k.wasmVM.Instantiate(codeInfo.CodeHash, env, info, initMsg, vmStore, cosmwasmAPI, querier, k.gasMeter(ctx), gas, costJSONDeserialization) - k.consumeRuntimeGas(ctx, gasUsed) + gas := k.runtimeGasForContract(sdkCtx) + res, gasUsed, err := k.wasmVM.Instantiate(codeInfo.CodeHash, env, info, initMsg, vmStore, cosmwasmAPI, querier, k.gasMeter(sdkCtx), gas, costJSONDeserialization) + k.consumeRuntimeGas(sdkCtx, gasUsed) if err != nil { return nil, nil, errorsmod.Wrap(types.ErrInstantiateFailed, err.Error()) } // persist instance first - createdAt := types.NewAbsoluteTxPosition(ctx) + createdAt := types.NewAbsoluteTxPosition(sdkCtx) contractInfo := types.NewContractInfo(codeID, creator, admin, label, createdAt) // check for IBC flag @@ -336,7 +334,7 @@ func (k Keeper) instantiate( } if report.HasIBCEntryPoints { // register IBC port - ibcPort, err := k.ensureIbcPort(ctx, contractAddress) + ibcPort, err := k.ensureIbcPort(sdkCtx, contractAddress) if err != nil { return nil, nil, err } @@ -345,19 +343,29 @@ func (k Keeper) instantiate( // store contract before dispatch so that contract could be called back historyEntry := contractInfo.InitialHistory(initMsg) - k.addToContractCodeSecondaryIndex(ctx, contractAddress, historyEntry) - k.addToContractCreatorSecondaryIndex(ctx, creator, historyEntry.Updated, contractAddress) - k.appendToContractHistory(ctx, contractAddress, historyEntry) - k.storeContractInfo(ctx, contractAddress, &contractInfo) + err = k.addToContractCodeSecondaryIndex(sdkCtx, contractAddress, historyEntry) + if err != nil { + return nil, nil, err + } + err = k.addToContractCreatorSecondaryIndex(sdkCtx, creator, historyEntry.Updated, contractAddress) + if err != nil { + return nil, nil, err + } + err = k.appendToContractHistory(sdkCtx, contractAddress, historyEntry) + if err != nil { + return nil, nil, err + } - ctx.EventManager().EmitEvent(sdk.NewEvent( + k.mustStoreContractInfo(sdkCtx, contractAddress, &contractInfo) + + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeInstantiate, sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()), sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)), )) - ctx = types.WithSubMsgAuthzPolicy(ctx, authPolicy.SubMessageAuthorizationPolicy(types.AuthZActionInstantiate)) - data, err := k.handleContractResponse(ctx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) + sdkCtx = types.WithSubMsgAuthzPolicy(sdkCtx, authPolicy.SubMessageAuthorizationPolicy(types.AuthZActionInstantiate)) + data, err := k.handleContractResponse(sdkCtx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) if err != nil { return nil, nil, errorsmod.Wrap(err, "dispatch") } @@ -366,41 +374,42 @@ func (k Keeper) instantiate( } // Execute executes the contract instance -func (k Keeper) execute(ctx sdk.Context, contractAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) { +func (k Keeper) execute(ctx context.Context, contractAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "execute") + sdkCtx := sdk.UnwrapSDKContext(ctx) contractInfo, codeInfo, prefixStore, err := k.contractInstance(ctx, contractAddress) if err != nil { return nil, err } executeCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(ctx, contractInfo.CodeID), len(msg)) - ctx.GasMeter().ConsumeGas(executeCosts, "Loading CosmWasm module: execute") + sdkCtx.GasMeter().ConsumeGas(executeCosts, "Loading CosmWasm module: execute") // add more funds if !coins.IsZero() { - if err := k.bank.TransferCoins(ctx, caller, contractAddress, coins); err != nil { + if err := k.bank.TransferCoins(sdkCtx, caller, contractAddress, coins); err != nil { return nil, err } } - env := types.NewEnv(ctx, contractAddress) + env := types.NewEnv(sdkCtx, contractAddress) info := types.NewInfo(caller, coins) // prepare querier - querier := k.newQueryHandler(ctx, contractAddress) - gas := k.runtimeGasForContract(ctx) - res, gasUsed, execErr := k.wasmVM.Execute(codeInfo.CodeHash, env, info, msg, prefixStore, cosmwasmAPI, querier, k.gasMeter(ctx), gas, costJSONDeserialization) - k.consumeRuntimeGas(ctx, gasUsed) + querier := k.newQueryHandler(sdkCtx, contractAddress) + gas := k.runtimeGasForContract(sdkCtx) + res, gasUsed, execErr := k.wasmVM.Execute(codeInfo.CodeHash, env, info, msg, prefixStore, cosmwasmAPI, querier, k.gasMeter(sdkCtx), gas, costJSONDeserialization) + k.consumeRuntimeGas(sdkCtx, gasUsed) if execErr != nil { return nil, errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error()) } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeExecute, sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()), )) - data, err := k.handleContractResponse(ctx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) + data, err := k.handleContractResponse(sdkCtx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) if err != nil { return nil, errorsmod.Wrap(err, "dispatch") } @@ -409,7 +418,7 @@ func (k Keeper) execute(ctx sdk.Context, contractAddress, caller sdk.AccAddress, } func (k Keeper) migrate( - ctx sdk.Context, + ctx context.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, newCodeID uint64, @@ -417,8 +426,10 @@ func (k Keeper) migrate( authZ types.AuthorizationPolicy, ) ([]byte, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "migrate") + + sdkCtx := sdk.UnwrapSDKContext(ctx) migrateSetupCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(ctx, newCodeID), len(msg)) - ctx.GasMeter().ConsumeGas(migrateSetupCosts, "Loading CosmWasm module: migrate") + sdkCtx.GasMeter().ConsumeGas(migrateSetupCosts, "Loading CosmWasm module: migrate") contractInfo := k.GetContractInfo(ctx, contractAddress) if contractInfo == nil { @@ -446,42 +457,51 @@ func (k Keeper) migrate( return nil, errorsmod.Wrap(types.ErrMigrationFailed, "requires ibc callbacks") case report.HasIBCEntryPoints && contractInfo.IBCPortID == "": // add ibc port - ibcPort, err := k.ensureIbcPort(ctx, contractAddress) + ibcPort, err := k.ensureIbcPort(sdkCtx, contractAddress) if err != nil { return nil, err } contractInfo.IBCPortID = ibcPort } - env := types.NewEnv(ctx, contractAddress) + env := types.NewEnv(sdkCtx, contractAddress) // prepare querier - querier := k.newQueryHandler(ctx, contractAddress) + querier := k.newQueryHandler(sdkCtx, contractAddress) prefixStoreKey := types.GetContractStorePrefix(contractAddress) - vmStore := types.NewStoreAdapter(prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey)) - gas := k.runtimeGasForContract(ctx) - res, gasUsed, err := k.wasmVM.Migrate(newCodeInfo.CodeHash, env, msg, vmStore, cosmwasmAPI, &querier, k.gasMeter(ctx), gas, costJSONDeserialization) - k.consumeRuntimeGas(ctx, gasUsed) + vmStore := types.NewStoreAdapter(prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(sdkCtx)), prefixStoreKey)) + gas := k.runtimeGasForContract(sdkCtx) + res, gasUsed, err := k.wasmVM.Migrate(newCodeInfo.CodeHash, env, msg, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gas, costJSONDeserialization) + k.consumeRuntimeGas(sdkCtx, gasUsed) if err != nil { return nil, errorsmod.Wrap(types.ErrMigrationFailed, err.Error()) } // delete old secondary index entry - k.removeFromContractCodeSecondaryIndex(ctx, contractAddress, k.getLastContractHistoryEntry(ctx, contractAddress)) + err = k.removeFromContractCodeSecondaryIndex(ctx, contractAddress, k.mustGetLastContractHistoryEntry(sdkCtx, contractAddress)) + if err != nil { + return nil, err + } // persist migration updates - historyEntry := contractInfo.AddMigration(ctx, newCodeID, msg) - k.appendToContractHistory(ctx, contractAddress, historyEntry) - k.addToContractCodeSecondaryIndex(ctx, contractAddress, historyEntry) - k.storeContractInfo(ctx, contractAddress, contractInfo) + historyEntry := contractInfo.AddMigration(sdkCtx, newCodeID, msg) + err = k.appendToContractHistory(ctx, contractAddress, historyEntry) + if err != nil { + return nil, err + } + err = k.addToContractCodeSecondaryIndex(ctx, contractAddress, historyEntry) + if err != nil { + return nil, err + } + k.mustStoreContractInfo(ctx, contractAddress, contractInfo) - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeMigrate, sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(newCodeID, 10)), sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()), )) - ctx = types.WithSubMsgAuthzPolicy(ctx, authZ.SubMessageAuthorizationPolicy(types.AuthZActionMigrateContract)) - data, err := k.handleContractResponse(ctx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) + sdkCtx = types.WithSubMsgAuthzPolicy(sdkCtx, authZ.SubMessageAuthorizationPolicy(types.AuthZActionMigrateContract)) + data, err := k.handleContractResponse(sdkCtx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) if err != nil { return nil, errorsmod.Wrap(err, "dispatch") } @@ -497,34 +517,36 @@ func (k Keeper) migrate( // customized though by passing a new policy with the context. See types.WithSubMsgAuthzPolicy. // The policy will be read in msgServer.selectAuthorizationPolicy and used for sub-message executions. // This is an extension point for some very advanced scenarios only. Use with care! -func (k Keeper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) { +func (k Keeper) Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "sudo") + contractInfo, codeInfo, prefixStore, err := k.contractInstance(ctx, contractAddress) if err != nil { return nil, err } sudoSetupCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(ctx, contractInfo.CodeID), len(msg)) - ctx.GasMeter().ConsumeGas(sudoSetupCosts, "Loading CosmWasm module: sudo") + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.GasMeter().ConsumeGas(sudoSetupCosts, "Loading CosmWasm module: sudo") - env := types.NewEnv(ctx, contractAddress) + env := types.NewEnv(sdkCtx, contractAddress) // prepare querier - querier := k.newQueryHandler(ctx, contractAddress) - gas := k.runtimeGasForContract(ctx) - res, gasUsed, execErr := k.wasmVM.Sudo(codeInfo.CodeHash, env, msg, prefixStore, cosmwasmAPI, querier, k.gasMeter(ctx), gas, costJSONDeserialization) - k.consumeRuntimeGas(ctx, gasUsed) + querier := k.newQueryHandler(sdkCtx, contractAddress) + gas := k.runtimeGasForContract(sdkCtx) + res, gasUsed, execErr := k.wasmVM.Sudo(codeInfo.CodeHash, env, msg, prefixStore, cosmwasmAPI, querier, k.gasMeter(sdkCtx), gas, costJSONDeserialization) + k.consumeRuntimeGas(sdkCtx, gasUsed) if execErr != nil { return nil, errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error()) } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeSudo, sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()), )) // sudo submessages are executed with the default authorization policy - data, err := k.handleContractResponse(ctx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) + data, err := k.handleContractResponse(sdkCtx, contractAddress, contractInfo.IBCPortID, res.Messages, res.Attributes, res.Data, res.Events) if err != nil { return nil, errorsmod.Wrap(err, "dispatch") } @@ -569,25 +591,25 @@ func (k Keeper) reply(ctx sdk.Context, contractAddress sdk.AccAddress, reply was } // addToContractCodeSecondaryIndex adds element to the index for contracts-by-codeid queries -func (k Keeper) addToContractCodeSecondaryIndex(ctx sdk.Context, contractAddress sdk.AccAddress, entry types.ContractCodeHistoryEntry) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetContractByCreatedSecondaryIndexKey(contractAddress, entry), []byte{}) +func (k Keeper) addToContractCodeSecondaryIndex(ctx context.Context, contractAddress sdk.AccAddress, entry types.ContractCodeHistoryEntry) error { + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.GetContractByCreatedSecondaryIndexKey(contractAddress, entry), []byte{}) } // removeFromContractCodeSecondaryIndex removes element to the index for contracts-by-codeid queries -func (k Keeper) removeFromContractCodeSecondaryIndex(ctx sdk.Context, contractAddress sdk.AccAddress, entry types.ContractCodeHistoryEntry) { - ctx.KVStore(k.storeKey).Delete(types.GetContractByCreatedSecondaryIndexKey(contractAddress, entry)) +func (k Keeper) removeFromContractCodeSecondaryIndex(ctx context.Context, contractAddress sdk.AccAddress, entry types.ContractCodeHistoryEntry) error { + return k.storeService.OpenKVStore(ctx).Delete(types.GetContractByCreatedSecondaryIndexKey(contractAddress, entry)) } // addToContractCreatorSecondaryIndex adds element to the index for contracts-by-creator queries -func (k Keeper) addToContractCreatorSecondaryIndex(ctx sdk.Context, creatorAddress sdk.AccAddress, position *types.AbsoluteTxPosition, contractAddress sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetContractByCreatorSecondaryIndexKey(creatorAddress, position.Bytes(), contractAddress), []byte{}) +func (k Keeper) addToContractCreatorSecondaryIndex(ctx context.Context, creatorAddress sdk.AccAddress, position *types.AbsoluteTxPosition, contractAddress sdk.AccAddress) error { + store := k.storeService.OpenKVStore(ctx) + return store.Set(types.GetContractByCreatorSecondaryIndexKey(creatorAddress, position.Bytes(), contractAddress), []byte{}) } // IterateContractsByCreator iterates over all contracts with given creator address in order of creation time asc. -func (k Keeper) IterateContractsByCreator(ctx sdk.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractsByCreatorPrefix(creator)) +func (k Keeper) IterateContractsByCreator(ctx context.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.GetContractsByCreatorPrefix(creator)) for iter := prefixStore.Iterator(nil, nil); iter.Valid(); iter.Next() { key := iter.Key() if cb(key[types.AbsoluteTxPositionLen:]) { @@ -597,8 +619,8 @@ func (k Keeper) IterateContractsByCreator(ctx sdk.Context, creator sdk.AccAddres } // IterateContractsByCode iterates over all contracts with given codeID ASC on code update time. -func (k Keeper) IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(address sdk.AccAddress) bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractByCodeIDSecondaryIndexPrefix(codeID)) +func (k Keeper) IterateContractsByCode(ctx context.Context, codeID uint64, cb func(address sdk.AccAddress) bool) { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.GetContractByCodeIDSecondaryIndexPrefix(codeID)) iter := prefixStore.Iterator(nil, nil) defer iter.Close() @@ -610,8 +632,9 @@ func (k Keeper) IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(a } } -func (k Keeper) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ types.AuthorizationPolicy) error { - contractInfo := k.GetContractInfo(ctx, contractAddress) +func (k Keeper) setContractAdmin(ctx context.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ types.AuthorizationPolicy) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + contractInfo := k.GetContractInfo(sdkCtx, contractAddress) if contractInfo == nil { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unknown contract") } @@ -620,8 +643,8 @@ func (k Keeper) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAd } newAdminStr := newAdmin.String() contractInfo.Admin = newAdminStr - k.storeContractInfo(ctx, contractAddress, contractInfo) - ctx.EventManager().EmitEvent(sdk.NewEvent( + k.mustStoreContractInfo(sdkCtx, contractAddress, contractInfo) + sdkCtx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeUpdateContractAdmin, sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()), sdk.NewAttribute(types.AttributeKeyNewAdmin, newAdminStr), @@ -630,11 +653,11 @@ func (k Keeper) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAd return nil } -func (k Keeper) appendToContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress, newEntries ...types.ContractCodeHistoryEntry) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) appendToContractHistory(ctx context.Context, contractAddr sdk.AccAddress, newEntries ...types.ContractCodeHistoryEntry) error { + store := k.storeService.OpenKVStore(ctx) // find last element position var pos uint64 - prefixStore := prefix.NewStore(store, types.GetContractCodeHistoryElementPrefix(contractAddr)) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.GetContractCodeHistoryElementPrefix(contractAddr)) iter := prefixStore.ReverseIterator(nil, nil) defer iter.Close() @@ -648,12 +671,15 @@ func (k Keeper) appendToContractHistory(ctx sdk.Context, contractAddr sdk.AccAdd for _, e := range newEntries { pos++ key := types.GetContractCodeHistoryElementKey(contractAddr, pos) - store.Set(key, k.cdc.MustMarshal(&e)) //nolint:gosec + if err := store.Set(key, k.cdc.MustMarshal(&e)); err != nil { //nolint:gosec + return err + } } + return nil } -func (k Keeper) GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) []types.ContractCodeHistoryEntry { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractCodeHistoryElementPrefix(contractAddr)) +func (k Keeper) GetContractHistory(ctx context.Context, contractAddr sdk.AccAddress) []types.ContractCodeHistoryEntry { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.GetContractCodeHistoryElementPrefix(contractAddr)) r := make([]types.ContractCodeHistoryEntry, 0) iter := prefixStore.Iterator(nil, nil) defer iter.Close() @@ -670,9 +696,9 @@ func (k Keeper) GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) return r } -// getLastContractHistoryEntry returns the last element from history. To be used internally only as it panics when none exists -func (k Keeper) getLastContractHistoryEntry(ctx sdk.Context, contractAddr sdk.AccAddress) types.ContractCodeHistoryEntry { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractCodeHistoryElementPrefix(contractAddr)) +// mustGetLastContractHistoryEntry returns the last element from history. To be used internally only as it panics when none exists +func (k Keeper) mustGetLastContractHistoryEntry(ctx context.Context, contractAddr sdk.AccAddress) types.ContractCodeHistoryEntry { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.GetContractCodeHistoryElementPrefix(contractAddr)) iter := prefixStore.ReverseIterator(nil, nil) defer iter.Close() @@ -688,36 +714,35 @@ func (k Keeper) getLastContractHistoryEntry(ctx sdk.Context, contractAddr sdk.Ac } // QuerySmart queries the smart contract itself. -func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { +func (k Keeper) QuerySmart(ctx context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-smart") - // checks and increase query stack size - ctx, err := checkAndIncreaseQueryStackSize(ctx, k.maxQueryStackSize) + sdkCtx, err := checkAndIncreaseQueryStackSize(sdk.UnwrapSDKContext(ctx), k.maxQueryStackSize) if err != nil { return nil, err } - contractInfo, codeInfo, prefixStore, err := k.contractInstance(ctx, contractAddr) + contractInfo, codeInfo, prefixStore, err := k.contractInstance(sdkCtx, contractAddr) if err != nil { return nil, err } - smartQuerySetupCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(ctx, contractInfo.CodeID), len(req)) - ctx.GasMeter().ConsumeGas(smartQuerySetupCosts, "Loading CosmWasm module: query") + smartQuerySetupCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(sdkCtx, contractInfo.CodeID), len(req)) + sdkCtx.GasMeter().ConsumeGas(smartQuerySetupCosts, "Loading CosmWasm module: query") // prepare querier - querier := k.newQueryHandler(ctx, contractAddr) + querier := k.newQueryHandler(sdkCtx, contractAddr) - env := types.NewEnv(ctx, contractAddr) - queryResult, gasUsed, qErr := k.wasmVM.Query(codeInfo.CodeHash, env, req, prefixStore, cosmwasmAPI, querier, k.gasMeter(ctx), k.runtimeGasForContract(ctx), costJSONDeserialization) - k.consumeRuntimeGas(ctx, gasUsed) + env := types.NewEnv(sdkCtx, contractAddr) + queryResult, gasUsed, qErr := k.wasmVM.Query(codeInfo.CodeHash, env, req, prefixStore, cosmwasmAPI, querier, k.gasMeter(sdkCtx), k.runtimeGasForContract(sdkCtx), costJSONDeserialization) + k.consumeRuntimeGas(sdkCtx, gasUsed) if qErr != nil { return nil, errorsmod.Wrap(types.ErrQueryFailed, qErr.Error()) } return queryResult, nil } -func checkAndIncreaseQueryStackSize(ctx sdk.Context, maxQueryStackSize uint32) (sdk.Context, error) { +func checkAndIncreaseQueryStackSize(ctx context.Context, maxQueryStackSize uint32) (sdk.Context, error) { var queryStackSize uint32 = 0 if size, ok := types.QueryStackSize(ctx); ok { queryStackSize = size @@ -728,29 +753,32 @@ func checkAndIncreaseQueryStackSize(ctx sdk.Context, maxQueryStackSize uint32) ( // did we go too far? if queryStackSize > maxQueryStackSize { - return ctx, types.ErrExceedMaxQueryStackSize + return sdk.Context{}, types.ErrExceedMaxQueryStackSize } // set updated stack size - return types.WithQueryStackSize(ctx, queryStackSize), nil + return types.WithQueryStackSize(sdk.UnwrapSDKContext(ctx), queryStackSize), nil } // QueryRaw returns the contract's state for give key. Returns `nil` when key is `nil`. -func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte { +func (k Keeper) QueryRaw(ctx context.Context, contractAddress sdk.AccAddress, key []byte) []byte { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-raw") if key == nil { return nil } prefixStoreKey := types.GetContractStorePrefix(contractAddress) - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), prefixStoreKey) return prefixStore.Get(key) } // internal helper function -func (k Keeper) contractInstance(ctx sdk.Context, contractAddress sdk.AccAddress) (types.ContractInfo, types.CodeInfo, wasmvm.KVStore, error) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) contractInstance(ctx context.Context, contractAddress sdk.AccAddress) (types.ContractInfo, types.CodeInfo, wasmvm.KVStore, error) { + store := k.storeService.OpenKVStore(ctx) - contractBz := store.Get(types.GetContractAddressKey(contractAddress)) + contractBz, err := store.Get(types.GetContractAddressKey(contractAddress)) + if err != nil { + return types.ContractInfo{}, types.CodeInfo{}, nil, err + } if contractBz == nil { return types.ContractInfo{}, types.CodeInfo{}, nil, types.ErrNoSuchContractFn(contractAddress.String()). Wrapf("address %s", contractAddress.String()) @@ -758,7 +786,11 @@ func (k Keeper) contractInstance(ctx sdk.Context, contractAddress sdk.AccAddress var contractInfo types.ContractInfo k.cdc.MustUnmarshal(contractBz, &contractInfo) - codeInfoBz := store.Get(types.GetCodeKey(contractInfo.CodeID)) + codeInfoBz, err := store.Get(types.GetCodeKey(contractInfo.CodeID)) + if err != nil { + return types.ContractInfo{}, types.CodeInfo{}, nil, err + } + if codeInfoBz == nil { return contractInfo, types.CodeInfo{}, nil, types.ErrNoSuchCodeFn(contractInfo.CodeID). Wrapf("code id %d", contractInfo.CodeID) @@ -766,14 +798,17 @@ func (k Keeper) contractInstance(ctx sdk.Context, contractAddress sdk.AccAddress var codeInfo types.CodeInfo k.cdc.MustUnmarshal(codeInfoBz, &codeInfo) prefixStoreKey := types.GetContractStorePrefix(contractAddress) - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), prefixStoreKey) return contractInfo, codeInfo, types.NewStoreAdapter(prefixStore), nil } -func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { - store := ctx.KVStore(k.storeKey) +func (k Keeper) GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + store := k.storeService.OpenKVStore(ctx) var contract types.ContractInfo - contractBz := store.Get(types.GetContractAddressKey(contractAddress)) + contractBz, err := store.Get(types.GetContractAddressKey(contractAddress)) + if err != nil { + panic(err) + } if contractBz == nil { return nil } @@ -781,19 +816,26 @@ func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) return &contract } -func (k Keeper) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.GetContractAddressKey(contractAddress)) +func (k Keeper) HasContractInfo(ctx context.Context, contractAddress sdk.AccAddress) bool { + store := k.storeService.OpenKVStore(ctx) + ok, err := store.Has(types.GetContractAddressKey(contractAddress)) + if err != nil { + panic(err) + } + return ok } -// storeContractInfo persists the ContractInfo. No secondary index updated here. -func (k Keeper) storeContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress, contract *types.ContractInfo) { - store := ctx.KVStore(k.storeKey) - store.Set(types.GetContractAddressKey(contractAddress), k.cdc.MustMarshal(contract)) +// mustStoreContractInfo persists the ContractInfo. No secondary index updated here. +func (k Keeper) mustStoreContractInfo(ctx context.Context, contractAddress sdk.AccAddress, contract *types.ContractInfo) { + store := k.storeService.OpenKVStore(ctx) + err := store.Set(types.GetContractAddressKey(contractAddress), k.cdc.MustMarshal(contract)) + if err != nil { + panic(err) + } } -func (k Keeper) IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.ContractKeyPrefix) +func (k Keeper) IterateContractInfo(ctx context.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.ContractKeyPrefix) iter := prefixStore.Iterator(nil, nil) defer iter.Close() @@ -809,9 +851,9 @@ func (k Keeper) IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, typ // IterateContractState iterates through all elements of the key value store for the given contract address and passes // them to the provided callback function. The callback method can return true to abort early. -func (k Keeper) IterateContractState(ctx sdk.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool) { +func (k Keeper) IterateContractState(ctx context.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool) { prefixStoreKey := types.GetContractStorePrefix(contractAddress) - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), prefixStoreKey) iter := prefixStore.Iterator(nil, nil) defer iter.Close() @@ -822,9 +864,9 @@ func (k Keeper) IterateContractState(ctx sdk.Context, contractAddress sdk.AccAdd } } -func (k Keeper) importContractState(ctx sdk.Context, contractAddress sdk.AccAddress, models []types.Model) error { +func (k Keeper) importContractState(ctx context.Context, contractAddress sdk.AccAddress, models []types.Model) error { prefixStoreKey := types.GetContractStorePrefix(contractAddress) - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), prefixStoreKey) for _, model := range models { if model.Value == nil { model.Value = []byte{} @@ -837,10 +879,13 @@ func (k Keeper) importContractState(ctx sdk.Context, contractAddress sdk.AccAddr return nil } -func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo { - store := ctx.KVStore(k.storeKey) +func (k Keeper) GetCodeInfo(ctx context.Context, codeID uint64) *types.CodeInfo { + store := k.storeService.OpenKVStore(ctx) var codeInfo types.CodeInfo - codeInfoBz := store.Get(types.GetCodeKey(codeID)) + codeInfoBz, err := store.Get(types.GetCodeKey(codeID)) + if err != nil { + panic(err) + } if codeInfoBz == nil { return nil } @@ -848,13 +893,17 @@ func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo { return &codeInfo } -func (k Keeper) containsCodeInfo(ctx sdk.Context, codeID uint64) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.GetCodeKey(codeID)) +func (k Keeper) containsCodeInfo(ctx context.Context, codeID uint64) bool { + store := k.storeService.OpenKVStore(ctx) + ok, err := store.Has(types.GetCodeKey(codeID)) + if err != nil { + panic(err) + } + return ok } -func (k Keeper) IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo) bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.CodeKeyPrefix) +func (k Keeper) IterateCodeInfos(ctx context.Context, cb func(uint64, types.CodeInfo) bool) { + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.CodeKeyPrefix) iter := prefixStore.Iterator(nil, nil) defer iter.Close() @@ -868,10 +917,13 @@ func (k Keeper) IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo } } -func (k Keeper) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) GetByteCode(ctx context.Context, codeID uint64) ([]byte, error) { + store := k.storeService.OpenKVStore(ctx) var codeInfo types.CodeInfo - codeInfoBz := store.Get(types.GetCodeKey(codeID)) + codeInfoBz, err := store.Get(types.GetCodeKey(codeID)) + if err != nil { + return nil, err + } if codeInfoBz == nil { return nil, nil } @@ -880,7 +932,7 @@ func (k Keeper) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error) { } // PinCode pins the wasm contract in wasmvm cache -func (k Keeper) pinCode(ctx sdk.Context, codeID uint64) error { +func (k Keeper) pinCode(ctx context.Context, codeID uint64) error { codeInfo := k.GetCodeInfo(ctx, codeID) if codeInfo == nil { return types.ErrNoSuchCodeFn(codeID).Wrapf("code id %d", codeID) @@ -889,11 +941,14 @@ func (k Keeper) pinCode(ctx sdk.Context, codeID uint64) error { if err := k.wasmVM.Pin(codeInfo.CodeHash); err != nil { return errorsmod.Wrap(types.ErrPinContractFailed, err.Error()) } - store := ctx.KVStore(k.storeKey) + store := k.storeService.OpenKVStore(ctx) // store 1 byte to not run into `nil` debugging issues - store.Set(types.GetPinnedCodeIndexPrefix(codeID), []byte{1}) + err := store.Set(types.GetPinnedCodeIndexPrefix(codeID), []byte{1}) + if err != nil { + return err + } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypePinCode, sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)), )) @@ -901,7 +956,7 @@ func (k Keeper) pinCode(ctx sdk.Context, codeID uint64) error { } // UnpinCode removes the wasm contract from wasmvm cache -func (k Keeper) unpinCode(ctx sdk.Context, codeID uint64) error { +func (k Keeper) unpinCode(ctx context.Context, codeID uint64) error { codeInfo := k.GetCodeInfo(ctx, codeID) if codeInfo == nil { return types.ErrNoSuchCodeFn(codeID).Wrapf("code id %d", codeID) @@ -910,10 +965,13 @@ func (k Keeper) unpinCode(ctx sdk.Context, codeID uint64) error { return errorsmod.Wrap(types.ErrUnpinContractFailed, err.Error()) } - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetPinnedCodeIndexPrefix(codeID)) + store := k.storeService.OpenKVStore(ctx) + err := store.Delete(types.GetPinnedCodeIndexPrefix(codeID)) + if err != nil { + return err + } - ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( types.EventTypeUnpinCode, sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)), )) @@ -921,14 +979,18 @@ func (k Keeper) unpinCode(ctx sdk.Context, codeID uint64) error { } // IsPinnedCode returns true when codeID is pinned in wasmvm cache -func (k Keeper) IsPinnedCode(ctx sdk.Context, codeID uint64) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.GetPinnedCodeIndexPrefix(codeID)) +func (k Keeper) IsPinnedCode(ctx context.Context, codeID uint64) bool { + store := k.storeService.OpenKVStore(ctx) + ok, err := store.Has(types.GetPinnedCodeIndexPrefix(codeID)) + if err != nil { + panic(err) + } + return ok } // InitializePinnedCodes updates wasmvm to pin to cache all contracts marked as pinned -func (k Keeper) InitializePinnedCodes(ctx sdk.Context) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PinnedCodeIndexPrefix) +func (k Keeper) InitializePinnedCodes(ctx context.Context) error { + store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.PinnedCodeIndexPrefix) iter := store.Iterator(nil, nil) defer iter.Close() @@ -946,7 +1008,7 @@ func (k Keeper) InitializePinnedCodes(ctx sdk.Context) error { } // setContractInfoExtension updates the extension point data that is stored with the contract info -func (k Keeper) setContractInfoExtension(ctx sdk.Context, contractAddr sdk.AccAddress, ext types.ContractInfoExtension) error { +func (k Keeper) setContractInfoExtension(ctx context.Context, contractAddr sdk.AccAddress, ext types.ContractInfoExtension) error { info := k.GetContractInfo(ctx, contractAddr) if info == nil { return types.ErrNoSuchContractFn(contractAddr.String()). @@ -955,12 +1017,12 @@ func (k Keeper) setContractInfoExtension(ctx sdk.Context, contractAddr sdk.AccAd if err := info.SetExtension(ext); err != nil { return err } - k.storeContractInfo(ctx, contractAddr, info) + k.mustStoreContractInfo(ctx, contractAddr, info) return nil } // setAccessConfig updates the access config of a code id. -func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, authz types.AuthorizationPolicy) error { +func (k Keeper) setAccessConfig(ctx context.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, authz types.AuthorizationPolicy) error { info := k.GetCodeInfo(ctx, codeID) if info == nil { return types.ErrNoSuchCodeFn(codeID).Wrapf("code id %d", codeID) @@ -971,7 +1033,7 @@ func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAd } info.InstantiateConfig = newConfig - k.storeCodeInfo(ctx, codeID, *info) + k.mustStoreCodeInfo(ctx, codeID, *info) evt := sdk.NewEvent( types.EventTypeUpdateCodeAccessConfig, sdk.NewAttribute(types.AttributeKeyCodePermission, newConfig.Permission.String()), @@ -981,7 +1043,7 @@ func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAd attr := sdk.NewAttribute(types.AttributeKeyAuthorizedAddresses, strings.Join(addrs, ",")) evt.Attributes = append(evt.Attributes, attr.ToKVPair()) } - ctx.EventManager().EmitEvent(evt) + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(evt) return nil } @@ -1031,60 +1093,84 @@ func (k Keeper) consumeRuntimeGas(ctx sdk.Context, gas uint64) { ctx.GasMeter().ConsumeGas(consumed, "wasm contract") // throw OutOfGas error if we ran out (got exactly to zero due to better limit enforcing) if ctx.GasMeter().IsOutOfGas() { - panic(sdk.ErrorOutOfGas{Descriptor: "Wasm engine function execution"}) + panic(storetypes.ErrorOutOfGas{Descriptor: "Wasm engine function execution"}) } } -func (k Keeper) autoIncrementID(ctx sdk.Context, sequenceKey []byte) uint64 { - store := ctx.KVStore(k.storeKey) - bz := store.Get(sequenceKey) +func (k Keeper) mustAutoIncrementID(ctx context.Context, sequenceKey []byte) uint64 { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(sequenceKey) + if err != nil { + panic(err) + } id := uint64(1) if bz != nil { id = binary.BigEndian.Uint64(bz) } bz = sdk.Uint64ToBigEndian(id + 1) - store.Set(sequenceKey, bz) + err = store.Set(sequenceKey, bz) + if err != nil { + panic(err) + } return id } // PeekAutoIncrementID reads the current value without incrementing it. -func (k Keeper) PeekAutoIncrementID(ctx sdk.Context, sequenceKey []byte) uint64 { - store := ctx.KVStore(k.storeKey) - bz := store.Get(sequenceKey) +func (k Keeper) PeekAutoIncrementID(ctx context.Context, sequenceKey []byte) (uint64, error) { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(sequenceKey) + if err != nil { + return 0, errorsmod.Wrap(err, "sequence key") + } id := uint64(1) if bz != nil { id = binary.BigEndian.Uint64(bz) } - return id + return id, nil } -func (k Keeper) importAutoIncrementID(ctx sdk.Context, sequenceKey []byte, val uint64) error { - store := ctx.KVStore(k.storeKey) - if store.Has(sequenceKey) { +func (k Keeper) importAutoIncrementID(ctx context.Context, sequenceKey []byte, val uint64) error { + store := k.storeService.OpenKVStore(ctx) + ok, err := store.Has(sequenceKey) + if err != nil { + return errorsmod.Wrap(err, "sequence key") + } + if ok { return errorsmod.Wrapf(types.ErrDuplicate, "autoincrement id: %s", string(sequenceKey)) } bz := sdk.Uint64ToBigEndian(val) - store.Set(sequenceKey, bz) - return nil + return store.Set(sequenceKey, bz) } -func (k Keeper) importContract(ctx sdk.Context, contractAddr sdk.AccAddress, c *types.ContractInfo, state []types.Model, entries []types.ContractCodeHistoryEntry) error { +func (k Keeper) importContract(ctx context.Context, contractAddr sdk.AccAddress, c *types.ContractInfo, state []types.Model, historyEntries []types.ContractCodeHistoryEntry) error { if !k.containsCodeInfo(ctx, c.CodeID) { return types.ErrNoSuchCodeFn(c.CodeID).Wrapf("code id %d", c.CodeID) } if k.HasContractInfo(ctx, contractAddr) { return errorsmod.Wrapf(types.ErrDuplicate, "contract: %s", contractAddr) } + if len(historyEntries) == 0 { + return types.ErrEmpty.Wrap("contract history") + } creatorAddress, err := sdk.AccAddressFromBech32(c.Creator) if err != nil { return err } - k.appendToContractHistory(ctx, contractAddr, entries...) - k.storeContractInfo(ctx, contractAddr, c) - k.addToContractCodeSecondaryIndex(ctx, contractAddr, entries[len(entries)-1]) - k.addToContractCreatorSecondaryIndex(ctx, creatorAddress, entries[0].Updated, contractAddr) + err = k.appendToContractHistory(ctx, contractAddr, historyEntries...) + if err != nil { + return err + } + k.mustStoreContractInfo(ctx, contractAddr, c) + err = k.addToContractCodeSecondaryIndex(ctx, contractAddr, historyEntries[len(historyEntries)-1]) + if err != nil { + return err + } + err = k.addToContractCreatorSecondaryIndex(ctx, creatorAddress, historyEntries[0].Updated, contractAddr) + if err != nil { + return err + } return k.importContractState(ctx, contractAddr, state) } @@ -1094,17 +1180,17 @@ func (k Keeper) newQueryHandler(ctx sdk.Context, contractAddress sdk.AccAddress) // MultipliedGasMeter wraps the GasMeter from context and multiplies all reads by out defined multiplier type MultipliedGasMeter struct { - originalMeter sdk.GasMeter + originalMeter storetypes.GasMeter GasRegister types.GasRegister } -func NewMultipliedGasMeter(originalMeter sdk.GasMeter, gr types.GasRegister) MultipliedGasMeter { +func NewMultipliedGasMeter(originalMeter storetypes.GasMeter, gr types.GasRegister) MultipliedGasMeter { return MultipliedGasMeter{originalMeter: originalMeter, GasRegister: gr} } var _ wasmvm.GasMeter = MultipliedGasMeter{} -func (m MultipliedGasMeter) GasConsumed() sdk.Gas { +func (m MultipliedGasMeter) GasConsumed() storetypes.Gas { return m.GasRegister.ToWasmVMGas(m.originalMeter.GasConsumed()) } @@ -1123,11 +1209,11 @@ func moduleLogger(ctx sdk.Context) log.Logger { // Querier creates a new grpc querier instance func Querier(k *Keeper) *GrpcQuerier { - return NewGrpcQuerier(k.cdc, k.storeKey, k, k.queryGasLimit) + return NewGrpcQuerier(k.cdc, k.storeService, k, k.queryGasLimit) } // QueryGasLimit returns the gas limit for smart queries. -func (k Keeper) QueryGasLimit() sdk.Gas { +func (k Keeper) QueryGasLimit() storetypes.Gas { return k.queryGasLimit } @@ -1185,13 +1271,13 @@ func NewVestingCoinBurner(bank types.BankKeeper) VestingCoinBurner { // CleanupExistingAccount accepts only vesting account types to burns all their original vesting coin balances. // Other account types will be rejected and returned as unhandled. -func (b VestingCoinBurner) CleanupExistingAccount(ctx sdk.Context, existingAcc authtypes.AccountI) (handled bool, err error) { +func (b VestingCoinBurner) CleanupExistingAccount(ctx sdk.Context, existingAcc sdk.AccountI) (handled bool, err error) { v, ok := existingAcc.(vestingexported.VestingAccount) if !ok { return false, nil } - ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + ctx = ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) coinsToBurn := sdk.NewCoins() for _, orig := range v.GetOriginalVesting() { // focus on the coin denoms that were setup originally; getAllBalances has some issues coinsToBurn = append(coinsToBurn, b.bank.GetBalance(ctx, existingAcc.GetAddress(), orig.Denom)) diff --git a/x/wasm/keeper/keeper_cgo.go b/x/wasm/keeper/keeper_cgo.go index 743ac64de4..cb5baaa359 100644 --- a/x/wasm/keeper/keeper_cgo.go +++ b/x/wasm/keeper/keeper_cgo.go @@ -7,8 +7,10 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" + "cosmossdk.io/collections" + corestoretypes "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -17,7 +19,7 @@ import ( // If customEncoders is non-nil, we can use this to override some of the message handler, especially custom func NewKeeper( cdc codec.Codec, - storeKey storetypes.StoreKey, + storeService corestoretypes.KVStoreService, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, @@ -35,8 +37,9 @@ func NewKeeper( authority string, opts ...Option, ) Keeper { + sb := collections.NewSchemaBuilder(storeService) keeper := &Keeper{ - storeKey: storeKey, + storeService: storeService, cdc: cdc, wasmVM: nil, accountKeeper: accountKeeper, @@ -49,6 +52,7 @@ func NewKeeper( gasRegister: types.NewDefaultWasmGasRegister(), maxQueryStackSize: types.DefaultMaxQueryStackSize, acceptedAccountTypes: defaultAcceptedAccountTypes, + params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), propagateGovAuthorization: map[types.AuthorizationPolicyAction]struct{}{ types.AuthZActionInstantiate: {}, }, diff --git a/x/wasm/keeper/keeper_no_cgo.go b/x/wasm/keeper/keeper_no_cgo.go index 4a5db265a6..e0b86812d3 100644 --- a/x/wasm/keeper/keeper_no_cgo.go +++ b/x/wasm/keeper/keeper_no_cgo.go @@ -3,8 +3,8 @@ package keeper import ( + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 8b4cce4227..2ec02394a1 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -21,10 +21,11 @@ import ( "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - stypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -306,7 +307,7 @@ func TestCreateWithSimulation(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) ctx = ctx.WithBlockHeader(tmproto.Header{Height: 1}). - WithGasMeter(stypes.NewInfiniteGasMeter()) + WithGasMeter(storetypes.NewInfiniteGasMeter()) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) @@ -318,7 +319,7 @@ func TestCreateWithSimulation(t *testing.T) { // then try to create it in non-simulation mode (should not fail) ctx, keepers = CreateTestInput(t, false, AvailableCapabilities) - ctx = ctx.WithGasMeter(sdk.NewGasMeter(10_000_000)) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(10_000_000)) creator = keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) contractID, _, err = keepers.ContractKeeper.Create(ctx, creator, hackatomWasm, nil) @@ -337,15 +338,15 @@ func TestIsSimulationMode(t *testing.T) { exp bool }{ "genesis block": { - ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{}).WithGasMeter(stypes.NewInfiniteGasMeter()), + ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{}).WithGasMeter(storetypes.NewInfiniteGasMeter()), exp: false, }, "any regular block": { - ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{Height: 1}).WithGasMeter(stypes.NewGasMeter(10000000)), + ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{Height: 1}).WithGasMeter(storetypes.NewGasMeter(10000000)), exp: false, }, "simulation": { - ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{Height: 1}).WithGasMeter(stypes.NewInfiniteGasMeter()), + ctx: sdk.Context{}.WithBlockHeader(tmproto.Header{Height: 1}).WithGasMeter(storetypes.NewInfiniteGasMeter()), exp: true, }, } @@ -385,12 +386,12 @@ func TestCreateWithBrokenGzippedPayload(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/broken_crc.gzip") require.NoError(t, err, "reading gzipped WASM code") - gm := sdk.NewInfiniteGasMeter() + gm := storetypes.NewInfiniteGasMeter() codeID, checksum, err := keeper.Create(ctx.WithGasMeter(gm), creator, wasmCode, nil) require.Error(t, err) assert.Empty(t, codeID) assert.Empty(t, checksum) - assert.GreaterOrEqual(t, gm.GasConsumed(), sdk.Gas(121384)) // 809232 * 0.15 (default uncompress costs) = 121384 + assert.GreaterOrEqual(t, gm.GasConsumed(), storetypes.Gas(121384)) // 809232 * 0.15 (default uncompress costs) = 121384 } func TestInstantiate(t *testing.T) { @@ -418,7 +419,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1b5bd), gasAfter-gasBefore) + require.Equal(t, uint64(0x1bc64), gasAfter-gasBefore) } // ensure it is stored properly @@ -573,11 +574,11 @@ func TestInstantiateWithAccounts(t *testing.T) { specs := map[string]struct { option Option - account authtypes.AccountI + account sdk.AccountI initBalance sdk.Coin deposit sdk.Coins expErr error - expAccount authtypes.AccountI + expAccount sdk.AccountI expBalance sdk.Coins }{ "unused BaseAccount exists": { @@ -600,60 +601,60 @@ func TestInstantiateWithAccounts(t *testing.T) { }, "no account existed before create with deposit": { expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), // +1 for next seq - deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), - expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), }, "prunable DelayedVestingAccount gets overwritten": { - account: vestingtypes.NewDelayedVestingAccount( + account: must(vestingtypes.NewDelayedVestingAccount( authtypes.NewBaseAccount(contractAddr, nil, 0, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), - initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), - deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix())), + initBalance: sdk.NewCoin("denom", sdkmath.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1))), expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created - expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1))), }, "prunable ContinuousVestingAccount gets overwritten": { - account: vestingtypes.NewContinuousVestingAccount( + account: must(vestingtypes.NewContinuousVestingAccount( authtypes.NewBaseAccount(contractAddr, nil, 0, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix()), - initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), - deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix())), + initBalance: sdk.NewCoin("denom", sdkmath.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1))), expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created - expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), - }, - "prunable account without balance gets overwritten": { - account: vestingtypes.NewContinuousVestingAccount( - authtypes.NewBaseAccount(contractAddr, nil, 0, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(0))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix()), - expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created - expBalance: sdk.NewCoins(), - }, + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1))), + }, + // "prunable account without balance gets overwritten": { // todo : can not initialize vesting with empty balance + // account: must(vestingtypes.NewContinuousVestingAccount( + // authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + // sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(0))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix())), + // expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created + // expBalance: sdk.NewCoins(), + // }, "unknown account type is rejected with error": { account: authtypes.NewModuleAccount( authtypes.NewBaseAccount(contractAddr, nil, 0, 0), "testing", ), - initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), + initBalance: sdk.NewCoin("denom", sdkmath.NewInt(1_000)), expErr: types.ErrAccountExists, }, "with option used to set non default type to accept list": { option: WithAcceptedAccountTypesOnContractInstantiation(&vestingtypes.DelayedVestingAccount{}), - account: vestingtypes.NewDelayedVestingAccount( + account: must(vestingtypes.NewDelayedVestingAccount( authtypes.NewBaseAccount(contractAddr, nil, 0, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), - initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), - deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), - expAccount: vestingtypes.NewDelayedVestingAccount(authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), - expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_001))), + sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix())), + initBalance: sdk.NewCoin("denom", sdkmath.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1))), + expAccount: must(vestingtypes.NewDelayedVestingAccount(authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix())), + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_001))), }, "pruning account fails": { - option: WithAccountPruner(wasmtesting.AccountPrunerMock{CleanupExistingAccountFn: func(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) { + option: WithAccountPruner(wasmtesting.AccountPrunerMock{CleanupExistingAccountFn: func(ctx sdk.Context, existingAccount sdk.AccountI) (handled bool, err error) { return false, types.ErrUnsupportedForContract.Wrap("testing") }}), - account: vestingtypes.NewDelayedVestingAccount( + account: must(vestingtypes.NewDelayedVestingAccount( authtypes.NewBaseAccount(contractAddr, nil, 0, 0), - sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), + sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix())), expErr: types.ErrUnsupportedForContract, }, } @@ -843,7 +844,7 @@ func TestExecute(t *testing.T) { assert.Equal(t, deposit, bankKeeper.GetAllBalances(ctx, contractAcct.GetAddress())) // unauthorized - trialCtx so we don't change state - trialCtx := ctx.WithMultiStore(ctx.MultiStore().CacheWrap().(sdk.MultiStore)) + trialCtx := ctx.WithMultiStore(ctx.MultiStore().CacheWrap().(storetypes.MultiStore)) _, err = keepers.ContractKeeper.Execute(trialCtx, addr, creator, []byte(`{"release":{}}`), nil) require.Error(t, err) require.True(t, errors.Is(err, types.ErrExecuteFailed)) @@ -862,7 +863,7 @@ func TestExecute(t *testing.T) { // make sure gas is properly deducted from ctx gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1a155), gasAfter-gasBefore) + require.Equal(t, uint64(0x1ac6a), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) @@ -1047,14 +1048,14 @@ func TestExecuteWithCpuLoop(t *testing.T) { // make sure we set a limit before calling var gasLimit uint64 = 400_000 - ctx = ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(gasLimit)) require.Equal(t, uint64(0), ctx.GasMeter().GasConsumed()) // ensure we get an out of gas panic defer func() { r := recover() require.NotNil(t, r) - _, ok := r.(sdk.ErrorOutOfGas) + _, ok := r.(storetypes.ErrorOutOfGas) require.True(t, ok, "%v", r) }() @@ -1090,14 +1091,14 @@ func TestExecuteWithStorageLoop(t *testing.T) { // make sure we set a limit before calling var gasLimit uint64 = 400_002 - ctx = ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(gasLimit)) require.Equal(t, uint64(0), ctx.GasMeter().GasConsumed()) // ensure we get an out of gas panic defer func() { r := recover() require.NotNil(t, r) - _, ok := r.(sdk.ErrorOutOfGas) + _, ok := r.(storetypes.ErrorOutOfGas) require.True(t, ok, "%v", r) }() @@ -1310,21 +1311,22 @@ func TestMigrateReplacesTheSecondIndex(t *testing.T) { example := InstantiateHackatomExampleContract(t, ctx, keepers) // then assert a second index exists - store := ctx.KVStore(keepers.WasmKeeper.storeKey) + store := keepers.WasmKeeper.storeService.OpenKVStore(ctx) oldContractInfo := keepers.WasmKeeper.GetContractInfo(ctx, example.Contract) require.NotNil(t, oldContractInfo) createHistoryEntry := types.ContractCodeHistoryEntry{ CodeID: example.CodeID, Updated: types.NewAbsoluteTxPosition(ctx), } - exists := store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, createHistoryEntry)) + exists, err := store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, createHistoryEntry)) + require.NoError(t, err) require.True(t, exists) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) // increment for different block // when do migrate newCodeExample := StoreBurnerExampleContract(t, ctx, keepers) migMsgBz := BurnerExampleInitMsg{Payout: example.CreatorAddr}.GetBytes(t) - _, err := keepers.ContractKeeper.Migrate(ctx, example.Contract, example.CreatorAddr, newCodeExample.CodeID, migMsgBz) + _, err = keepers.ContractKeeper.Migrate(ctx, example.Contract, example.CreatorAddr, newCodeExample.CodeID, migMsgBz) require.NoError(t, err) // then the new index exists @@ -1332,10 +1334,12 @@ func TestMigrateReplacesTheSecondIndex(t *testing.T) { CodeID: newCodeExample.CodeID, Updated: types.NewAbsoluteTxPosition(ctx), } - exists = store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, migrateHistoryEntry)) + exists, err = store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, migrateHistoryEntry)) + require.NoError(t, err) require.True(t, exists) // and the old index was removed - exists = store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, createHistoryEntry)) + exists, err = store.Has(types.GetContractByCreatedSecondaryIndexKey(example.Contract, createHistoryEntry)) + require.NoError(t, err) require.False(t, exists) } @@ -1857,8 +1861,8 @@ func TestPinnedContractLoops(t *testing.T) { }, }, 0, nil } - ctx = ctx.WithGasMeter(sdk.NewGasMeter(20000)) - require.PanicsWithValue(t, sdk.ErrorOutOfGas{Descriptor: "ReadFlat"}, func() { + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(20000)) + require.PanicsWithValue(t, storetypes.ErrorOutOfGas{Descriptor: "ReadFlat"}, func() { _, err := k.execute(ctx, example.Contract, RandomAccountAddress(t), anyMsg, nil) require.NoError(t, err) }) @@ -2027,8 +2031,8 @@ func TestQueryIsolation(t *testing.T) { return other.HandleQuery(ctx, caller, request) } // here we write to DB which should not be persisted - ctx.KVStore(k.storeKey).Set([]byte(`set_in_query`), []byte(`this_is_allowed`)) - return nil, nil + err := k.storeService.OpenKVStore(ctx).Set([]byte(`set_in_query`), []byte(`this_is_allowed`)) + return nil, err }) }).apply(k) @@ -2043,7 +2047,9 @@ func TestQueryIsolation(t *testing.T) { em := sdk.NewEventManager() _, gotErr := k.reply(ctx.WithEventManager(em), example.Contract, wasmvmtypes.Reply{}) require.NoError(t, gotErr) - assert.Nil(t, ctx.KVStore(k.storeKey).Get([]byte(`set_in_query`))) + got, err := k.storeService.OpenKVStore(ctx).Get([]byte(`set_in_query`)) + require.NoError(t, err) + assert.Nil(t, got) } func TestSetAccessConfig(t *testing.T) { @@ -2147,7 +2153,7 @@ func TestSetAccessConfig(t *testing.T) { err := k.SetParams(ctx, newParams) require.NoError(t, err) - k.storeCodeInfo(ctx, codeID, types.NewCodeInfo(nil, creatorAddr, types.AllowNobody)) + k.mustStoreCodeInfo(ctx, codeID, types.NewCodeInfo(nil, creatorAddr, types.AllowNobody)) // when gotErr := k.setAccessConfig(ctx, codeID, spec.caller, spec.newConfig, spec.authz) if spec.expErr { @@ -2194,7 +2200,7 @@ func TestAppendToContractHistory(t *testing.T) { for i := 0; i < 10; i++ { var entry types.ContractCodeHistoryEntry f.RandSource(sRandom).Fuzz(&entry) - k.appendToContractHistory(ctx, addr, entry) + require.NoError(t, k.appendToContractHistory(ctx, addr, entry)) orderedEntries[j] = append(orderedEntries[j], entry) } } @@ -2202,7 +2208,7 @@ func TestAppendToContractHistory(t *testing.T) { for j, addr := range variableLengthAddresses { gotHistory := k.GetContractHistory(ctx, addr) assert.Equal(t, orderedEntries[j], gotHistory, "%d: %X", j, addr) - assert.Equal(t, orderedEntries[j][len(orderedEntries[j])-1], k.getLastContractHistoryEntry(ctx, addr)) + assert.Equal(t, orderedEntries[j][len(orderedEntries[j])-1], k.mustGetLastContractHistoryEntry(ctx, addr)) } }) } @@ -2216,40 +2222,35 @@ func TestCoinBurnerPruneBalances(t *testing.T) { // create vesting account var vestingAddr sdk.AccAddress = rand.Bytes(types.ContractAddrLen) msgCreateVestingAccount := vestingtypes.NewMsgCreateVestingAccount(senderAddr, vestingAddr, amts, time.Now().Add(time.Minute).Unix(), false) - _, err := vesting.NewMsgServerImpl(keepers.AccountKeeper, keepers.BankKeeper).CreateVestingAccount(sdk.WrapSDKContext(parentCtx), msgCreateVestingAccount) + _, err := vesting.NewMsgServerImpl(keepers.AccountKeeper, keepers.BankKeeper).CreateVestingAccount(parentCtx, msgCreateVestingAccount) require.NoError(t, err) myVestingAccount := keepers.AccountKeeper.GetAccount(parentCtx, vestingAddr) require.NotNil(t, myVestingAccount) specs := map[string]struct { - setupAcc func(t *testing.T, ctx sdk.Context) authtypes.AccountI + setupAcc func(t *testing.T, ctx sdk.Context) sdk.AccountI expBalances sdk.Coins expHandled bool expErr *errorsmod.Error }{ "vesting account - all removed": { - setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { - t.Helper() - return myVestingAccount - }, + setupAcc: func(t *testing.T, ctx sdk.Context) sdk.AccountI { return myVestingAccount }, expBalances: sdk.NewCoins(), expHandled: true, }, "vesting account with other tokens - only original denoms removed": { - setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { - t.Helper() - keepers.Faucet.Fund(ctx, vestingAddr, sdk.NewCoin("other", sdk.NewInt(2))) + setupAcc: func(t *testing.T, ctx sdk.Context) sdk.AccountI { + keepers.Faucet.Fund(ctx, vestingAddr, sdk.NewCoin("other", sdkmath.NewInt(2))) return myVestingAccount }, - expBalances: sdk.NewCoins(sdk.NewCoin("other", sdk.NewInt(2))), + expBalances: sdk.NewCoins(sdk.NewCoin("other", sdkmath.NewInt(2))), expHandled: true, }, "non vesting account - not handled": { - setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { - t.Helper() + setupAcc: func(t *testing.T, ctx sdk.Context) sdk.AccountI { return &authtypes.BaseAccount{Address: myVestingAccount.GetAddress().String()} }, - expBalances: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(100))), + expBalances: sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(100))), expHandled: false, }, } @@ -2261,7 +2262,7 @@ func TestCoinBurnerPruneBalances(t *testing.T) { keepers.AccountKeeper.SetAccount(ctx, keepers.AccountKeeper.NewAccountWithAddress(ctx, vestingAddr)) // when - noGasCtx := ctx.WithGasMeter(sdk.NewGasMeter(0)) // should not use callers gas + noGasCtx := ctx.WithGasMeter(storetypes.NewGasMeter(0)) // should not use callers gas gotHandled, gotErr := NewVestingCoinBurner(keepers.BankKeeper).CleanupExistingAccount(noGasCtx, existingAccount) // then if spec.expErr != nil { @@ -2318,7 +2319,7 @@ func TestIteratorContractByCreator(t *testing.T) { Beneficiary: mockAddress1, }.GetBytes(t) - depositContract := sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))) + depositContract := sdk.NewCoins(sdk.NewCoin("denom", sdkmath.NewInt(1_000))) gotAddr1, _, _ := keepers.ContractKeeper.Instantiate(parentCtx, contract1ID, mockAddress1, nil, initMsgBz, "label", depositContract) ctx := parentCtx.WithBlockHeight(parentCtx.BlockHeight() + 1) @@ -2435,38 +2436,38 @@ func TestSetContractAdmin(t *testing.T) { func TestGasConsumed(t *testing.T) { specs := map[string]struct { - originalMeter stypes.GasMeter + originalMeter storetypes.GasMeter gasRegister types.WasmGasRegister - consumeGas sdk.Gas + consumeGas storetypes.Gas expPanic bool expMultipliedGasConsumed uint64 }{ "all good": { - originalMeter: sdk.NewGasMeter(100), + originalMeter: storetypes.NewGasMeter(100), gasRegister: types.NewWasmGasRegister(types.DefaultGasRegisterConfig()), - consumeGas: sdk.Gas(1), + consumeGas: storetypes.Gas(1), expMultipliedGasConsumed: 140000000, }, "consumeGas = limit": { - originalMeter: sdk.NewGasMeter(1), + originalMeter: storetypes.NewGasMeter(1), gasRegister: types.NewWasmGasRegister(types.DefaultGasRegisterConfig()), - consumeGas: sdk.Gas(1), + consumeGas: storetypes.Gas(1), expMultipliedGasConsumed: 140000000, }, "consumeGas > limit": { - originalMeter: sdk.NewGasMeter(10), + originalMeter: storetypes.NewGasMeter(10), gasRegister: types.NewWasmGasRegister(types.DefaultGasRegisterConfig()), - consumeGas: sdk.Gas(11), + consumeGas: storetypes.Gas(11), expPanic: true, }, "nil original meter": { gasRegister: types.NewWasmGasRegister(types.DefaultGasRegisterConfig()), - consumeGas: sdk.Gas(1), + consumeGas: storetypes.Gas(1), expPanic: true, }, "nil gas register": { - originalMeter: sdk.NewGasMeter(100), - consumeGas: sdk.Gas(1), + originalMeter: storetypes.NewGasMeter(100), + consumeGas: storetypes.Gas(1), expPanic: true, }, } @@ -2495,3 +2496,10 @@ func attrsToStringMap(attrs []abci.EventAttribute) map[string]string { } return r } + +func must[t any](s t, err error) t { + if err != nil { + panic(err) + } + return s +} diff --git a/x/wasm/keeper/migrations.go b/x/wasm/keeper/migrations.go index a7209035fc..5188c5bb2a 100644 --- a/x/wasm/keeper/migrations.go +++ b/x/wasm/keeper/migrations.go @@ -28,11 +28,11 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { // Migrate2to3 migrates the x/wasm module state from the consensus // version 2 to version 3. func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) + return v2.MigrateStore(ctx, m.keeper.storeService, m.legacySubspace, m.keeper.cdc) } // Migrate3to4 migrates the x/wasm module state from the consensus // version 3 to version 4. func (m Migrator) Migrate3to4(ctx sdk.Context) error { - return v3.NewMigrator(m.keeper, m.keeper.storeCodeInfo).Migrate3to4(ctx, m.keeper.storeKey, m.keeper.cdc) + return v3.NewMigrator(m.keeper, m.keeper.mustStoreCodeInfo).Migrate3to4(ctx, m.keeper.storeService, m.keeper.cdc) } diff --git a/x/wasm/keeper/migrations_integration_test.go b/x/wasm/keeper/migrations_integration_test.go index 5cd5a78283..a2ec8fd329 100644 --- a/x/wasm/keeper/migrations_integration_test.go +++ b/x/wasm/keeper/migrations_integration_test.go @@ -3,13 +3,13 @@ package keeper_test import ( "testing" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -34,7 +34,15 @@ func TestModuleMigrations(t *testing.T) { CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, } + + // upgrade code shipped with v0.40 + // https://github.com/CosmWasm/wasmd/blob/v0.40.0/app/upgrades.go#L66 sp, _ := wasmApp.ParamsKeeper.GetSubspace(types.ModuleName) + keyTable := types.ParamKeyTable() + if !sp.HasKeyTable() { + sp.WithKeyTable(keyTable) + } + sp.SetParamSet(ctx, ¶ms) }, exp: types.Params{ @@ -50,12 +58,13 @@ func TestModuleMigrations(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - ctx, _ := wasmApp.BaseApp.NewContext(false, tmproto.Header{}).CacheContext() + ctx, _ := wasmApp.BaseApp.NewContext(false).CacheContext() spec.setup(ctx) - fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) + fromVM, err := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) + require.NoError(t, err) fromVM[types.ModuleName] = spec.startVersion - _, err := upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) + _, err = upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) require.NoError(t, err) // when @@ -82,7 +91,7 @@ func TestAccessConfigMigrations(t *testing.T) { return wasmApp.ModuleManager.RunMigrations(ctx, wasmApp.Configurator(), fromVM) } - ctx, _ := wasmApp.BaseApp.NewContext(false, tmproto.Header{}).CacheContext() + ctx, _ := wasmApp.BaseApp.NewContext(false).CacheContext() // any address permission code1, err := storeCode(ctx, wasmApp, types.AccessTypeAnyOfAddresses.With(address)) @@ -96,7 +105,8 @@ func TestAccessConfigMigrations(t *testing.T) { code3, err := storeCode(ctx, wasmApp, types.AllowNobody) require.NoError(t, err) - fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) + fromVM, err := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) + require.NoError(t, err) fromVM[types.ModuleName] = wasmApp.ModuleManager.GetVersionMap()[types.ModuleName] _, err = upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) require.NoError(t, err) diff --git a/x/wasm/keeper/msg_dispatcher.go b/x/wasm/keeper/msg_dispatcher.go index 9520e0002e..cbd66eed1f 100644 --- a/x/wasm/keeper/msg_dispatcher.go +++ b/x/wasm/keeper/msg_dispatcher.go @@ -9,6 +9,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -53,14 +54,14 @@ func (d MessageDispatcher) DispatchMessages(ctx sdk.Context, contractAddr sdk.Ac // dispatchMsgWithGasLimit sends a message with gas limit applied func (d MessageDispatcher) dispatchMsgWithGasLimit(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, msg wasmvmtypes.CosmosMsg, gasLimit uint64) (events []sdk.Event, data [][]byte, err error) { - limitedMeter := sdk.NewGasMeter(gasLimit) + limitedMeter := storetypes.NewGasMeter(gasLimit) subCtx := ctx.WithGasMeter(limitedMeter) // catch out of gas panic and just charge the entire gas limit defer func() { if r := recover(); r != nil { // if it's not an OutOfGas error, raise it again - if _, ok := r.(sdk.ErrorOutOfGas); !ok { + if _, ok := r.(storetypes.ErrorOutOfGas); !ok { // log it to get the original stack trace somewhere (as panic(r) keeps message but stacktrace to here moduleLogger(ctx).Info("SubMsg rethrowing panic: %#v", r) panic(r) diff --git a/x/wasm/keeper/msg_dispatcher_test.go b/x/wasm/keeper/msg_dispatcher_test.go index f9bc676cb4..3cecfe6639 100644 --- a/x/wasm/keeper/msg_dispatcher_test.go +++ b/x/wasm/keeper/msg_dispatcher_test.go @@ -7,10 +7,12 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" @@ -171,7 +173,7 @@ func TestDispatchSubmessages(t *testing.T) { }, msgHandler: &wasmtesting.MockMessageHandler{ DispatchMsgFn: func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) { - ctx.GasMeter().ConsumeGas(sdk.Gas(101), "testing") + ctx.GasMeter().ConsumeGas(storetypes.Gas(101), "testing") return nil, [][]byte{[]byte("someData")}, nil }, }, @@ -186,7 +188,7 @@ func TestDispatchSubmessages(t *testing.T) { replyer: &mockReplyer{}, msgHandler: &wasmtesting.MockMessageHandler{ DispatchMsgFn: func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) { - ctx.GasMeter().ConsumeGas(sdk.Gas(1), "testing") + ctx.GasMeter().ConsumeGas(storetypes.Gas(1), "testing") return nil, [][]byte{[]byte("someData")}, nil }, }, @@ -392,8 +394,8 @@ func TestDispatchSubmessages(t *testing.T) { var mockStore wasmtesting.MockCommitMultiStore em := sdk.NewEventManager() ctx := sdk.Context{}.WithMultiStore(&mockStore). - WithGasMeter(sdk.NewGasMeter(100)). - WithEventManager(em).WithLogger(log.TestingLogger()) + WithGasMeter(storetypes.NewGasMeter(100)). + WithEventManager(em).WithLogger(log.NewTestLogger(t)) d := NewMessageDispatcher(spec.msgHandler, spec.replyer) // run the test diff --git a/x/wasm/keeper/msg_server.go b/x/wasm/keeper/msg_server.go index 8c7e3774dd..0cd43165c7 100644 --- a/x/wasm/keeper/msg_server.go +++ b/x/wasm/keeper/msg_server.go @@ -23,11 +23,10 @@ func NewMsgServerImpl(k *Keeper) types.MsgServer { } // StoreCode stores a new wasm code on chain -func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*types.MsgStoreCodeResponse, error) { +func (m msgServer) StoreCode(ctx context.Context, msg *types.MsgStoreCode) (*types.MsgStoreCodeResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -47,11 +46,10 @@ func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*t } // InstantiateContract instantiate a new contract with classic sequence based address generation -func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInstantiateContract) (*types.MsgInstantiateContractResponse, error) { +func (m msgServer) InstantiateContract(ctx context.Context, msg *types.MsgInstantiateContract) (*types.MsgInstantiateContractResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -78,11 +76,10 @@ func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInst } // InstantiateContract2 instantiate a new contract with predicatable address generated -func (m msgServer) InstantiateContract2(goCtx context.Context, msg *types.MsgInstantiateContract2) (*types.MsgInstantiateContract2Response, error) { +func (m msgServer) InstantiateContract2(ctx context.Context, msg *types.MsgInstantiateContract2) (*types.MsgInstantiateContract2Response, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -110,12 +107,11 @@ func (m msgServer) InstantiateContract2(goCtx context.Context, msg *types.MsgIns }, nil } -func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteContract) (*types.MsgExecuteContractResponse, error) { +func (m msgServer) ExecuteContract(ctx context.Context, msg *types.MsgExecuteContract) (*types.MsgExecuteContractResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -135,12 +131,11 @@ func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteC }, nil } -func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateContract) (*types.MsgMigrateContractResponse, error) { +func (m msgServer) MigrateContract(ctx context.Context, msg *types.MsgMigrateContract) (*types.MsgMigrateContractResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -162,12 +157,11 @@ func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateC }, nil } -func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) (*types.MsgUpdateAdminResponse, error) { +func (m msgServer) UpdateAdmin(ctx context.Context, msg *types.MsgUpdateAdmin) (*types.MsgUpdateAdminResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -190,12 +184,11 @@ func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) return &types.MsgUpdateAdminResponse{}, nil } -func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) (*types.MsgClearAdminResponse, error) { +func (m msgServer) ClearAdmin(ctx context.Context, msg *types.MsgClearAdmin) (*types.MsgClearAdminResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -214,12 +207,11 @@ func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) ( return &types.MsgClearAdminResponse{}, nil } -func (m msgServer) UpdateInstantiateConfig(goCtx context.Context, msg *types.MsgUpdateInstantiateConfig) (*types.MsgUpdateInstantiateConfigResponse, error) { +func (m msgServer) UpdateInstantiateConfig(ctx context.Context, msg *types.MsgUpdateInstantiateConfig) (*types.MsgUpdateInstantiateConfigResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, errorsmod.Wrap(err, "sender") @@ -234,7 +226,7 @@ func (m msgServer) UpdateInstantiateConfig(goCtx context.Context, msg *types.Msg } // UpdateParams updates the module parameters -func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (m msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if err := req.ValidateBasic(); err != nil { return nil, err } @@ -243,7 +235,6 @@ func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(goCtx) if err := m.keeper.SetParams(ctx, req.Params); err != nil { return nil, err } @@ -252,7 +243,7 @@ func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam } // PinCodes pins a set of code ids in the wasmvm cache. -func (m msgServer) PinCodes(goCtx context.Context, req *types.MsgPinCodes) (*types.MsgPinCodesResponse, error) { +func (m msgServer) PinCodes(ctx context.Context, req *types.MsgPinCodes) (*types.MsgPinCodesResponse, error) { if err := req.ValidateBasic(); err != nil { return nil, err } @@ -262,7 +253,6 @@ func (m msgServer) PinCodes(goCtx context.Context, req *types.MsgPinCodes) (*typ return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(goCtx) for _, codeID := range req.CodeIDs { if err := m.keeper.pinCode(ctx, codeID); err != nil { return nil, err @@ -273,7 +263,7 @@ func (m msgServer) PinCodes(goCtx context.Context, req *types.MsgPinCodes) (*typ } // UnpinCodes unpins a set of code ids in the wasmvm cache. -func (m msgServer) UnpinCodes(goCtx context.Context, req *types.MsgUnpinCodes) (*types.MsgUnpinCodesResponse, error) { +func (m msgServer) UnpinCodes(ctx context.Context, req *types.MsgUnpinCodes) (*types.MsgUnpinCodesResponse, error) { if err := req.ValidateBasic(); err != nil { return nil, err } @@ -283,7 +273,6 @@ func (m msgServer) UnpinCodes(goCtx context.Context, req *types.MsgUnpinCodes) ( return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) } - ctx := sdk.UnwrapSDKContext(goCtx) for _, codeID := range req.CodeIDs { if err := m.keeper.unpinCode(ctx, codeID); err != nil { return nil, err @@ -294,7 +283,7 @@ func (m msgServer) UnpinCodes(goCtx context.Context, req *types.MsgUnpinCodes) ( } // SudoContract calls sudo on a contract. -func (m msgServer) SudoContract(goCtx context.Context, req *types.MsgSudoContract) (*types.MsgSudoContractResponse, error) { +func (m msgServer) SudoContract(ctx context.Context, req *types.MsgSudoContract) (*types.MsgSudoContractResponse, error) { if err := req.ValidateBasic(); err != nil { return nil, err } @@ -308,7 +297,6 @@ func (m msgServer) SudoContract(goCtx context.Context, req *types.MsgSudoContrac return nil, errorsmod.Wrap(err, "contract") } - ctx := sdk.UnwrapSDKContext(goCtx) data, err := m.keeper.Sudo(ctx, contractAddr, req.Msg) if err != nil { return nil, err @@ -429,7 +417,7 @@ func contains[T comparable](src []T, o T) bool { return false } -func (m msgServer) selectAuthorizationPolicy(ctx sdk.Context, actor string) types.AuthorizationPolicy { +func (m msgServer) selectAuthorizationPolicy(ctx context.Context, actor string) types.AuthorizationPolicy { if actor == m.keeper.GetAuthority() { return newGovAuthorizationPolicy(m.keeper.propagateGovAuthorization) } diff --git a/x/wasm/keeper/msg_server_integration_test.go b/x/wasm/keeper/msg_server_integration_test.go index ef7f0a4b0d..da681fd5e9 100644 --- a/x/wasm/keeper/msg_server_integration_test.go +++ b/x/wasm/keeper/msg_server_integration_test.go @@ -28,7 +28,7 @@ var hackatomContract []byte func TestStoreCode(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) _, _, sender := testdata.KeyTestPubAddr() msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { m.WASMByteCode = wasmContract @@ -57,7 +57,7 @@ func TestStoreCode(t *testing.T) { func TestUpdateParams(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -147,7 +147,7 @@ func TestUpdateParams(t *testing.T) { func TestAddCodeUploadParamsAddresses(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -243,7 +243,7 @@ func TestAddCodeUploadParamsAddresses(t *testing.T) { func TestRemoveCodeUploadParamsAddresses(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -339,7 +339,7 @@ func TestRemoveCodeUploadParamsAddresses(t *testing.T) { func TestPinCodes(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -396,7 +396,7 @@ func TestPinCodes(t *testing.T) { func TestUnpinCodes(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + ctx := wasmApp.BaseApp.NewContext(false) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -461,7 +461,7 @@ func TestUnpinCodes(t *testing.T) { func TestSudoContract(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -552,7 +552,7 @@ func TestSudoContract(t *testing.T) { func TestStoreAndInstantiateContract(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -612,7 +612,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { func TestUpdateAdmin(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -677,7 +677,7 @@ func TestUpdateAdmin(t *testing.T) { func TestClearAdmin(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -739,7 +739,7 @@ func TestClearAdmin(t *testing.T) { func TestMigrateContract(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -826,7 +826,7 @@ func TestMigrateContract(t *testing.T) { func TestInstantiateContract(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -898,7 +898,7 @@ func TestInstantiateContract(t *testing.T) { func TestInstantiateContract2(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -977,7 +977,7 @@ func TestInstantiateContract2(t *testing.T) { func TestUpdateInstantiateConfig(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) var ( creator sdk.AccAddress = make([]byte, types.ContractAddrLen) @@ -1051,7 +1051,7 @@ func TestUpdateInstantiateConfig(t *testing.T) { func TestStoreAndMigrateContract(t *testing.T) { wasmApp := app.Setup(t) - ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + ctx := wasmApp.BaseApp.NewContextLegacy(false, tmproto.Header{Time: time.Now()}) checksum, err := wasmvm.CreateChecksum(hackatomContract) require.NoError(t, err) diff --git a/x/wasm/keeper/msg_server_test.go b/x/wasm/keeper/msg_server_test.go index 61d05f65b1..ff34162ccf 100644 --- a/x/wasm/keeper/msg_server_test.go +++ b/x/wasm/keeper/msg_server_test.go @@ -3,11 +3,14 @@ package keeper import ( "testing" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/assert" - "github.com/cosmos/cosmos-sdk/store" + "cosmossdk.io/log" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -22,7 +25,9 @@ func TestSelectAuthorizationPolicy(t *testing.T) { }, authority: myGovAuthority.String(), }} - ctx := sdk.NewContext(store.NewCommitMultiStore(nil), tmproto.Header{}, false, log.NewNopLogger()) + + ms := store.NewCommitMultiStore(dbm.NewMemDB(), log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + ctx := sdk.NewContext(ms, tmproto.Header{}, false, log.NewNopLogger()) specs := map[string]struct { ctx sdk.Context diff --git a/x/wasm/keeper/options.go b/x/wasm/keeper/options.go index 7ccf7d9e52..234197be8d 100644 --- a/x/wasm/keeper/options.go +++ b/x/wasm/keeper/options.go @@ -6,7 +6,7 @@ import ( "github.com/prometheus/client_golang/prometheus" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -162,7 +162,7 @@ func WithMaxQueryStackSize(m uint32) Option { // when they exist for an address on contract instantiation. // // Values should be references and contain the `*authtypes.BaseAccount` as default bank account type. -func WithAcceptedAccountTypesOnContractInstantiation(accts ...authtypes.AccountI) Option { +func WithAcceptedAccountTypesOnContractInstantiation(accts ...sdk.AccountI) Option { m := asTypeMap(accts) return optsFn(func(k *Keeper) { k.acceptedAccountTypes = m @@ -183,7 +183,7 @@ func WitGovSubMsgAuthZPropagated(entries ...types.AuthorizationPolicyAction) Opt }) } -func asTypeMap(accts []authtypes.AccountI) map[reflect.Type]struct{} { +func asTypeMap(accts []sdk.AccountI) map[reflect.Type]struct{} { m := make(map[reflect.Type]struct{}, len(accts)) for _, a := range accts { if a == nil { diff --git a/x/wasm/keeper/options_test.go b/x/wasm/keeper/options_test.go index b26e1af7c2..ff3523a8c1 100644 --- a/x/wasm/keeper/options_test.go +++ b/x/wasm/keeper/options_test.go @@ -9,6 +9,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/runtime" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -20,6 +23,9 @@ import ( ) func TestConstructorOptions(t *testing.T) { + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + codec := MakeEncodingConfig(t).Codec + specs := map[string]struct { srcOpt Option verify func(*testing.T, Keeper) @@ -28,7 +34,6 @@ func TestConstructorOptions(t *testing.T) { "wasm engine": { srcOpt: WithWasmEngine(&wasmtesting.MockWasmEngine{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockWasmEngine{}, k.wasmVM) }, }, @@ -47,7 +52,6 @@ func TestConstructorOptions(t *testing.T) { return &wasmtesting.MockWasmEngine{} }), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockWasmEngine{}, k.wasmVM) }, isPostOpt: true, @@ -55,14 +59,12 @@ func TestConstructorOptions(t *testing.T) { "message handler": { srcOpt: WithMessageHandler(&wasmtesting.MockMessageHandler{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockMessageHandler{}, k.messenger) }, }, "query plugins": { srcOpt: WithQueryHandler(&wasmtesting.MockQueryHandler{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockQueryHandler{}, k.wasmVMQueryHandler) }, }, @@ -72,7 +74,6 @@ func TestConstructorOptions(t *testing.T) { return &wasmtesting.MockMessageHandler{} }), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockMessageHandler{}, k.messenger) }, isPostOpt: true, @@ -83,7 +84,6 @@ func TestConstructorOptions(t *testing.T) { return &wasmtesting.MockQueryHandler{} }), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockQueryHandler{}, k.wasmVMQueryHandler) }, isPostOpt: true, @@ -91,21 +91,18 @@ func TestConstructorOptions(t *testing.T) { "coin transferrer": { srcOpt: WithCoinTransferrer(&wasmtesting.MockCoinTransferrer{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockCoinTransferrer{}, k.bank) }, }, "costs": { srcOpt: WithGasRegister(&wasmtesting.MockGasRegister{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, &wasmtesting.MockGasRegister{}, k.gasRegister) }, }, "api costs": { srcOpt: WithAPICosts(1, 2), verify: func(t *testing.T, k Keeper) { - t.Helper() t.Cleanup(setAPIDefaults) assert.Equal(t, uint64(1), costHumanize) assert.Equal(t, uint64(2), costCanonical) @@ -114,14 +111,12 @@ func TestConstructorOptions(t *testing.T) { "max recursion query limit": { srcOpt: WithMaxQueryStackSize(1), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.IsType(t, uint32(1), k.maxQueryStackSize) }, }, "accepted account types": { srcOpt: WithAcceptedAccountTypesOnContractInstantiation(&authtypes.BaseAccount{}, &vestingtypes.ContinuousVestingAccount{}), verify: func(t *testing.T, k Keeper) { - t.Helper() exp := map[reflect.Type]struct{}{ reflect.TypeOf(&authtypes.BaseAccount{}): {}, reflect.TypeOf(&vestingtypes.ContinuousVestingAccount{}): {}, @@ -132,14 +127,12 @@ func TestConstructorOptions(t *testing.T) { "account pruner": { srcOpt: WithAccountPruner(VestingCoinBurner{}), verify: func(t *testing.T, k Keeper) { - t.Helper() assert.Equal(t, VestingCoinBurner{}, k.accountPruner) }, }, "gov propagation": { srcOpt: WitGovSubMsgAuthZPropagated(types.AuthZActionInstantiate, types.AuthZActionMigrateContract), verify: func(t *testing.T, k Keeper) { - t.Helper() exp := map[types.AuthorizationPolicyAction]struct{}{ types.AuthZActionInstantiate: {}, types.AuthZActionMigrateContract: {}, @@ -153,7 +146,7 @@ func TestConstructorOptions(t *testing.T) { opt := spec.srcOpt _, gotPostOptMarker := opt.(postOptsFn) require.Equal(t, spec.isPostOpt, gotPostOptMarker) - k := NewKeeper(nil, nil, authkeeper.AccountKeeper{}, &bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, nil, nil, "tempDir", types.DefaultWasmConfig(), AvailableCapabilities, "", opt) + k := NewKeeper(codec, runtime.NewKVStoreService(storeKey), authkeeper.AccountKeeper{}, &bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, nil, nil, "tempDir", types.DefaultWasmConfig(), AvailableCapabilities, "", spec.srcOpt) spec.verify(t, k) }) } diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 4ecee9c9a9..3e43e7ed62 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -12,6 +12,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -98,7 +100,7 @@ func mustSubmitAndExecuteLegacyProposal(t *testing.T, ctx sdk.Context, content v contentMsg, err := submitLegacyProposal(t, ctx.WithEventManager(sdk.NewEventManager()), content, myActorAddress, govAuthority, msgServer) require.NoError(t, err) - _, err = msgServer.ExecLegacyContent(sdk.WrapSDKContext(ctx), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) + _, err = msgServer.ExecLegacyContent(ctx, v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) require.NoError(t, err) } @@ -115,11 +117,12 @@ func submitLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content "", "my title", "my description", + false, ) require.NoError(t, err) // when stored - _, err = msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), proposal) + _, err = msgServer.SubmitProposal(ctx, proposal) return contentMsg, err } @@ -294,7 +297,7 @@ func TestInstantiateProposal_NoAdmin(t *testing.T) { require.NoError(t, gotErr) // and when em := sdk.NewEventManager() - _, err = msgServer.ExecLegacyContent(sdk.WrapSDKContext(ctx.WithEventManager(em)), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) + _, err = msgServer.ExecLegacyContent(ctx.WithEventManager(em), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) // then require.NoError(t, err) contractAddr, err := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr") @@ -475,7 +478,7 @@ func TestExecuteProposal(t *testing.T) { // check balance bal := bankKeeper.GetBalance(ctx, contractAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(100)) + require.Equal(t, bal.Amount, sdkmath.NewInt(100)) releaseMsg := struct { Release struct{} `json:"release"` @@ -500,7 +503,7 @@ func TestExecuteProposal(t *testing.T) { // balance should not change bal = bankKeeper.GetBalance(ctx, contractAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(100)) + require.Equal(t, bal.Amount, sdkmath.NewInt(100)) // try again with the proper run-as src := &types.ExecuteContractProposal{ //nolint:staticcheck // testing deprecated function @@ -518,7 +521,7 @@ func TestExecuteProposal(t *testing.T) { // balance should be empty (proper release) bal = bankKeeper.GetBalance(ctx, contractAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(0)) + require.Equal(t, bal.Amount, sdkmath.NewInt(0)) } func TestSudoProposal(t *testing.T) { @@ -532,9 +535,9 @@ func TestSudoProposal(t *testing.T) { // check balance bal := bankKeeper.GetBalance(ctx, contractAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(100)) + require.Equal(t, bal.Amount, sdkmath.NewInt(100)) bal = bankKeeper.GetBalance(ctx, anyAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(0)) + require.Equal(t, bal.Amount, sdkmath.NewInt(0)) type StealMsg struct { Recipient string `json:"recipient"` @@ -564,9 +567,9 @@ func TestSudoProposal(t *testing.T) { // balance should be empty (and verifier richer) bal = bankKeeper.GetBalance(ctx, contractAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(25)) + require.Equal(t, bal.Amount, sdkmath.NewInt(25)) bal = bankKeeper.GetBalance(ctx, anyAddr, "denom") - require.Equal(t, bal.Amount, sdk.NewInt(75)) + require.Equal(t, bal.Amount, sdkmath.NewInt(75)) } func TestAdminProposals(t *testing.T) { @@ -740,7 +743,7 @@ func TestPinCodesProposal(t *testing.T) { require.NoError(t, gotErr) // and proposal execute - _, err := msgServer.ExecLegacyContent(sdk.WrapSDKContext(ctx), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) + _, err := msgServer.ExecLegacyContent(ctx, v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) require.NoError(t, err) // then @@ -831,7 +834,7 @@ func TestUnpinCodesProposal(t *testing.T) { require.NoError(t, gotErr) // and proposal execute - _, err := msgServer.ExecLegacyContent(sdk.WrapSDKContext(ctx), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) + _, err := msgServer.ExecLegacyContent(ctx, v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) require.NoError(t, err) // then @@ -927,7 +930,7 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { require.NoError(t, gotErr) // and proposal execute - _, err := msgServer.ExecLegacyContent(sdk.WrapSDKContext(ctx), v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) + _, err := msgServer.ExecLegacyContent(ctx, v1.NewMsgExecLegacyContent(contentMsg.Content, govAuthority)) require.NoError(t, err) // then diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index 3cc80d2d6e..e5bd3575ae 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -8,11 +8,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + corestoretypes "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -24,14 +26,14 @@ var _ types.QueryServer = &GrpcQuerier{} type GrpcQuerier struct { cdc codec.Codec - storeKey storetypes.StoreKey + storeService corestoretypes.KVStoreService keeper types.ViewKeeper - queryGasLimit sdk.Gas + queryGasLimit storetypes.Gas } // NewGrpcQuerier constructor -func NewGrpcQuerier(cdc codec.Codec, storeKey storetypes.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *GrpcQuerier { - return &GrpcQuerier{cdc: cdc, storeKey: storeKey, keeper: keeper, queryGasLimit: queryGasLimit} +func NewGrpcQuerier(cdc codec.Codec, storeService corestoretypes.KVStoreService, keeper types.ViewKeeper, queryGasLimit storetypes.Gas) *GrpcQuerier { + return &GrpcQuerier{cdc: cdc, storeService: storeService, keeper: keeper, queryGasLimit: queryGasLimit} } func (q GrpcQuerier) ContractInfo(c context.Context, req *types.QueryContractInfoRequest) (*types.QueryContractInfoResponse, error) { @@ -68,7 +70,8 @@ func (q GrpcQuerier) ContractHistory(c context.Context, req *types.QueryContract ctx := sdk.UnwrapSDKContext(c) r := make([]types.ContractCodeHistoryEntry, 0) - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.GetContractCodeHistoryElementPrefix(contractAddr)) + + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.GetContractCodeHistoryElementPrefix(contractAddr)) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, value []byte, accumulate bool) (bool, error) { if accumulate { var e types.ContractCodeHistoryEntry @@ -103,7 +106,8 @@ func (q GrpcQuerier) ContractsByCode(c context.Context, req *types.QueryContract ctx := sdk.UnwrapSDKContext(c) r := make([]string, 0) - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.GetContractByCodeIDSecondaryIndexPrefix(req.CodeId)) + + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.GetContractByCodeIDSecondaryIndexPrefix(req.CodeId)) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, value []byte, accumulate bool) (bool, error) { if accumulate { var contractAddr sdk.AccAddress = key[types.AbsoluteTxPositionLen:] @@ -141,7 +145,7 @@ func (q GrpcQuerier) AllContractState(c context.Context, req *types.QueryAllCont } r := make([]types.Model, 0) - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.GetContractStorePrefix(contractAddr)) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.GetContractStorePrefix(contractAddr)) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, value []byte, accumulate bool) (bool, error) { if accumulate { r = append(r, types.Model{ @@ -190,12 +194,12 @@ func (q GrpcQuerier) SmartContractState(c context.Context, req *types.QuerySmart if err != nil { return nil, err } - ctx := sdk.UnwrapSDKContext(c).WithGasMeter(sdk.NewGasMeter(q.queryGasLimit)) + ctx := sdk.UnwrapSDKContext(c).WithGasMeter(storetypes.NewGasMeter(q.queryGasLimit)) // recover from out-of-gas panic defer func() { if r := recover(); r != nil { switch rType := r.(type) { - case sdk.ErrorOutOfGas: + case storetypes.ErrorOutOfGas: err = errorsmod.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v; gasWanted: %d, gasUsed: %d", rType.Descriptor, ctx.GasMeter().Limit(), ctx.GasMeter().GasConsumed(), @@ -254,7 +258,7 @@ func (q GrpcQuerier) Codes(c context.Context, req *types.QueryCodesRequest) (*ty ctx := sdk.UnwrapSDKContext(c) r := make([]types.CodeInfoResponse, 0) - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.CodeKeyPrefix) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.CodeKeyPrefix) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, value []byte, accumulate bool) (bool, error) { if accumulate { var c types.CodeInfo @@ -323,7 +327,8 @@ func (q GrpcQuerier) PinnedCodes(c context.Context, req *types.QueryPinnedCodesR ctx := sdk.UnwrapSDKContext(c) r := make([]uint64, 0) - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.PinnedCodeIndexPrefix) + + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.PinnedCodeIndexPrefix) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, _ []byte, accumulate bool) (bool, error) { if accumulate { r = append(r, sdk.BigEndianToUint64(key)) @@ -362,7 +367,7 @@ func (q GrpcQuerier) ContractsByCreator(c context.Context, req *types.QueryContr if err != nil { return nil, err } - prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.GetContractsByCreatorPrefix(creatorAddress)) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), types.GetContractsByCreatorPrefix(creatorAddress)) pageRes, err := query.FilteredPaginate(prefixStore, paginationParams, func(key, _ []byte, accumulate bool) (bool, error) { if accumulate { accAddres := sdk.AccAddress(key[types.AbsoluteTxPositionLen:]) diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index 8de6b6aabf..e196c537f9 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -11,13 +11,14 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cometbft/cometbft/libs/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -106,7 +107,7 @@ func TestQueryAllContractState(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, err := q.AllContractState(sdk.WrapSDKContext(ctx), spec.srcQuery) + got, err := q.AllContractState(ctx, spec.srcQuery) if spec.expErr != nil { require.Equal(t, spec.expErr.Error(), err.Error()) @@ -158,7 +159,7 @@ func TestQuerySmartContractState(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, err := q.SmartContractState(sdk.WrapSDKContext(ctx), spec.srcQuery) + got, err := q.SmartContractState(ctx, spec.srcQuery) require.True(t, errors.Is(err, spec.expErr), "but got %+v", err) if spec.expErr != nil { return @@ -171,12 +172,12 @@ func TestQuerySmartContractState(t *testing.T) { func TestQuerySmartContractPanics(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) contractAddr := BuildContractAddressClassic(1, 1) - keepers.WasmKeeper.storeCodeInfo(ctx, 1, types.CodeInfo{}) - keepers.WasmKeeper.storeContractInfo(ctx, contractAddr, &types.ContractInfo{ + keepers.WasmKeeper.mustStoreCodeInfo(ctx, 1, types.CodeInfo{}) + keepers.WasmKeeper.mustStoreContractInfo(ctx, contractAddr, &types.ContractInfo{ CodeID: 1, Created: types.NewAbsoluteTxPosition(ctx), }) - ctx = ctx.WithGasMeter(sdk.NewGasMeter(types.DefaultInstanceCost)).WithLogger(log.TestingLogger()) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(types.DefaultInstanceCost)).WithLogger(log.NewTestLogger(t)) specs := map[string]struct { doInContract func() @@ -203,7 +204,7 @@ func TestQuerySmartContractPanics(t *testing.T) { }} // when q := Querier(keepers.WasmKeeper) - got, err := q.SmartContractState(sdk.WrapSDKContext(ctx), &types.QuerySmartContractStateRequest{ + got, err := q.SmartContractState(ctx, &types.QuerySmartContractStateRequest{ Address: contractAddr.String(), QueryData: types.RawContractMessage("{}"), }) @@ -260,7 +261,7 @@ func TestQueryRawContractState(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, err := q.RawContractState(sdk.WrapSDKContext(ctx), spec.srcQuery) + got, err := q.RawContractState(ctx, spec.srcQuery) if spec.expErr != nil { assert.Equal(t, spec.expErr.Error(), err.Error()) return @@ -297,7 +298,7 @@ func TestQueryContractsByCode(t *testing.T) { var h int64 = 10 setBlock := func(ctx sdk.Context, height int64) sdk.Context { ctx = ctx.WithBlockHeight(height) - meter := sdk.NewGasMeter(1000000) + meter := storetypes.NewGasMeter(1000000) ctx = ctx.WithGasMeter(meter) ctx = ctx.WithBlockGasMeter(meter) return ctx @@ -380,7 +381,7 @@ func TestQueryContractsByCode(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, err := q.ContractsByCode(sdk.WrapSDKContext(ctx), spec.req) + got, err := q.ContractsByCode(ctx, spec.req) if spec.expErr != nil { assert.NotNil(t, err) @@ -519,11 +520,12 @@ func TestQueryContractHistory(t *testing.T) { xCtx, _ := ctx.CacheContext() cAddr, _ := sdk.AccAddressFromBech32(myContractBech32Addr) - keeper.appendToContractHistory(xCtx, cAddr, spec.srcHistory...) + require.NoError(t, keeper.appendToContractHistory(xCtx, cAddr, spec.srcHistory...)) // when q := Querier(keeper) - got, gotErr := q.ContractHistory(sdk.WrapSDKContext(xCtx), &spec.req) //nolint:gosec + got, gotErr := q.ContractHistory(xCtx, &spec.req) //nolint:gosec + // then if spec.expErr != nil { require.Error(t, gotErr) @@ -599,7 +601,7 @@ func TestQueryCodeList(t *testing.T) { } // when q := Querier(keeper) - got, gotErr := q.Codes(sdk.WrapSDKContext(xCtx), &spec.req) //nolint:gosec + got, gotErr := q.Codes(xCtx, &spec.req) //nolint:gosec // then if spec.expErr != nil { @@ -631,7 +633,7 @@ func TestQueryContractInfo(t *testing.T) { govv1beta1.RegisterInterfaces(keepers.EncodingConfig.InterfaceRegistry) k := keepers.WasmKeeper - querier := NewGrpcQuerier(k.cdc, k.storeKey, k, k.queryGasLimit) + querier := NewGrpcQuerier(k.cdc, k.storeService, k, k.queryGasLimit) myExtension := func(info *types.ContractInfo) { // abuse gov proposal as a random protobuf extension with an Any type myExt, err := govv1beta1.NewProposal(&govv1beta1.TextProposal{Title: "foo", Description: "bar"}, 1, anyDate, anyDate) @@ -671,9 +673,9 @@ func TestQueryContractInfo(t *testing.T) { for name, spec := range specs { t.Run(name, func(t *testing.T) { xCtx, _ := ctx.CacheContext() - k.storeContractInfo(xCtx, contractAddr, &spec.stored) //nolint:gosec + k.mustStoreContractInfo(xCtx, contractAddr, &spec.stored) //nolint:gosec // when - gotRsp, gotErr := querier.ContractInfo(sdk.WrapSDKContext(xCtx), spec.src) + gotRsp, gotErr := querier.ContractInfo(xCtx, spec.src) if spec.expErr { require.Error(t, gotErr) return @@ -730,7 +732,7 @@ func TestQueryPinnedCodes(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, gotErr := q.PinnedCodes(sdk.WrapSDKContext(ctx), spec.srcQuery) + got, gotErr := q.PinnedCodes(ctx, spec.srcQuery) if spec.expErr != nil { require.Error(t, gotErr) assert.ErrorIs(t, gotErr, spec.expErr) @@ -749,7 +751,7 @@ func TestQueryParams(t *testing.T) { q := Querier(keeper) - paramsResponse, err := q.Params(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + paramsResponse, err := q.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.NotNil(t, paramsResponse) @@ -764,7 +766,7 @@ func TestQueryParams(t *testing.T) { }) require.NoError(t, err) - paramsResponse, err = q.Params(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + paramsResponse, err = q.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.NotNil(t, paramsResponse) @@ -808,7 +810,7 @@ func TestQueryCodeInfo(t *testing.T) { ) q := Querier(keeper) - got, err := q.Code(sdk.WrapSDKContext(ctx), &types.QueryCodeRequest{ + got, err := q.Code(ctx, &types.QueryCodeRequest{ CodeId: spec.codeID, }) require.NoError(t, err) @@ -881,7 +883,7 @@ func TestQueryCodeInfoList(t *testing.T) { }) } q := Querier(keeper) - got, err := q.Codes(sdk.WrapSDKContext(ctx), &types.QueryCodesRequest{ + got, err := q.Codes(ctx, &types.QueryCodesRequest{ Pagination: &query.PageRequest{ Limit: 3, }, @@ -917,7 +919,7 @@ func TestQueryContractsByCreatorList(t *testing.T) { var h int64 = 10 setBlock := func(ctx sdk.Context, height int64) sdk.Context { ctx = ctx.WithBlockHeight(height) - meter := sdk.NewGasMeter(1000000) + meter := storetypes.NewGasMeter(1000000) ctx = ctx.WithGasMeter(meter) ctx = ctx.WithBlockGasMeter(meter) return ctx @@ -981,7 +983,7 @@ func TestQueryContractsByCreatorList(t *testing.T) { q := Querier(keepers.WasmKeeper) for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got, gotErr := q.ContractsByCreator(sdk.WrapSDKContext(ctx), spec.srcQuery) + got, gotErr := q.ContractsByCreator(ctx, spec.srcQuery) if spec.expErr != nil { require.Error(t, gotErr) assert.ErrorContains(t, gotErr, spec.expErr.Error()) diff --git a/x/wasm/keeper/query_plugin_integration_test.go b/x/wasm/keeper/query_plugin_integration_test.go index 83dea003b0..b6316d8d45 100644 --- a/x/wasm/keeper/query_plugin_integration_test.go +++ b/x/wasm/keeper/query_plugin_integration_test.go @@ -9,11 +9,12 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cosmos/gogoproto/proto" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -528,9 +529,9 @@ func TestDistributionQuery(t *testing.T) { }, "delegation rewards - existing delegation": { setup: func(t *testing.T, ctx sdk.Context) sdk.Context { - val1, ok := keepers.StakingKeeper.GetValidator(ctx, val1Addr) - require.True(t, ok) - _, err := keepers.StakingKeeper.Delegate(ctx, delegator, sdk.NewInt(10_000_000), stakingtypes.Unbonded, val1, true) + val1, err := keepers.StakingKeeper.GetValidator(ctx, val1Addr) + require.NoError(t, err) + _, err = keepers.StakingKeeper.Delegate(ctx, delegator, sdkmath.NewInt(10_000_000), stakingtypes.Unbonded, val1, true) require.NoError(t, err) setValidatorRewards(ctx, keepers.StakingKeeper, keepers.DistKeeper, val1Addr, "100000000") return nextBlock(ctx, keepers.StakingKeeper) @@ -557,9 +558,9 @@ func TestDistributionQuery(t *testing.T) { }, "delegation rewards - validator empty": { setup: func(t *testing.T, ctx sdk.Context) sdk.Context { - val, found := keepers.StakingKeeper.GetValidator(ctx, val1Addr) - require.True(t, found) - _, err := keepers.StakingKeeper.Delegate(ctx, delegator, sdk.NewInt(10_000_000), stakingtypes.Unbonded, val, true) + val, err := keepers.StakingKeeper.GetValidator(ctx, val1Addr) + require.NoError(t, err) + _, err = keepers.StakingKeeper.Delegate(ctx, delegator, sdkmath.NewInt(10_000_000), stakingtypes.Unbonded, val, true) require.NoError(t, err) return ctx }, @@ -570,9 +571,9 @@ func TestDistributionQuery(t *testing.T) { }, "delegation total rewards": { setup: func(t *testing.T, ctx sdk.Context) sdk.Context { - val, found := keepers.StakingKeeper.GetValidator(ctx, val1Addr) - require.True(t, found) - _, err := keepers.StakingKeeper.Delegate(ctx, delegator, sdk.NewInt(10_000_000), stakingtypes.Unbonded, val, true) + val, err := keepers.StakingKeeper.GetValidator(ctx, val1Addr) + require.NoError(t, err) + _, err = keepers.StakingKeeper.Delegate(ctx, delegator, sdkmath.NewInt(10_000_000), stakingtypes.Unbonded, val, true) require.NoError(t, err) setValidatorRewards(ctx, keepers.StakingKeeper, keepers.DistKeeper, val1Addr, "100000000") return nextBlock(ctx, keepers.StakingKeeper) @@ -597,9 +598,9 @@ func TestDistributionQuery(t *testing.T) { "delegator validators": { setup: func(t *testing.T, ctx sdk.Context) sdk.Context { for _, v := range []sdk.ValAddress{val1Addr, val2Addr} { - val, found := keepers.StakingKeeper.GetValidator(ctx, v) - require.True(t, found) - _, err := keepers.StakingKeeper.Delegate(ctx, delegator, sdk.NewInt(10_000_000), stakingtypes.Unbonded, val, true) + val, err := keepers.StakingKeeper.GetValidator(ctx, v) + require.NoError(t, err) + _, err = keepers.StakingKeeper.Delegate(ctx, delegator, sdkmath.NewInt(10_000_000), stakingtypes.Unbonded, val, true) require.NoError(t, err) } return ctx @@ -653,7 +654,7 @@ func TestIBCListChannelsQuery(t *testing.T) { myIBCPortID := "myValidPortID" cInfo := keeper.GetContractInfo(pCtx, ibcExample.Contract) cInfo.IBCPortID = myIBCPortID - keeper.storeContractInfo(pCtx, ibcExample.Contract, cInfo) + keeper.mustStoreContractInfo(pCtx, ibcExample.Contract, cInfo) // store a random channel to be ignored in queries unusedChan := channeltypes.Channel{ State: channeltypes.OPEN, diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index b89afdc4c3..6e2cfa09b8 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -1,15 +1,18 @@ package keeper import ( + "context" "encoding/json" "errors" "fmt" wasmvmtypes "github.com/CosmWasm/wasmvm/types" abci "github.com/cometbft/cometbft/abci/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/cosmos/gogoproto/proto" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -17,7 +20,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -51,7 +54,7 @@ func (q QueryHandler) Query(request wasmvmtypes.QueryRequest, gasLimit uint64) ( // set a limit for a subCtx sdkGas := q.gasRegister.FromWasmVMGas(gasLimit) // discard all changes/ events in subCtx by not committing the cached context - subCtx, _ := q.Ctx.WithGasMeter(sdk.NewGasMeter(sdkGas)).CacheContext() + subCtx, _ := q.Ctx.WithGasMeter(storetypes.NewGasMeter(sdkGas)).CacheContext() // make sure we charge the higher level context even on panic defer func() { @@ -92,15 +95,15 @@ type QueryPlugins struct { } type contractMetaDataSource interface { - GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo + GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo } type wasmQueryKeeper interface { contractMetaDataSource - GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo - QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) - IsPinnedCode(ctx sdk.Context, codeID uint64) bool + GetCodeInfo(ctx context.Context, codeID uint64) *types.CodeInfo + QueryRaw(ctx context.Context, contractAddress sdk.AccAddress, key []byte) []byte + QuerySmart(ctx context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + IsPinnedCode(ctx context.Context, codeID uint64) bool } func DefaultQueryPlugins( @@ -324,7 +327,7 @@ func RejectStargateQuerier() func(ctx sdk.Context, request *wasmvmtypes.Stargate // AcceptedStargateQueries define accepted Stargate queries as a map with path as key and response type as value. // For example: // acceptList["/cosmos.auth.v1beta1.Query/Account"]= &authtypes.QueryAccountResponse{} -type AcceptedStargateQueries map[string]codec.ProtoMarshaler +type AcceptedStargateQueries map[string]proto.Message // AcceptListStargateQuerier supports a preconfigured set of stargate queries only. // All arguments must be non nil. @@ -346,7 +349,7 @@ func AcceptListStargateQuerier(acceptList AcceptedStargateQueries, queryRouter G return nil, wasmvmtypes.UnsupportedRequest{Kind: fmt.Sprintf("No route to query '%s'", request.Path)} } - res, err := route(ctx, abci.RequestQuery{ + res, err := route(ctx, &abci.RequestQuery{ Data: request.Data, Path: request.Path, }) @@ -361,14 +364,20 @@ func AcceptListStargateQuerier(acceptList AcceptedStargateQueries, queryRouter G func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKeeper) func(ctx sdk.Context, request *wasmvmtypes.StakingQuery) ([]byte, error) { return func(ctx sdk.Context, request *wasmvmtypes.StakingQuery) ([]byte, error) { if request.BondedDenom != nil { - denom := keeper.BondDenom(ctx) + denom, err := keeper.BondDenom(ctx) + if err != nil { + return nil, errorsmod.Wrap(err, "bond denom") + } res := wasmvmtypes.BondedDenomResponse{ Denom: denom, } return json.Marshal(res) } if request.AllValidators != nil { - validators := keeper.GetBondedValidatorsByPower(ctx) + validators, err := keeper.GetBondedValidatorsByPower(ctx) + if err != nil { + return nil, err + } // validators := keeper.GetAllValidators(ctx) wasmVals := make([]wasmvmtypes.Validator, len(validators)) for i, v := range validators { @@ -389,9 +398,14 @@ func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKee if err != nil { return nil, err } - v, found := keeper.GetValidator(ctx, valAddr) + res := wasmvmtypes.ValidatorResponse{} - if found { + v, err := keeper.GetValidator(ctx, valAddr) + switch { + case stakingtypes.ErrNoValidatorFound.Is(err): // return empty result for backwards compatibility. Changed in SDK 50 + case err != nil: + return nil, err + default: res.Validator = &wasmvmtypes.Validator{ Address: v.OperatorAddress, Commission: v.Commission.Rate.String(), @@ -406,7 +420,10 @@ func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKee if err != nil { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, request.AllDelegations.Delegator) } - sdkDels := keeper.GetAllDelegatorDelegations(ctx, delegator) + sdkDels, err := keeper.GetAllDelegatorDelegations(ctx, delegator) + if err != nil { + return nil, err + } delegations, err := sdkToDelegations(ctx, keeper, sdkDels) if err != nil { return nil, err @@ -427,8 +444,12 @@ func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKee } var res wasmvmtypes.DelegationResponse - d, found := keeper.GetDelegation(ctx, delegator, validator) - if found { + d, err := keeper.GetDelegation(ctx, delegator, validator) + switch { + case stakingtypes.ErrNoDelegation.Is(err): // return empty result for backwards compatibility. Changed in SDK 50 + case err != nil: + return nil, err + default: res.Delegation, err = sdkToFullDelegation(ctx, keeper, distKeeper, d) if err != nil { return nil, err @@ -442,7 +463,10 @@ func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKee func sdkToDelegations(ctx sdk.Context, keeper types.StakingKeeper, delegations []stakingtypes.Delegation) (wasmvmtypes.Delegations, error) { result := make([]wasmvmtypes.Delegation, len(delegations)) - bondDenom := keeper.BondDenom(ctx) + bondDenom, err := keeper.BondDenom(ctx) + if err != nil { + return nil, errorsmod.Wrap(err, "bond denom") + } for i, d := range delegations { delAddr, err := sdk.AccAddressFromBech32(d.DelegatorAddress) @@ -456,9 +480,9 @@ func sdkToDelegations(ctx sdk.Context, keeper types.StakingKeeper, delegations [ // shares to amount logic comes from here: // https://github.com/cosmos/cosmos-sdk/blob/v0.38.3/x/staking/keeper/querier.go#L404 - val, found := keeper.GetValidator(ctx, valAddr) - if !found { - return nil, errorsmod.Wrap(stakingtypes.ErrNoValidatorFound, "can't load validator for delegation") + val, err := keeper.GetValidator(ctx, valAddr) + if err != nil { // is stakingtypes.ErrNoValidatorFound + return nil, errorsmod.Wrap(err, "can't load validator for delegation") } amount := sdk.NewCoin(bondDenom, val.TokensFromShares(d.Shares).TruncateInt()) @@ -480,11 +504,15 @@ func sdkToFullDelegation(ctx sdk.Context, keeper types.StakingKeeper, distKeeper if err != nil { return nil, errorsmod.Wrap(err, "validator address") } - val, found := keeper.GetValidator(ctx, valAddr) - if !found { - return nil, errorsmod.Wrap(stakingtypes.ErrNoValidatorFound, "can't load validator for delegation") + val, err := keeper.GetValidator(ctx, valAddr) + if err != nil { // is stakingtypes.ErrNoValidatorFound + return nil, errorsmod.Wrap(err, "can't load validator for delegation") + } + bondDenom, err := keeper.BondDenom(ctx) + if err != nil { + return nil, errorsmod.Wrap(err, "bond denom") } - bondDenom := keeper.BondDenom(ctx) + amount := sdk.NewCoin(bondDenom, val.TokensFromShares(delegation.Shares).TruncateInt()) delegationCoins := ConvertSdkCoinToWasmCoin(amount) @@ -495,7 +523,11 @@ func sdkToFullDelegation(ctx sdk.Context, keeper types.StakingKeeper, distKeeper // otherwise, it can redelegate the full amount // (there are cases of partial funds redelegated, but this is a start) redelegateCoins := wasmvmtypes.NewCoin(0, bondDenom) - if !keeper.HasReceivingRedelegation(ctx, delAddr, valAddr) { + found, err := keeper.HasReceivingRedelegation(ctx, delAddr, valAddr) + if err != nil { + return nil, err + } + if !found { redelegateCoins = delegationCoins } @@ -521,12 +553,12 @@ func sdkToFullDelegation(ctx sdk.Context, keeper types.StakingKeeper, distKeeper // https://github.com/cosmos/cosmos-sdk/issues/7466 is merged func getAccumulatedRewards(ctx sdk.Context, distKeeper types.DistributionKeeper, delegation stakingtypes.Delegation) ([]wasmvmtypes.Coin, error) { // Try to get *delegator* reward info! - params := distrtypes.QueryDelegationRewardsRequest{ + params := distributiontypes.QueryDelegationRewardsRequest{ DelegatorAddress: delegation.DelegatorAddress, ValidatorAddress: delegation.ValidatorAddress, } cache, _ := ctx.CacheContext() - qres, err := distKeeper.DelegationRewards(sdk.WrapSDKContext(cache), ¶ms) + qres, err := distKeeper.DelegationRewards(cache, ¶ms) if err != nil { return nil, err } @@ -605,7 +637,7 @@ func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, reque return func(ctx sdk.Context, req *wasmvmtypes.DistributionQuery) ([]byte, error) { switch { case req.DelegatorWithdrawAddress != nil: - got, err := k.DelegatorWithdrawAddress(ctx, &distrtypes.QueryDelegatorWithdrawAddressRequest{DelegatorAddress: req.DelegatorWithdrawAddress.DelegatorAddress}) + got, err := k.DelegatorWithdrawAddress(ctx, &distributiontypes.QueryDelegatorWithdrawAddressRequest{DelegatorAddress: req.DelegatorWithdrawAddress.DelegatorAddress}) if err != nil { return nil, err } @@ -613,7 +645,7 @@ func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, reque WithdrawAddress: got.WithdrawAddress, }) case req.DelegationRewards != nil: - got, err := k.DelegationRewards(ctx, &distrtypes.QueryDelegationRewardsRequest{ + got, err := k.DelegationRewards(ctx, &distributiontypes.QueryDelegationRewardsRequest{ DelegatorAddress: req.DelegationRewards.DelegatorAddress, ValidatorAddress: req.DelegationRewards.ValidatorAddress, }) @@ -624,7 +656,7 @@ func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, reque Rewards: ConvertSDKDecCoinsToWasmDecCoins(got.Rewards), }) case req.DelegationTotalRewards != nil: - got, err := k.DelegationTotalRewards(ctx, &distrtypes.QueryDelegationTotalRewardsRequest{ + got, err := k.DelegationTotalRewards(ctx, &distributiontypes.QueryDelegationTotalRewardsRequest{ DelegatorAddress: req.DelegationTotalRewards.DelegatorAddress, }) if err != nil { @@ -635,7 +667,7 @@ func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, reque Total: ConvertSDKDecCoinsToWasmDecCoins(got.Total), }) case req.DelegatorValidators != nil: - got, err := k.DelegatorValidators(ctx, &distrtypes.QueryDelegatorValidatorsRequest{ + got, err := k.DelegatorValidators(ctx, &distributiontypes.QueryDelegatorValidatorsRequest{ DelegatorAddress: req.DelegatorValidators.DelegatorAddress, }) if err != nil { @@ -650,7 +682,7 @@ func DistributionQuerier(k types.DistributionKeeper) func(ctx sdk.Context, reque } // ConvertSDKDelegatorRewardsToWasmRewards convert sdk to wasmvm type -func ConvertSDKDelegatorRewardsToWasmRewards(rewards []distrtypes.DelegationDelegatorReward) []wasmvmtypes.DelegatorReward { +func ConvertSDKDelegatorRewardsToWasmRewards(rewards []distributiontypes.DelegationDelegatorReward) []wasmvmtypes.DelegatorReward { r := make([]wasmvmtypes.DelegatorReward, len(rewards)) for i, v := range rewards { r[i] = wasmvmtypes.DelegatorReward{ @@ -738,7 +770,7 @@ func ConvertSdkDenomUnitsToWasmDenomUnits(denomUnits []*banktypes.DenomUnit) []w // ConvertProtoToJSONMarshal unmarshals the given bytes into a proto message and then marshals it to json. // This is done so that clients calling stargate queries do not need to define their own proto unmarshalers, // being able to use response directly by json marshaling, which is supported in cosmwasm. -func ConvertProtoToJSONMarshal(cdc codec.Codec, protoResponse codec.ProtoMarshaler, bz []byte) ([]byte, error) { +func ConvertProtoToJSONMarshal(cdc codec.Codec, protoResponse proto.Message, bz []byte) ([]byte, error) { // unmarshal binary into stargate response data structure err := cdc.Unmarshal(bz, protoResponse) if err != nil { diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index 78666f3cd3..57b0ddaef8 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -10,24 +10,23 @@ import ( "time" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" - "github.com/cometbft/cometbft/libs/rand" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -52,7 +51,7 @@ func TestIBCQuerier(t *testing.T) { PortID: &wasmvmtypes.PortIDQuery{}, }, wasmKeeper: &mockWasmQueryKeeper{ - GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { return &types.ContractInfo{IBCPortID: "myIBCPortID"} }, }, @@ -103,7 +102,7 @@ func TestIBCQuerier(t *testing.T) { }, }, wasmKeeper: &mockWasmQueryKeeper{ - GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { return &types.ContractInfo{IBCPortID: "myLoadedPortID"} }, }, @@ -211,8 +210,8 @@ func TestIBCQuerier(t *testing.T) { } func TestBankQuerierBalance(t *testing.T) { - mock := bankKeeperMock{GetBalanceFn: func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - return sdk.NewCoin(denom, sdk.NewInt(1)) + mock := bankKeeperMock{GetBalanceFn: func(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin { + return sdk.NewCoin(denom, sdkmath.NewInt(1)) }} ctx := sdk.Context{} @@ -247,7 +246,7 @@ func TestBankQuerierMetadata(t *testing.T) { }, } - mock := bankKeeperMock{GetDenomMetadataFn: func(ctx sdk.Context, denom string) (banktypes.Metadata, bool) { + mock := bankKeeperMock{GetDenomMetadataFn: func(ctx context.Context, denom string) (banktypes.Metadata, bool) { if denom == "utest" { return metadata, true } else { @@ -379,13 +378,13 @@ func TestContractInfoWasmQuerier(t *testing.T) { ContractInfo: &wasmvmtypes.ContractInfoQuery{ContractAddr: myValidContractAddr}, }, mock: mockWasmQueryKeeper{ - GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { val := types.ContractInfoFixture(func(i *types.ContractInfo) { i.Admin, i.Creator, i.IBCPortID = myAdminAddr, myCreatorAddr, "myIBCPort" }) return &val }, - IsPinnedCodeFn: func(ctx sdk.Context, codeID uint64) bool { return true }, + IsPinnedCodeFn: func(ctx context.Context, codeID uint64) bool { return true }, }, expRes: wasmvmtypes.ContractInfoResponse{ CodeID: 1, @@ -405,7 +404,7 @@ func TestContractInfoWasmQuerier(t *testing.T) { req: &wasmvmtypes.WasmQuery{ ContractInfo: &wasmvmtypes.ContractInfoQuery{ContractAddr: myValidContractAddr}, }, - mock: mockWasmQueryKeeper{GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + mock: mockWasmQueryKeeper{GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { return nil }}, expErr: true, @@ -415,13 +414,13 @@ func TestContractInfoWasmQuerier(t *testing.T) { ContractInfo: &wasmvmtypes.ContractInfoQuery{ContractAddr: myValidContractAddr}, }, mock: mockWasmQueryKeeper{ - GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { val := types.ContractInfoFixture(func(i *types.ContractInfo) { i.Admin, i.Creator = myAdminAddr, myCreatorAddr }) return &val }, - IsPinnedCodeFn: func(ctx sdk.Context, codeID uint64) bool { return false }, + IsPinnedCodeFn: func(ctx context.Context, codeID uint64) bool { return false }, }, expRes: wasmvmtypes.ContractInfoResponse{ CodeID: 1, @@ -435,13 +434,13 @@ func TestContractInfoWasmQuerier(t *testing.T) { ContractInfo: &wasmvmtypes.ContractInfoQuery{ContractAddr: myValidContractAddr}, }, mock: mockWasmQueryKeeper{ - GetContractInfoFn: func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { + GetContractInfoFn: func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { val := types.ContractInfoFixture(func(i *types.ContractInfo) { i.Creator = myCreatorAddr }) return &val }, - IsPinnedCodeFn: func(ctx sdk.Context, codeID uint64) bool { return true }, + IsPinnedCodeFn: func(ctx context.Context, codeID uint64) bool { return true }, }, expRes: wasmvmtypes.ContractInfoResponse{ CodeID: 1, @@ -482,7 +481,7 @@ func TestCodeInfoWasmQuerier(t *testing.T) { CodeInfo: &wasmvmtypes.CodeInfoQuery{CodeID: 1}, }, mock: mockWasmQueryKeeper{ - GetCodeInfoFn: func(ctx sdk.Context, codeID uint64) *types.CodeInfo { + GetCodeInfoFn: func(ctx context.Context, codeID uint64) *types.CodeInfo { return &types.CodeInfo{ CodeHash: myRawChecksum, Creator: myCreatorAddr, @@ -510,7 +509,7 @@ func TestCodeInfoWasmQuerier(t *testing.T) { CodeInfo: &wasmvmtypes.CodeInfoQuery{CodeID: 1}, }, mock: mockWasmQueryKeeper{ - GetCodeInfoFn: func(ctx sdk.Context, codeID uint64) *types.CodeInfo { + GetCodeInfoFn: func(ctx context.Context, codeID uint64) *types.CodeInfo { return nil }, }, @@ -561,7 +560,8 @@ func TestQueryErrors(t *testing.T) { mock := keeper.WasmVMQueryHandlerFn(func(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error) { return nil, spec.src }) - ctx := sdk.Context{}.WithGasMeter(sdk.NewInfiniteGasMeter()).WithMultiStore(store.NewCommitMultiStore(dbm.NewMemDB())).WithLogger(log.TestingLogger()) + ms := store.NewCommitMultiStore(dbm.NewMemDB(), log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + ctx := sdk.Context{}.WithGasMeter(storetypes.NewInfiniteGasMeter()).WithMultiStore(ms).WithLogger(log.NewTestLogger(t)) q := keeper.NewQueryHandler(ctx, mock, sdk.AccAddress{}, types.NewDefaultWasmGasRegister()) _, gotErr := q.Query(wasmvmtypes.QueryRequest{}, 1) assert.Equal(t, spec.expErr, gotErr) @@ -571,11 +571,11 @@ func TestQueryErrors(t *testing.T) { func TestAcceptListStargateQuerier(t *testing.T) { wasmApp := app.SetupWithEmptyStore(t) - ctx := wasmApp.NewUncachedContext(false, tmproto.Header{ChainID: "foo", Height: 1, Time: time.Now()}) + ctx := wasmApp.NewUncachedContext(false, cmtproto.Header{ChainID: "foo", Height: 1, Time: time.Now()}) err := wasmApp.StakingKeeper.SetParams(ctx, stakingtypes.DefaultParams()) require.NoError(t, err) - addrs := app.AddTestAddrsIncremental(wasmApp, ctx, 2, sdk.NewInt(1_000_000)) + addrs := app.AddTestAddrsIncremental(wasmApp, ctx, 2, sdkmath.NewInt(1_000_000)) accepted := keeper.AcceptedStargateQueries{ "/cosmos.auth.v1beta1.Query/Account": &authtypes.QueryAccountResponse{}, "/no/route/to/this": &authtypes.QueryAccountResponse{}, @@ -635,102 +635,43 @@ func TestAcceptListStargateQuerier(t *testing.T) { } } -func TestDistributionQuerier(t *testing.T) { - t.Skip("not implemented") - ctx := sdk.Context{} - var myAddr sdk.AccAddress = rand.Bytes(address.Len) - var myOtherAddr sdk.AccAddress = rand.Bytes(address.Len) - specs := map[string]struct { - q wasmvmtypes.DistributionQuery - mockFn func(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress - expAddr string - expErr bool - }{ - "withdrawal override": { - q: wasmvmtypes.DistributionQuery{ - DelegatorWithdrawAddress: &wasmvmtypes.DelegatorWithdrawAddressQuery{DelegatorAddress: myAddr.String()}, - }, - mockFn: func(_ sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress { - return myOtherAddr - }, - expAddr: myOtherAddr.String(), - }, - "no withdrawal override": { - q: wasmvmtypes.DistributionQuery{ - DelegatorWithdrawAddress: &wasmvmtypes.DelegatorWithdrawAddressQuery{DelegatorAddress: myAddr.String()}, - }, - mockFn: func(_ sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress { - return delAddr - }, - expAddr: myAddr.String(), - }, - "empty address": { - q: wasmvmtypes.DistributionQuery{ - DelegatorWithdrawAddress: &wasmvmtypes.DelegatorWithdrawAddressQuery{}, - }, - expErr: true, - }, - "unknown query": { - q: wasmvmtypes.DistributionQuery{}, - expErr: true, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - // mock := distrKeeperMock{GetDelegatorWithdrawAddrFn: spec.mockFn} - var mock types.DistributionKeeper - q := keeper.DistributionQuerier(mock) - - gotBz, gotErr := q(ctx, &spec.q) //nolint:gosec - if spec.expErr { - require.Error(t, gotErr) - return - } - require.NoError(t, gotErr) - var rsp wasmvmtypes.DelegatorWithdrawAddressResponse - require.NoError(t, json.Unmarshal(gotBz, &rsp)) - assert.Equal(t, spec.expAddr, rsp.WithdrawAddress) - }) - } -} - type mockWasmQueryKeeper struct { - GetContractInfoFn func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo - QueryRawFn func(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - QuerySmartFn func(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) ([]byte, error) - IsPinnedCodeFn func(ctx sdk.Context, codeID uint64) bool - GetCodeInfoFn func(ctx sdk.Context, codeID uint64) *types.CodeInfo + GetContractInfoFn func(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo + QueryRawFn func(ctx context.Context, contractAddress sdk.AccAddress, key []byte) []byte + QuerySmartFn func(ctx context.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) ([]byte, error) + IsPinnedCodeFn func(ctx context.Context, codeID uint64) bool + GetCodeInfoFn func(ctx context.Context, codeID uint64) *types.CodeInfo } -func (m mockWasmQueryKeeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo { +func (m mockWasmQueryKeeper) GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *types.ContractInfo { if m.GetContractInfoFn == nil { panic("not expected to be called") } return m.GetContractInfoFn(ctx, contractAddress) } -func (m mockWasmQueryKeeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte { +func (m mockWasmQueryKeeper) QueryRaw(ctx context.Context, contractAddress sdk.AccAddress, key []byte) []byte { if m.QueryRawFn == nil { panic("not expected to be called") } return m.QueryRawFn(ctx, contractAddress, key) } -func (m mockWasmQueryKeeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { +func (m mockWasmQueryKeeper) QuerySmart(ctx context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { if m.QuerySmartFn == nil { panic("not expected to be called") } return m.QuerySmartFn(ctx, contractAddr, req) } -func (m mockWasmQueryKeeper) IsPinnedCode(ctx sdk.Context, codeID uint64) bool { +func (m mockWasmQueryKeeper) IsPinnedCode(ctx context.Context, codeID uint64) bool { if m.IsPinnedCodeFn == nil { panic("not expected to be called") } return m.IsPinnedCodeFn(ctx, codeID) } -func (m mockWasmQueryKeeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo { +func (m mockWasmQueryKeeper) GetCodeInfo(ctx context.Context, codeID uint64) *types.CodeInfo { if m.GetCodeInfoFn == nil { panic("not expected to be called") } @@ -738,35 +679,35 @@ func (m mockWasmQueryKeeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types. } type bankKeeperMock struct { - GetSupplyFn func(ctx sdk.Context, denom string) sdk.Coin - GetBalanceFn func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetAllBalancesFn func(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetDenomMetadataFn func(ctx sdk.Context, denom string) (banktypes.Metadata, bool) + GetSupplyFn func(ctx context.Context, denom string) sdk.Coin + GetBalanceFn func(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetAllBalancesFn func(ctx context.Context, addr sdk.AccAddress) sdk.Coins + GetDenomMetadataFn func(ctx context.Context, denom string) (banktypes.Metadata, bool) GetDenomsMetadataFn func(ctx context.Context, req *banktypes.QueryDenomsMetadataRequest) (*banktypes.QueryDenomsMetadataResponse, error) } -func (m bankKeeperMock) GetSupply(ctx sdk.Context, denom string) sdk.Coin { +func (m bankKeeperMock) GetSupply(ctx context.Context, denom string) sdk.Coin { if m.GetSupplyFn == nil { panic("not expected to be called") } return m.GetSupplyFn(ctx, denom) } -func (m bankKeeperMock) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { +func (m bankKeeperMock) GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin { if m.GetBalanceFn == nil { panic("not expected to be called") } return m.GetBalanceFn(ctx, addr, denom) } -func (m bankKeeperMock) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { +func (m bankKeeperMock) GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins { if m.GetAllBalancesFn == nil { panic("not expected to be called") } return m.GetAllBalancesFn(ctx, addr) } -func (m bankKeeperMock) GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) { +func (m bankKeeperMock) GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool) { if m.GetDenomMetadataFn == nil { panic("not expected to be called") } @@ -784,9 +725,9 @@ func TestConvertProtoToJSONMarshal(t *testing.T) { testCases := []struct { name string queryPath string - protoResponseStruct codec.ProtoMarshaler + protoResponseStruct proto.Message originalResponse string - expectedProtoResponse codec.ProtoMarshaler + expectedProtoResponse proto.Message expectedError bool }{ { @@ -795,7 +736,7 @@ func TestConvertProtoToJSONMarshal(t *testing.T) { originalResponse: "0a090a036261721202333012050a03666f6f", protoResponseStruct: &banktypes.QueryAllBalancesResponse{}, expectedProtoResponse: &banktypes.QueryAllBalancesResponse{ - Balances: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(30))), + Balances: sdk.NewCoins(sdk.NewCoin("bar", sdkmath.NewInt(30))), Pagination: &query.PageResponse{ NextKey: []byte("foo"), }, @@ -814,7 +755,7 @@ func TestConvertProtoToJSONMarshal(t *testing.T) { t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { originalVersionBz, err := hex.DecodeString(tc.originalResponse) require.NoError(t, err) - appCodec := app.MakeEncodingConfig().Codec + appCodec := app.MakeEncodingConfig(t).Codec jsonMarshalledResponse, err := keeper.ConvertProtoToJSONMarshal(appCodec, tc.protoResponseStruct, originalVersionBz) if tc.expectedError { @@ -869,11 +810,11 @@ func TestConvertSDKDecCoinToWasmDecCoin(t *testing.T) { } func TestResetProtoMarshalerAfterJsonMarshal(t *testing.T) { - appCodec := app.MakeEncodingConfig().Codec + appCodec := app.MakeEncodingConfig(t).Codec protoMarshaler := &banktypes.QueryAllBalancesResponse{} expected := appCodec.MustMarshalJSON(&banktypes.QueryAllBalancesResponse{ - Balances: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(30))), + Balances: sdk.NewCoins(sdk.NewCoin("bar", sdkmath.NewInt(30))), Pagination: &query.PageResponse{ NextKey: []byte("foo"), }, @@ -901,8 +842,8 @@ func TestDeterministicJsonMarshal(t *testing.T) { originalResponse string updatedResponse string queryPath string - responseProtoStruct codec.ProtoMarshaler - expectedProto func() codec.ProtoMarshaler + responseProtoStruct proto.Message + expectedProto func() proto.Message }{ /** * @@ -930,7 +871,7 @@ func TestDeterministicJsonMarshal(t *testing.T) { "0a530a202f636f736d6f732e617574682e763162657461312e426173654163636f756e74122f0a2d636f736d6f733166387578756c746e3873717a687a6e72737a3371373778776171756867727367366a79766679122d636f736d6f733166387578756c746e3873717a687a6e72737a3371373778776171756867727367366a79766679", "/cosmos.auth.v1beta1.Query/Account", &authtypes.QueryAccountResponse{}, - func() codec.ProtoMarshaler { + func() proto.Message { account := authtypes.BaseAccount{ Address: "cosmos1f8uxultn8sqzhznrsz3q77xwaquhgrsg6jyvfy", } @@ -945,7 +886,7 @@ func TestDeterministicJsonMarshal(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { - appCodec := app.MakeEncodingConfig().Codec + appCodec := app.MakeEncodingConfig(t).Codec originVersionBz, err := hex.DecodeString(tc.originalResponse) require.NoError(t, err) diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 4d10d12e64..b3aaaec621 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -8,6 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -112,7 +114,7 @@ func TestGasCostOnQuery(t *testing.T) { keeper.queryGasLimit = 1000 // make sure we set a limit before calling - ctx = ctx.WithGasMeter(sdk.NewGasMeter(tc.gasLimit)) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(tc.gasLimit)) require.Equal(t, uint64(0), ctx.GasMeter().GasConsumed()) // do the query @@ -187,9 +189,9 @@ func TestGasOnExternalQuery(t *testing.T) { recurse := tc.msg msg := buildRecurseQuery(t, recurse) - querier := NewGrpcQuerier(keeper.cdc, keeper.storeKey, keeper, tc.gasLimit) + querier := NewGrpcQuerier(keeper.cdc, keeper.storeService, keeper, tc.gasLimit) req := &types.QuerySmartContractStateRequest{Address: contractAddr.String(), QueryData: msg} - _, gotErr := querier.SmartContractState(sdk.WrapSDKContext(ctx), req) + _, gotErr := querier.SmartContractState(ctx, req) if tc.expOutOfGas { require.Error(t, gotErr, sdkerrors.ErrOutOfGas) return @@ -274,7 +276,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) { totalWasmQueryCounter = 0 // make sure we set a limit before calling - ctx = ctx.WithGasMeter(sdk.NewGasMeter(tc.gasLimit)) + ctx = ctx.WithGasMeter(storetypes.NewGasMeter(tc.gasLimit)) require.Equal(t, uint64(0), ctx.GasMeter().GasConsumed()) // prepare the query diff --git a/x/wasm/keeper/reflect_test.go b/x/wasm/keeper/reflect_test.go index e5cf79ff65..c53360bbf2 100644 --- a/x/wasm/keeper/reflect_test.go +++ b/x/wasm/keeper/reflect_test.go @@ -228,7 +228,6 @@ func TestRustPanicIsHandled(t *testing.T) { } func checkAccount(t *testing.T, ctx sdk.Context, accKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, expected sdk.Coins) { - t.Helper() acct := accKeeper.GetAccount(ctx, addr) if expected == nil { assert.Nil(t, acct) diff --git a/x/wasm/keeper/relay.go b/x/wasm/keeper/relay.go index 209218b86c..c542f6c04e 100644 --- a/x/wasm/keeper/relay.go +++ b/x/wasm/keeper/relay.go @@ -4,8 +4,8 @@ import ( "time" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" errorsmod "cosmossdk.io/errors" diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index b1ee4f3438..812d94fd8a 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -11,6 +11,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" @@ -27,7 +29,7 @@ func TestOnOpenChannel(t *testing.T) { specs := map[string]struct { contractAddr sdk.AccAddress - contractGas sdk.Gas + contractGas storetypes.Gas contractErr error expGas uint64 expErr bool @@ -81,7 +83,7 @@ func TestOnOpenChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expGas, ctx.GasMeter().GasConsumed()-before-storageCosts) }) } @@ -100,7 +102,7 @@ func TestOnConnectChannel(t *testing.T) { contractResp *wasmvmtypes.IBCBasicResponse contractErr error overwriteMessenger *wasmtesting.MockMessageHandler - expContractGas sdk.Gas + expContractGas storetypes.Gas expErr bool expEventTypes []string }{ @@ -187,7 +189,7 @@ func TestOnConnectChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -212,7 +214,7 @@ func TestOnCloseChannel(t *testing.T) { contractResp *wasmvmtypes.IBCBasicResponse contractErr error overwriteMessenger *wasmtesting.MockMessageHandler - expContractGas sdk.Gas + expContractGas storetypes.Gas expErr bool expEventTypes []string }{ @@ -297,7 +299,7 @@ func TestOnCloseChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -316,7 +318,7 @@ func TestOnRecvPacket(t *testing.T) { parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) specs := map[string]struct { contractAddr sdk.AccAddress @@ -324,7 +326,7 @@ func TestOnRecvPacket(t *testing.T) { contractErr error overwriteMessenger *wasmtesting.MockMessageHandler mockReplyFn func(codeID wasmvm.Checksum, env wasmvmtypes.Env, reply wasmvmtypes.Reply, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) - expContractGas sdk.Gas + expContractGas storetypes.Gas expAck []byte expErr bool expPanic bool @@ -481,7 +483,7 @@ func TestOnRecvPacket(t *testing.T) { require.Equal(t, spec.expAck, gotAck.Acknowledgement()) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched on success/ err response @@ -512,7 +514,7 @@ func TestOnAckPacket(t *testing.T) { contractResp *wasmvmtypes.IBCBasicResponse contractErr error overwriteMessenger *wasmtesting.MockMessageHandler - expContractGas sdk.Gas + expContractGas storetypes.Gas expErr bool expEventTypes []string }{ @@ -592,7 +594,7 @@ func TestOnAckPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -617,7 +619,7 @@ func TestOnTimeoutPacket(t *testing.T) { contractResp *wasmvmtypes.IBCBasicResponse contractErr error overwriteMessenger *wasmtesting.MockMessageHandler - expContractGas sdk.Gas + expContractGas storetypes.Gas expErr bool expEventTypes []string }{ @@ -712,7 +714,7 @@ func TestOnTimeoutPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2903) + const storageCosts = storetypes.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) diff --git a/x/wasm/keeper/snapshotter.go b/x/wasm/keeper/snapshotter.go index d527d44b2c..ab813cc0ec 100644 --- a/x/wasm/keeper/snapshotter.go +++ b/x/wasm/keeper/snapshotter.go @@ -5,12 +5,13 @@ import ( "io" "math" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + snapshot "cosmossdk.io/store/snapshots/types" + storetypes "cosmossdk.io/store/types" - snapshot "github.com/cosmos/cosmos-sdk/snapshots/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/ioutils" @@ -24,10 +25,10 @@ const SnapshotFormat = 1 type WasmSnapshotter struct { wasm *Keeper - cms sdk.MultiStore + cms storetypes.MultiStore } -func NewWasmSnapshotter(cms sdk.MultiStore, wasm *Keeper) *WasmSnapshotter { +func NewWasmSnapshotter(cms storetypes.MultiStore, wasm *Keeper) *WasmSnapshotter { return &WasmSnapshotter{ wasm: wasm, cms: cms, diff --git a/x/wasm/keeper/snapshotter_integration_test.go b/x/wasm/keeper/snapshotter_integration_test.go index d93d782282..2262198597 100644 --- a/x/wasm/keeper/snapshotter_integration_test.go +++ b/x/wasm/keeper/snapshotter_integration_test.go @@ -12,6 +12,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" @@ -61,7 +63,9 @@ func TestSnapshotter(t *testing.T) { srcCodeIDToChecksum[codeID] = checksum } // create snapshot - srcWasmApp.Commit() + _, err := srcWasmApp.Commit() + require.NoError(t, err) + snapshotHeight := uint64(srcWasmApp.LastBlockHeight()) snapshot, err := srcWasmApp.SnapshotManager().Create(snapshotHeight) require.NoError(t, err) @@ -111,14 +115,13 @@ func TestSnapshotter(t *testing.T) { } func newWasmExampleApp(t *testing.T) (*app.WasmApp, sdk.AccAddress) { - t.Helper() senderPrivKey := ed25519.GenPrivKey() - pubKey, err := cryptocodec.ToTmPubKeyInterface(senderPrivKey.PubKey()) + pubKey, err := cryptocodec.ToCmtPubKeyInterface(senderPrivKey.PubKey()) require.NoError(t, err) senderAddr := senderPrivKey.PubKey().Address().Bytes() acc := authtypes.NewBaseAccount(senderAddr, senderPrivKey.PubKey(), 0, 0) - amount, ok := sdk.NewIntFromString("10000000000000000000") + amount, ok := sdkmath.NewIntFromString("10000000000000000000") require.True(t, ok) balance := banktypes.Balance{ diff --git a/x/wasm/keeper/staking_test.go b/x/wasm/keeper/staking_test.go index f7a1809c4f..6e1023d98f 100644 --- a/x/wasm/keeper/staking_test.go +++ b/x/wasm/keeper/staking_test.go @@ -9,13 +9,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -24,11 +25,11 @@ import ( ) type StakingInitMsg struct { - Name string `json:"name"` - Symbol string `json:"symbol"` - Decimals uint8 `json:"decimals"` - Validator sdk.ValAddress `json:"validator"` - ExitTax sdk.Dec `json:"exit_tax"` + Name string `json:"name"` + Symbol string `json:"symbol"` + Decimals uint8 `json:"decimals"` + Validator sdk.ValAddress `json:"validator"` + ExitTax sdkmath.LegacyDec `json:"exit_tax"` // MinWithdrawal is uint128 encoded as a string (use math.Int?) MinWithdrawl string `json:"min_withdrawal"` } @@ -81,12 +82,12 @@ type TokenInfoResponse struct { } type InvestmentResponse struct { - TokenSupply string `json:"token_supply"` - StakedTokens sdk.Coin `json:"staked_tokens"` - NominalValue sdk.Dec `json:"nominal_value"` - Owner sdk.AccAddress `json:"owner"` - Validator sdk.ValAddress `json:"validator"` - ExitTax sdk.Dec `json:"exit_tax"` + TokenSupply string `json:"token_supply"` + StakedTokens sdk.Coin `json:"staked_tokens"` + NominalValue sdkmath.LegacyDec `json:"nominal_value"` + Owner sdk.AccAddress `json:"owner"` + Validator sdk.ValAddress `json:"validator"` + ExitTax sdkmath.LegacyDec `json:"exit_tax"` // MinWithdrawl is uint128 encoded as a string (use math.Int?) MinWithdrawl string `json:"min_withdrawal"` } @@ -97,9 +98,9 @@ func TestInitializeStaking(t *testing.T) { valAddr := addValidator(t, ctx, stakingKeeper, k.Faucet, sdk.NewInt64Coin("stake", 1234567)) ctx = nextBlock(ctx, stakingKeeper) - v, found := stakingKeeper.GetValidator(ctx, valAddr) - assert.True(t, found) - assert.Equal(t, v.GetDelegatorShares(), sdk.NewDec(1234567)) + v, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) + assert.Equal(t, v.GetDelegatorShares(), sdkmath.LegacyNewDec(1234567)) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000), sdk.NewInt64Coin("stake", 500000)) creator := k.Faucet.NewFundedRandomAccount(ctx, deposit...) @@ -117,7 +118,7 @@ func TestInitializeStaking(t *testing.T) { Symbol: "DRV", Decimals: 0, Validator: valAddr, - ExitTax: sdk.MustNewDecFromStr("0.10"), + ExitTax: sdkmath.LegacyMustNewDecFromStr("0.10"), MinWithdrawl: "100", } initBz, err := json.Marshal(&initMsg) @@ -137,7 +138,7 @@ func TestInitializeStaking(t *testing.T) { Symbol: "MISS", Decimals: 0, Validator: sdk.ValAddress(bob), - ExitTax: sdk.MustNewDecFromStr("0.10"), + ExitTax: sdkmath.LegacyMustNewDecFromStr("0.10"), MinWithdrawl: "100", } badBz, err := json.Marshal(&badInitMsg) @@ -148,7 +149,7 @@ func TestInitializeStaking(t *testing.T) { // no changes to bonding shares val, _ := stakingKeeper.GetValidator(ctx, valAddr) - assert.Equal(t, val.GetDelegatorShares(), sdk.NewDec(1234567)) + assert.Equal(t, val.GetDelegatorShares(), sdkmath.LegacyNewDec(1234567)) } type initInfo struct { @@ -167,16 +168,15 @@ type initInfo struct { } func initializeStaking(t *testing.T) initInfo { - t.Helper() ctx, k := CreateTestInput(t, false, AvailableCapabilities) accKeeper, stakingKeeper, keeper, bankKeeper := k.AccountKeeper, k.StakingKeeper, k.WasmKeeper, k.BankKeeper valAddr := addValidator(t, ctx, stakingKeeper, k.Faucet, sdk.NewInt64Coin("stake", 1000000)) ctx = nextBlock(ctx, stakingKeeper) - v, found := stakingKeeper.GetValidator(ctx, valAddr) - assert.True(t, found) - assert.Equal(t, v.GetDelegatorShares(), sdk.NewDec(1000000)) + v, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) + assert.Equal(t, v.GetDelegatorShares(), sdkmath.LegacyNewDec(1000000)) assert.Equal(t, v.Status, stakingtypes.Bonded) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000), sdk.NewInt64Coin("stake", 500000)) @@ -195,7 +195,7 @@ func initializeStaking(t *testing.T) initInfo { Symbol: "DRV", Decimals: 0, Validator: valAddr, - ExitTax: sdk.MustNewDecFromStr("0.10"), + ExitTax: sdkmath.LegacyMustNewDecFromStr("0.10"), MinWithdrawl: "100", } initBz, err := json.Marshal(&initMsg) @@ -226,8 +226,8 @@ func TestBonding(t *testing.T) { keeper, stakingKeeper, accKeeper, bankKeeper := initInfo.wasmKeeper, initInfo.stakingKeeper, initInfo.accKeeper, initInfo.bankKeeper // initial checks of bonding state - val, found := stakingKeeper.GetValidator(ctx, valAddr) - require.True(t, found) + val, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) initPower := val.GetDelegatorShares() // bob has 160k, putting 80k into the contract @@ -255,12 +255,12 @@ func TestBonding(t *testing.T) { // make sure the proper number of tokens have been bonded val, _ = stakingKeeper.GetValidator(ctx, valAddr) finalPower := val.GetDelegatorShares() - assert.Equal(t, sdk.NewInt(80000), finalPower.Sub(initPower).TruncateInt()) + assert.Equal(t, sdkmath.NewInt(80000), finalPower.Sub(initPower).TruncateInt()) // check the delegation itself - d, found := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) - require.True(t, found) - assert.Equal(t, d.Shares, sdk.MustNewDecFromStr("80000")) + d, err := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) + require.NoError(t, err) + assert.Equal(t, d.Shares, sdkmath.LegacyMustNewDecFromStr("80000")) // check we have the desired balance assertBalance(t, ctx, keeper, contractAddr, bob, "80000") @@ -274,8 +274,8 @@ func TestUnbonding(t *testing.T) { keeper, stakingKeeper, accKeeper, bankKeeper := initInfo.wasmKeeper, initInfo.stakingKeeper, initInfo.accKeeper, initInfo.bankKeeper // initial checks of bonding state - val, found := stakingKeeper.GetValidator(ctx, valAddr) - require.True(t, found) + val, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) initPower := val.GetDelegatorShares() // bob has 160k, putting 80k into the contract @@ -313,16 +313,16 @@ func TestUnbonding(t *testing.T) { // make sure the proper number of tokens have been bonded (80k - 27k = 53k) val, _ = stakingKeeper.GetValidator(ctx, valAddr) finalPower := val.GetDelegatorShares() - assert.Equal(t, sdk.NewInt(53000), finalPower.Sub(initPower).TruncateInt(), finalPower.String()) + assert.Equal(t, sdkmath.NewInt(53000), finalPower.Sub(initPower).TruncateInt(), finalPower.String()) // check the delegation itself - d, found := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) - require.True(t, found) - assert.Equal(t, d.Shares, sdk.MustNewDecFromStr("53000")) + d, err := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) + require.NoError(t, err) + assert.Equal(t, d.Shares, sdkmath.LegacyMustNewDecFromStr("53000")) // check there is unbonding in progress - un, found := stakingKeeper.GetUnbondingDelegation(ctx, contractAddr, valAddr) - require.True(t, found) + un, err := stakingKeeper.GetUnbondingDelegation(ctx, contractAddr, valAddr) + require.NoError(t, err) require.Equal(t, 1, len(un.Entries)) assert.Equal(t, "27000", un.Entries[0].Balance.String()) @@ -340,10 +340,10 @@ func TestReinvest(t *testing.T) { distKeeper := initInfo.distKeeper // initial checks of bonding state - val, found := stakingKeeper.GetValidator(ctx, valAddr) - require.True(t, found) + val, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) initPower := val.GetDelegatorShares() - assert.Equal(t, val.Tokens, sdk.NewInt(1000000), "%s", val.Tokens) + assert.Equal(t, val.Tokens, sdkmath.NewInt(1000000), "%s", val.Tokens) // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) @@ -380,19 +380,19 @@ func TestReinvest(t *testing.T) { checkAccount(t, ctx, accKeeper, bankKeeper, bob, funds) // check the delegation itself - d, found := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) - require.True(t, found) + d, err := stakingKeeper.GetDelegation(ctx, contractAddr, valAddr) + require.NoError(t, err) // we started with 200k and added 36k - assert.Equal(t, d.Shares, sdk.MustNewDecFromStr("236000")) + assert.Equal(t, d.Shares, sdkmath.LegacyMustNewDecFromStr("236000")) // make sure the proper number of tokens have been bonded (80k + 40k = 120k) val, _ = stakingKeeper.GetValidator(ctx, valAddr) finalPower := val.GetDelegatorShares() - assert.Equal(t, sdk.NewInt(236000), finalPower.Sub(initPower).TruncateInt(), finalPower.String()) + assert.Equal(t, sdkmath.NewInt(236000), finalPower.Sub(initPower).TruncateInt(), finalPower.String()) // check there is no unbonding in progress - un, found := stakingKeeper.GetUnbondingDelegation(ctx, contractAddr, valAddr) - assert.False(t, found, "%#v", un) + _, err = stakingKeeper.GetUnbondingDelegation(ctx, contractAddr, valAddr) + require.ErrorIs(t, stakingtypes.ErrNoUnbondingDelegation, err) // check we have the desired balance assertBalance(t, ctx, keeper, contractAddr, bob, "200000") @@ -409,9 +409,9 @@ func TestQueryStakingInfo(t *testing.T) { distKeeper := initInfo.distKeeper // initial checks of bonding state - val, found := stakingKeeper.GetValidator(ctx, valAddr) - require.True(t, found) - assert.Equal(t, sdk.NewInt(1000000), val.Tokens) + val, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) + assert.Equal(t, sdkmath.NewInt(1000000), val.Tokens) // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) @@ -434,7 +434,8 @@ func TestQueryStakingInfo(t *testing.T) { setValidatorRewards(ctx, stakingKeeper, distKeeper, valAddr, "240000") // see what the current rewards are - origReward := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + origReward, err := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + require.NoError(t, err) // STEP 2: Prepare the mask contract deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -575,7 +576,8 @@ func TestQueryStakingInfo(t *testing.T) { require.Equal(t, wasmvmtypes.NewCoin(36000, "stake"), delInfo2.AccumulatedRewards[0]) // ensure rewards did not change when querying (neither amount nor period) - finalReward := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + finalReward, err := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + require.NoError(t, err) require.Equal(t, origReward, finalReward) } @@ -587,9 +589,9 @@ func TestQueryStakingPlugin(t *testing.T) { distKeeper := initInfo.distKeeper // initial checks of bonding state - val, found := stakingKeeper.GetValidator(ctx, valAddr) - require.True(t, found) - assert.Equal(t, sdk.NewInt(1000000), val.Tokens) + val, err := stakingKeeper.GetValidator(ctx, valAddr) + require.NoError(t, err) + assert.Equal(t, sdkmath.NewInt(1000000), val.Tokens) // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) @@ -612,7 +614,8 @@ func TestQueryStakingPlugin(t *testing.T) { setValidatorRewards(ctx, stakingKeeper, distKeeper, valAddr, "240000") // see what the current rewards are - origReward := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + origReward, err := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + require.NoError(t, err) // Step 2: Try out the query plugins query := wasmvmtypes.StakingQuery{ @@ -641,18 +644,31 @@ func TestQueryStakingPlugin(t *testing.T) { require.Equal(t, wasmvmtypes.NewCoin(36000, "stake"), delInfo.AccumulatedRewards[0]) // ensure rewards did not change when querying (neither amount nor period) - finalReward := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + finalReward, err := distKeeper.GetValidatorCurrentRewards(ctx, valAddr) + require.NoError(t, err) require.Equal(t, origReward, finalReward) + + // with empty delegation (regression to ensure api stability) + query = wasmvmtypes.StakingQuery{ + Delegation: &wasmvmtypes.DelegationQuery{ + Delegator: RandomBech32AccountAddress(t), + Validator: valAddr.String(), + }, + } + raw, err = StakingQuerier(stakingKeeper, distributionkeeper.NewQuerier(distKeeper))(ctx, &query) + require.NoError(t, err) + var res2 wasmvmtypes.DelegationResponse + mustUnmarshal(t, raw, &res2) + assert.Empty(t, res2.Delegation) } // adds a few validators and returns a list of validators that are registered func addValidator(t *testing.T, ctx sdk.Context, stakingKeeper *stakingkeeper.Keeper, faucet *TestFaucet, value sdk.Coin) sdk.ValAddress { - t.Helper() owner := faucet.NewFundedRandomAccount(ctx, value) privKey := secp256k1.GenPrivKey() pubKey := privKey.PubKey() - addr := sdk.ValAddress(pubKey.Address()) + valAddr := sdk.ValAddress(owner) pkAny, err := codectypes.NewAnyWithValue(pubKey) require.NoError(t, err) @@ -661,43 +677,50 @@ func addValidator(t *testing.T, ctx sdk.Context, stakingKeeper *stakingkeeper.Ke Moniker: "Validator power", }, Commission: stakingtypes.CommissionRates{ - Rate: sdk.MustNewDecFromStr("0.1"), - MaxRate: sdk.MustNewDecFromStr("0.2"), - MaxChangeRate: sdk.MustNewDecFromStr("0.01"), + Rate: sdkmath.LegacyMustNewDecFromStr("0.1"), + MaxRate: sdkmath.LegacyMustNewDecFromStr("0.2"), + MaxChangeRate: sdkmath.LegacyMustNewDecFromStr("0.01"), }, - MinSelfDelegation: sdk.OneInt(), + MinSelfDelegation: sdkmath.OneInt(), DelegatorAddress: owner.String(), - ValidatorAddress: addr.String(), + ValidatorAddress: valAddr.String(), Pubkey: pkAny, Value: value, } - _, err = stakingkeeper.NewMsgServerImpl(stakingKeeper).CreateValidator(sdk.WrapSDKContext(ctx), msg) + _, err = stakingkeeper.NewMsgServerImpl(stakingKeeper).CreateValidator(ctx, msg) require.NoError(t, err) - return addr + return valAddr } // this will commit the current set, update the block height and set historic info // basically, letting two blocks pass func nextBlock(ctx sdk.Context, stakingKeeper *stakingkeeper.Keeper) sdk.Context { - staking.EndBlocker(ctx, stakingKeeper) + if _, err := stakingKeeper.EndBlocker(ctx); err != nil { + panic(err) + } ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) - staking.BeginBlocker(ctx, stakingKeeper) + _ = stakingKeeper.BeginBlocker(ctx) return ctx } func setValidatorRewards(ctx sdk.Context, stakingKeeper *stakingkeeper.Keeper, distKeeper distributionkeeper.Keeper, valAddr sdk.ValAddress, reward string) { // allocate some rewards - vali := stakingKeeper.Validator(ctx, valAddr) - amount, err := sdk.NewDecFromStr(reward) + vali, err := stakingKeeper.Validator(ctx, valAddr) + if err != nil { + panic(err) + } + amount, err := sdkmath.LegacyNewDecFromStr(reward) if err != nil { panic(err) } payout := sdk.DecCoins{{Denom: "stake", Amount: amount}} - distKeeper.AllocateTokensToValidator(ctx, vali, payout) + err = distKeeper.AllocateTokensToValidator(ctx, vali, payout) + if err != nil { + panic(err) + } } func assertBalance(t *testing.T, ctx sdk.Context, keeper Keeper, contract, addr sdk.AccAddress, expected string) { - t.Helper() query := StakingQueryMsg{ Balance: &addressQuery{ Address: addr, @@ -714,7 +737,6 @@ func assertBalance(t *testing.T, ctx sdk.Context, keeper Keeper, contract, addr } func assertClaims(t *testing.T, ctx sdk.Context, keeper Keeper, contract, addr sdk.AccAddress, expected string) { - t.Helper() query := StakingQueryMsg{ Claims: &addressQuery{ Address: addr, @@ -731,7 +753,6 @@ func assertClaims(t *testing.T, ctx sdk.Context, keeper Keeper, contract, addr s } func assertSupply(t *testing.T, ctx sdk.Context, keeper Keeper, contract sdk.AccAddress, expectedIssued string, expectedBonded sdk.Coin) { - t.Helper() query := StakingQueryMsg{Investment: &struct{}{}} queryBz, err := json.Marshal(query) require.NoError(t, err) diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index fe301dc37b..99ead92795 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -112,8 +113,8 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { // prep - create one chain and upload the code ctx, keepers := CreateTestInput(t, false, ReflectFeatures) - ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) - ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) + ctx = ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) + ctx = ctx.WithBlockGasMeter(storetypes.NewInfiniteGasMeter()) keeper := keepers.WasmKeeper contractStart := sdk.NewCoins(sdk.NewInt64Coin(fundedDenom, int64(fundedAmount))) uploader := keepers.Faucet.NewFundedRandomAccount(ctx, contractStart.Add(contractStart...)...) @@ -193,14 +194,12 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { assertReturnedEvents := func(expectedEvents int) assertion { return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) { - t.Helper() require.Len(t, response.Ok.Events, expectedEvents) } } assertGasUsed := func(minGas, maxGas uint64) assertion { return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) { - t.Helper() gasUsed := ctx.GasMeter().GasConsumed() assert.True(t, gasUsed >= minGas, "Used %d gas (less than expected %d)", gasUsed, minGas) assert.True(t, gasUsed <= maxGas, "Used %d gas (more than expected %d)", gasUsed, maxGas) @@ -209,13 +208,11 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { assertErrorString := func(shouldContain string) assertion { return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) { - t.Helper() assert.Contains(t, response.Err, shouldContain) } } assertGotContractAddr := func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) { - t.Helper() // should get the events emitted on new contract event := response.Ok.Events[0] require.Equal(t, event.Type, "instantiate") @@ -246,7 +243,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { "send tokens": { submsgID: 5, msg: validBankSend, - resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(102000, 103000)}, + resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(105000, 106000)}, }, "not enough tokens": { submsgID: 6, @@ -266,7 +263,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { msg: validBankSend, gasLimit: &subGasLimit, // uses same gas as call without limit (note we do not charge the 40k on reply) - resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(102000, 103000)}, + resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(105000, 106000)}, }, "not enough tokens with limit": { submsgID: 16, @@ -312,12 +309,12 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { reflectSendBz, err := json.Marshal(reflectSend) require.NoError(t, err) - execCtx := ctx.WithGasMeter(sdk.NewGasMeter(ctxGasLimit)) + execCtx := ctx.WithGasMeter(storetypes.NewGasMeter(ctxGasLimit)) defer func() { if tc.isOutOfGasPanic { r := recover() require.NotNil(t, r, "expected panic") - if _, ok := r.(sdk.ErrorOutOfGas); !ok { + if _, ok := r.(storetypes.ErrorOutOfGas); !ok { t.Fatalf("Expected OutOfGas panic, got: %#v\n", r) } } @@ -370,7 +367,7 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { Bank: nilEncoder, } - ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageHandler(NewSDKMessageHandler(nil, customEncoders))) + ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageHandler(NewSDKMessageHandler(MakeTestCodec(t), nil, customEncoders))) keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index 1c8a415ffc..0f6110853a 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -9,33 +9,44 @@ import ( "testing" "time" - dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" - "github.com/cometbft/cometbft/libs/log" "github.com/cometbft/cometbft/libs/rand" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -43,17 +54,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" "github.com/cosmos/cosmos-sdk/x/distribution" distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" @@ -70,10 +75,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" wasmappparams "github.com/CosmWasm/wasmd/app/params" "github.com/CosmWasm/wasmd/x/wasm/keeper/testdata" @@ -90,8 +91,6 @@ var moduleBasics = module.NewBasicManager( distribution.AppModuleBasic{}, gov.NewAppModuleBasic([]govclient.ProposalHandler{ paramsclient.ProposalHandler, - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, }), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -103,10 +102,8 @@ var moduleBasics = module.NewBasicManager( vesting.AppModuleBasic{}, ) -func MakeTestCodec(tb testing.TB) codec.Codec { - tb.Helper() - - return MakeEncodingConfig(tb).Codec +func MakeTestCodec(t testing.TB) codec.Codec { + return MakeEncodingConfig(t).Codec } func MakeEncodingConfig(_ testing.TB) wasmappparams.EncodingConfig { @@ -143,11 +140,9 @@ type TestFaucet struct { minterModuleName string } -func NewTestFaucet(tb testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, minterModuleName string, initialAmount ...sdk.Coin) *TestFaucet { - tb.Helper() - - require.NotEmpty(tb, initialAmount) - r := &TestFaucet{t: tb, bankKeeper: bankKeeper, minterModuleName: minterModuleName} +func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, minterModuleName string, initialAmount ...sdk.Coin) *TestFaucet { + require.NotEmpty(t, initialAmount) + r := &TestFaucet{t: t, bankKeeper: bankKeeper, minterModuleName: minterModuleName} _, addr := keyPubAddr() r.sender = addr r.Mint(ctx, addr, initialAmount...) @@ -195,40 +190,34 @@ type TestKeepers struct { Router MessageRouter EncodingConfig wasmappparams.EncodingConfig Faucet *TestFaucet - MultiStore sdk.CommitMultiStore + MultiStore storetypes.CommitMultiStore ScopedWasmKeeper capabilitykeeper.ScopedKeeper WasmStoreKey *storetypes.KVStoreKey } // CreateDefaultTestInput common settings for CreateTestInput -func CreateDefaultTestInput(tb testing.TB) (sdk.Context, TestKeepers) { - tb.Helper() - - return CreateTestInput(tb, false, "staking") +func CreateDefaultTestInput(t testing.TB) (sdk.Context, TestKeepers) { + return CreateTestInput(t, false, "staking") } // CreateTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) -func CreateTestInput(tb testing.TB, isCheckTx bool, availableCapabilities string, opts ...Option) (sdk.Context, TestKeepers) { - tb.Helper() - +func CreateTestInput(t testing.TB, isCheckTx bool, availableCapabilities string, opts ...Option) (sdk.Context, TestKeepers) { // Load default wasm config - return createTestInput(tb, isCheckTx, availableCapabilities, types.DefaultWasmConfig(), dbm.NewMemDB(), opts...) + return createTestInput(t, isCheckTx, availableCapabilities, types.DefaultWasmConfig(), dbm.NewMemDB(), opts...) } // encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) func createTestInput( - tb testing.TB, + t testing.TB, isCheckTx bool, availableCapabilities string, wasmConfig types.WasmConfig, db dbm.DB, opts ...Option, ) (sdk.Context, TestKeepers) { - tb.Helper() - - tempDir := tb.TempDir() + tempDir := t.TempDir() - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distributiontypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, @@ -236,21 +225,22 @@ func createTestInput( capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, types.StoreKey, ) - ms := store.NewCommitMultiStore(db) + logger := log.NewTestLogger(t) + ms := store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics()) for _, v := range keys { ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) } - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) for _, v := range tkeys { ms.MountStoreWithDB(v, storetypes.StoreTypeTransient, db) } - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) for _, v := range memKeys { ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) } - require.NoError(tb, ms.LoadLatestVersion()) + require.NoError(t, ms.LoadLatestVersion()) ctx := sdk.NewContext(ms, tmproto.Header{ Height: 1234567, @@ -258,14 +248,14 @@ func createTestInput( }, isCheckTx, log.NewNopLogger()) ctx = types.WithTXCounter(ctx, 0) - encodingConfig := MakeEncodingConfig(tb) + encodingConfig := MakeEncodingConfig(t) appCodec, legacyAmino := encodingConfig.Codec, encodingConfig.Amino paramsKeeper := paramskeeper.NewKeeper( appCodec, legacyAmino, keys[paramstypes.StoreKey], - tkeys[paramstypes.TStoreKey], + tkeys[paramstypes.StoreKey], ) for _, m := range []string{ authtypes.ModuleName, @@ -285,43 +275,7 @@ func createTestInput( } subspace := func(m string) paramstypes.Subspace { r, ok := paramsKeeper.GetSubspace(m) - require.True(tb, ok) - - var keyTable paramstypes.KeyTable - switch r.Name() { - case authtypes.ModuleName: - keyTable = authtypes.ParamKeyTable() //nolint:staticcheck - case banktypes.ModuleName: - keyTable = banktypes.ParamKeyTable() //nolint:staticcheck - case stakingtypes.ModuleName: - keyTable = stakingtypes.ParamKeyTable() - case minttypes.ModuleName: - keyTable = minttypes.ParamKeyTable() //nolint:staticcheck - case distributiontypes.ModuleName: - keyTable = distributiontypes.ParamKeyTable() //nolint:staticcheck - case slashingtypes.ModuleName: - keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck - case govtypes.ModuleName: - keyTable = govv1.ParamKeyTable() //nolint:staticcheck - case crisistypes.ModuleName: - keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck - // ibc types - case ibctransfertypes.ModuleName: - keyTable = ibctransfertypes.ParamKeyTable() - case icahosttypes.SubModuleName: - keyTable = icahosttypes.ParamKeyTable() - case icacontrollertypes.SubModuleName: - keyTable = icacontrollertypes.ParamKeyTable() - // wasm - case types.ModuleName: - keyTable = types.ParamKeyTable() //nolint:staticcheck - default: - return r - } - - if !r.HasKeyTable() { - r = r.WithKeyTable(keyTable) - } + require.True(t, ok) return r } maccPerms := map[string][]string{ // module account permissions @@ -334,70 +288,72 @@ func createTestInput( ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, types.ModuleName: {authtypes.Burner}, } + accountKeeper := authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], // target store - authtypes.ProtoBaseAccount, // prototype + runtime.NewKVStoreService(keys[authtypes.StoreKey]), + authtypes.ProtoBaseAccount, maccPerms, + authcodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, - authtypes.NewModuleAddress(authtypes.ModuleName).String(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) blockedAddrs := make(map[string]bool) for acc := range maccPerms { blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true } - - require.NoError(tb, accountKeeper.SetParams(ctx, authtypes.DefaultParams())) + require.NoError(t, accountKeeper.Params.Set(ctx, authtypes.DefaultParams())) bankKeeper := bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), accountKeeper, blockedAddrs, authtypes.NewModuleAddress(banktypes.ModuleName).String(), + logger, ) - require.NoError(tb, bankKeeper.SetParams(ctx, banktypes.DefaultParams())) + require.NoError(t, bankKeeper.SetParams(ctx, banktypes.DefaultParams())) stakingKeeper := stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authtypes.NewModuleAddress(stakingtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) stakingtypes.DefaultParams() - require.NoError(tb, stakingKeeper.SetParams(ctx, TestingStakeParams)) + require.NoError(t, stakingKeeper.SetParams(ctx, TestingStakeParams)) distKeeper := distributionkeeper.NewKeeper( appCodec, - keys[distributiontypes.StoreKey], + runtime.NewKVStoreService(keys[distributiontypes.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(distributiontypes.ModuleName).String(), ) - require.NoError(tb, distKeeper.SetParams(ctx, distributiontypes.DefaultParams())) + require.NoError(t, distKeeper.Params.Set(ctx, distributiontypes.DefaultParams())) + require.NoError(t, distKeeper.FeePool.Set(ctx, distributiontypes.InitialFeePool())) stakingKeeper.SetHooks(distKeeper.Hooks()) - // set genesis items required for distribution - distKeeper.SetFeePool(ctx, distributiontypes.InitialFeePool()) - upgradeKeeper := upgradekeeper.NewKeeper( map[int64]bool{}, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, tempDir, nil, authtypes.NewModuleAddress(upgradetypes.ModuleName).String(), ) - faucet := NewTestFaucet(tb, ctx, bankKeeper, minttypes.ModuleName, sdk.NewCoin("stake", sdk.NewInt(100_000_000_000))) + faucet := NewTestFaucet(t, ctx, bankKeeper, minttypes.ModuleName, sdk.NewCoin("stake", sdkmath.NewInt(100_000_000_000))) // set some funds ot pay out validatores, based on code from: // https://github.com/cosmos/cosmos-sdk/blob/fea231556aee4d549d7551a6190389c4328194eb/x/distribution/keeper/keeper_test.go#L50-L57 distrAcc := distKeeper.GetDistributionAccount(ctx) - faucet.Fund(ctx, distrAcc.GetAddress(), sdk.NewCoin("stake", sdk.NewInt(2000000))) + faucet.Fund(ctx, distrAcc.GetAddress(), sdk.NewCoin("stake", sdkmath.NewInt(2000000))) accountKeeper.SetModuleAccount(ctx, distrAcc) capabilityKeeper := capabilitykeeper.NewKeeper( @@ -415,8 +371,8 @@ func createTestInput( stakingKeeper, upgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - querier := baseapp.NewGRPCQueryRouter() querier.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) msgRouter := baseapp.NewMsgServiceRouter() @@ -427,7 +383,7 @@ func createTestInput( keeper := NewKeeper( appCodec, - keys[types.StoreKey], + runtime.NewKVStoreService(keys[types.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, @@ -445,23 +401,23 @@ func createTestInput( authtypes.NewModuleAddress(govtypes.ModuleName).String(), opts..., ) - require.NoError(tb, keeper.SetParams(ctx, types.DefaultParams())) + require.NoError(t, keeper.SetParams(ctx, types.DefaultParams())) // add wasm handler so we can loop-back (contracts calling contracts) contractKeeper := NewDefaultPermissionKeeper(&keeper) govKeeper := govkeeper.NewKeeper( appCodec, - keys[govtypes.StoreKey], + runtime.NewKVStoreService(keys[govtypes.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, + distKeeper, msgRouter, govtypes.DefaultConfig(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - require.NoError(tb, govKeeper.SetParams(ctx, govv1.DefaultParams())) - govKeeper.SetProposalID(ctx, 1) + require.NoError(t, govKeeper.Params.Set(ctx, govv1.DefaultParams())) am := module.NewManager( // minimal module set that we use for message/ query tests bank.NewAppModule(appCodec, bankKeeper, accountKeeper, subspace(banktypes.ModuleName)), @@ -469,9 +425,9 @@ func createTestInput( distribution.NewAppModule(appCodec, distKeeper, accountKeeper, bankKeeper, stakingKeeper, subspace(distributiontypes.ModuleName)), gov.NewAppModule(appCodec, govKeeper, accountKeeper, bankKeeper, subspace(govtypes.ModuleName)), ) - am.RegisterServices(module.NewConfigurator(appCodec, msgRouter, querier)) + am.RegisterServices(module.NewConfigurator(appCodec, msgRouter, querier)) //nolint:errcheck types.RegisterMsgServer(msgRouter, NewMsgServerImpl(&keeper)) - types.RegisterQueryServer(querier, NewGrpcQuerier(appCodec, keys[types.ModuleName], keeper, keeper.queryGasLimit)) + types.RegisterQueryServer(querier, NewGrpcQuerier(appCodec, runtime.NewKVStoreService(keys[types.ModuleName]), keeper, keeper.queryGasLimit)) keepers := TestKeepers{ AccountKeeper: accountKeeper, @@ -514,7 +470,7 @@ var _ MessageRouter = MessageRouterFunc(nil) type MessageRouterFunc func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) -func (m MessageRouterFunc) Handler(msg sdk.Msg) baseapp.MsgServiceHandler { +func (m MessageRouterFunc) Handler(_ sdk.Msg) baseapp.MsgServiceHandler { return m } @@ -587,10 +543,8 @@ func DeterministicAccountAddress(_ testing.TB, v byte) sdk.AccAddress { return bytes.Repeat([]byte{v}, address.Len) } -func RandomBech32AccountAddress(tb testing.TB) string { - tb.Helper() - - return RandomAccountAddress(tb).String() +func RandomBech32AccountAddress(t testing.TB) string { + return RandomAccountAddress(t).String() } type ExampleContract struct { @@ -601,47 +555,35 @@ type ExampleContract struct { Checksum []byte } -func StoreHackatomExampleContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { - tb.Helper() - - return StoreExampleContractWasm(tb, ctx, keepers, testdata.HackatomContractWasm()) +func StoreHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { + return StoreExampleContractWasm(t, ctx, keepers, testdata.HackatomContractWasm()) } -func StoreBurnerExampleContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { - tb.Helper() - - return StoreExampleContractWasm(tb, ctx, keepers, testdata.BurnerContractWasm()) +func StoreBurnerExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { + return StoreExampleContractWasm(t, ctx, keepers, testdata.BurnerContractWasm()) } -func StoreIBCReflectContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { - tb.Helper() - - return StoreExampleContractWasm(tb, ctx, keepers, testdata.IBCReflectContractWasm()) +func StoreIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { + return StoreExampleContractWasm(t, ctx, keepers, testdata.IBCReflectContractWasm()) } -func StoreReflectContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { - tb.Helper() - - return StoreExampleContractWasm(tb, ctx, keepers, testdata.ReflectContractWasm()) +func StoreReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { + return StoreExampleContractWasm(t, ctx, keepers, testdata.ReflectContractWasm()) } -func StoreExampleContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract { - tb.Helper() - +func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract { wasmCode, err := os.ReadFile(wasmFile) - require.NoError(tb, err) - return StoreExampleContractWasm(tb, ctx, keepers, wasmCode) + require.NoError(t, err) + return StoreExampleContractWasm(t, ctx, keepers, wasmCode) } -func StoreExampleContractWasm(tb testing.TB, ctx sdk.Context, keepers TestKeepers, wasmCode []byte) ExampleContract { - tb.Helper() - +func StoreExampleContractWasm(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmCode []byte) ExampleContract { anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) creator, creatorAddr := keyPubAddr() - fundAccounts(tb, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) + fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) codeID, _, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) - require.NoError(tb, err) + require.NoError(t, err) hash := keepers.WasmKeeper.GetCodeInfo(ctx, codeID).CodeHash return ExampleContract{anyAmount, creator, creatorAddr, codeID, hash} } @@ -654,11 +596,11 @@ type ExampleContractInstance struct { } // SeedNewContractInstance sets the mock WasmEngine in keeper and calls store + instantiate to init the contract's metadata -func SeedNewContractInstance(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContractInstance { - tb.Helper() - exampleContract := StoreRandomContract(tb, ctx, keepers, mock) +func SeedNewContractInstance(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContractInstance { + t.Helper() + exampleContract := StoreRandomContract(t, ctx, keepers, mock) contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, exampleContract.CodeID, exampleContract.CreatorAddr, exampleContract.CreatorAddr, []byte(`{}`), "", nil) - require.NoError(tb, err) + require.NoError(t, err) return ExampleContractInstance{ ExampleContract: exampleContract, Contract: contractAddr, @@ -666,26 +608,24 @@ func SeedNewContractInstance(tb testing.TB, ctx sdk.Context, keepers TestKeepers } // StoreRandomContract sets the mock WasmEngine in keeper and calls store -func StoreRandomContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContract { - tb.Helper() - - return StoreRandomContractWithAccessConfig(tb, ctx, keepers, mock, nil) +func StoreRandomContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContract { + return StoreRandomContractWithAccessConfig(t, ctx, keepers, mock, nil) } func StoreRandomContractWithAccessConfig( - tb testing.TB, ctx sdk.Context, + t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine, cfg *types.AccessConfig, ) ExampleContract { - tb.Helper() + t.Helper() anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) creator, creatorAddr := keyPubAddr() - fundAccounts(tb, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) + fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) keepers.WasmKeeper.wasmVM = mock wasmCode := append(wasmIdent, rand.Bytes(10)...) codeID, checksum, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, cfg) - require.NoError(tb, err) + require.NoError(t, err) exampleContract := ExampleContract{InitialAmount: anyAmount, Creator: creator, CreatorAddr: creatorAddr, CodeID: codeID, Checksum: checksum} return exampleContract } @@ -702,25 +642,24 @@ type HackatomExampleInstance struct { } // InstantiateHackatomExampleContract load and instantiate the "./testdata/hackatom.wasm" contract -func InstantiateHackatomExampleContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance { - tb.Helper() - - contract := StoreHackatomExampleContract(tb, ctx, keepers) +func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance { + contract := StoreHackatomExampleContract(t, ctx, keepers) verifier, verifierAddr := keyPubAddr() - fundAccounts(tb, ctx, keepers.AccountKeeper, keepers.BankKeeper, verifierAddr, contract.InitialAmount) + fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, verifierAddr, contract.InitialAmount) beneficiary, beneficiaryAddr := keyPubAddr() - initMsgBz := HackatomExampleInitMsg{ + initMsgBz, err := json.Marshal(HackatomExampleInitMsg{ Verifier: verifierAddr, Beneficiary: beneficiaryAddr, - }.GetBytes(tb) + }) + require.NoError(t, err) initialAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) adminAddr := contract.CreatorAddr label := "demo contract to query" contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, contract.CodeID, contract.CreatorAddr, adminAddr, initMsgBz, label, initialAmount) - require.NoError(tb, err) + require.NoError(t, err) return HackatomExampleInstance{ ExampleContract: contract, Contract: contractAddr, @@ -741,15 +680,13 @@ type ExampleInstance struct { } // InstantiateReflectExampleContract load and instantiate the "./testdata/reflect.wasm" contract -func InstantiateReflectExampleContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleInstance { - tb.Helper() - - example := StoreReflectContract(tb, ctx, keepers) +func InstantiateReflectExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleInstance { + example := StoreReflectContract(t, ctx, keepers) initialAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) label := "demo contract to query" contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, example.CodeID, example.CreatorAddr, example.CreatorAddr, []byte("{}"), label, initialAmount) - require.NoError(tb, err) + require.NoError(t, err) return ExampleInstance{ ExampleContract: example, Contract: contractAddr, @@ -763,11 +700,9 @@ type HackatomExampleInitMsg struct { Beneficiary sdk.AccAddress `json:"beneficiary"` } -func (m HackatomExampleInitMsg) GetBytes(tb testing.TB) []byte { - tb.Helper() - +func (m HackatomExampleInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) - require.NoError(tb, err) + require.NoError(t, err) return initMsgBz } @@ -778,20 +713,25 @@ type IBCReflectExampleInstance struct { ReflectCodeID uint64 } -// InstantiateIBCReflectContract load and instantiate the "./testdata/ibc_reflect.wasm" contract -func InstantiateIBCReflectContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance { - tb.Helper() +func (m IBCReflectExampleInstance) GetBytes(t testing.TB) []byte { + initMsgBz, err := json.Marshal(m) + require.NoError(t, err) + return initMsgBz +} - reflectID := StoreReflectContract(tb, ctx, keepers).CodeID - ibcReflectID := StoreIBCReflectContract(tb, ctx, keepers).CodeID +// InstantiateIBCReflectContract load and instantiate the "./testdata/ibc_reflect.wasm" contract +func InstantiateIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance { + reflectID := StoreReflectContract(t, ctx, keepers).CodeID + ibcReflectID := StoreIBCReflectContract(t, ctx, keepers).CodeID - initMsgBz := IBCReflectInitMsg{ + initMsgBz, err := json.Marshal(IBCReflectInitMsg{ ReflectCodeID: reflectID, - }.GetBytes(tb) - adminAddr := RandomAccountAddress(tb) + }) + require.NoError(t, err) + adminAddr := RandomAccountAddress(t) contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, ibcReflectID, adminAddr, adminAddr, initMsgBz, "ibc-reflect-factory", nil) - require.NoError(tb, err) + require.NoError(t, err) return IBCReflectExampleInstance{ Admin: adminAddr, Contract: contractAddr, @@ -804,11 +744,9 @@ type IBCReflectInitMsg struct { ReflectCodeID uint64 `json:"reflect_code_id"` } -func (m IBCReflectInitMsg) GetBytes(tb testing.TB) []byte { - tb.Helper() - +func (m IBCReflectInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) - require.NoError(tb, err) + require.NoError(t, err) return initMsgBz } @@ -817,18 +755,16 @@ type BurnerExampleInitMsg struct { Delete uint32 `json:"delete"` } -func (m BurnerExampleInitMsg) GetBytes(tb testing.TB) []byte { - tb.Helper() +func (m BurnerExampleInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) - require.NoError(tb, err) + require.NoError(t, err) return initMsgBz } -func fundAccounts(tb testing.TB, ctx sdk.Context, am authkeeper.AccountKeeper, bank bankkeeper.Keeper, addr sdk.AccAddress, coins sdk.Coins) { - tb.Helper() +func fundAccounts(t testing.TB, ctx sdk.Context, am authkeeper.AccountKeeper, bank bankkeeper.Keeper, addr sdk.AccAddress, coins sdk.Coins) { acc := am.NewAccountWithAddress(ctx, addr) am.SetAccount(ctx, acc) - NewTestFaucet(tb, ctx, bank, minttypes.ModuleName, coins...).Fund(ctx, addr, coins...) + NewTestFaucet(t, ctx, bank, minttypes.ModuleName, coins...).Fund(ctx, addr, coins...) } var keyCounter uint64 diff --git a/x/wasm/keeper/wasmtesting/extension_mocks.go b/x/wasm/keeper/wasmtesting/extension_mocks.go index 3ab14c9a1c..0bf241cf6d 100644 --- a/x/wasm/keeper/wasmtesting/extension_mocks.go +++ b/x/wasm/keeper/wasmtesting/extension_mocks.go @@ -2,7 +2,6 @@ package wasmtesting import ( sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) type MockCoinTransferrer struct { @@ -17,10 +16,10 @@ func (m *MockCoinTransferrer) TransferCoins(ctx sdk.Context, fromAddr, toAddr sd } type AccountPrunerMock struct { - CleanupExistingAccountFn func(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) + CleanupExistingAccountFn func(ctx sdk.Context, existingAccount sdk.AccountI) (handled bool, err error) } -func (m AccountPrunerMock) CleanupExistingAccount(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) { +func (m AccountPrunerMock) CleanupExistingAccount(ctx sdk.Context, existingAccount sdk.AccountI) (handled bool, err error) { if m.CleanupExistingAccountFn == nil { panic("not expected to be called") } diff --git a/x/wasm/keeper/wasmtesting/gas_register.go b/x/wasm/keeper/wasmtesting/gas_register.go index d0f718af3a..e38abe4da8 100644 --- a/x/wasm/keeper/wasmtesting/gas_register.go +++ b/x/wasm/keeper/wasmtesting/gas_register.go @@ -3,71 +3,71 @@ package wasmtesting import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) // MockGasRegister mock that implements keeper.GasRegister type MockGasRegister struct { - CompileCostFn func(byteLength int) sdk.Gas - NewContractInstanceCostFn func(pinned bool, msgLen int) sdk.Gas - InstantiateContractCostFn func(pinned bool, msgLen int) sdk.Gas - ReplyCostFn func(pinned bool, reply wasmvmtypes.Reply) sdk.Gas - EventCostsFn func(evts []wasmvmtypes.EventAttribute) sdk.Gas - ToWasmVMGasFn func(source sdk.Gas) uint64 - FromWasmVMGasFn func(source uint64) sdk.Gas - UncompressCostsFn func(byteLength int) sdk.Gas + CompileCostFn func(byteLength int) storetypes.Gas + NewContractInstanceCostFn func(pinned bool, msgLen int) storetypes.Gas + InstantiateContractCostFn func(pinned bool, msgLen int) storetypes.Gas + ReplyCostFn func(pinned bool, reply wasmvmtypes.Reply) storetypes.Gas + EventCostsFn func(evts []wasmvmtypes.EventAttribute) storetypes.Gas + ToWasmVMGasFn func(source storetypes.Gas) uint64 + FromWasmVMGasFn func(source uint64) storetypes.Gas + UncompressCostsFn func(byteLength int) storetypes.Gas } -func (m MockGasRegister) NewContractInstanceCosts(pinned bool, msgLen int) sdk.Gas { +func (m MockGasRegister) NewContractInstanceCosts(pinned bool, msgLen int) storetypes.Gas { if m.NewContractInstanceCostFn == nil { panic("not expected to be called") } return m.NewContractInstanceCostFn(pinned, msgLen) } -func (m MockGasRegister) CompileCosts(byteLength int) sdk.Gas { +func (m MockGasRegister) CompileCosts(byteLength int) storetypes.Gas { if m.CompileCostFn == nil { panic("not expected to be called") } return m.CompileCostFn(byteLength) } -func (m MockGasRegister) UncompressCosts(byteLength int) sdk.Gas { +func (m MockGasRegister) UncompressCosts(byteLength int) storetypes.Gas { if m.UncompressCostsFn == nil { panic("not expected to be called") } return m.UncompressCostsFn(byteLength) } -func (m MockGasRegister) InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas { +func (m MockGasRegister) InstantiateContractCosts(pinned bool, msgLen int) storetypes.Gas { if m.InstantiateContractCostFn == nil { panic("not expected to be called") } return m.InstantiateContractCostFn(pinned, msgLen) } -func (m MockGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas { +func (m MockGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) storetypes.Gas { if m.ReplyCostFn == nil { panic("not expected to be called") } return m.ReplyCostFn(pinned, reply) } -func (m MockGasRegister) EventCosts(evts []wasmvmtypes.EventAttribute, _ wasmvmtypes.Events) sdk.Gas { +func (m MockGasRegister) EventCosts(evts []wasmvmtypes.EventAttribute, _ wasmvmtypes.Events) storetypes.Gas { if m.EventCostsFn == nil { panic("not expected to be called") } return m.EventCostsFn(evts) } -func (m MockGasRegister) ToWasmVMGas(source sdk.Gas) uint64 { +func (m MockGasRegister) ToWasmVMGas(source storetypes.Gas) uint64 { if m.ToWasmVMGasFn == nil { panic("not expected to be called") } return m.ToWasmVMGasFn(source) } -func (m MockGasRegister) FromWasmVMGas(source uint64) sdk.Gas { +func (m MockGasRegister) FromWasmVMGas(source uint64) storetypes.Gas { if m.FromWasmVMGasFn == nil { panic("not expected to be called") } diff --git a/x/wasm/keeper/wasmtesting/mock_keepers.go b/x/wasm/keeper/wasmtesting/mock_keepers.go index 8cae741855..beb4f5eab1 100644 --- a/x/wasm/keeper/wasmtesting/mock_keepers.go +++ b/x/wasm/keeper/wasmtesting/mock_keepers.go @@ -1,11 +1,11 @@ package wasmtesting import ( - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/keeper/wasmtesting/store.go b/x/wasm/keeper/wasmtesting/store.go index 6548c8bae2..2cb9a6de6f 100644 --- a/x/wasm/keeper/wasmtesting/store.go +++ b/x/wasm/keeper/wasmtesting/store.go @@ -1,13 +1,12 @@ package wasmtesting import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) // MockCommitMultiStore mock with a CacheMultiStore to capture commits type MockCommitMultiStore struct { - sdk.CommitMultiStore + storetypes.CommitMultiStore Committed []bool } @@ -17,7 +16,7 @@ func (m *MockCommitMultiStore) CacheMultiStore() storetypes.CacheMultiStore { } type mockCMS struct { - sdk.CommitMultiStore + storetypes.CommitMultiStore committed *bool } diff --git a/x/wasm/migrations/v1/store.go b/x/wasm/migrations/v1/store.go index f970d85c09..ab245b0e2a 100644 --- a/x/wasm/migrations/v1/store.go +++ b/x/wasm/migrations/v1/store.go @@ -1,17 +1,19 @@ package v1 import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) // AddToSecondIndexFn creates a secondary index entry for the creator fo the contract -type AddToSecondIndexFn func(ctx sdk.Context, creatorAddress sdk.AccAddress, position *types.AbsoluteTxPosition, contractAddress sdk.AccAddress) +type AddToSecondIndexFn func(ctx context.Context, creatorAddress sdk.AccAddress, position *types.AbsoluteTxPosition, contractAddress sdk.AccAddress) error // Keeper abstract keeper type wasmKeeper interface { - IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) + IterateContractInfo(ctx context.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) } // Migrator is a struct for handling in-place store migrations. @@ -29,7 +31,10 @@ func NewMigrator(k wasmKeeper, fn AddToSecondIndexFn) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { m.keeper.IterateContractInfo(ctx, func(contractAddr sdk.AccAddress, contractInfo types.ContractInfo) bool { creator := sdk.MustAccAddressFromBech32(contractInfo.Creator) - m.addToSecondIndexFn(ctx, creator, contractInfo.Created, contractAddr) + err := m.addToSecondIndexFn(ctx, creator, contractInfo.Created, contractAddr) + if err != nil { + panic(err) + } return false }) return nil diff --git a/x/wasm/migrations/v2/store.go b/x/wasm/migrations/v2/store.go index 64c94ba837..de1490dbca 100644 --- a/x/wasm/migrations/v2/store.go +++ b/x/wasm/migrations/v2/store.go @@ -1,8 +1,9 @@ package v2 import ( + corestoretypes "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/exported" @@ -13,8 +14,8 @@ import ( // version 3. Specifically, it takes the parameters that are currently stored // and managed by the x/params module and stores them directly into the x/wasm // module state. -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) +func MigrateStore(ctx sdk.Context, storeService corestoretypes.KVStoreService, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { + store := storeService.OpenKVStore(ctx) var currParams types.Params legacySubspace.GetParamSet(ctx, &currParams) @@ -27,7 +28,5 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace return err } - store.Set(types.ParamsKey, bz) - - return nil + return store.Set(types.ParamsKey, bz) } diff --git a/x/wasm/migrations/v2/store_test.go b/x/wasm/migrations/v2/store_test.go index 3f21bf4555..df52ef3686 100644 --- a/x/wasm/migrations/v2/store_test.go +++ b/x/wasm/migrations/v2/store_test.go @@ -5,6 +5,9 @@ import ( "github.com/stretchr/testify/require" + storetypes "cosmossdk.io/store/types" + + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -29,13 +32,13 @@ func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { func TestMigrate(t *testing.T) { cdc := moduletestutil.MakeTestEncodingConfig(wasm.AppModuleBasic{}).Codec - storeKey := sdk.NewKVStoreKey(types.StoreKey) - tKey := sdk.NewTransientStoreKey("transient_test") + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) store := ctx.KVStore(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v2.MigrateStore(ctx, storeKey, legacySubspace, cdc)) + require.NoError(t, v2.MigrateStore(ctx, runtime.NewKVStoreService(storeKey), legacySubspace, cdc)) var res types.Params bz := store.Get(types.ParamsKey) diff --git a/x/wasm/migrations/v3/store.go b/x/wasm/migrations/v3/store.go index 0e72e300e9..a4408ea61e 100644 --- a/x/wasm/migrations/v3/store.go +++ b/x/wasm/migrations/v3/store.go @@ -1,22 +1,25 @@ package v3 import ( + "context" "encoding/binary" + corestoretypes "cosmossdk.io/core/store" + "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) // StoreCodeInfoFn stores code info -type StoreCodeInfoFn func(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo) +type StoreCodeInfoFn func(ctx context.Context, codeID uint64, codeInfo types.CodeInfo) // Keeper abstract keeper type wasmKeeper interface { - SetParams(ctx sdk.Context, ps types.Params) error + SetParams(ctx context.Context, ps types.Params) error } // Migrator is a struct for handling in-place store migrations. @@ -31,10 +34,13 @@ func NewMigrator(k wasmKeeper, fn StoreCodeInfoFn) Migrator { } // Migrate3to4 migrates from version 3 to 4. -func (m Migrator) Migrate3to4(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { +func (m Migrator) Migrate3to4(ctx sdk.Context, storeService corestoretypes.KVStoreService, cdc codec.BinaryCodec) error { var legacyParams Params - store := ctx.KVStore(storeKey) - bz := store.Get(types.ParamsKey) + store := storeService.OpenKVStore(ctx) + bz, err := store.Get(types.ParamsKey) + if err != nil { + return err + } if bz != nil { cdc.MustUnmarshal(bz, &legacyParams) @@ -53,7 +59,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context, storeKey storetypes.StoreKey, cdc } } - prefixStore := prefix.NewStore(store, types.CodeKeyPrefix) + prefixStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.CodeKeyPrefix) iter := prefixStore.Iterator(nil, nil) defer iter.Close() diff --git a/x/wasm/module.go b/x/wasm/module.go index 5caf74e5c0..8d5c8dc7f8 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -195,15 +195,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw return cdc.MustMarshalJSON(gs) } -// BeginBlock returns the begin blocker for the wasm module. -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock returns the end blocker for the wasm module. It returns no validator -// updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} - // ____________________________________________________________________________ // AppModuleSimulation functions @@ -219,12 +210,12 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei } // RegisterStoreDecoder registers a decoder for supply module's types -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations(&simState, am.accountKeeper, am.bankKeeper, am.keeper) + return simulation.WeightedOperations(simState.AppParams, am.accountKeeper, am.bankKeeper, am.keeper) } // ____________________________________________________________________________ diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index 95638d521f..a68c1d9dc8 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -556,7 +556,7 @@ func assertAttribute(t *testing.T, key, value string, attr abci.EventAttribute) func assertCodeList(t *testing.T, q *baseapp.GRPCQueryRouter, ctx sdk.Context, expectedNum int, marshaler codec.Codec) { t.Helper() path := "/cosmwasm.wasm.v1.Query/Codes" - resp, sdkerr := q.Route(path)(ctx, abci.RequestQuery{Path: path}) + resp, sdkerr := q.Route(path)(ctx, &abci.RequestQuery{Path: path}) require.NoError(t, sdkerr) require.True(t, resp.IsOK()) @@ -577,7 +577,7 @@ func assertCodeBytes(t *testing.T, q *baseapp.GRPCQueryRouter, ctx sdk.Context, require.NoError(t, err) path := "/cosmwasm.wasm.v1.Query/Code" - resp, err := q.Route(path)(ctx, abci.RequestQuery{Path: path, Data: bz}) + resp, err := q.Route(path)(ctx, &abci.RequestQuery{Path: path, Data: bz}) if len(expectedBytes) == 0 { require.Equal(t, types.ErrNoSuchCodeFn(codeID).Wrapf("code id %d", codeID).Error(), err.Error()) return @@ -597,7 +597,7 @@ func assertContractList(t *testing.T, q *baseapp.GRPCQueryRouter, ctx sdk.Contex require.NoError(t, err) path := "/cosmwasm.wasm.v1.Query/ContractsByCode" - resp, sdkerr := q.Route(path)(ctx, abci.RequestQuery{Path: path, Data: bz}) + resp, sdkerr := q.Route(path)(ctx, &abci.RequestQuery{Path: path, Data: bz}) if len(expContractAddrs) == 0 { assert.ErrorIs(t, err, types.ErrNotFound) return @@ -622,7 +622,7 @@ func assertContractState(t *testing.T, q *baseapp.GRPCQueryRouter, ctx sdk.Conte require.NoError(t, err) path := "/cosmwasm.wasm.v1.Query/RawContractState" - resp, sdkerr := q.Route(path)(ctx, abci.RequestQuery{Path: path, Data: bz}) + resp, sdkerr := q.Route(path)(ctx, &abci.RequestQuery{Path: path, Data: bz}) require.NoError(t, sdkerr) require.True(t, resp.IsOK()) bz = resp.Value @@ -640,7 +640,7 @@ func assertContractInfo(t *testing.T, q *baseapp.GRPCQueryRouter, ctx sdk.Contex require.NoError(t, err) path := "/cosmwasm.wasm.v1.Query/ContractInfo" - resp, sdkerr := q.Route(path)(ctx, abci.RequestQuery{Path: path, Data: bz}) + resp, sdkerr := q.Route(path)(ctx, &abci.RequestQuery{Path: path, Data: bz}) require.NoError(t, sdkerr) require.True(t, resp.IsOK()) bz = resp.Value diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index a9eadc7f90..06ee186b0f 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -7,10 +7,10 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/wasm/relay_test.go b/x/wasm/relay_test.go index 91a6a37d15..b8017e10fc 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -8,15 +8,15 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,20 +33,19 @@ func TestFromIBCTransferToContract(t *testing.T) { // then the contract can handle the receiving side of an ics20 transfer // that was started on chain A via ibc transfer module - transferAmount := sdk.NewInt(1) + transferAmount := sdkmath.NewInt(1) specs := map[string]struct { contract wasmtesting.IBCContractCallbacks setupContract func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) expChainAPendingSendPackets int expChainBPendingSendPackets int - expChainABalanceDiff math.Int - expChainBBalanceDiff math.Int + expChainABalanceDiff sdkmath.Int + expChainBBalanceDiff sdkmath.Int expErr bool }{ "ack": { contract: &ackReceiverContract{}, setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { - t.Helper() c := contract.(*ackReceiverContract) c.t = t c.chain = chain @@ -59,26 +58,24 @@ func TestFromIBCTransferToContract(t *testing.T) { "nack": { contract: &nackReceiverContract{}, setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { - t.Helper() c := contract.(*nackReceiverContract) c.t = t }, expChainAPendingSendPackets: 0, expChainBPendingSendPackets: 0, - expChainABalanceDiff: sdk.ZeroInt(), - expChainBBalanceDiff: sdk.ZeroInt(), + expChainABalanceDiff: sdkmath.ZeroInt(), + expChainBBalanceDiff: sdkmath.ZeroInt(), }, "error": { contract: &errorReceiverContract{}, setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { - t.Helper() c := contract.(*errorReceiverContract) c.t = t }, expChainAPendingSendPackets: 1, expChainBPendingSendPackets: 0, expChainABalanceDiff: transferAmount.Neg(), - expChainBBalanceDiff: sdk.ZeroInt(), + expChainBBalanceDiff: sdkmath.ZeroInt(), expErr: true, }, } @@ -187,7 +184,7 @@ func TestContractCanInitiateIBCTransferMsg(t *testing.T) { // when contract is triggered to send IBCTransferMsg receiverAddress := chainB.SenderAccount.GetAddress() - coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) // start transfer from chainA to chainB startMsg := &types.MsgExecuteContract{ @@ -260,7 +257,7 @@ func TestContractCanEmulateIBCTransferMessage(t *testing.T) { // when contract is triggered to send the ibc package to chain B timeout := uint64(chainB.LastHeader.Header.Time.Add(time.Hour).UnixNano()) // enough time to not timeout receiverAddress := chainB.SenderAccount.GetAddress() - coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) // start transfer from chainA to chainB startMsg := &types.MsgExecuteContract{ @@ -337,7 +334,7 @@ func TestContractCanEmulateIBCTransferMessageWithTimeout(t *testing.T) { // when contract is triggered to send the ibc package to chain B timeout := uint64(chainB.LastHeader.Header.Time.Add(time.Nanosecond).UnixNano()) // will timeout receiverAddress := chainB.SenderAccount.GetAddress() - coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) initialContractBalance := chainA.Balance(myContractAddr, sdk.DefaultBondDenom) initialSenderBalance := chainA.Balance(chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) @@ -425,7 +422,7 @@ func TestContractEmulateIBCTransferMessageOnDiffContractIBCChannel(t *testing.T) // when contract is triggered to send the ibc package to chain B timeout := uint64(chainB.LastHeader.Header.Time.Add(time.Hour).UnixNano()) // enough time to not timeout receiverAddress := chainB.SenderAccount.GetAddress() - coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) // start transfer from chainA - A2 to chainB via IBC channel startMsg := &types.MsgExecuteContract{ @@ -539,7 +536,7 @@ func TestContractHandlesChannelCloseNotOwned(t *testing.T) { Msg: closeIBCChannel{ ChannelID: path.EndpointA.ChannelID, }.GetBytes(), - Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } _, err := chainA.SendMsgs(closeIBCChannelMsg) @@ -632,7 +629,7 @@ func (s *sendEmulatedIBCTransferContract) IBCPacketTimeout(_ wasmvm.Checksum, _ if err := data.ValidateBasic(); err != nil { return nil, 0, err } - amount, _ := sdk.NewIntFromString(data.Amount) + amount, _ := sdkmath.NewIntFromString(data.Amount) returnTokens := &wasmvmtypes.BankMsg{ Send: &wasmvmtypes.SendMsg{ diff --git a/x/wasm/simulation/genesis.go b/x/wasm/simulation/genesis.go index 3c687f07e2..94db6be27f 100644 --- a/x/wasm/simulation/genesis.go +++ b/x/wasm/simulation/genesis.go @@ -14,7 +14,8 @@ func RandomizedGenState(simstate *module.SimulationState) { Codes: nil, Contracts: nil, Sequences: []types.Sequence{ - {IDKey: types.KeySequenceCodeID, Value: simstate.Rand.Uint64()}, + {IDKey: types.KeySequenceCodeID, Value: simstate.Rand.Uint64() % 1_000_000_000}, + {IDKey: types.KeySequenceInstanceID, Value: simstate.Rand.Uint64() % 1_000_000_000}, }, } diff --git a/x/wasm/simulation/operations.go b/x/wasm/simulation/operations.go index 6e937badb4..845aa33963 100644 --- a/x/wasm/simulation/operations.go +++ b/x/wasm/simulation/operations.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "encoding/json" "math/rand" "os" @@ -13,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -40,20 +40,20 @@ const ( // WasmKeeper is a subset of the wasm keeper used by simulations type WasmKeeper interface { GetAuthority() string - GetParams(ctx sdk.Context) types.Params - IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo) bool) - IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) - PeekAutoIncrementID(ctx sdk.Context, lastIDKey []byte) uint64 + GetParams(ctx context.Context) types.Params + IterateCodeInfos(ctx context.Context, cb func(uint64, types.CodeInfo) bool) + IterateContractInfo(ctx context.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) + QuerySmart(ctx context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + PeekAutoIncrementID(ctx context.Context, lastIDKey []byte) (uint64, error) } type BankKeeper interface { simulation.BankKeeper - IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool + IsSendEnabledCoin(ctx context.Context, coin sdk.Coin) bool } // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - simstate *module.SimulationState, + appParams simtypes.AppParams, ak types.AccountKeeper, bk BankKeeper, wasmKeeper WasmKeeper, @@ -67,42 +67,27 @@ func WeightedOperations( weightMsgMigrateContract int wasmContractPath string ) - - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgStoreCode, &weightMsgStoreCode, nil, - func(_ *rand.Rand) { - weightMsgStoreCode = params.DefaultWeightMsgStoreCode - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgInstantiateContract, &weightMsgInstantiateContract, nil, - func(_ *rand.Rand) { - weightMsgInstantiateContract = params.DefaultWeightMsgInstantiateContract - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgExecuteContract, &weightMsgInstantiateContract, nil, - func(_ *rand.Rand) { - weightMsgExecuteContract = params.DefaultWeightMsgExecuteContract - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgUpdateAdmin, &weightMsgUpdateAdmin, nil, - func(_ *rand.Rand) { - weightMsgUpdateAdmin = params.DefaultWeightMsgUpdateAdmin - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgClearAdmin, &weightMsgClearAdmin, nil, - func(_ *rand.Rand) { - weightMsgClearAdmin = params.DefaultWeightMsgClearAdmin - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgMigrateContract, &weightMsgMigrateContract, nil, - func(_ *rand.Rand) { - weightMsgMigrateContract = params.DefaultWeightMsgMigrateContract - }, - ) - simstate.AppParams.GetOrGenerate(simstate.Cdc, OpReflectContractPath, &wasmContractPath, nil, - func(_ *rand.Rand) { - wasmContractPath = "" - }, - ) + appParams.GetOrGenerate(OpWeightMsgStoreCode, &weightMsgStoreCode, nil, func(_ *rand.Rand) { + weightMsgStoreCode = params.DefaultWeightMsgStoreCode + }) + appParams.GetOrGenerate(OpWeightMsgInstantiateContract, &weightMsgInstantiateContract, nil, func(_ *rand.Rand) { + weightMsgInstantiateContract = params.DefaultWeightMsgInstantiateContract + }) + appParams.GetOrGenerate(OpWeightMsgExecuteContract, &weightMsgInstantiateContract, nil, func(_ *rand.Rand) { + weightMsgExecuteContract = params.DefaultWeightMsgExecuteContract + }) + appParams.GetOrGenerate(OpWeightMsgUpdateAdmin, &weightMsgUpdateAdmin, nil, func(_ *rand.Rand) { + weightMsgUpdateAdmin = params.DefaultWeightMsgUpdateAdmin + }) + appParams.GetOrGenerate(OpWeightMsgClearAdmin, &weightMsgClearAdmin, nil, func(_ *rand.Rand) { + weightMsgClearAdmin = params.DefaultWeightMsgClearAdmin + }) + appParams.GetOrGenerate(OpWeightMsgMigrateContract, &weightMsgMigrateContract, nil, func(_ *rand.Rand) { + weightMsgMigrateContract = params.DefaultWeightMsgMigrateContract + }) + appParams.GetOrGenerate(OpReflectContractPath, &wasmContractPath, nil, func(_ *rand.Rand) { + wasmContractPath = "" + }) var wasmBz []byte if wasmContractPath == "" { @@ -497,7 +482,6 @@ func BuildOperationInput( TxGen: txConfig, Cdc: nil, Msg: msg, - MsgType: msg.Type(), Context: ctx, SimAccount: simAccount, AccountKeeper: ak, diff --git a/x/wasm/types/authz.go b/x/wasm/types/authz.go index 7a55dda860..e0b4945961 100644 --- a/x/wasm/types/authz.go +++ b/x/wasm/types/authz.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "context" "strings" wasmvm "github.com/CosmWasm/wasmvm" @@ -44,7 +45,7 @@ func (a StoreCodeAuthorization) MsgTypeURL() string { } // Accept implements Authorization.Accept. -func (a *StoreCodeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { +func (a *StoreCodeAuthorization) Accept(ctx context.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { storeMsg, ok := msg.(*MsgStoreCode) if !ok { return authztypes.AcceptResponse{}, sdkerrors.ErrInvalidRequest.Wrap("unknown msg type") @@ -58,7 +59,8 @@ func (a *StoreCodeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authztype if !ok { return authztypes.AcceptResponse{}, sdkerrors.ErrNotFound.Wrap("gas register") } - ctx.GasMeter().ConsumeGas(gasRegister.UncompressCosts(len(code)), "Uncompress gzip bytecode") + sdk.UnwrapSDKContext(ctx).GasMeter(). + ConsumeGas(gasRegister.UncompressCosts(len(code)), "Uncompress gzip bytecode") wasmCode, err := ioutils.Uncompress(code, int64(MaxWasmSize)) if err != nil { return authztypes.AcceptResponse{}, sdkerrors.ErrInvalidRequest.Wrap("uncompress wasm archive") @@ -163,8 +165,8 @@ func (a ContractExecutionAuthorization) NewAuthz(g []ContractGrant) authztypes.A } // Accept implements Authorization.Accept. -func (a *ContractExecutionAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { - return AcceptGrantedMessage[*MsgExecuteContract](ctx, a.Grants, msg, a) +func (a *ContractExecutionAuthorization) Accept(goCtx context.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { + return AcceptGrantedMessage[*MsgExecuteContract](sdk.UnwrapSDKContext(goCtx), a.Grants, msg, a) } // ValidateBasic implements Authorization.ValidateBasic. @@ -195,8 +197,8 @@ func (a ContractMigrationAuthorization) MsgTypeURL() string { } // Accept implements Authorization.Accept. -func (a *ContractMigrationAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { - return AcceptGrantedMessage[*MsgMigrateContract](ctx, a.Grants, msg, a) +func (a *ContractMigrationAuthorization) Accept(goCtx context.Context, msg sdk.Msg) (authztypes.AcceptResponse, error) { + return AcceptGrantedMessage[*MsgMigrateContract](sdk.UnwrapSDKContext(goCtx), a.Grants, msg, a) } // NewAuthz factory method to create an Authorization with updated grants diff --git a/x/wasm/types/authz.pb.go b/x/wasm/types/authz.pb.go index eb4110acd0..3213bcf1f3 100644 --- a/x/wasm/types/authz.pb.go +++ b/x/wasm/types/authz.pb.go @@ -557,56 +557,57 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/authz.proto", fileDescriptor_36ff3a20cf32b258) } var fileDescriptor_36ff3a20cf32b258 = []byte{ - // 772 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xee, 0x02, 0x1f, 0x1f, 0x1d, 0xe0, 0xfb, 0xb1, 0xe1, 0x6b, 0x5a, 0x20, 0x5b, 0xb2, 0xdf, - 0xaf, 0x4a, 0xd2, 0xdd, 0x14, 0xe3, 0xa5, 0x07, 0x4d, 0x5b, 0x45, 0x8d, 0x60, 0xcc, 0xaa, 0x81, - 0x78, 0x69, 0xa6, 0xdb, 0x61, 0x3b, 0xb2, 0x3b, 0xd3, 0xec, 0x4c, 0x81, 0x92, 0x18, 0xef, 0x9e, - 0xbc, 0x79, 0xf5, 0x68, 0x3c, 0x71, 0xe8, 0xd1, 0x3f, 0x80, 0x70,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0x36, 0xd2, 0xbf, 0xbd, 0x14, 0x35, 0x59, - 0x75, 0x64, 0x33, 0x7d, 0x05, 0x8c, 0xae, 0x61, 0x9f, 0xa3, 0x30, 0x39, 0x7c, 0x4e, 0xdb, 0x6b, - 0x7b, 0xad, 0xec, 0xbf, 0xe7, 0xb7, 0x5d, 0x14, 0x5d, 0x56, 0x1d, 0xd5, 0xce, 0x24, 0x60, 0x72, - 0x19, 0x6e, 0x95, 0xa0, 0xef, 0x33, 0x81, 0xa8, 0xcf, 0x82, 0x78, 0x88, 0x02, 0x88, 0x09, 0x26, - 0x9e, 0x10, 0x37, 0xe2, 0x74, 0x03, 0xf9, 0x5b, 0x17, 0x25, 0x1e, 0x5d, 0xaf, 0x2e, 0xae, 0xb7, - 0xa7, 0xbd, 0xf9, 0x41, 0x13, 0x80, 0x8b, 0x0d, 0x52, 0x55, 0x80, 0xcf, 0xc1, 0xaf, 0x30, 0xa0, - 0x8d, 0xae, 0xe9, 0x52, 0x96, 0x72, 0x4f, 0x34, 0x6e, 0x3a, 0xe6, 0x29, 0x51, 0x4c, 0x8a, 0x37, - 0x22, 0xbb, 0xbd, 0xff, 0x9c, 0xce, 0x78, 0x98, 0xd7, 0x1a, 0x15, 0xcb, 0xa5, 0x81, 0x9a, 0x54, - 0xea, 0x27, 0xcb, 0xaa, 0xeb, 0x6a, 0xf8, 0x44, 0x05, 0x4c, 0x5a, 0xb3, 0x0d, 0x70, 0x49, 0xfa, - 0x5d, 0xb2, 0xe6, 0x37, 0xe1, 0x85, 0xa0, 0x82, 0x09, 0xaa, 0x4a, 0xfa, 0xff, 0x83, 0xdf, 0xdd, - 0x48, 0x5e, 0xb9, 0xff, 0xd4, 0x7e, 0x13, 0x61, 0xa7, 0x1d, 0x3d, 0xa9, 0x73, 0xe8, 0x0a, 0xea, - 0xec, 0x51, 0x65, 0xba, 0x20, 0x51, 0xf0, 0x7d, 0xba, 0x59, 0xf0, 0xfd, 0x65, 0xc4, 0x18, 0xf4, - 0x10, 0x93, 0xce, 0xc9, 0xdf, 0xbf, 0xb0, 0xc7, 0xba, 0x73, 0x74, 0x70, 0x2b, 0xf3, 0x05, 0x48, - 0x45, 0xff, 0xbf, 0x3a, 0x47, 0x55, 0x95, 0x79, 0x80, 0x9a, 0x2a, 0xa9, 0xeb, 0x60, 0x64, 0x1d, - 0x35, 0xa5, 0x27, 0xe2, 0x8e, 0x78, 0xcf, 0x2f, 0xfd, 0x14, 0xb6, 0x21, 0xb1, 0xcf, 0x42, 0x30, - 0xdf, 0x68, 0x20, 0xd1, 0x97, 0x6d, 0x83, 0x2f, 0x80, 0xb1, 0x40, 0x45, 0x04, 0x81, 0x89, 0x62, - 0xe2, 0xfb, 0x41, 0x5a, 0x77, 0xe0, 0x66, 0x67, 0x58, 0xc9, 0xb4, 0xd3, 0xd9, 0x77, 0xb9, 0x83, - 0x19, 0x08, 0x5f, 0xbc, 0xbd, 0xfb, 0xd5, 0x88, 0xed, 0x1e, 0x1a, 0xda, 0xfe, 0xa1, 0xa1, 0x7d, - 0x39, 0x34, 0xb4, 0xd7, 0x47, 0x46, 0x6c, 0xff, 0xc8, 0x88, 0x7d, 0x3c, 0x32, 0x62, 0xcf, 0xfe, - 0x3b, 0x61, 0x8a, 0x12, 0x65, 0xc1, 0x4a, 0xfb, 0xc3, 0x5b, 0xb5, 0xb7, 0xe4, 0x07, 0x58, 0x18, - 0xa3, 0x32, 0x2a, 0x66, 0xc3, 0xf5, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x55, 0xf8, 0x5e, 0x18, - 0x1f, 0x08, 0x00, 0x00, + // 794 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x4f, 0x1b, 0x47, + 0x14, 0xf6, 0x02, 0xa5, 0x78, 0x80, 0xfe, 0x58, 0x51, 0xcb, 0x06, 0xb4, 0x46, 0xdb, 0x5f, 0x2e, + 0x92, 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 0xd7, 0x3b, 0x9f, 0x64, + 0xcf, 0xde, 0x95, 0x9f, 0x66, 0x21, 0x8c, 0xda, 0xb8, 0x98, 0x0d, 0x3f, 0x7f, 0x0c, 0x00, 0x00, + 0xff, 0xff, 0xe7, 0xfe, 0xd3, 0xec, 0x39, 0x08, 0x00, 0x00, } func (m *StoreCodeAuthorization) Marshal() (dAtA []byte, err error) { diff --git a/x/wasm/types/authz_test.go b/x/wasm/types/authz_test.go index 65667218b9..12ea9e07b5 100644 --- a/x/wasm/types/authz_test.go +++ b/x/wasm/types/authz_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -97,7 +99,7 @@ func TestContractAuthzFilterAccept(t *testing.T) { filter ContractAuthzFilterX src RawContractMessage exp bool - expGasConsumed sdk.Gas + expGasConsumed storetypes.Gas expErr bool }{ "allow all - accepts json obj": { @@ -119,25 +121,25 @@ func TestContractAuthzFilterAccept(t *testing.T) { filter: NewAcceptedMessageKeysFilter("foo"), src: []byte(`{"foo": "bar"}`), exp: true, - expGasConsumed: sdk.Gas(len(`{"foo": "bar"}`)), + expGasConsumed: storetypes.Gas(len(`{"foo": "bar"}`)), }, "allowed key - multiple": { filter: NewAcceptedMessageKeysFilter("foo", "other"), src: []byte(`{"other": "value"}`), exp: true, - expGasConsumed: sdk.Gas(len(`{"other": "value"}`)), + expGasConsumed: storetypes.Gas(len(`{"other": "value"}`)), }, "allowed key - non accepted key": { filter: NewAcceptedMessageKeysFilter("foo"), src: []byte(`{"bar": "value"}`), exp: false, - expGasConsumed: sdk.Gas(len(`{"bar": "value"}`)), + expGasConsumed: storetypes.Gas(len(`{"bar": "value"}`)), }, "allowed key - unsupported array msg": { filter: NewAcceptedMessageKeysFilter("foo", "other"), src: []byte(`[{"foo":"bar"}]`), expErr: false, - expGasConsumed: sdk.Gas(len(`[{"foo":"bar"}]`)), + expGasConsumed: storetypes.Gas(len(`[{"foo":"bar"}]`)), }, "allowed key - invalid msg": { filter: NewAcceptedMessageKeysFilter("foo", "other"), @@ -177,7 +179,7 @@ func TestContractAuthzFilterAccept(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - gm := sdk.NewGasMeter(1_000_000) + gm := storetypes.NewGasMeter(1_000_000) allowed, gotErr := spec.filter.Accept(sdk.Context{}.WithGasMeter(gm), spec.src) // then @@ -193,7 +195,7 @@ func TestContractAuthzFilterAccept(t *testing.T) { } func TestContractAuthzLimitValidate(t *testing.T) { - oneToken := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) + oneToken := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt()) specs := map[string]struct { src ContractAuthzLimitX expErr bool @@ -220,11 +222,11 @@ func TestContractAuthzLimitValidate(t *testing.T) { expErr: true, }, "max funds - contains empty value": { - src: &MaxFundsLimit{Amounts: sdk.Coins{oneToken, sdk.NewCoin("other", sdk.ZeroInt())}.Sort()}, + src: &MaxFundsLimit{Amounts: sdk.Coins{oneToken, sdk.NewCoin("other", sdkmath.ZeroInt())}.Sort()}, expErr: true, }, "max funds - unsorted": { - src: &MaxFundsLimit{Amounts: sdk.Coins{oneToken, sdk.NewCoin("other", sdk.OneInt())}}, + src: &MaxFundsLimit{Amounts: sdk.Coins{oneToken, sdk.NewCoin("other", sdkmath.OneInt())}}, expErr: true, }, "combined": { @@ -260,8 +262,8 @@ func TestContractAuthzLimitValidate(t *testing.T) { } func TestContractAuthzLimitAccept(t *testing.T) { - oneToken := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) - otherToken := sdk.NewCoin("other", sdk.OneInt()) + oneToken := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt()) + otherToken := sdk.NewCoin("other", sdkmath.OneInt()) specs := map[string]struct { limit ContractAuthzLimitX src AuthzableWasmMsg @@ -280,7 +282,7 @@ func TestContractAuthzLimitAccept(t *testing.T) { }, "max calls - accepted with zero fund set": { limit: NewMaxCallsLimit(1), - src: &MsgExecuteContract{Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.ZeroInt()))}, + src: &MsgExecuteContract{Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.ZeroInt()))}, exp: &ContractAuthzLimitAcceptResult{Accepted: true, DeleteLimit: true}, }, "max calls - rejected with some fund transfer": { @@ -558,7 +560,7 @@ func TestAcceptGrantedMessage(t *testing.T) { }, }, "accepted and not updated - limit not touched": { - auth: NewContractExecutionAuthorization(mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), NewAllowAllMessagesFilter())), + auth: NewContractExecutionAuthorization(mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), NewAllowAllMessagesFilter())), msg: &MsgExecuteContract{ Sender: sdk.AccAddress(randBytes(SDKAddrLen)).String(), Contract: myContractAddr.String(), @@ -593,21 +595,21 @@ func TestAcceptGrantedMessage(t *testing.T) { "accepted and updated - multi, one updated": { auth: NewContractExecutionAuthorization( mustGrant(otherContractAddr, NewMaxCallsLimit(1), NewAllowAllMessagesFilter()), - mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2))), NewAcceptedMessageKeysFilter("bar")), - mustGrant(myContractAddr, NewCombinedLimit(2, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2))), NewAcceptedMessageKeysFilter("foo")), + mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2))), NewAcceptedMessageKeysFilter("bar")), + mustGrant(myContractAddr, NewCombinedLimit(2, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2))), NewAcceptedMessageKeysFilter("foo")), ), msg: &MsgExecuteContract{ Sender: sdk.AccAddress(randBytes(SDKAddrLen)).String(), Contract: myContractAddr.String(), Msg: []byte(`{"foo":"bar"}`), - Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), + Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), }, expResult: authztypes.AcceptResponse{ Accept: true, Updated: NewContractExecutionAuthorization( mustGrant(otherContractAddr, NewMaxCallsLimit(1), NewAllowAllMessagesFilter()), - mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2))), NewAcceptedMessageKeysFilter("bar")), - mustGrant(myContractAddr, NewCombinedLimit(1, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), NewAcceptedMessageKeysFilter("foo")), + mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2))), NewAcceptedMessageKeysFilter("bar")), + mustGrant(myContractAddr, NewCombinedLimit(1, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1))), NewAcceptedMessageKeysFilter("foo")), ), }, }, @@ -626,17 +628,17 @@ func TestAcceptGrantedMessage(t *testing.T) { Sender: sdk.AccAddress(randBytes(SDKAddrLen)).String(), Contract: myContractAddr.String(), Msg: []byte(`{"foo":"bar"}`), - Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), + Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), }, expResult: authztypes.AcceptResponse{Accept: false}, }, "not accepted - funds exceeds limit": { - auth: NewContractExecutionAuthorization(mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), NewAllowAllMessagesFilter())), + auth: NewContractExecutionAuthorization(mustGrant(myContractAddr, NewMaxFundsLimit(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), NewAllowAllMessagesFilter())), msg: &MsgExecuteContract{ Sender: sdk.AccAddress(randBytes(SDKAddrLen)).String(), Contract: myContractAddr.String(), Msg: []byte(`{"foo":"bar"}`), - Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2))), + Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(2))), }, expResult: authztypes.AcceptResponse{Accept: false}, }, @@ -646,7 +648,7 @@ func TestAcceptGrantedMessage(t *testing.T) { Sender: sdk.AccAddress(randBytes(SDKAddrLen)).String(), Contract: myContractAddr.String(), Msg: []byte(`{"foo":"bar"}`), - Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())), + Funds: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.OneInt())), }, expResult: authztypes.AcceptResponse{Accept: false}, }, @@ -711,7 +713,7 @@ func TestAcceptGrantedMessage(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - ctx := sdk.Context{}.WithGasMeter(sdk.NewInfiniteGasMeter()) + ctx := sdk.Context{}.WithGasMeter(storetypes.NewInfiniteGasMeter()) gotResult, gotErr := spec.auth.Accept(ctx, spec.msg) if spec.expErr != nil { require.ErrorIs(t, gotErr, spec.expErr) @@ -959,7 +961,7 @@ func TestStoreCodeAuthorizationAccept(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - ctx := sdk.Context{}.WithGasMeter(sdk.NewInfiniteGasMeter()) + ctx := sdk.Context{}.WithGasMeter(storetypes.NewInfiniteGasMeter()) gotResult, gotErr := spec.auth.Accept(ctx, spec.msg) if spec.expErr != nil { require.ErrorIs(t, gotErr, spec.expErr) diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go index 3b0a823623..2f3985380e 100644 --- a/x/wasm/types/codec.go +++ b/x/wasm/types/codec.go @@ -3,14 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/x/authz" - authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" - govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" ) // RegisterLegacyAminoCodec registers the account types and interface @@ -127,23 +123,3 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/wasm module codec. - - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - amino.Seal() - - // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be - // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances - RegisterLegacyAminoCodec(authzcodec.Amino) - RegisterLegacyAminoCodec(govcodec.Amino) - RegisterLegacyAminoCodec(groupcodec.Amino) -} diff --git a/x/wasm/types/context.go b/x/wasm/types/context.go index 006e397624..60d5dedc04 100644 --- a/x/wasm/types/context.go +++ b/x/wasm/types/context.go @@ -1,6 +1,8 @@ package types import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -25,7 +27,7 @@ func WithTXCounter(ctx sdk.Context, counter uint32) sdk.Context { // TXCounter returns the tx counter value and found bool from the context. // The result will be (0, false) for external queries or simulations where no counter available. -func TXCounter(ctx sdk.Context) (uint32, bool) { +func TXCounter(ctx context.Context) (uint32, bool) { val, ok := ctx.Value(contextKeyTXCount).(uint32) return val, ok } @@ -36,7 +38,7 @@ func WithQueryStackSize(ctx sdk.Context, counter uint32) sdk.Context { } // QueryStackSize reads the stack position for smart queries from the context -func QueryStackSize(ctx sdk.Context) (uint32, bool) { +func QueryStackSize(ctx context.Context) (uint32, bool) { val, ok := ctx.Value(contextKeyQueryStackSize).(uint32) return val, ok } @@ -50,7 +52,7 @@ func WithSubMsgAuthzPolicy(ctx sdk.Context, policy AuthorizationPolicy) sdk.Cont } // SubMsgAuthzPolicy reads the authorization policy for submessages from the context -func SubMsgAuthzPolicy(ctx sdk.Context) (AuthorizationPolicy, bool) { +func SubMsgAuthzPolicy(ctx context.Context) (AuthorizationPolicy, bool) { val, ok := ctx.Value(contextKeySubMsgAuthzPolicy).(AuthorizationPolicy) return val, ok } @@ -64,7 +66,7 @@ func WithGasRegister(ctx sdk.Context, gr GasRegister) sdk.Context { } // GasRegisterFromContext reads the gas register from the context -func GasRegisterFromContext(ctx sdk.Context) (GasRegister, bool) { +func GasRegisterFromContext(ctx context.Context) (GasRegister, bool) { val, ok := ctx.Value(contextKeyGasRegister).(GasRegister) return val, ok } diff --git a/x/wasm/types/events.go b/x/wasm/types/events.go index ea6060bda9..e1588d6f36 100644 --- a/x/wasm/types/events.go +++ b/x/wasm/types/events.go @@ -3,7 +3,7 @@ package types import ( "fmt" - "github.com/cosmos/ibc-go/v7/modules/core/exported" + "github.com/cosmos/ibc-go/v8/modules/core/exported" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/wasm/types/expected_keepers.go b/x/wasm/types/expected_keepers.go index 720baaaaf4..6e037dbdef 100644 --- a/x/wasm/types/expected_keepers.go +++ b/x/wasm/types/expected_keepers.go @@ -3,51 +3,50 @@ package types import ( "context" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // BankViewKeeper defines a subset of methods implemented by the cosmos-sdk bank keeper type BankViewKeeper interface { - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetSupply(ctx sdk.Context, denom string) sdk.Coin - GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetSupply(ctx context.Context, denom string) sdk.Coin + GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool) DenomsMetadata(ctx context.Context, req *banktypes.QueryDenomsMetadataRequest) (*banktypes.QueryDenomsMetadataResponse, error) } // Burner is a subset of the sdk bank keeper methods type Burner interface { - BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } // BankKeeper defines a subset of methods implemented by the cosmos-sdk bank keeper type BankKeeper interface { BankViewKeeper Burner - IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error + IsSendEnabledCoins(ctx context.Context, coins ...sdk.Coin) error BlockedAddr(addr sdk.AccAddress) bool - SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error } // AccountKeeper defines a subset of methods implemented by the cosmos-sdk account keeper type AccountKeeper interface { // Return a new account with the next account number and the specified address. Does not save the new account to the store. - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // Retrieve an account from the store. - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // Set an account in the store. - SetAccount(ctx sdk.Context, acc authtypes.AccountI) + SetAccount(ctx context.Context, acc sdk.AccountI) } // DistributionKeeper defines a subset of methods implemented by the cosmos-sdk distribution keeper @@ -61,19 +60,19 @@ type DistributionKeeper interface { // StakingKeeper defines a subset of methods implemented by the cosmos-sdk staking keeper type StakingKeeper interface { // BondDenom - Bondable coin denomination - BondDenom(ctx sdk.Context) (res string) + BondDenom(ctx context.Context) (string, error) // GetValidator get a single validator - GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + GetValidator(ctx context.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, err error) // GetBondedValidatorsByPower get the current group of bonded validators sorted by power-rank - GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator + GetBondedValidatorsByPower(ctx context.Context) ([]stakingtypes.Validator, error) // GetAllDelegatorDelegations return all delegations for a delegator - GetAllDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.Delegation + GetAllDelegatorDelegations(ctx context.Context, delegator sdk.AccAddress) ([]stakingtypes.Delegation, error) // GetDelegation return a specific delegation - GetDelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + GetDelegation(ctx context.Context, + delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.Delegation, error) // HasReceivingRedelegation check if validator is receiving a redelegation - HasReceivingRedelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool + HasReceivingRedelegation(ctx context.Context, + delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) (bool, error) } // ChannelKeeper defines the expected IBC channel keeper diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index a77d823a3b..d00b39ce67 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -1,29 +1,31 @@ package types import ( + "context" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" ) // ViewKeeper provides read only operations type ViewKeeper interface { - GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) []ContractCodeHistoryEntry - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) - QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool - GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *ContractInfo - IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, ContractInfo) bool) - IterateContractsByCreator(ctx sdk.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) - IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(address sdk.AccAddress) bool) - IterateContractState(ctx sdk.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool) - GetCodeInfo(ctx sdk.Context, codeID uint64) *CodeInfo - IterateCodeInfos(ctx sdk.Context, cb func(uint64, CodeInfo) bool) - GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error) - IsPinnedCode(ctx sdk.Context, codeID uint64) bool - GetParams(ctx sdk.Context) Params + GetContractHistory(ctx context.Context, contractAddr sdk.AccAddress) []ContractCodeHistoryEntry + QuerySmart(ctx context.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + QueryRaw(ctx context.Context, contractAddress sdk.AccAddress, key []byte) []byte + HasContractInfo(ctx context.Context, contractAddress sdk.AccAddress) bool + GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *ContractInfo + IterateContractInfo(ctx context.Context, cb func(sdk.AccAddress, ContractInfo) bool) + IterateContractsByCreator(ctx context.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) + IterateContractsByCode(ctx context.Context, codeID uint64, cb func(address sdk.AccAddress) bool) + IterateContractState(ctx context.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool) + GetCodeInfo(ctx context.Context, codeID uint64) *CodeInfo + IterateCodeInfos(ctx context.Context, cb func(uint64, CodeInfo) bool) + GetByteCode(ctx context.Context, codeID uint64) ([]byte, error) + IsPinnedCode(ctx context.Context, codeID uint64) bool + GetParams(ctx context.Context) Params } // ContractOpsKeeper contains mutable operations on a contract. diff --git a/x/wasm/types/gas_register.go b/x/wasm/types/gas_register.go index da5e989149..4ccbcf401a 100644 --- a/x/wasm/types/gas_register.go +++ b/x/wasm/types/gas_register.go @@ -4,9 +4,9 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -70,49 +70,49 @@ func DefaultPerByteUncompressCost() wasmvmtypes.UFraction { // GasRegister abstract source for gas costs type GasRegister interface { // NewContractInstanceCosts costs to create a new contract instance from code - NewContractInstanceCosts(pinned bool, msgLen int) sdk.Gas + NewContractInstanceCosts(pinned bool, msgLen int) storetypes.Gas // CompileCosts costs to persist and "compile" a new wasm contract - CompileCosts(byteLength int) sdk.Gas + CompileCosts(byteLength int) storetypes.Gas // UncompressCosts costs to unpack a new wasm contract - UncompressCosts(byteLength int) sdk.Gas + UncompressCosts(byteLength int) storetypes.Gas // InstantiateContractCosts costs when interacting with a wasm contract - InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas + InstantiateContractCosts(pinned bool, msgLen int) storetypes.Gas // ReplyCosts costs to to handle a message reply - ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas + ReplyCosts(pinned bool, reply wasmvmtypes.Reply) storetypes.Gas // EventCosts costs to persist an event - EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas + EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) storetypes.Gas // ToWasmVMGas converts from Cosmos SDK gas units to [CosmWasm gas] (aka. wasmvm gas) // // [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md - ToWasmVMGas(source sdk.Gas) uint64 + ToWasmVMGas(source storetypes.Gas) uint64 // FromWasmVMGas converts from [CosmWasm gas] (aka. wasmvm gas) to Cosmos SDK gas units // // [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md - FromWasmVMGas(source uint64) sdk.Gas + FromWasmVMGas(source uint64) storetypes.Gas } // WasmGasRegisterConfig config type type WasmGasRegisterConfig struct { // InstanceCost costs when interacting with a wasm contract - InstanceCost sdk.Gas + InstanceCost storetypes.Gas // CompileCosts costs to persist and "compile" a new wasm contract - CompileCost sdk.Gas + CompileCost storetypes.Gas // UncompressCost costs per byte to unpack a contract UncompressCost wasmvmtypes.UFraction // GasMultiplier is how many cosmwasm gas points = 1 sdk gas point // SDK reference costs can be found here: https://github.com/cosmos/cosmos-sdk/blob/02c6c9fafd58da88550ab4d7d494724a477c8a68/store/types/gas.go#L153-L164 - GasMultiplier sdk.Gas + GasMultiplier storetypes.Gas // EventPerAttributeCost is how much SDK gas is charged *per byte* for attribute data in events. // This is used with len(key) + len(value) - EventPerAttributeCost sdk.Gas + EventPerAttributeCost storetypes.Gas // EventAttributeDataCost is how much SDK gas is charged *per byte* for attribute data in events. // This is used with len(key) + len(value) - EventAttributeDataCost sdk.Gas + EventAttributeDataCost storetypes.Gas // EventAttributeDataFreeTier number of bytes of total attribute data that is free of charge EventAttributeDataFreeTier uint64 // ContractMessageDataCost SDK gas charged *per byte* of the message that goes to the contract // This is used with len(msg) - ContractMessageDataCost sdk.Gas + ContractMessageDataCost storetypes.Gas // CustomEventCost cost per custom event CustomEventCost uint64 } @@ -166,7 +166,7 @@ func (g WasmGasRegister) CompileCosts(byteLength int) storetypes.Gas { } // UncompressCosts costs to unpack a new wasm contract -func (g WasmGasRegister) UncompressCosts(byteLength int) sdk.Gas { +func (g WasmGasRegister) UncompressCosts(byteLength int) storetypes.Gas { if byteLength < 0 { panic(errorsmod.Wrap(ErrInvalid, "negative length")) } @@ -174,11 +174,11 @@ func (g WasmGasRegister) UncompressCosts(byteLength int) sdk.Gas { } // InstantiateContractCosts costs when interacting with a wasm contract -func (g WasmGasRegister) InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas { +func (g WasmGasRegister) InstantiateContractCosts(pinned bool, msgLen int) storetypes.Gas { if msgLen < 0 { panic(errorsmod.Wrap(ErrInvalid, "negative length")) } - dataCosts := sdk.Gas(msgLen) * g.c.ContractMessageDataCost + dataCosts := storetypes.Gas(msgLen) * g.c.ContractMessageDataCost if pinned { return dataCosts } @@ -186,14 +186,14 @@ func (g WasmGasRegister) InstantiateContractCosts(pinned bool, msgLen int) sdk.G } // ReplyCosts costs to to handle a message reply -func (g WasmGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas { - var eventGas sdk.Gas +func (g WasmGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) storetypes.Gas { + var eventGas storetypes.Gas msgLen := len(reply.Result.Err) if reply.Result.Ok != nil { msgLen += len(reply.Result.Ok.Data) var attrs []wasmvmtypes.EventAttribute for _, e := range reply.Result.Ok.Events { - eventGas += sdk.Gas(len(e.Type)) * g.c.EventAttributeDataCost + eventGas += storetypes.Gas(len(e.Type)) * g.c.EventAttributeDataCost attrs = append(attrs, e.Attributes...) } // apply free tier on the whole set not per event @@ -203,19 +203,19 @@ func (g WasmGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Ga } // EventCosts costs to persist an event -func (g WasmGasRegister) EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas { +func (g WasmGasRegister) EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) storetypes.Gas { gas, remainingFreeTier := g.eventAttributeCosts(attrs, g.c.EventAttributeDataFreeTier) for _, e := range events { gas += g.c.CustomEventCost - gas += sdk.Gas(len(e.Type)) * g.c.EventAttributeDataCost // no free tier with event type - var attrCost sdk.Gas + gas += storetypes.Gas(len(e.Type)) * g.c.EventAttributeDataCost // no free tier with event type + var attrCost storetypes.Gas attrCost, remainingFreeTier = g.eventAttributeCosts(e.Attributes, remainingFreeTier) gas += attrCost } return gas } -func (g WasmGasRegister) eventAttributeCosts(attrs []wasmvmtypes.EventAttribute, freeTier uint64) (sdk.Gas, uint64) { +func (g WasmGasRegister) eventAttributeCosts(attrs []wasmvmtypes.EventAttribute, freeTier uint64) (storetypes.Gas, uint64) { if len(attrs) == 0 { return 0, freeTier } @@ -225,10 +225,10 @@ func (g WasmGasRegister) eventAttributeCosts(attrs []wasmvmtypes.EventAttribute, } storedBytes, freeTier = calcWithFreeTier(storedBytes, freeTier) // total Length * costs + attribute count * costs - r := sdk.NewIntFromUint64(g.c.EventAttributeDataCost).Mul(sdk.NewIntFromUint64(storedBytes)). - Add(sdk.NewIntFromUint64(g.c.EventPerAttributeCost).Mul(sdk.NewIntFromUint64(uint64(len(attrs))))) + r := sdkmath.NewIntFromUint64(g.c.EventAttributeDataCost).Mul(sdkmath.NewIntFromUint64(storedBytes)). + Add(sdkmath.NewIntFromUint64(g.c.EventPerAttributeCost).Mul(sdkmath.NewIntFromUint64(uint64(len(attrs))))) if !r.IsUint64() { - panic(sdk.ErrorOutOfGas{Descriptor: "overflow"}) + panic(storetypes.ErrorOutOfGas{Descriptor: "overflow"}) } return r.Uint64(), freeTier } @@ -248,7 +248,7 @@ func calcWithFreeTier(storedBytes, freeTier uint64) (uint64, uint64) { func (g WasmGasRegister) ToWasmVMGas(source storetypes.Gas) uint64 { x := source * g.c.GasMultiplier if x < source { - panic(sdk.ErrorOutOfGas{Descriptor: "overflow"}) + panic(storetypes.ErrorOutOfGas{Descriptor: "overflow"}) } return x } @@ -256,6 +256,6 @@ func (g WasmGasRegister) ToWasmVMGas(source storetypes.Gas) uint64 { // FromWasmVMGas converts from [CosmWasm gas] (aka. wasmvm gas) to Cosmos SDK gas units // // [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md -func (g WasmGasRegister) FromWasmVMGas(source uint64) sdk.Gas { +func (g WasmGasRegister) FromWasmVMGas(source uint64) storetypes.Gas { return source / g.c.GasMultiplier } diff --git a/x/wasm/types/gas_register_test.go b/x/wasm/types/gas_register_test.go index 34155d4784..7d57f40169 100644 --- a/x/wasm/types/gas_register_test.go +++ b/x/wasm/types/gas_register_test.go @@ -8,26 +8,25 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/stretchr/testify/assert" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) func TestCompileCosts(t *testing.T) { specs := map[string]struct { srcLen int srcConfig WasmGasRegisterConfig - exp sdk.Gas + exp storetypes.Gas expPanic bool }{ "one byte": { srcLen: 1, srcConfig: DefaultGasRegisterConfig(), - exp: sdk.Gas(3), // DefaultCompileCost + exp: storetypes.Gas(3), // DefaultCompileCost }, "zero byte": { srcLen: 0, srcConfig: DefaultGasRegisterConfig(), - exp: sdk.Gas(0), + exp: storetypes.Gas(0), }, "negative len": { srcLen: -1, @@ -54,7 +53,7 @@ func TestNewContractInstanceCosts(t *testing.T) { srcLen int srcConfig WasmGasRegisterConfig pinned bool - exp sdk.Gas + exp storetypes.Gas expPanic bool }{ "small msg - pinned": { @@ -67,13 +66,13 @@ func TestNewContractInstanceCosts(t *testing.T) { srcLen: math.MaxUint32, srcConfig: DefaultGasRegisterConfig(), pinned: true, - exp: DefaultContractMessageDataCost * sdk.Gas(math.MaxUint32), + exp: DefaultContractMessageDataCost * storetypes.Gas(math.MaxUint32), }, "empty msg - pinned": { srcLen: 0, pinned: true, srcConfig: DefaultGasRegisterConfig(), - exp: sdk.Gas(0), + exp: storetypes.Gas(0), }, "small msg - unpinned": { srcLen: 1, @@ -117,7 +116,7 @@ func TestContractInstanceCosts(t *testing.T) { srcLen int srcConfig WasmGasRegisterConfig pinned bool - exp sdk.Gas + exp storetypes.Gas expPanic bool }{ "small msg - pinned": { @@ -136,7 +135,7 @@ func TestContractInstanceCosts(t *testing.T) { srcLen: 0, pinned: true, srcConfig: DefaultGasRegisterConfig(), - exp: sdk.Gas(0), + exp: storetypes.Gas(0), }, "small msg - unpinned": { srcLen: 1, @@ -179,7 +178,7 @@ func TestReplyCost(t *testing.T) { src wasmvmtypes.Reply srcConfig WasmGasRegisterConfig pinned bool - exp sdk.Gas + exp storetypes.Gas expPanic bool }{ "subcall response with events and data - pinned": { @@ -324,7 +323,7 @@ func TestEventCosts(t *testing.T) { specs := map[string]struct { srcAttrs []wasmvmtypes.EventAttribute srcEvents wasmvmtypes.Events - expGas sdk.Gas + expGas storetypes.Gas }{ "empty events": { srcEvents: make([]wasmvmtypes.Event, 1), @@ -435,7 +434,7 @@ func TestFromWasmVMGasConversion(t *testing.T) { func TestUncompressCosts(t *testing.T) { specs := map[string]struct { lenIn int - exp sdk.Gas + exp storetypes.Gas expPanic bool }{ "0": { diff --git a/x/wasm/types/genesis.pb.go b/x/wasm/types/genesis.pb.go index 52bd7cc7c4..ff6ad94589 100644 --- a/x/wasm/types/genesis.pb.go +++ b/x/wasm/types/genesis.pb.go @@ -9,6 +9,7 @@ import ( math "math" math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -318,43 +319,44 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/genesis.proto", fileDescriptor_2ab3f539b23472a6) } var fileDescriptor_2ab3f539b23472a6 = []byte{ - // 563 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x9b, 0xae, 0x0d, 0xad, 0x57, 0xd8, 0x30, 0x63, 0x44, 0xd5, 0x48, 0xab, 0x22, 0xa1, - 0x32, 0xa1, 0x46, 0x1b, 0x47, 0x2e, 0x90, 0x0d, 0x41, 0x98, 0x40, 0x28, 0x3b, 0x20, 0xed, 0x52, - 0xa5, 0xb1, 0xd7, 0x59, 0x2c, 0x71, 0x88, 0xdd, 0x42, 0xbe, 0x05, 0x9f, 0x02, 0x71, 0xe4, 0xce, - 0x17, 0xd8, 0x8d, 0x1d, 0x39, 0x55, 0x28, 0x3d, 0x20, 0xf1, 0x29, 0x26, 0xdb, 0x49, 0x16, 0xb5, - 0xeb, 0xc5, 0x4a, 0xde, 0xfb, 0xbf, 0x9f, 0xed, 0xbf, 0xdf, 0x03, 0xa6, 0x4f, 0x59, 0xf0, 0xc5, - 0x63, 0x81, 0x25, 0x97, 0xe9, 0x9e, 0x35, 0xc6, 0x21, 0x66, 0x84, 0x0d, 0xa2, 0x98, 0x72, 0x0a, - 0x37, 0xf3, 0xfc, 0x40, 0x2e, 0xd3, 0xbd, 0xf6, 0xd6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x13, 0xb8, 0x05, 0xea, 0x53, 0xef, 0x7c, 0x82, 0xa5, 0x57, 0x35, - 0x57, 0xfd, 0xd8, 0x2f, 0x2e, 0x52, 0x53, 0xbb, 0x4c, 0x4d, 0xed, 0x6f, 0x6a, 0x6a, 0xdf, 0xe6, - 0x66, 0xe5, 0x72, 0x6e, 0x56, 0xfe, 0xcc, 0xcd, 0xca, 0xc9, 0xe3, 0x31, 0xe1, 0x67, 0x93, 0xd1, - 0xc0, 0xa7, 0x81, 0x75, 0x40, 0x59, 0xf0, 0x31, 0x1f, 0x69, 0x64, 0x7d, 0x55, 0xa3, 0x2d, 0xe7, - 0x7a, 0xa4, 0xcb, 0x29, 0x7e, 0x76, 0x15, 0x00, 0x00, 0xff, 0xff, 0x45, 0x4b, 0xa7, 0x92, 0x40, - 0x04, 0x00, 0x00, + // 590 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x9b, 0xae, 0x0d, 0xad, 0x57, 0xd8, 0x30, 0x63, 0x84, 0x6a, 0xa4, 0x55, 0x91, 0x50, + 0x35, 0x41, 0xa3, 0x8d, 0x23, 0x17, 0xc8, 0x86, 0xa0, 0x4c, 0x20, 0x94, 0x1e, 0x90, 0x76, 0xa9, + 0xd2, 0xd8, 0xeb, 0x2c, 0x96, 0xb8, 0xc4, 0x6e, 0x21, 0xdf, 0x82, 0x4f, 0x81, 0x38, 0x72, 0xe0, + 0x43, 0xec, 0xc6, 0x84, 0x84, 0xc4, 0xa9, 0x42, 0xed, 0x01, 0x89, 0x4f, 0x81, 0xfc, 0x27, 0x59, + 0xd4, 0xae, 0x17, 0xab, 0xf6, 0xf3, 0xbe, 0xbf, 0xbe, 0xef, 0xe3, 0x37, 0x06, 0x76, 0x40, 0x59, + 0xf8, 0xd1, 0x67, 0xa1, 0x23, 0x97, 0xc9, 0x9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d, 0xb1, 0x33, + 0xa5, 0xf5, 0xc5, 0x00, 0x25, 0xd1, 0x25, 0xbc, 0x0f, 0xae, 0x89, 0x4e, 0xfa, 0x04, 0x49, 0x2b, + 0x4b, 0x2e, 0x98, 0x4d, 0x1b, 0xa6, 0x90, 0xba, 0x87, 0x9e, 0x29, 0xa4, 0x2e, 0x82, 0xae, 0xe8, + 0x52, 0x04, 0x45, 0x27, 0xd4, 0x2a, 0x4a, 0xc7, 0xeb, 0x57, 0xbb, 0xd6, 0x8d, 0x4e, 0x68, 0xde, + 0xf3, 0x4a, 0xa0, 0x0f, 0xe1, 0x3d, 0x00, 0x24, 0x63, 0x90, 0x70, 0x2c, 0xac, 0x32, 0xda, 0x35, + 0x4f, 0x52, 0x5d, 0x71, 0x00, 0xb7, 0x81, 0x39, 0x22, 0x51, 0x84, 0x91, 0x55, 0x6a, 0x1a, 0xed, + 0x8a, 0xa7, 0x77, 0xad, 0x5f, 0x45, 0x50, 0x49, 0xed, 0x83, 0x07, 0x60, 0x33, 0xb5, 0xa7, 0xef, + 0x23, 0x14, 0x63, 0xa6, 0x06, 0xa0, 0xea, 0x5a, 0x3f, 0xbf, 0x3f, 0xda, 0xd2, 0x33, 0xf3, 0x4c, + 0x29, 0x3d, 0x1e, 0x93, 0x68, 0xe8, 0x6d, 0xa4, 0x19, 0xfa, 0x18, 0xbe, 0x01, 0xd7, 0x33, 0x48, + 0xae, 0x21, 0x7b, 0xf5, 0xb5, 0x2d, 0x36, 0x55, 0x0b, 0x72, 0x02, 0xec, 0x82, 0x1b, 0x19, 0x8f, + 0x89, 0xe9, 0xd4, 0x73, 0x70, 0x67, 0x19, 0xf8, 0x9a, 0x22, 0x7c, 0x96, 0x27, 0x65, 0x95, 0xa8, + 0xb1, 0x26, 0xe0, 0x76, 0x86, 0x92, 0x66, 0x9d, 0x12, 0xc6, 0x69, 0x9c, 0xe8, 0xdb, 0xdf, 0x5d, + 0x5d, 0xa2, 0xf0, 0xfe, 0xa5, 0x0a, 0x7e, 0x1e, 0xf1, 0x38, 0xc9, 0xff, 0x49, 0x36, 0x6c, 0xb9, + 0xa0, 0x96, 0x0b, 0x2a, 0xe9, 0xe4, 0xc0, 0x26, 0x30, 0x09, 0xea, 0xbf, 0xc7, 0x89, 0x34, 0xb3, + 0xe6, 0x56, 0x67, 0xd3, 0x46, 0xb9, 0x7b, 0x78, 0x84, 0x13, 0xaf, 0x4c, 0xd0, 0x11, 0x4e, 0xe0, + 0x16, 0x28, 0x4f, 0xfc, 0xb3, 0x31, 0x96, 0x5e, 0x95, 0x3c, 0xb5, 0x71, 0x9f, 0x9e, 0xcf, 0x6c, + 0xe3, 0x62, 0x66, 0x1b, 0x7f, 0x66, 0xb6, 0xf1, 0x79, 0x6e, 0x17, 0x2e, 0xe6, 0x76, 0xe1, 0xf7, + 0xdc, 0x2e, 0x1c, 0x3f, 0x18, 0x12, 0x7e, 0x3a, 0x1e, 0x74, 0x02, 0x1a, 0x3a, 0x07, 0x94, 0x85, + 0xef, 0xd2, 0x77, 0x00, 0x39, 0x9f, 0xd4, 0x7b, 0x20, 0x1f, 0x83, 0x81, 0x29, 0xbf, 0xef, 0xc7, + 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x86, 0xe3, 0xf2, 0x58, 0x75, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/wasm/types/iavl_range_test.go b/x/wasm/types/iavl_range_test.go index 85607dab23..cbe2e13c9f 100644 --- a/x/wasm/types/iavl_range_test.go +++ b/x/wasm/types/iavl_range_test.go @@ -3,12 +3,13 @@ package types import ( "testing" - dbm "github.com/cometbft/cometbft-db" + dbm "github.com/cosmos/cosmos-db" iavl2 "github.com/cosmos/iavl" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/store" - "github.com/cosmos/cosmos-sdk/store/iavl" + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/iavl" ) // This is modeled close to @@ -16,8 +17,7 @@ import ( // and designed to ensure the IAVL store handles bounds the same way as the mock storage we use in Rust contract tests func TestIavlRangeBounds(t *testing.T) { memdb := dbm.NewMemDB() - tree, err := iavl2.NewMutableTree(memdb, 50, false) - require.NoError(t, err) + tree := iavl2.NewMutableTree(memdb, 50, false, log.NewTestLogger(t)) kvstore := iavl.UnsafeNewStore(tree) // values to compare with diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 9c85a08dff..9745e4772e 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -32,9 +32,11 @@ const ( ) // DisableAllProposals contains no wasm gov types. +// Deprecated: all gov v1beta1 types will be removed var DisableAllProposals []ProposalType // EnableAllProposals contains all wasm gov types as keys. +// Deprecated: all gov v1beta1 types will be removed var EnableAllProposals = []ProposalType{ ProposalTypeStoreCode, ProposalTypeInstantiateContract, @@ -50,24 +52,7 @@ var EnableAllProposals = []ProposalType{ ProposalTypeStoreAndInstantiateContractProposal, } -// ConvertToProposals maps each key to a ProposalType and returns a typed list. -// If any string is not a valid type (in this file), then return an error -func ConvertToProposals(keys []string) ([]ProposalType, error) { - valid := make(map[string]bool, len(EnableAllProposals)) - for _, key := range EnableAllProposals { - valid[string(key)] = true - } - - proposals := make([]ProposalType, len(keys)) - for i, key := range keys { - if _, ok := valid[key]; !ok { - return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "'%s' is not a valid ProposalType", key) - } - proposals[i] = ProposalType(key) - } - return proposals, nil -} - +// Deprecated: all gov v1beta1 types will be removed func init() { // register new content types with the sdk v1beta1.RegisterProposalType(string(ProposalTypeStoreCode)) v1beta1.RegisterProposalType(string(ProposalTypeInstantiateContract)) @@ -83,20 +68,6 @@ func init() { // register new content types with the sdk v1beta1.RegisterProposalType(string(ProposalTypeStoreAndInstantiateContractProposal)) } -func NewStoreCodeProposal( - title string, - description string, - runAs string, - wasmBz []byte, - permission *AccessConfig, - unpinCode bool, - source string, - builder string, - codeHash []byte, -) *StoreCodeProposal { - return &StoreCodeProposal{title, description, runAs, wasmBz, permission, unpinCode, source, builder, codeHash} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p StoreCodeProposal) ProposalRoute() string { return RouterKey } @@ -170,19 +141,6 @@ func (p StoreCodeProposal) MarshalYAML() (interface{}, error) { }, nil } -func NewInstantiateContractProposal( - title string, - description string, - runAs string, - admin string, - codeID uint64, - label string, - msg RawContractMessage, - funds sdk.Coins, -) *InstantiateContractProposal { - return &InstantiateContractProposal{title, description, runAs, admin, codeID, label, msg, funds} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p InstantiateContractProposal) ProposalRoute() string { return RouterKey } @@ -266,21 +224,6 @@ func (p InstantiateContractProposal) MarshalYAML() (interface{}, error) { }, nil } -func NewInstantiateContract2Proposal( - title string, - description string, - runAs string, - admin string, - codeID uint64, - label string, - msg RawContractMessage, - funds sdk.Coins, - salt []byte, - fixMsg bool, -) *InstantiateContract2Proposal { - return &InstantiateContract2Proposal{title, description, runAs, admin, codeID, label, msg, funds, salt, fixMsg} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p InstantiateContract2Proposal) ProposalRoute() string { return RouterKey } @@ -374,38 +317,6 @@ func (p InstantiateContract2Proposal) MarshalYAML() (interface{}, error) { }, nil } -func NewStoreAndInstantiateContractProposal( - title string, - description string, - runAs string, - wasmBz []byte, - source string, - builder string, - codeHash []byte, - permission *AccessConfig, - unpinCode bool, - admin string, - label string, - msg RawContractMessage, - funds sdk.Coins, -) *StoreAndInstantiateContractProposal { - return &StoreAndInstantiateContractProposal{ - Title: title, - Description: description, - RunAs: runAs, - WASMByteCode: wasmBz, - Source: source, - Builder: builder, - CodeHash: codeHash, - InstantiatePermission: permission, - UnpinCode: unpinCode, - Admin: admin, - Label: label, - Msg: msg, - Funds: funds, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p StoreAndInstantiateContractProposal) ProposalRoute() string { return RouterKey } @@ -514,22 +425,6 @@ func (p StoreAndInstantiateContractProposal) MarshalYAML() (interface{}, error) }, nil } -func NewMigrateContractProposal( - title string, - description string, - contract string, - codeID uint64, - msg RawContractMessage, -) *MigrateContractProposal { - return &MigrateContractProposal{ - Title: title, - Description: description, - Contract: contract, - CodeID: codeID, - Msg: msg, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p MigrateContractProposal) ProposalRoute() string { return RouterKey } @@ -587,20 +482,6 @@ func (p MigrateContractProposal) MarshalYAML() (interface{}, error) { }, nil } -func NewSudoContractProposal( - title string, - description string, - contract string, - msg RawContractMessage, -) *SudoContractProposal { - return &SudoContractProposal{ - Title: title, - Description: description, - Contract: contract, - Msg: msg, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p SudoContractProposal) ProposalRoute() string { return RouterKey } @@ -652,17 +533,6 @@ func (p SudoContractProposal) MarshalYAML() (interface{}, error) { }, nil } -func NewExecuteContractProposal( - title string, - description string, - runAs string, - contract string, - msg RawContractMessage, - funds sdk.Coins, -) *ExecuteContractProposal { - return &ExecuteContractProposal{title, description, runAs, contract, msg, funds} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p ExecuteContractProposal) ProposalRoute() string { return RouterKey } @@ -726,15 +596,6 @@ func (p ExecuteContractProposal) MarshalYAML() (interface{}, error) { }, nil } -func NewUpdateAdminProposal( - title string, - description string, - newAdmin string, - contract string, -) *UpdateAdminProposal { - return &UpdateAdminProposal{title, description, newAdmin, contract} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p UpdateAdminProposal) ProposalRoute() string { return RouterKey } @@ -771,14 +632,6 @@ func (p UpdateAdminProposal) String() string { `, p.Title, p.Description, p.Contract, p.NewAdmin) } -func NewClearAdminProposal( - title string, - description string, - contract string, -) *ClearAdminProposal { - return &ClearAdminProposal{title, description, contract} -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p ClearAdminProposal) ProposalRoute() string { return RouterKey } @@ -811,18 +664,6 @@ func (p ClearAdminProposal) String() string { `, p.Title, p.Description, p.Contract) } -func NewPinCodesProposal( - title string, - description string, - codeIDs []uint64, -) *PinCodesProposal { - return &PinCodesProposal{ - Title: title, - Description: description, - CodeIDs: codeIDs, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p PinCodesProposal) ProposalRoute() string { return RouterKey } @@ -855,18 +696,6 @@ func (p PinCodesProposal) String() string { `, p.Title, p.Description, p.CodeIDs) } -func NewUnpinCodesProposal( - title string, - description string, - codeIDs []uint64, -) *UnpinCodesProposal { - return &UnpinCodesProposal{ - Title: title, - Description: description, - CodeIDs: codeIDs, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p UnpinCodesProposal) ProposalRoute() string { return RouterKey } @@ -921,18 +750,6 @@ func validateProposalCommons(title, description string) error { return nil } -func NewUpdateInstantiateConfigProposal( - title string, - description string, - accessConfigUpdates ...AccessConfigUpdate, -) *UpdateInstantiateConfigProposal { - return &UpdateInstantiateConfigProposal{ - Title: title, - Description: description, - AccessConfigUpdates: accessConfigUpdates, - } -} - // ProposalRoute returns the routing key of a parameter change proposal. func (p UpdateInstantiateConfigProposal) ProposalRoute() string { return RouterKey } diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index 8c69183055..6d74a697b7 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -508,9 +508,9 @@ var xxx_messageInfo_ClearAdminProposal proto.InternalMessageInfo // Deprecated: Do not use. type PinCodesProposal struct { // Title is a short summary - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Description is a human readable text - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // CodeIDs references the new WASM codes CodeIDs []uint64 `protobuf:"varint,3,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` } @@ -560,9 +560,9 @@ var xxx_messageInfo_PinCodesProposal proto.InternalMessageInfo // Deprecated: Do not use. type UnpinCodesProposal struct { // Title is a short summary - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Description is a human readable text - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // CodeIDs references the WASM codes CodeIDs []uint64 `protobuf:"varint,3,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` } @@ -796,80 +796,82 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 1163 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcd, 0x6f, 0xe3, 0x44, - 0x14, 0xcf, 0x34, 0x89, 0x93, 0x4c, 0x02, 0x64, 0xbd, 0xfd, 0x98, 0xed, 0x16, 0x3b, 0x78, 0x57, - 0xab, 0x68, 0xa5, 0x4d, 0xd4, 0x22, 0x10, 0x84, 0x0f, 0x29, 0x2e, 0x8b, 0xe8, 0x8a, 0x4a, 0x95, - 0xab, 0x6a, 0x25, 0x2e, 0x61, 0x62, 0x4f, 0x52, 0x8b, 0xc4, 0x13, 0x79, 0xec, 0x7e, 0xfc, 0x0b, - 0x9c, 0x38, 0x71, 0xe1, 0x8e, 0x2a, 0x4e, 0x2b, 0xc1, 0xbf, 0x80, 0x54, 0x71, 0xda, 0x03, 0x87, - 0x45, 0x48, 0x81, 0x4d, 0x0f, 0x7b, 0xe0, 0x80, 0xd4, 0x23, 0x07, 0x40, 0x9e, 0x71, 0x52, 0xb7, - 0x4d, 0xe2, 0x2e, 0xb4, 0x2b, 0x21, 0x71, 0x71, 0xf2, 0x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28, 0x13, 0xe3, 0x81, 0x80, 0xf6, 0x67, 0x0a, 0xde, - 0xe2, 0x45, 0x7f, 0xdd, 0xb1, 0x5e, 0x60, 0x61, 0x7f, 0xf9, 0xdd, 0x58, 0xfa, 0xf2, 0xba, 0x31, - 0xe9, 0x6c, 0x37, 0x36, 0x2a, 0x76, 0x33, 0xd1, 0x62, 0x77, 0x54, 0xc7, 0x66, 0xc7, 0xd4, 0xb1, - 0xb9, 0xe7, 0x78, 0xc1, 0xc2, 0xab, 0xad, 0x63, 0x4f, 0x7a, 0xc9, 0xfc, 0xa4, 0x5e, 0xb2, 0x30, - 0xa5, 0x97, 0x7c, 0xe9, 0x4c, 0x2f, 0xb9, 0x1e, 0xbf, 0xf9, 0xca, 0x27, 0xbd, 0xe4, 0xf4, 0x6d, - 0x85, 0x80, 0xfe, 0xf1, 0xe1, 0x53, 0x25, 0xf1, 0xe4, 0xa9, 0x92, 0x38, 0x18, 0x28, 0xe0, 0x70, - 0xa0, 0x80, 0xc7, 0x03, 0x05, 0xfc, 0x3a, 0x50, 0xc0, 0x17, 0x47, 0x4a, 0xe2, 0xf1, 0x91, 0x92, - 0x78, 0x72, 0xa4, 0x24, 0x3e, 0xb9, 0x13, 0x61, 0xbe, 0x4a, 0x59, 0xf7, 0xe1, 0xf0, 0xf3, 0x82, - 0x55, 0xdd, 0x13, 0x9f, 0x19, 0x38, 0xfb, 0xa6, 0xc4, 0xbf, 0x28, 0xbc, 0xfe, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x0f, 0x40, 0x90, 0x22, 0x08, 0x11, 0x00, 0x00, + // 1188 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcb, 0x6f, 0x1b, 0x45, + 0x18, 0xf7, 0xc4, 0xf6, 0xda, 0x1e, 0x1b, 0x70, 0xb7, 0x79, 0x4c, 0xd2, 0xb0, 0x6b, 0xb6, 0x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x7b, 0xfc, 0x44, 0x89, 0xdd, 0xeb, 0x29, 0x60, 0xaf, 0xa7, 0x80, 0x47, 0x3d, 0x05, 0xfc, 0xd9, + 0x53, 0xc0, 0xb7, 0xfb, 0x4a, 0xec, 0xd1, 0xbe, 0x12, 0x7b, 0xbc, 0xaf, 0xc4, 0xbe, 0xb8, 0x39, + 0xc0, 0x7c, 0x99, 0xd0, 0xd6, 0xdd, 0xfe, 0xa7, 0x15, 0xbb, 0xbc, 0x23, 0x3e, 0xb1, 0x70, 0xf6, + 0x75, 0x89, 0x7f, 0x4d, 0x79, 0xeb, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x45, 0x58, 0x4b, 0x26, + 0x04, 0x12, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go index 622485886f..d221e33feb 100644 --- a/x/wasm/types/proposal_test.go +++ b/x/wasm/types/proposal_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -252,13 +254,13 @@ func TestValidateInstantiateContractProposal(t *testing.T) { }, "init funds negative": { src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(-1)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(-1)}} }), expErr: true, }, "init funds with duplicates": { src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "foo", Amount: sdk.NewInt(2)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(1)}, {Denom: "foo", Amount: sdkmath.NewInt(2)}} }), expErr: true, }, @@ -349,13 +351,13 @@ func TestValidateInstantiateContract2Proposal(t *testing.T) { }, "init funds negative": { src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(-1)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(-1)}} }), expErr: true, }, "init funds with duplicates": { src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "foo", Amount: sdk.NewInt(2)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(1)}, {Denom: "foo", Amount: sdkmath.NewInt(2)}} }), expErr: true, }, @@ -491,13 +493,13 @@ func TestValidateStoreAndInstantiateContractProposal(t *testing.T) { }, "init funds negative": { src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(-1)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(-1)}} }), expErr: true, }, "init funds with duplicates": { src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "foo", Amount: sdk.NewInt(2)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(1)}, {Denom: "foo", Amount: sdkmath.NewInt(2)}} }), expErr: true, }, @@ -792,7 +794,7 @@ func TestProposalStrings(t *testing.T) { }, "instantiate contract": { src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "bar", Amount: sdk.NewInt(2)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(1)}, {Denom: "bar", Amount: sdkmath.NewInt(2)}} }), exp: `Instantiate Code Proposal: Title: Foo @@ -911,7 +913,7 @@ code_hash: 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d }, "instantiate contract": { src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { - p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "bar", Amount: sdk.NewInt(2)}} + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdkmath.NewInt(1)}, {Denom: "bar", Amount: sdkmath.NewInt(2)}} }), exp: `title: Foo description: Bar @@ -999,44 +1001,6 @@ code_ids: } } -func TestConvertToProposals(t *testing.T) { - cases := map[string]struct { - input string - isError bool - proposals []ProposalType - }{ - "one proper item": { - input: "UpdateAdmin", - proposals: []ProposalType{ProposalTypeUpdateAdmin}, - }, - "multiple proper items": { - input: "StoreCode,InstantiateContract,MigrateContract", - proposals: []ProposalType{ProposalTypeStoreCode, ProposalTypeInstantiateContract, ProposalTypeMigrateContract}, - }, - "empty trailing item": { - input: "StoreCode,", - isError: true, - }, - "invalid item": { - input: "StoreCode,InvalidProposalType", - isError: true, - }, - } - - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - chunks := strings.Split(tc.input, ",") - proposals, err := ConvertToProposals(chunks) - if tc.isError { - require.Error(t, err) - } else { - require.NoError(t, err) - require.Equal(t, proposals, tc.proposals) - } - }) - } -} - func TestUnmarshalContentFromJson(t *testing.T) { specs := map[string]struct { src string @@ -1064,7 +1028,7 @@ func TestUnmarshalContentFromJson(t *testing.T) { CodeID: 1, Label: "testing", Msg: []byte("{}"), - Funds: sdk.NewCoins(sdk.NewCoin("ALX", sdk.NewInt(2)), sdk.NewCoin("BLX", sdk.NewInt(3))), + Funds: sdk.NewCoins(sdk.NewCoin("ALX", sdkmath.NewInt(2)), sdk.NewCoin("BLX", sdkmath.NewInt(3))), }, }, "migrate ": { @@ -1094,37 +1058,3 @@ func TestUnmarshalContentFromJson(t *testing.T) { }) } } - -func TestProposalJsonSignBytes(t *testing.T) { - const myInnerMsg = `{"foo":"bar"}` - specs := map[string]struct { - src v1beta1.Content - exp string - }{ - "instantiate contract": { - src: &InstantiateContractProposal{Msg: RawContractMessage(myInnerMsg)}, - exp: ` -{ - "type":"cosmos-sdk/MsgSubmitProposal", - "value":{"content":{"type":"wasm/InstantiateContractProposal","value":{"funds":[],"msg":{"foo":"bar"}}},"initial_deposit":[]} -}`, - }, - "migrate contract": { - src: &MigrateContractProposal{Msg: RawContractMessage(myInnerMsg)}, - exp: ` -{ - "type":"cosmos-sdk/MsgSubmitProposal", - "value":{"content":{"type":"wasm/MigrateContractProposal","value":{"msg":{"foo":"bar"}}},"initial_deposit":[]} -}`, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - msg, err := v1beta1.NewMsgSubmitProposal(spec.src, sdk.NewCoins(), []byte{}) - require.NoError(t, err) - - bz := msg.GetSignBytes() - assert.JSONEq(t, spec.exp, string(bz), "exp %s\n got: %s\n", spec.exp, string(bz)) - }) - } -} diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index 653f1a9a79..b8874bfbba 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -12,6 +12,7 @@ import ( math_bits "math/bits" github_com_cometbft_cometbft_libs_bytes "github.com/cometbft/cometbft/libs/bytes" + _ "github.com/cosmos/cosmos-proto" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -1110,91 +1111,93 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/query.proto", fileDescriptor_9677c207036b9f2b) } var fileDescriptor_9677c207036b9f2b = []byte{ - // 1346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x98, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x3d, 0xa9, 0xe3, 0x1f, 0x93, 0x96, 0x3a, 0x43, 0x69, 0x8d, 0x49, 0xd7, 0xd1, 0x52, - 0xd2,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 0x8a, 0xf8, 0xa5, 0x7d, 0xd2, 0x1f, 0x59, 0xf0, 0x07, 0x46, 0xb6, 0x33, 0xf3, 0xbf, 0x1d, - 0x83, 0xe3, 0x82, 0x0d, 0x7d, 0x03, 0xe0, 0xd1, 0x60, 0xa3, 0x89, 0xfa, 0xb4, 0x63, 0x51, 0xdd, - 0x71, 0xee, 0xfc, 0x50, 0x73, 0x3d, 0xff, 0xea, 0x85, 0x87, 0xbf, 0xff, 0xfd, 0x68, 0x6c, 0x06, - 0x9d, 0xd1, 0x7b, 0x5a, 0x7d, 0x3f, 0x52, 0x7d, 0x4b, 0x8a, 0xb0, 0x8d, 0x7e, 0x00, 0xf0, 0x78, - 0x57, 0x0b, 0x89, 0x2e, 0x0e, 0x70, 0x17, 0x6e, 0x76, 0x73, 0xda, 0xb0, 0xd3, 0x25, 0xe0, 0x15, - 0x01, 0xa8, 0xa1, 0x0b, 0xc3, 0x00, 0xea, 0xab, 0x12, 0xea, 0x71, 0x00, 0x54, 0x36, 0x6c, 0x03, - 0x41, 0xc3, 0x9d, 0xe5, 0x40, 0xd0, 0xae, 0x3e, 0x50, 0x9d, 0x17, 0xa0, 0x17, 0x50, 0xa1, 0x1f, - 0xa8, 0x49, 0xf4, 0x2d, 0x79, 0xcd, 0xb7, 0xf5, 0x4e, 0x77, 0xf8, 0x23, 0x80, 0x99, 0xee, 0x66, - 0x0a, 0x45, 0x39, 0x8e, 0x68, 0xfc, 0x72, 0xfa, 0xd0, 0xf3, 0x87, 0x21, 0xed, 0x91, 0x94, 0x09, - 0xa8, 0x5f, 0x00, 0xcc, 0x74, 0xf7, 0x3d, 0x91, 0xa4, 0x11, 0x9d, 0x57, 0x24, 0x69, 0x54, 0x43, - 0xa5, 0xbe, 0x29, 0x48, 0xaf, 0xa1, 0xab, 0x43, 0x91, 0x3a, 0x78, 0x53, 0xdf, 0xea, 0x34, 0x4c, - 0xdb, 0xe8, 0x57, 0x00, 0x51, 0x6f, 0x13, 0x84, 0x2e, 0x45, 0x60, 0x44, 0xb6, 0x68, 0xb9, 0xb9, - 0x43, 0x58, 0x48, 0xf4, 0xb7, 0x04, 0xfa, 0xeb, 0xe8, 0xda, 0x70, 0x22, 0xbb, 0x0b, 0x85, 0xe1, - 0x1b, 0x30, 0x2e, 0x8e, 0xad, 0x1a, 0x79, 0x0e, 0x3b, 0x67, 0xf5, 0xd5, 0x03, 0xe7, 0x48, 0xa2, - 0x59, 0x41, 0xa4, 0xa2, 0xe9, 0x41, 0x07, 0x14, 0x39, 0x70, 0x5c, 0x14, 0x29, 0x74, 0xd0, 0xba, - 0x7e, 0xe9, 0xc8, 0x9d, 0x39, 0x78, 0x92, 0xf4, 0xae, 0x08, 0xef, 0x59, 0x74, 0xb2, 0xbf, 0x77, - 0xf4, 0x25, 0x80, 0x13, 0x81, 0xfa, 0x88, 0xce, 0x45, 0xac, 0xda, 0x5b, 0xa7, 0x73, 0x85, 0x61, - 0xa6, 0x4a, 0x8c, 0x19, 0x81, 0x31, 0x8d, 0x94, 0xfe, 0x18, 0x4c, 0xaf, 0x0b, 0x23, 0xb4, 0x0d, - 0x13, 0x5e, 0x61, 0x43, 0x51, 0xe1, 0x85, 0xea, 0x67, 0xee, 0xb5, 0x01, 0xb3, 0x86, 0x76, 0xef, - 0x39, 0x7d, 0x0a, 0x20, 0xea, 0xad, 0x50, 0x91, 0x27, 0x37, 0xb2, 0xc0, 0x46, 0x9e, 0xdc, 0xe8, - 0xf2, 0x37, 0xcc, 0xa5, 0x63, 0xba, 0x2c, 0xcf, 0xfa, 0x56, 0x57, 0xf9, 0xde, 0x2e, 0x2e, 0xed, - 0xfc, 0xa5, 0xc4, 0x9e, 0xb4, 0x94, 0xd8, 0x4e, 0x4b, 0x01, 0xbb, 0x2d, 0x05, 0xfc, 0xd9, 0x52, - 0xc0, 0x57, 0x7b, 0x4a, 0x6c, 0x77, 0x4f, 0x89, 0xfd, 0xb1, 0xa7, 0xc4, 0x3e, 0x9c, 0x09, 0xb4, - 0xec, 0x8b, 0x94, 0xd5, 0xee, 0xf9, 0x2e, 0x4c, 0xfd, 0x81, 0xe7, 0x4a, 0xfc, 0xcb, 0x54, 0x4e, - 0x88, 0x7f, 0x82, 0x2e, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x05, 0x38, 0x11, 0xcc, 0x12, + // 1378 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x98, 0xcf, 0x6f, 0x1b, 0x45, + 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x38, 0x93, 0xf6, 0xad, 0x33, 0x6f, 0x69, 0x5d, 0xd3, 0xae, 0xa3, + 0xa5, 0x84, 0xd4, 0x6d, 0xbd, 0x8d, 0xdb, 0x52, 0x51, 0x84, 0x90, 0x9d, 0x42, 0xd3, 0x8a, 0x42, + 0xea, 0x4a, 0x20, 0xc1, 0xc1, 0x8c, 0xbd, 0x13, 0x67, 0xa5, 0x78, 0xc7, 0xdd, 0x99, 0xfe, 0xb0, + 0xa2, 0x70, 0xe8, 0xb5, 0x1c, 0x90, 0x10, 0x07, 0xb8, 0xc0, 0xa1, 0x82, 0x4a, 0x08, 0x09, 0x01, + 0x87, 0x8a, 0x2b, 0x97, 0x1c, 0x2b, 0xb8, 0x70, 0xb2, 0xc0, 0x45, 0x02, 0xf5, 0x4f, 0xe8, 0x09, + 0xed, 0xcc, 0xac, 0xbd, 0x6b, 0x7b, 0xed, 0x25, 0xf8, 0xc0, 0xc5, 0x5a, 0xef, 0x3c, 0xcf, 0x3c, + 0x9f, 0xf9, 0xce, 0x33, 0xf3, 0x3c, 0x36, 0x3c, 0x52, 0xa3, 0xac, 0x71, 0x1b, 0xb3, 0x86, 0x21, + 0x3e, 0x6e, 0x2d, 0x1b, 0x37, 0x6e, 0x12, 0xa7, 0x95, 0x6f, 0x3a, 0x94, 0x53, 0x94, 0xf2, 0x46, + 0xf3, 0xe2, 0xe3, 0x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0f, 0x99, 0x75, 0xb0, 0xb6, 0x67, 0x72, 0x51, + 0x4c, 0x15, 0xc6, 0xa2, 0xc0, 0x58, 0x40, 0xda, 0x70, 0x0c, 0x66, 0x34, 0x85, 0x13, 0xda, 0x86, + 0x09, 0x59, 0x0c, 0x51, 0xd8, 0xf2, 0x02, 0x35, 0x37, 0xf3, 0xfc, 0x18, 0xab, 0xc8, 0xe1, 0x65, + 0xd0, 0x87, 0x00, 0xa2, 0xc1, 0xda, 0x15, 0x9a, 0xb9, 0xa1, 0x45, 0x39, 0x34, 0x73, 0xc3, 0x0b, + 0x63, 0x94, 0x43, 0xc7, 0x0c, 0x55, 0xb8, 0x8d, 0xad, 0xbe, 0x92, 0xbf, 0x5d, 0x5a, 0xdd, 0xf9, + 0x5d, 0x8b, 0x3d, 0xe8, 0x68, 0xb1, 0x9d, 0x8e, 0x06, 0x1e, 0x75, 0x34, 0xf0, 0x5b, 0x47, 0x03, + 0x1f, 0x3d, 0xd6, 0x62, 0x8f, 0x1e, 0x6b, 0xb1, 0x5f, 0x1f, 0x6b, 0xb1, 0x77, 0x17, 0x7d, 0x6d, + 0xfe, 0x0a, 0x65, 0x8d, 0x77, 0xbc, 0x10, 0xa6, 0x71, 0x47, 0x86, 0x12, 0x7f, 0xc3, 0x55, 0x13, + 0xe2, 0xff, 0xb0, 0x33, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x21, 0x39, 0xc1, 0xed, 0x13, 0x00, 0x00, } diff --git a/x/wasm/types/test_fixtures.go b/x/wasm/types/test_fixtures.go index 7f021813d6..5e9aadd10a 100644 --- a/x/wasm/types/test_fixtures.go +++ b/x/wasm/types/test_fixtures.go @@ -9,6 +9,8 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -174,7 +176,7 @@ func MsgInstantiateContractFixture(mutators ...func(*MsgInstantiateContract)) *M Msg: []byte(`{"foo":"bar"}`), Funds: sdk.Coins{{ Denom: "stake", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }}, } for _, m := range mutators { @@ -194,7 +196,7 @@ func MsgExecuteContractFixture(mutators ...func(*MsgExecuteContract)) *MsgExecut Msg: []byte(`{"do":"something"}`), Funds: sdk.Coins{{ Denom: "stake", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }}, } for _, m := range mutators { @@ -203,6 +205,7 @@ func MsgExecuteContractFixture(mutators ...func(*MsgExecuteContract)) *MsgExecut return r } +// Deprecated: all gov v1beta1 types will be removed func StoreCodeProposalFixture(mutators ...func(*StoreCodeProposal)) *StoreCodeProposal { const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" wasm := []byte{0x0} @@ -227,6 +230,7 @@ func StoreCodeProposalFixture(mutators ...func(*StoreCodeProposal)) *StoreCodePr return p } +// Deprecated: all gov v1beta1 types will be removed func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractProposal)) *InstantiateContractProposal { var ( anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) @@ -262,6 +266,7 @@ func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractP return p } +// Deprecated: all gov v1beta1 types will be removed func InstantiateContract2ProposalFixture(mutators ...func(p *InstantiateContract2Proposal)) *InstantiateContract2Proposal { var ( anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) @@ -302,6 +307,7 @@ func InstantiateContract2ProposalFixture(mutators ...func(p *InstantiateContract return p } +// Deprecated: all gov v1beta1 types will be removed func StoreAndInstantiateContractProposalFixture(mutators ...func(p *StoreAndInstantiateContractProposal)) *StoreAndInstantiateContractProposal { var ( anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) @@ -346,6 +352,7 @@ func StoreAndInstantiateContractProposalFixture(mutators ...func(p *StoreAndInst return p } +// Deprecated: all gov v1beta1 types will be removed func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal)) *MigrateContractProposal { var ( anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) @@ -377,6 +384,7 @@ func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal) return p } +// Deprecated: all gov v1beta1 types will be removed func SudoContractProposalFixture(mutators ...func(p *SudoContractProposal)) *SudoContractProposal { const ( contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" @@ -395,6 +403,7 @@ func SudoContractProposalFixture(mutators ...func(p *SudoContractProposal)) *Sud return p } +// Deprecated: all gov v1beta1 types will be removed func ExecuteContractProposalFixture(mutators ...func(p *ExecuteContractProposal)) *ExecuteContractProposal { const ( contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" @@ -409,7 +418,7 @@ func ExecuteContractProposalFixture(mutators ...func(p *ExecuteContractProposal) Msg: []byte(`{"do":"something"}`), Funds: sdk.Coins{{ Denom: "stake", - Amount: sdk.NewInt(1), + Amount: sdkmath.NewInt(1), }}, } @@ -419,6 +428,7 @@ func ExecuteContractProposalFixture(mutators ...func(p *ExecuteContractProposal) return p } +// Deprecated: all gov v1beta1 types will be removed func UpdateAdminProposalFixture(mutators ...func(p *UpdateAdminProposal)) *UpdateAdminProposal { const ( contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" @@ -437,6 +447,7 @@ func UpdateAdminProposalFixture(mutators ...func(p *UpdateAdminProposal)) *Updat return p } +// Deprecated: all gov v1beta1 types will be removed func ClearAdminProposalFixture(mutators ...func(p *ClearAdminProposal)) *ClearAdminProposal { const contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" p := &ClearAdminProposal{ diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 2bf96987be..a50196bd6c 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -74,10 +74,6 @@ func (msg MsgStoreCode) ValidateBasic() error { return nil } -func (msg MsgStoreCode) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgStoreCode) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -122,10 +118,6 @@ func (msg MsgInstantiateContract) ValidateBasic() error { return nil } -func (msg MsgInstantiateContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgInstantiateContract) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -159,10 +151,6 @@ func (msg MsgExecuteContract) ValidateBasic() error { return nil } -func (msg MsgExecuteContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgExecuteContract) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -212,10 +200,6 @@ func (msg MsgMigrateContract) ValidateBasic() error { return nil } -func (msg MsgMigrateContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgMigrateContract) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -263,10 +247,6 @@ func (msg MsgUpdateAdmin) ValidateBasic() error { return nil } -func (msg MsgUpdateAdmin) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgUpdateAdmin) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -293,10 +273,6 @@ func (msg MsgClearAdmin) ValidateBasic() error { return nil } -func (msg MsgClearAdmin) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgClearAdmin) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -317,10 +293,6 @@ func (msg MsgIBCSend) ValidateBasic() error { return nil } -func (msg MsgIBCSend) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgIBCSend) GetSigners() []sdk.AccAddress { return nil } @@ -337,10 +309,6 @@ func (msg MsgIBCCloseChannel) ValidateBasic() error { return nil } -func (msg MsgIBCCloseChannel) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgIBCCloseChannel) GetSigners() []sdk.AccAddress { return nil } @@ -386,10 +354,6 @@ func (msg MsgInstantiateContract2) ValidateBasic() error { return nil } -func (msg MsgInstantiateContract2) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgInstantiateContract2) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -426,10 +390,6 @@ func (msg MsgUpdateInstantiateConfig) ValidateBasic() error { return nil } -func (msg MsgUpdateInstantiateConfig) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgUpdateInstantiateConfig) GetSigners() []sdk.AccAddress { senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { // should never happen as valid basic rejects invalid addresses @@ -454,10 +414,6 @@ func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgUpdateParams) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -481,12 +437,6 @@ func (msg MsgPinCodes) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgPinCodes) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - -const maxCodeIDTotal = 50 - func (msg MsgPinCodes) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -494,6 +444,8 @@ func (msg MsgPinCodes) ValidateBasic() error { return validateCodeIDs(msg.CodeIDs) } +const maxCodeIDTotal = 50 + // ensure not empty, not duplicates and not exceeding max number func validateCodeIDs(codeIDs []uint64) error { switch n := len(codeIDs); { @@ -524,10 +476,6 @@ func (msg MsgUnpinCodes) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgUnpinCodes) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgUnpinCodes) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -551,10 +499,6 @@ func (msg MsgSudoContract) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgSudoContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgSudoContract) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -584,10 +528,6 @@ func (msg MsgStoreAndInstantiateContract) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgStoreAndInstantiateContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgStoreAndInstantiateContract) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -643,10 +583,6 @@ func (msg MsgAddCodeUploadParamsAddresses) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgAddCodeUploadParamsAddresses) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgAddCodeUploadParamsAddresses) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -675,10 +611,6 @@ func (msg MsgRemoveCodeUploadParamsAddresses) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgRemoveCodeUploadParamsAddresses) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgRemoveCodeUploadParamsAddresses) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") @@ -722,10 +654,6 @@ func (msg MsgStoreAndMigrateContract) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{authority} } -func (msg MsgStoreAndMigrateContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - func (msg MsgStoreAndMigrateContract) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") diff --git a/x/wasm/types/tx.pb.go b/x/wasm/types/tx.pb.go index 21e6e2201a..4e38b0dc97 100644 --- a/x/wasm/types/tx.pb.go +++ b/x/wasm/types/tx.pb.go @@ -1616,110 +1616,111 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/tx.proto", fileDescriptor_4f74d82755520264) } var fileDescriptor_4f74d82755520264 = []byte{ - // 1644 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,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, 0x62, 0xa9, 0x29, 0x12, 0x81, 0x1b, 0xad, 0xc0, 0x7e, 0x37, 0x17, - 0x33, 0x49, 0x56, 0x6f, 0x09, 0x31, 0x73, 0x69, 0x55, 0x62, 0x39, 0x48, 0x34, 0xb6, 0x50, 0xe3, - 0x3e, 0xee, 0xa8, 0x14, 0xb4, 0xe0, 0x8c, 0xf9, 0x87, 0xe3, 0x30, 0x5d, 0xc5, 0xf2, 0x6a, 0x4f, - 0xc9, 0x15, 0x5d, 0x33, 0xda, 0x62, 0xc3, 0x08, 0xb4, 0x64, 0x1a, 0x26, 0x44, 0x49, 0x55, 0x34, - 0x22, 0x2b, 0x29, 0xd0, 0x81, 0x5b, 0x93, 0x48, 0xa0, 0x26, 0x69, 0x98, 0x68, 0x8a, 0x75, 0xd4, - 0xcc, 0x44, 0x29, 0x2b, 0x19, 0xb0, 0x79, 0x88, 0xa8, 0x58, 0x26, 0xf6, 0x4c, 0x55, 0xa6, 0xff, - 0xec, 0xe6, 0x58, 0x41, 0xdc, 0xb1, 0xd5, 0xa8, 0x22, 0x8c, 0x45, 0x19, 0x09, 0x26, 0x09, 0xbb, - 0x09, 0x13, 0x9b, 0x1d, 0x4d, 0xc2, 0x99, 0xd8, 0x5c, 0x24, 0x3f, 0x59, 0x9a, 0x2d, 0x58, 0xe1, - 0x61, 0x06, 0x66, 0xc1, 0x0a, 0xcc, 0xc2, 0x8a, 0xae, 0x68, 0x95, 0xff, 0x3d, 0xea, 0xe6, 0xc6, - 0xbe, 0xf8, 0x39, 0x97, 0x97, 0x15, 0x63, 0xab, 0x53, 0x2f, 0x34, 0x74, 0xd5, 0x8a, 0x25, 0xeb, - 0xef, 0x2a, 0x96, 0xee, 0x5b, 0x71, 0x67, 0x32, 0xe0, 0xcf, 0x9e, 0x3e, 0x58, 0x60, 0x04, 0x2a, - 0xbe, 0xfc, 0x1f, 0x8f, 0x77, 0xce, 0xd8, 0xde, 0xf1, 0xb1, 0x13, 0xff, 0x3a, 0x64, 0xf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x9d, 0x9a, 0x3b, 0xd5, 0x13, 0x1a, 0xda, 0xa1, 0x4c, 0x6e, 0x6b, - 0x44, 0xfa, 0xad, 0x51, 0xbe, 0xe0, 0x51, 0xff, 0x94, 0xad, 0xbe, 0x6b, 0x57, 0x3e, 0x43, 0x8e, - 0x02, 0xd7, 0x8c, 0xad, 0x36, 0x2f, 0xc3, 0xb1, 0x2a, 0x96, 0x57, 0x9a, 0x48, 0x6c, 0x87, 0x2b, - 0x18, 0xa6, 0x03, 0xef, 0xd1, 0x81, 0xb5, 0x75, 0xe8, 0xc9, 0xe5, 0x67, 0xe0, 0x74, 0xdf, 0x84, - 0xa3, 0xc1, 0xef, 0x0c, 0xb1, 0x2b, 0x55, 0xae, 0x3f, 0x53, 0x37, 0x15, 0x39, 0x50, 0x1f, 0x57, - 0x14, 0x8c, 0x07, 0x46, 0xc1, 0x3d, 0xe0, 0x4c, 0xab, 0x06, 0x1c, 0xf3, 0x91, 0x91, 0x8e, 0xf9, - 0x8c, 0x86, 0x76, 0x56, 0x7d, 0x4f, 0xfa, 0xa2, 0x07, 0x76, 0xae, 0xdf, 0xf4, 0x03, 0x58, 0xf8, - 0x8b, 0xc0, 0x07, 0xaf, 0x3a, 0x06, 0xf9, 0x92, 0x81, 0x13, 0x0e, 0xd9, 0x9a, 0xd8, 0x16, 0x55, - 0xcc, 0xde, 0x80, 0xa4, 0xd8, 0x31, 0xb6, 0xf4, 0xb6, 0x62, 0xec, 0x51, 0x43, 0x54, 0x32, 0xdf, - 0x7f, 0x75, 0x35, 0x6d, 0x15, 0x82, 0x65, 0x5a, 0xb1, 0xd6, 0x8d, 0xb6, 0xa2, 0xc9, 0x42, 0x8f, - 0x94, 0x7d, 0x19, 0x62, 0x2d, 0x22, 0x81, 0x18, 0x69, 0xb2, 0x94, 0x19, 0x04, 0x4b, 0x77, 0xa8, - 0x24, 0xcd, 0xca, 0x41, 0xab, 0x81, 0xc5, 0x42, 0x33, 0xa3, 0x27, 0xcc, 0x84, 0x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 0x20, 0xdd, 0xf7, 0x2e, 0xb0, 0x06, 0x09, 0xa7, 0xe7, 0x3f, 0xe7, 0xcb, 0x66, 0x2f, 0x73, - 0x97, 0x42, 0x97, 0xdd, 0x4e, 0x76, 0xb5, 0xe1, 0xfe, 0x4e, 0xee, 0x11, 0x04, 0x38, 0x79, 0xb0, - 0x3b, 0x66, 0x3f, 0x60, 0xe0, 0x4c, 0x58, 0x6b, 0x7c, 0x2d, 0xb8, 0x2c, 0xf9, 0x73, 0x70, 0x2f, - 0x1d, 0x94, 0xc3, 0xd1, 0xe5, 0x13, 0x06, 0x72, 0xc3, 0x9a, 0x01, 0xff, 0x58, 0x1a, 0xc2, 0xc5, - 0xbd, 0x72, 0x18, 0x2e, 0x47, 0xaf, 0x8f, 0x18, 0x38, 0x1b, 0xda, 0x98, 0xf9, 0x57, 0xb7, 0x30, - 0x16, 0xee, 0xe6, 0x81, 0x59, 0xdc, 0x79, 0x19, 0xd4, 0x35, 0x2c, 0x86, 0xda, 0xde, 0x5b, 0xc1, - 0xae, 0x1f, 0x84, 0xda, 0xde, 0xbe, 0x72, 0xeb, 0xd1, 0xaf, 0xd9, 0xb1, 0x47, 0xfb, 0x59, 0xe6, - 0xf1, 0x7e, 0x96, 0xf9, 0x65, 0x3f, 0xcb, 0x7c, 0xfc, 0x24, 0x3b, 0xf6, 0xf8, 0x49, 0x76, 0xec, - 0x87, 0x27, 0xd9, 0xb1, 0xb7, 0x2e, 0xbb, 0x9a, 0xfb, 0x15, 0x1d, 0xab, 0x77, 0xed, 0x0f, 0x3f, - 0x52, 0x71, 0x97, 0x7e, 0x00, 0x22, 0x0d, 0x7e, 0x3d, 0x46, 0x3e, 0xe8, 0xfc, 0xf7, 0xaf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xdf, 0x59, 0x6a, 0x1b, 0x9a, 0x1a, 0x00, 0x00, + // 1660 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00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+ 0x00, 0x00, 0xff, 0xff, 0xea, 0xa8, 0x7e, 0x75, 0xaa, 0x1c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index e3ea0f610a..87f439b0ca 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -8,8 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) const ( @@ -137,7 +138,7 @@ func TestInstantiateContractValidation(t *testing.T) { CodeID: firstCodeID, Label: "foo", Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(200)}}, }, valid: true, }, @@ -148,7 +149,7 @@ func TestInstantiateContractValidation(t *testing.T) { Label: "foo", Msg: []byte(`{"some": "data"}`), // we cannot use sdk.NewCoin() constructors as they panic on creating invalid data (before we can test) - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(-200)}}, }, valid: false, }, @@ -247,7 +248,7 @@ func TestInstantiateContract2Validation(t *testing.T) { CodeID: firstCodeID, Label: strings.Repeat("a", MaxLabelSize), Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(200)}}, Salt: bytes.Repeat([]byte{0}, MaxSaltSize), FixMsg: true, }, @@ -260,7 +261,7 @@ func TestInstantiateContract2Validation(t *testing.T) { Label: "foo", Msg: []byte(`{"some": "data"}`), // we cannot use sdk.NewCoin() constructors as they panic on creating invalid data (before we can test) - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(-200)}}, Salt: []byte{0}, }, valid: false, @@ -341,7 +342,7 @@ func TestExecuteContractValidation(t *testing.T) { Sender: goodAddress, Contract: goodAddress, Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(200)}}, }, valid: true, }, @@ -380,7 +381,7 @@ func TestExecuteContractValidation(t *testing.T) { Sender: goodAddress, Contract: goodAddress, Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-1)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(-1)}}, }, valid: false, }, @@ -389,7 +390,7 @@ func TestExecuteContractValidation(t *testing.T) { Sender: goodAddress, Contract: goodAddress, Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(1)}, sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(1)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(1)}, sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(1)}}, }, valid: false, }, @@ -623,45 +624,6 @@ func TestMsgMigrateContract(t *testing.T) { } } -func TestMsgJsonSignBytes(t *testing.T) { - const myInnerMsg = `{"foo":"bar"}` - specs := map[string]struct { - src legacytx.LegacyMsg - exp string - }{ - "MsgInstantiateContract": { - src: &MsgInstantiateContract{Msg: RawContractMessage(myInnerMsg)}, - exp: ` -{ - "type":"wasm/MsgInstantiateContract", - "value": {"msg": {"foo":"bar"}, "funds":[]} -}`, - }, - "MsgExecuteContract": { - src: &MsgExecuteContract{Msg: RawContractMessage(myInnerMsg)}, - exp: ` -{ - "type":"wasm/MsgExecuteContract", - "value": {"msg": {"foo":"bar"}, "funds":[]} -}`, - }, - "MsgMigrateContract": { - src: &MsgMigrateContract{Msg: RawContractMessage(myInnerMsg)}, - exp: ` -{ - "type":"wasm/MsgMigrateContract", - "value": {"msg": {"foo":"bar"}} -}`, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - bz := spec.src.GetSignBytes() - assert.JSONEq(t, spec.exp, string(bz), "raw: %s", string(bz)) - }) - } -} - func TestMsgUpdateInstantiateConfig(t *testing.T) { // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() @@ -1155,7 +1117,7 @@ func TestMsgStoreAndInstantiateContractValidation(t *testing.T) { Authority: goodAddress, Label: "foo", Msg: []byte(`{"some": "data"}`), - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(200)}}, WASMByteCode: []byte("foo"), InstantiatePermission: &AllowEverybody, UnpinCode: true, @@ -1206,7 +1168,7 @@ func TestMsgStoreAndInstantiateContractValidation(t *testing.T) { Label: "foo", Msg: []byte(`{"some": "data"}`), // we cannot use sdk.NewCoin() constructors as they panic on creating invalid data (before we can test) - Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-200)}}, + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdkmath.NewInt(-200)}}, WASMByteCode: []byte("foo"), }, valid: false, diff --git a/x/wasm/types/types.pb.go b/x/wasm/types/types.pb.go index b565530d24..16ad44eb15 100644 --- a/x/wasm/types/types.pb.go +++ b/x/wasm/types/types.pb.go @@ -145,7 +145,7 @@ var xxx_messageInfo_AccessTypeParam proto.InternalMessageInfo // AccessConfig access control type. type AccessConfig struct { Permission AccessType `protobuf:"varint,1,opt,name=permission,proto3,enum=cosmwasm.wasm.v1.AccessType" json:"permission,omitempty" yaml:"permission"` - Addresses []string `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty" yaml:"addresses"` + Addresses []string `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty"` } func (m *AccessConfig) Reset() { *m = AccessConfig{} } @@ -491,80 +491,81 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/types.proto", fileDescriptor_e6155d98fa173e02) } var fileDescriptor_e6155d98fa173e02 = []byte{ - // 1167 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xda, 0x4e, 0x62, 0x4f, 0x03, 0x6c, 0x87, 0x94, 0x3a, 0x26, 0xb2, 0xcd, 0x52, 0x4a, - 0x9a, 0xb6, 0x76, 0x1b, 0x10, 0x87, 0x1e, 0x2a, 0x79, 0xed, 0x6d, 0xb3, 0x95, 0x62, 0x5b, 0x63, - 0x97, 0x12, 0xa4, 0xb2, 0xda, 0x1f, 0x63, 0x67, 0x55, 0x7b, 0xc7, 0xda, 0x19, 0xa7, 0xde, 0xff, - 0x00, 0x59, 0x42, 0xe2, 0xc0, 0x81, 0x8b, 0x25, 0xa4, 0x22, 0xe8, 0x91, 0x03, 0x7f, 0x44, 0xc5, - 0x01, 0xf5, 0xc8, 0xc9, 0x82, 0xf4, 0x00, 0xe7, 0x1c, 0x38, 0x94, 0x0b, 0xda, 0x99, 0xb8, 0xbb, - 0xa2, 0x4d, 0x63, 0x2e, 0xab, 0x99, 0xf7, 0xde, 0xf7, 0xcd, 0x37, 0xdf, 0xcc, 0x1b, 0x2d, 0xd8, - 0xb0, 0x09, 0x1d, 0x3c, 0x34, 0xe9, 0xa0, 0xc2, 0x3f, 0x07, 0xd7, 0x2b, 0x2c, 0x18, 0x62, 0x5a, - 0x1e, 0xfa, 0x84, 0x11, 0x28, 0xcf, 0xb3, 0x65, 0xfe, 0x39, 0xb8, 0x9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 0x88, 0x78, 0x57, 0xbf, 0x8d, - 0xaa, 0x1d, 0x4d, 0x4e, 0xe6, 0x2f, 0x4f, 0xa6, 0xa5, 0x0f, 0x4f, 0xe3, 0xde, 0x75, 0x7b, 0xbe, - 0xc9, 0xf0, 0xc2, 0xf4, 0xb7, 0xb5, 0x86, 0xd6, 0xd6, 0xdb, 0x72, 0x6a, 0x31, 0xfa, 0xdb, 0xd8, - 0xc3, 0xd4, 0xa5, 0xf9, 0x74, 0x78, 0x64, 0xea, 0xce, 0x93, 0x3f, 0x0a, 0x89, 0xc7, 0x87, 0x05, - 0xe9, 0xc9, 0x61, 0x41, 0x7a, 0x7a, 0x58, 0x90, 0x7e, 0x3f, 0x2c, 0x48, 0x5f, 0x3f, 0x2b, 0x24, - 0x9e, 0x3e, 0x2b, 0x24, 0x7e, 0x7b, 0x56, 0x48, 0x7c, 0x7e, 0x31, 0xd6, 0x10, 0x35, 0x42, 0x07, - 0xf7, 0xe6, 0x7f, 0x4b, 0x4e, 0x65, 0x2c, 0xfe, 0x9a, 0xf8, 0x2f, 0x93, 0xb5, 0xcc, 0xdf, 0xbb, - 0x8f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x0e, 0x96, 0x9d, 0x53, 0x09, 0x00, 0x00, + // 1183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xbf, 0x8f, 0x1b, 0xc5, + 0x17, 0xf7, 0xda, 0xbe, 0x3b, 0x7b, 0x72, 0xdf, 0x2f, 0x9b, 0xe1, 0x42, 0x7c, 0xe6, 0xb4, 0x36, + 0x4b, 0x08, 0x97, 0x4b, 0x62, 0x27, 0x07, 0x4a, 0x91, 0x22, 0x92, 0x7f, 0x6c, 0x72, 0x1b, 0xe9, + 0x6c, 0x6b, 0xec, 0x10, 0x0e, 0x29, 0xac, 0xf6, 0xc7, 0xd8, 0xb7, 0x8a, 0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, + 0x77, 0xe7, 0xff, 0x5f, 0x4e, 0x79, 0x2c, 0xfe, 0xc3, 0xf8, 0x4f, 0x98, 0xb5, 0xcc, 0xe7, 0xdd, + 0x7b, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xfd, 0x12, 0x8b, 0xa5, 0x09, 0x00, 0x00, } func (this *AccessTypeParam) Equal(that interface{}) bool { diff --git a/x/wasm/types/wasmer_engine.go b/x/wasm/types/wasmer_engine.go index d3b465de77..e27715bf74 100644 --- a/x/wasm/types/wasmer_engine.go +++ b/x/wasm/types/wasmer_engine.go @@ -4,7 +4,7 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "cosmossdk.io/store/types" ) // DefaultMaxQueryStackSize maximum size of the stack of contract instances doing queries @@ -262,11 +262,11 @@ var _ wasmvm.KVStore = &StoreAdapter{} // StoreAdapter adapter to bridge SDK store impl to wasmvm type StoreAdapter struct { - parent sdk.KVStore + parent storetypes.KVStore } // NewStoreAdapter constructor -func NewStoreAdapter(s sdk.KVStore) *StoreAdapter { +func NewStoreAdapter(s storetypes.KVStore) *StoreAdapter { if s == nil { panic("store must not be nil") }