diff --git a/.circleci/config.yml b/.circleci/config.yml index 89ed609b..b4a50ece 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: lint: docker: - - image: golangci/golangci-lint:v1.42.1-alpine + - image: golangci/golangci-lint:v1.43.0 steps: - checkout - run: diff --git a/app/ante.go b/app/ante.go index e7aeb4ae..1bca9a8f 100644 --- a/app/ante.go +++ b/app/ante.go @@ -2,47 +2,66 @@ package app import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/cosmos/cosmos-sdk/x/auth/types" - channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/keeper" - ibcante "github.com/cosmos/cosmos-sdk/x/ibc/core/ante" - - wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" + channelkeeper "github.com/cosmos/ibc-go/v2/modules/core/04-channel/keeper" + ibcante "github.com/cosmos/ibc-go/v2/modules/core/ante" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" ) -// NewAnteHandler returns an AnteHandler that checks and increments sequence -// numbers, checks signatures & account numbers, and deducts fees from the first -// signer. -func NewAnteHandler( - ak ante.AccountKeeper, - bankKeeper types.BankKeeper, - sigGasConsumer ante.SignatureVerificationGasConsumer, - signModeHandler signing.SignModeHandler, - txCounterStoreKey sdk.StoreKey, - channelKeeper channelkeeper.Keeper, - wasmConfig wasmTypes.WasmConfig, -) sdk.AnteHandler { - // copied sdk https://github.com/cosmos/cosmos-sdk/blob/v0.42.9/x/auth/ante/ante.go - return sdk.ChainAnteDecorators( - ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - wasmkeeper.NewLimitSimulationGasDecorator(wasmConfig.SimulationGasLimit), // after setup context to enforce limits early - wasmkeeper.NewCountTXDecorator(txCounterStoreKey), +// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC +// channel keeper. +type HandlerOptions struct { + ante.HandlerOptions + + IBCChannelkeeper channelkeeper.Keeper + WasmConfig *wasmTypes.WasmConfig + TXCounterStoreKey sdk.StoreKey +} + +func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.AccountKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler") + } + if options.BankKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler") + } + if options.SignModeHandler == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") + } + if options.WasmConfig == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder") + } + if options.TXCounterStoreKey == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder") + } + + var sigGasConsumer = options.SigGasConsumer + if sigGasConsumer == nil { + sigGasConsumer = ante.DefaultSigVerificationGasConsumer + } + + 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), ante.NewRejectExtensionOptionsDecorator(), ante.NewMempoolFeeDecorator(), ante.NewValidateBasicDecorator(), - ante.TxTimeoutHeightDecorator{}, - ante.NewValidateMemoDecorator(ak), - ante.NewConsumeGasForTxSizeDecorator(ak), - ante.NewRejectFeeGranterDecorator(), - ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators - ante.NewValidateSigCountDecorator(ak), - ante.NewDeductFeeDecorator(ak, bankKeeper), - ante.NewSigGasConsumeDecorator(ak, sigGasConsumer), - ante.NewSigVerificationDecorator(ak, signModeHandler), - ante.NewIncrementSequenceDecorator(ak), - ibcante.NewAnteDecorator(channelKeeper), - ) + ante.NewTxTimeoutHeightDecorator(), + ante.NewValidateMemoDecorator(options.AccountKeeper), + ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), + // SetPubKeyDecorator must be called before all signature verification decorators + ante.NewSetPubKeyDecorator(options.AccountKeeper), + ante.NewValidateSigCountDecorator(options.AccountKeeper), + ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), + ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + ante.NewIncrementSequenceDecorator(options.AccountKeeper), + ibcante.NewAnteDecorator(options.IBCChannelkeeper), + } + + return sdk.ChainAnteDecorators(anteDecorators...), nil } diff --git a/app/app.go b/app/app.go index 2ce66b16..df279767 100644 --- a/app/app.go +++ b/app/app.go @@ -8,19 +8,9 @@ import ( "path/filepath" "strings" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/gorilla/mux" - "github.com/rakyll/statik/fs" - "github.com/spf13/cast" - abci "github.com/tendermint/tendermint/abci/types" - tmjson "github.com/tendermint/tendermint/libs/json" - "github.com/tendermint/tendermint/libs/log" - tmos "github.com/tendermint/tendermint/libs/os" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - dbm "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -39,6 +29,10 @@ import ( authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" "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" @@ -55,19 +49,14 @@ import ( "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" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - transfer "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer" - ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/keeper" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - ibc "github.com/cosmos/cosmos-sdk/x/ibc/core" - ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client" - porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types" - ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" - ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper" "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" @@ -86,7 +75,27 @@ import ( 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" + transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v2/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v2/modules/core" + ibcclient "github.com/cosmos/ibc-go/v2/modules/core/02-client" + ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client" + ibcclienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper" + "github.com/gorilla/mux" + "github.com/rakyll/statik/fs" + "github.com/spf13/cast" + abci "github.com/tendermint/tendermint/abci/types" + tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/tendermint/tendermint/libs/log" + tmos "github.com/tendermint/tendermint/libs/os" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + dbm "github.com/tendermint/tm-db" + wasmappparams "github.com/CosmWasm/wasmd/app/params" "github.com/CosmWasm/wasmd/x/wasm" wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" @@ -161,17 +170,27 @@ var ( mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( - append(wasmclient.ProposalHandlers, paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler)..., + append( + wasmclient.ProposalHandlers, + paramsclient.ProposalHandler, + distrclient.ProposalHandler, + upgradeclient.ProposalHandler, + upgradeclient.CancelProposalHandler, + ibcclientclient.UpdateClientProposalHandler, + ibcclientclient.UpgradeProposalHandler, + )..., ), params.AppModuleBasic{}, - wasm.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, ibc.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, + wasm.AppModuleBasic{}, ) // module account permissions @@ -187,7 +206,6 @@ var ( } ) -// Verify app interface at compile time var ( _ simapp.App = (*WasmApp)(nil) _ servertypes.Application = (*WasmApp)(nil) @@ -197,7 +215,7 @@ var ( type WasmApp struct { *baseapp.BaseApp legacyAmino *codec.LegacyAmino //nolint:staticcheck - appCodec codec.Marshaler + appCodec codec.Codec interfaceRegistry types.InterfaceRegistry invCheckPeriod uint @@ -222,6 +240,8 @@ type WasmApp struct { ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly evidenceKeeper evidencekeeper.Keeper transferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper wasmKeeper wasm.Keeper scopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -233,6 +253,9 @@ type WasmApp struct { // simulation manager sm *module.SimulationManager + + // module configurator + configurator module.Configurator } // NewWasmApp returns a reference to an initialized WasmApp. @@ -244,19 +267,19 @@ func NewWasmApp( skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, + encodingConfig wasmappparams.EncodingConfig, enabledProposals []wasm.ProposalType, appOpts servertypes.AppOptions, wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *WasmApp { - encodingConfig := MakeEncodingConfig() appCodec, legacyAmino := encodingConfig.Marshaler, encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) - bApp.SetAppVersion(version.Version) + bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) keys := sdk.NewKVStoreKeys( @@ -264,7 +287,7 @@ func NewWasmApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, - wasm.StoreKey, + feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -280,42 +303,97 @@ func NewWasmApp( memKeys: memKeys, } - app.paramsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + app.paramsKeeper = initParamsKeeper( + appCodec, + legacyAmino, + keys[paramstypes.StoreKey], + tkeys[paramstypes.TStoreKey], + ) // set the BaseApp's parameter store bApp.SetParamStore(app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) // add capability keeper and ScopeToModule for ibc module - app.capabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + app.capabilityKeeper = capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + memKeys[capabilitytypes.MemStoreKey], + ) scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.capabilityKeeper.ScopeToModule(wasm.ModuleName) + app.capabilityKeeper.Seal() // add keepers app.accountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], app.getSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, + appCodec, + keys[authtypes.StoreKey], + app.getSubspace(authtypes.ModuleName), + authtypes.ProtoBaseAccount, + maccPerms, ) app.bankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.accountKeeper, app.getSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), + appCodec, + keys[banktypes.StoreKey], + app.accountKeeper, + app.getSubspace(banktypes.ModuleName), + app.ModuleAccountAddrs(), + ) + app.AuthzKeeper = authzkeeper.NewKeeper( + keys[authzkeeper.StoreKey], + appCodec, + app.BaseApp.MsgServiceRouter(), + ) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + keys[feegrant.StoreKey], + app.accountKeeper, ) stakingKeeper := stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], app.accountKeeper, app.bankKeeper, app.getSubspace(stakingtypes.ModuleName), + appCodec, + keys[stakingtypes.StoreKey], + app.accountKeeper, + app.bankKeeper, + app.getSubspace(stakingtypes.ModuleName), ) app.mintKeeper = mintkeeper.NewKeeper( - appCodec, keys[minttypes.StoreKey], app.getSubspace(minttypes.ModuleName), &stakingKeeper, - app.accountKeeper, app.bankKeeper, authtypes.FeeCollectorName, + appCodec, + keys[minttypes.StoreKey], + app.getSubspace(minttypes.ModuleName), + &stakingKeeper, + app.accountKeeper, + app.bankKeeper, + authtypes.FeeCollectorName, ) app.distrKeeper = distrkeeper.NewKeeper( - appCodec, keys[distrtypes.StoreKey], app.getSubspace(distrtypes.ModuleName), app.accountKeeper, app.bankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + appCodec, + keys[distrtypes.StoreKey], + app.getSubspace(distrtypes.ModuleName), + app.accountKeeper, + app.bankKeeper, + &stakingKeeper, + authtypes.FeeCollectorName, + app.ModuleAccountAddrs(), ) app.slashingKeeper = slashingkeeper.NewKeeper( - appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.getSubspace(slashingtypes.ModuleName), + appCodec, + keys[slashingtypes.StoreKey], + &stakingKeeper, + app.getSubspace(slashingtypes.ModuleName), ) app.crisisKeeper = crisiskeeper.NewKeeper( - app.getSubspace(crisistypes.ModuleName), invCheckPeriod, app.bankKeeper, authtypes.FeeCollectorName, + app.getSubspace(crisistypes.ModuleName), + invCheckPeriod, + app.bankKeeper, + authtypes.FeeCollectorName, + ) + app.upgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + keys[upgradetypes.StoreKey], + appCodec, + homePath, + app.BaseApp, ) - app.upgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks @@ -323,34 +401,47 @@ func NewWasmApp( stakingtypes.NewMultiStakingHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()), ) - // Create IBC Keeper app.ibcKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.getSubspace(ibchost.ModuleName), app.stakingKeeper, scopedIBCKeeper, + appCodec, + keys[ibchost.StoreKey], + app.getSubspace(ibchost.ModuleName), + app.stakingKeeper, + app.upgradeKeeper, + scopedIBCKeeper, ) // register the proposal types govRouter := govtypes.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). + govRouter. + AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)). AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)). - AddRoute(ibchost.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.ibcKeeper.ClientKeeper)) + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)) // Create Transfer Keepers app.transferKeeper = ibctransferkeeper.NewKeeper( - appCodec, keys[ibctransfertypes.StoreKey], app.getSubspace(ibctransfertypes.ModuleName), - app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper, - app.accountKeeper, app.bankKeeper, scopedTransferKeeper, + appCodec, + keys[ibctransfertypes.StoreKey], + app.getSubspace(ibctransfertypes.ModuleName), + app.ibcKeeper.ChannelKeeper, + &app.ibcKeeper.PortKeeper, + app.accountKeeper, + app.bankKeeper, + scopedTransferKeeper, ) transferModule := transfer.NewAppModule(app.transferKeeper) - // Create static IBC router, add transfer route, then set and seal it + // create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, keys[evidencetypes.StoreKey], &app.stakingKeeper, app.slashingKeeper, + appCodec, + keys[evidencetypes.StoreKey], + &app.stakingKeeper, + app.slashingKeeper, ) app.evidenceKeeper = *evidenceKeeper @@ -375,7 +466,7 @@ func NewWasmApp( &app.ibcKeeper.PortKeeper, scopedWasmKeeper, app.transferKeeper, - app.Router(), + app.MsgServiceRouter(), app.GRPCQueryRouter(), wasmDir, wasmConfig, @@ -409,14 +500,15 @@ func NewWasmApp( // must be passed by reference here. app.mm = module.NewManager( genutil.NewAppModule( - app.accountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx, + app.accountKeeper, + app.stakingKeeper, + app.BaseApp.DeliverTx, encodingConfig.TxConfig, ), - auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts), + auth.NewAppModule(appCodec, app.accountKeeper, nil), vesting.NewAppModule(app.accountKeeper, app.bankKeeper), bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper), capability.NewAppModule(appCodec, *app.capabilityKeeper), - crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants), gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper), mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper), slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper), @@ -425,9 +517,12 @@ func NewWasmApp( upgrade.NewAppModule(app.upgradeKeeper), wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper), evidence.NewAppModule(app.evidenceKeeper), + feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry), ibc.NewAppModule(app.ibcKeeper), params.NewAppModule(app.paramsKeeper), transferModule, + crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them ) // During begin block slashing happens after distr.BeginBlocker so that @@ -435,32 +530,67 @@ func NewWasmApp( // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 app.mm.SetOrderBeginBlockers( - upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, - evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, + 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, + paramstypes.ModuleName, + vestingtypes.ModuleName, + // additional non simd modules + ibchost.ModuleName, + ibctransfertypes.ModuleName, + wasm.ModuleName, ) - app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. // NOTE: Capability module must occur first so that it can initialize any capabilities // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. - // wasm module should be a the end as it can call other modules functionality direct or via message dispatching during + // 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, ... app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, - slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + authz.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + vestingtypes.ModuleName, + // additional non simd modules + ibchost.ModuleName, + ibctransfertypes.ModuleName, // wasm after ibc transfer wasm.ModuleName, ) + // Uncomment if you want to set a custom migration order here. + // app.mm.SetOrderMigrations(custom order) + app.mm.RegisterInvariants(&app.crisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.mm.RegisterServices(module.NewConfigurator(app.MsgServiceRouter(), app.GRPCQueryRouter())) - // add test gRPC service for testing gRPC queries in isolation - // testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.QueryImpl{}) // TODO: this is testdata !!!! + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(app.configurator) // create the simulation manager and define the order of the modules for deterministic simulations // @@ -470,14 +600,16 @@ func NewWasmApp( auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts), bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper), capability.NewAppModule(appCodec, *app.capabilityKeeper), + feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper), mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper), staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper), distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper), slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper), params.NewAppModule(app.paramsKeeper), - wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper), evidence.NewAppModule(app.evidenceKeeper), + wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper), ibc.NewAppModule(app.ibcKeeper), transferModule, ) @@ -489,36 +621,38 @@ func NewWasmApp( app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) - // initialize BaseApp + anteHandler, err := NewAnteHandler( + HandlerOptions{ + HandlerOptions: ante.HandlerOptions{ + AccountKeeper: app.accountKeeper, + BankKeeper: app.bankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + IBCChannelkeeper: app.ibcKeeper.ChannelKeeper, + WasmConfig: &wasmConfig, + TXCounterStoreKey: keys[wasm.StoreKey], + }, + ) + if err != nil { + panic(fmt.Errorf("failed to create AnteHandler: %s", err)) + } + + app.SetAnteHandler(anteHandler) app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) - app.SetAnteHandler( - NewAnteHandler( - app.accountKeeper, app.bankKeeper, ante.DefaultSigVerificationGasConsumer, - encodingConfig.TxConfig.SignModeHandler(), keys[wasm.StoreKey], app.ibcKeeper.ChannelKeeper, - wasmConfig, - ), - ) app.SetEndBlocker(app.EndBlocker) if loadLatest { if err := app.LoadLatestVersion(); err != nil { - tmos.Exit(err.Error()) + tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err)) } - - // Initialize and seal the capability keeper so all persistent capabilities - // are loaded in-memory and prevent any further modules from creating scoped - // sub-keepers. - // This must be done during creation of baseapp rather than in InitChain so - // that in-memory capabilities get regenerated on app restart. - // Note that since this reads from the store, we can only perform it when - // `loadLatest` is set to true. ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) - app.capabilityKeeper.InitializeAndSeal(ctx) // Initialize pinned codes in wasmvm as they are not persisted there if err := app.wasmKeeper.InitializePinnedCodes(ctx); err != nil { - panic(err) + tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } } @@ -547,6 +681,9 @@ func (app *WasmApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } + + app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } @@ -565,7 +702,7 @@ func (app *WasmApp) ModuleAccountAddrs() map[string]bool { return modAccAddrs } -// LegacyAmino returns SimApp's amino codec. +// LegacyAmino returns legacy amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. @@ -573,11 +710,6 @@ func (app *WasmApp) LegacyAmino() *codec.LegacyAmino { //nolint:staticcheck return app.legacyAmino } -// SimulationManager implements the SimulationApp interface -func (app *WasmApp) SimulationManager() *module.SimulationManager { - return app.sm -} - // getSubspace returns a param subspace for a given module name. // // NOTE: This is solely to be used for testing purposes. @@ -586,6 +718,11 @@ func (app *WasmApp) getSubspace(moduleName string) paramstypes.Subspace { return subspace } +// SimulationManager implements the SimulationApp interface +func (app *WasmApp) SimulationManager() *module.SimulationManager { + return app.sm +} + // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *WasmApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { @@ -604,7 +741,7 @@ func (app *WasmApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICo // register swagger API from root so that other applications can override easily if apiConfig.Swagger { - RegisterSwaggerAPI(clientCtx, apiSvr.Router) + RegisterSwaggerAPI(apiSvr.Router) } } @@ -618,12 +755,12 @@ func (app *WasmApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } -func (app *WasmApp) AppCodec() codec.JSONMarshaler { +func (app *WasmApp) AppCodec() codec.Codec { return app.appCodec } // RegisterSwaggerAPI registers swagger route with API Server -func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { +func RegisterSwaggerAPI(rtr *mux.Router) { statikFS, err := fs.New() if err != nil { panic(err) @@ -643,7 +780,7 @@ func GetMaccPerms() map[string][]string { } // initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { //nolint:staticcheck +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) paramsKeeper.Subspace(authtypes.ModuleName) diff --git a/app/app_test.go b/app/app_test.go index 495be698..a3bd66ab 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -19,7 +19,7 @@ var emptyWasmOpts []wasm.Option = nil func TestWasmdExport(t *testing.T) { db := db.NewMemDB() - gapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + gapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) genesisState := NewDefaultGenesisState() stateBytes, err := json.MarshalIndent(genesisState, "", " ") @@ -35,7 +35,7 @@ func TestWasmdExport(t *testing.T) { gapp.Commit() // 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, map[int64]bool{}, DefaultNodeHome, 0, wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) _, err = newGapp.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } @@ -43,7 +43,7 @@ func TestWasmdExport(t *testing.T) { // ensure that blocked addresses are properly set in bank keeper func TestBlockedAddrs(t *testing.T) { db := db.NewMemDB() - gapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + gapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) for acc := range maccPerms { t.Run(acc, func(t *testing.T) { diff --git a/app/encoding.go b/app/encoding.go index e4b9a03e..5416f77a 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,37 +1,17 @@ package app import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/x/auth/tx" + + "github.com/CosmWasm/wasmd/app/params" ) -// EncodingConfig specifies the concrete encoding types to use for a given app. -// This is provided for compatibility between protobuf and amino implementations. -type EncodingConfig struct { - InterfaceRegistry types.InterfaceRegistry - Marshaler codec.Marshaler - TxConfig client.TxConfig - Amino *codec.LegacyAmino //nolint:staticcheck -} - -func MakeEncodingConfig() EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) - - std.RegisterInterfaces(interfaceRegistry) - std.RegisterLegacyAminoCodec(amino) - - ModuleBasics.RegisterLegacyAminoCodec(amino) - ModuleBasics.RegisterInterfaces(interfaceRegistry) - return EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, - } +// 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) + return encodingConfig } diff --git a/app/genesis.go b/app/genesis.go index 340cd801..622c15d3 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" ) -// The genesis state of the blockchain is represented here as a map of raw json +// GenesisState The genesis state of the blockchain is represented here as a map of raw json // messages key'd by a identifier string. // The identifier is used to determine which module genesis information belongs // to so it may be appropriately routed during init chain. @@ -15,6 +15,6 @@ type GenesisState map[string]json.RawMessage // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState() GenesisState { - encCfg := MakeEncodingConfig() - return ModuleBasics.DefaultGenesis(encCfg.Marshaler) + encodingConfig := MakeEncodingConfig() + return ModuleBasics.DefaultGenesis(encodingConfig.Marshaler) } diff --git a/app/params/doc.go b/app/params/doc.go new file mode 100644 index 00000000..7c6035ca --- /dev/null +++ b/app/params/doc.go @@ -0,0 +1,19 @@ +/* +Package params defines the simulation parameters in the gaia. + +It contains the default weights used for each transaction used on the module's +simulation. These weights define the chance for a transaction to be simulated at +any gived operation. + +You can repace the default values for the weights by providing a params.json +file with the weights defined for each of the transaction operations: + + { + "op_weight_msg_send": 60, + "op_weight_msg_delegate": 100, + } + +In the example above, the `MsgSend` has 60% chance to be simulated, while the +`MsgDelegate` will always be simulated. +*/ +package params diff --git a/app/params/encoding.go b/app/params/encoding.go new file mode 100644 index 00000000..3d634abf --- /dev/null +++ b/app/params/encoding.go @@ -0,0 +1,16 @@ +package params + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" +) + +// EncodingConfig specifies the concrete encoding types to use for a given app. +// This is provided for compatibility between protobuf and amino implementations. +type EncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Marshaler codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} diff --git a/app/params/params.go b/app/params/params.go new file mode 100644 index 00000000..b6aa5fb5 --- /dev/null +++ b/app/params/params.go @@ -0,0 +1,7 @@ +package params + +// Simulation parameter constants +const ( + StakePerAccount = "stake_per_account" + InitiallyBondedValidators = "initially_bonded_validators" +) diff --git a/app/params/proto.go b/app/params/proto.go new file mode 100644 index 00000000..84ff35a3 --- /dev/null +++ b/app/params/proto.go @@ -0,0 +1,22 @@ +package params + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/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() + marshaler := codec.NewProtoCodec(interfaceRegistry) + txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) + + return EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: marshaler, + TxConfig: txCfg, + Amino: amino, + } +} diff --git a/app/params/weights.go b/app/params/weights.go new file mode 100644 index 00000000..0ba377b0 --- /dev/null +++ b/app/params/weights.go @@ -0,0 +1,23 @@ +package params + +// Default simulation operation weights for messages and gov proposals +const ( + DefaultWeightMsgSend int = 100 + DefaultWeightMsgMultiSend int = 10 + DefaultWeightMsgSetWithdrawAddress int = 50 + DefaultWeightMsgWithdrawDelegationReward int = 50 + DefaultWeightMsgWithdrawValidatorCommission int = 50 + DefaultWeightMsgFundCommunityPool int = 50 + DefaultWeightMsgDeposit int = 100 + DefaultWeightMsgVote int = 67 + DefaultWeightMsgUnjail int = 100 + DefaultWeightMsgCreateValidator int = 100 + DefaultWeightMsgEditValidator int = 5 + DefaultWeightMsgDelegate int = 100 + DefaultWeightMsgUndelegate int = 100 + DefaultWeightMsgBeginRedelegate int = 100 + + DefaultWeightCommunitySpendProposal int = 5 + DefaultWeightTextProposal int = 5 + DefaultWeightParamChangeProposal int = 5 +) diff --git a/app/sim_test.go b/app/sim_test.go index fd8f4100..25b7134f 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -13,24 +13,27 @@ import ( "github.com/cosmos/cosmos-sdk/types/kv" 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" + "github.com/cosmos/cosmos-sdk/x/feegrant" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/simulation" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/CosmWasm/wasmd/x/wasm" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) // Get flags every time the simulator is run @@ -81,7 +84,7 @@ func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs if ok { log += decoder(kvAs[i], kvBs[i]) } else { - log += fmt.Sprintf("store A %s => %s\nstore B %s => %s\n", kvAs[i].Key, kvAs[i].Value, kvBs[i].Key, kvBs[i].Value) + log += fmt.Sprintf("store A %q => %q\nstore B %q => %q\n", kvAs[i].Key, kvAs[i].Value, kvBs[i].Key, kvBs[i].Value) } } @@ -106,7 +109,8 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := NewWasmApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt) + encConf := MakeEncodingConfig() + app := NewWasmApp(logger, db, nil, true, map[int64]bool{}, dir, simapp.FlagPeriodValue, encConf, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt) require.Equal(t, appName, app.Name()) // Run randomized simulation @@ -131,12 +135,12 @@ func TestAppImportExport(t *testing.T) { simapp.PrintStats(db) } - fmt.Printf("exporting genesis...\n") + t.Log("exporting genesis...") exported, err := app.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err) - fmt.Printf("importing genesis...\n") + t.Log("importing genesis...") _, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2") require.NoError(t, err, "simulation setup failed") @@ -145,8 +149,7 @@ func TestAppImportExport(t *testing.T) { newDB.Close() require.NoError(t, os.RemoveAll(newDir)) }() - - newApp := NewWasmApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt) + newApp := NewWasmApp(logger, newDB, nil, true, map[int64]bool{}, newDir, simapp.FlagPeriodValue, encConf, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt) require.Equal(t, appName, newApp.Name()) var genesisState GenesisState @@ -158,7 +161,7 @@ func TestAppImportExport(t *testing.T) { newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState) newApp.StoreConsensusParams(ctxB, exported.ConsensusParams) - fmt.Printf("comparing stores...\n") + t.Log("comparing stores...") storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, @@ -177,9 +180,15 @@ func TestAppImportExport(t *testing.T) { {app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}}, {app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}}, {app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}}, + {app.keys[authzkeeper.StoreKey], newApp.keys[authzkeeper.StoreKey], [][]byte{}}, + {app.keys[feegrant.StoreKey], newApp.keys[feegrant.StoreKey], [][]byte{}}, {app.keys[wasm.StoreKey], newApp.keys[wasm.StoreKey], [][]byte{}}, } + // delete persistent tx counter value + ctxA.KVStore(app.keys[wasm.StoreKey]).Delete(wasmtypes.TXCounterPrefix) + + // diff both stores for _, skp := range storeKeysPrefixes { storeA := ctxA.KVStore(skp.A) storeB := ctxB.KVStore(skp.B) @@ -187,7 +196,7 @@ func TestAppImportExport(t *testing.T) { failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes) require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare") - fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B) + t.Logf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B) require.Len(t, failedKVAs, 0, GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) } } @@ -203,9 +212,9 @@ func TestFullAppSimulation(t *testing.T) { db.Close() require.NoError(t, os.RemoveAll(dir)) }() - + encConf := MakeEncodingConfig() app := NewWasmApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, - wasm.EnableAllProposals, simapp.EmptyAppOptions{}, nil, fauxMerkleModeOpt) + encConf, wasm.EnableAllProposals, simapp.EmptyAppOptions{}, nil, fauxMerkleModeOpt) require.Equal(t, "WasmApp", app.Name()) // run randomized simulation diff --git a/app/test_access.go b/app/test_access.go index ff3578f1..8770d713 100644 --- a/app/test_access.go +++ b/app/test_access.go @@ -3,34 +3,39 @@ package app import ( "testing" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + + "github.com/CosmWasm/wasmd/app/params" + "github.com/cosmos/cosmos-sdk/codec" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/keeper" - ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + ibctransferkeeper "github.com/cosmos/ibc-go/v2/modules/apps/transfer/keeper" + ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper" "github.com/CosmWasm/wasmd/x/wasm" ) type TestSupport struct { - t *testing.T + t testing.TB app *WasmApp } -func NewTestSupport(t *testing.T, app *WasmApp) *TestSupport { +func NewTestSupport(t testing.TB, app *WasmApp) *TestSupport { return &TestSupport{t: t, app: app} } -func (s TestSupport) IBCKeeper() ibckeeper.Keeper { - return *s.app.ibcKeeper +func (s TestSupport) IBCKeeper() *ibckeeper.Keeper { + return s.app.ibcKeeper } func (s TestSupport) WasmKeeper() wasm.Keeper { return s.app.wasmKeeper } -func (s TestSupport) AppCodec() codec.Marshaler { +func (s TestSupport) AppCodec() codec.Codec { return s.app.appCodec } func (s TestSupport) ScopedWasmIBCKeeper() capabilitykeeper.ScopedKeeper { @@ -56,3 +61,11 @@ func (s TestSupport) BankKeeper() bankkeeper.Keeper { func (s TestSupport) TransferKeeper() ibctransferkeeper.Keeper { return s.app.transferKeeper } + +func (s TestSupport) GetBaseApp() *baseapp.BaseApp { + return s.app.BaseApp +} + +func (s TestSupport) GetTxConfig() client.TxConfig { + return params.MakeEncodingConfig().TxConfig +} diff --git a/app/test_helpers.go b/app/test_helpers.go index 9548f228..0639df3e 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/CosmWasm/wasmd/x/wasm" - + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" @@ -18,6 +18,8 @@ import ( tmtypes "github.com/tendermint/tendermint/types" dbm "github.com/tendermint/tm-db" + "github.com/CosmWasm/wasmd/x/wasm" + bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -53,7 +55,7 @@ var DefaultConsensusParams = &abci.ConsensusParams{ func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*WasmApp, GenesisState) { db := dbm.NewMemDB() - app := NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, wasm.EnableAllProposals, EmptyBaseAppOptions{}, opts) + app := NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, opts) if withGenesis { return app, NewDefaultGenesisState() } @@ -131,6 +133,12 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt))...) } + // add bonded amount to bonded pool module account + balances = append(balances, banktypes.Balance{ + Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), + Coins: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)}, + }) + // update total supply bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}) genesisState[banktypes.ModuleName] = app.appCodec.MustMarshalJSON(bankGenesis) @@ -238,21 +246,11 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { func AddTestAddrsFromPubKeys(app *WasmApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) { initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt)) - setTotalSupply(app, ctx, accAmt, len(pubKeys)) - - // fill all the addresses with some coins, set the loose pool tokens simultaneously - for _, pubKey := range pubKeys { - saveAccount(app, ctx, sdk.AccAddress(pubKey.Address()), initCoins) + for _, pk := range pubKeys { + initAccountWithCoins(app, ctx, sdk.AccAddress(pk.Address()), initCoins) } } -// setTotalSupply provides the total supply based on accAmt * totalAccounts. -func setTotalSupply(app *WasmApp, ctx sdk.Context, accAmt sdk.Int, totalAccounts int) { - totalSupply := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt.MulRaw(int64(totalAccounts)))) - prevSupply := app.bankKeeper.GetSupply(ctx) - app.bankKeeper.SetSupply(ctx, banktypes.NewSupply(prevSupply.GetTotal().Add(totalSupply...))) -} - // AddTestAddrs constructs and returns accNum amount of accounts with an // initial balance of accAmt in random order func AddTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress { @@ -269,21 +267,22 @@ func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int, str testAddrs := strategy(accNum) initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt)) - setTotalSupply(app, ctx, accAmt, accNum) // fill all the addresses with some coins, set the loose pool tokens simultaneously for _, addr := range testAddrs { - saveAccount(app, ctx, addr, initCoins) + initAccountWithCoins(app, ctx, addr, initCoins) } return testAddrs } -// saveAccount saves the provided account into the WasmApp with balance based on initCoins. -func saveAccount(app *WasmApp, ctx sdk.Context, addr sdk.AccAddress, initCoins sdk.Coins) { - acc := app.accountKeeper.NewAccountWithAddress(ctx, addr) - app.accountKeeper.SetAccount(ctx, acc) - err := app.bankKeeper.AddCoins(ctx, addr, initCoins) +func initAccountWithCoins(app *WasmApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { + err := app.bankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) + if err != nil { + panic(err) + } + + err = app.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) if err != nil { panic(err) } @@ -381,6 +380,43 @@ func SignCheckDeliver( return gInfo, res, err } +// SignAndDeliver signs and delivers a transaction. No simulation occurs as the +// ibc testing package causes checkState and deliverState to diverge in block time. +func SignAndDeliver( + t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, + chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, +) (sdk.GasInfo, *sdk.Result, error) { + + tx, err := helpers.GenTx( + txCfg, + msgs, + sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, + 2*DefaultGas, + chainID, + accNums, + accSeqs, + priv..., + ) + require.NoError(t, err) + + // Simulate a sending a transaction and committing a block + app.BeginBlock(abci.RequestBeginBlock{Header: header}) + gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx) + + if expPass { + require.NoError(t, err) + require.NotNil(t, res) + } else { + require.Error(t, err) + require.Nil(t, res) + } + + app.EndBlock(abci.RequestEndBlock{}) + app.Commit() + + return gInfo, res, err +} + // GenSequenceOfTxs generates a set of signed transactions of messages, such // that they differ only by having the sequence numbers incremented between // every transaction. @@ -449,3 +485,31 @@ type EmptyBaseAppOptions struct{} func (ao EmptyBaseAppOptions) Get(o string) interface{} { return nil } + +// FundAccount is a utility function that funds an account by minting and +// sending the coins to the address. This should be used for testing purposes +// only! +// +// Instead of using the mint module account, which has the +// permission of minting, create a "faucet" account. (@fdymylja) +func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error { + if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { + return err + } + + return bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) +} + +// FundModuleAccount is a utility function that funds a module account by +// minting and sending the coins to the address. This should be used for testing +// purposes only! +// +// Instead of using the mint module account, which has the +// permission of minting, create a "faucet" account. (@fdymylja) +func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts sdk.Coins) error { + if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { + return err + } + + return bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, recipientMod, amounts) +} diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 93892f57..1fbfb486 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -27,7 +27,8 @@ import ( ) func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*app.WasmApp, app.GenesisState) { - wasmApp := app.NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, invCheckPeriod, wasm.EnableAllProposals, app.EmptyBaseAppOptions{}, opts) + encodingConfig := app.MakeEncodingConfig() + wasmApp := app.NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, invCheckPeriod, encodingConfig, wasm.EnableAllProposals, app.EmptyBaseAppOptions{}, opts) if withGenesis { return wasmApp, app.NewDefaultGenesisState() } @@ -36,11 +37,10 @@ func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option // SetupWithGenesisAccounts initializes a new WasmApp with the provided genesis // accounts and possible balances. -func SetupWithGenesisAccounts(db dbm.DB, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *app.WasmApp { +func SetupWithGenesisAccounts(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) - encodingConfig := app.MakeEncodingConfig() - appCodec := encodingConfig.Marshaler + appCodec := app.NewTestSupport(b, wasmApp).AppCodec() genesisState[authtypes.ModuleName] = appCodec.MustMarshalJSON(authGenesis) @@ -111,7 +111,7 @@ func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo { Coins: sdk.NewCoins(sdk.NewInt64Coin(denom, 100000000000)), } } - wasmApp := SetupWithGenesisAccounts(db, genAccs, bals...) + wasmApp := SetupWithGenesisAccounts(b, db, genAccs, bals...) // add wasm contract height := int64(2) diff --git a/cmd/wasmd/execute.go b/cmd/wasmd/execute.go deleted file mode 100644 index 8368eae0..00000000 --- a/cmd/wasmd/execute.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "context" - - "github.com/rs/zerolog" - "github.com/spf13/cobra" - tmcfg "github.com/tendermint/tendermint/config" - tmcli "github.com/tendermint/tendermint/libs/cli" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/server" -) - -// Execute executes the root command of an application. It handles creating a -// server context object with the appropriate server and client objects injected -// into the underlying stdlib Context. It also handles adding core CLI flags, -// specifically the logging flags. It returns an error upon execution failure. -func Execute(rootCmd *cobra.Command, defaultHome string) error { - // NOTE: file copied from cosmos-sdk/server/cmd - - // Create and set a client.Context on the command's Context. During the pre-run - // of the root command, a default initialized client.Context is provided to - // seed child command execution with values such as AccountRetriver, Keyring, - // and a Tendermint RPC. This requires the use of a pointer reference when - // getting and setting the client.Context. Ideally, we utilize - // https://github.com/spf13/cobra/pull/1118. - srvCtx := server.NewDefaultContext() - ctx := context.Background() - ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{}) - ctx = context.WithValue(ctx, server.ServerContextKey, srvCtx) - - rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)") - rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmcfg.LogFormatPlain, "The logging format (json|plain)") - - executor := tmcli.PrepareBaseCmd(rootCmd, "WM", defaultHome) - return executor.ExecuteContext(ctx) -} diff --git a/cmd/wasmd/genaccounts.go b/cmd/wasmd/genaccounts.go index 6429aafc..9acf2cea 100644 --- a/cmd/wasmd/genaccounts.go +++ b/cmd/wasmd/genaccounts.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,33 +39,33 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - depCdc := clientCtx.JSONMarshaler - cdc := depCdc.(codec.Marshaler) - serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config config.SetRoot(clientCtx.HomeDir) + var kr keyring.Keyring addr, err := sdk.AccAddressFromBech32(args[0]) if err != nil { inBuf := bufio.NewReader(cmd.InOrStdin()) keyringBackend, err := cmd.Flags().GetString(flags.FlagKeyringBackend) if err != nil { - return err + return fmt.Errorf("failed to parse keyring backend: %w", err) + } + if keyringBackend != "" && clientCtx.Keyring == nil { + var err error + kr, err = keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.HomeDir, inBuf) + if err != nil { + return err + } + } else { + kr = clientCtx.Keyring } - // attempt to lookup address from Keybase if no address was provided - kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.HomeDir, inBuf) + info, err := kr.Key(args[0]) if err != nil { - return err + return fmt.Errorf("failed to get address from Keyring: %w", err) } - - info, err := kb.Key(args[0]) - if err != nil { - return fmt.Errorf("failed to get address from Keybase: %w", err) - } - addr = info.GetAddress() } @@ -77,15 +76,15 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa vestingStart, err := cmd.Flags().GetInt64(flagVestingStart) if err != nil { - return err + return fmt.Errorf("failed to parse vesting start: %w", err) } vestingEnd, err := cmd.Flags().GetInt64(flagVestingEnd) if err != nil { - return err + return fmt.Errorf("failed to parse vesting end: %w", err) } vestingAmtStr, err := cmd.Flags().GetString(flagVestingAmt) if err != nil { - return err + return fmt.Errorf("failed to parse vesting amount: %w", err) } vestingAmt, err := sdk.ParseCoinsNormalized(vestingAmtStr) @@ -131,7 +130,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa return fmt.Errorf("failed to unmarshal genesis state: %w", err) } - authGenState := authtypes.GetGenesisStateFromAppState(cdc, appState) + authGenState := authtypes.GetGenesisStateFromAppState(clientCtx.Codec, appState) accs, err := authtypes.UnpackAccounts(authGenState.Accounts) if err != nil { @@ -153,18 +152,19 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa } authGenState.Accounts = genAccs - authGenStateBz, err := cdc.MarshalJSON(&authGenState) + authGenStateBz, err := clientCtx.Codec.MarshalJSON(&authGenState) if err != nil { return fmt.Errorf("failed to marshal auth genesis state: %w", err) } appState[authtypes.ModuleName] = authGenStateBz - bankGenState := banktypes.GetGenesisStateFromAppState(depCdc, appState) + bankGenState := banktypes.GetGenesisStateFromAppState(clientCtx.Codec, appState) bankGenState.Balances = append(bankGenState.Balances, balances) bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances) + bankGenState.Supply = bankGenState.Supply.Add(balances.Coins...) - bankGenStateBz, err := cdc.MarshalJSON(bankGenState) + bankGenStateBz, err := clientCtx.Codec.MarshalJSON(bankGenState) if err != nil { return fmt.Errorf("failed to marshal bank genesis state: %w", err) } diff --git a/cmd/wasmd/main.go b/cmd/wasmd/main.go index a267cf49..7bd3d012 100644 --- a/cmd/wasmd/main.go +++ b/cmd/wasmd/main.go @@ -4,6 +4,7 @@ import ( "os" "github.com/cosmos/cosmos-sdk/server" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/CosmWasm/wasmd/app" ) @@ -11,7 +12,7 @@ import ( func main() { rootCmd, _ := NewRootCmd() - if err := Execute(rootCmd, app.DefaultNodeHome); err != nil { + if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil { switch e := err.(type) { case server.ErrorCode: os.Exit(e.Code) diff --git a/cmd/wasmd/root.go b/cmd/wasmd/root.go index dde807e6..78fd9478 100644 --- a/cmd/wasmd/root.go +++ b/cmd/wasmd/root.go @@ -6,21 +6,9 @@ import ( "os" "path/filepath" - "github.com/prometheus/client_golang/prometheus" - - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - - authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" - vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" - bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" - "github.com/spf13/cast" - "github.com/spf13/cobra" - tmcli "github.com/tendermint/tendermint/libs/cli" - "github.com/tendermint/tendermint/libs/log" - dbm "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/baseapp" "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" @@ -31,47 +19,72 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" 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/prometheus/client_golang/prometheus" + "github.com/spf13/cast" + "github.com/spf13/cobra" + tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/tendermint/tendermint/libs/log" + dbm "github.com/tendermint/tm-db" "github.com/CosmWasm/wasmd/app" + "github.com/CosmWasm/wasmd/app/params" "github.com/CosmWasm/wasmd/x/wasm" clientcodec "github.com/CosmWasm/wasmd/x/wasm/client/codec" + 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, app.EncodingConfig) { +func NewRootCmd() (*cobra.Command, params.EncodingConfig) { encodingConfig := app.MakeEncodingConfig() - config := sdk.GetConfig() - config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub) - config.Seal() + 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() initClientCtx := client.Context{}. - WithJSONMarshaler(clientcodec.NewProtoCodec(encodingConfig.Marshaler, encodingConfig.InterfaceRegistry)). + WithCodec(clientcodec.NewProtoCodec(encodingConfig.Marshaler, encodingConfig.InterfaceRegistry)). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(app.DefaultNodeHome) + WithHomeDir(app.DefaultNodeHome). + WithViper("") rootCmd := &cobra.Command{ Use: version.AppName, Short: "Wasm Daemon (server)", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { + // set the default command outputs + cmd.SetOut(cmd.OutOrStdout()) + cmd.SetErr(cmd.ErrOrStderr()) + + initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) + if err != nil { + return err + } + + initClientCtx, err = config.ReadFromClientConfig(initClientCtx) + if err != nil { + return err + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } - return server.InterceptConfigsPreRunHandler(cmd) + return server.InterceptConfigsPreRunHandler(cmd, "", nil) }, } @@ -80,13 +93,10 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) { return rootCmd, encodingConfig } -func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) { - authclient.Codec = encodingConfig.Marshaler - +func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), - genutilcli.MigrateGenesisCmd(), genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), @@ -94,9 +104,13 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) { tmcli.NewCompletionCmd(rootCmd, true), // testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), debug.Cmd(), + config.Cmd(), ) - server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, createWasmAppAndExport, addModuleInitFlags) + ac := appCreator{ + encCfg: encodingConfig, + } + server.AddCommands(rootCmd, app.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( @@ -121,9 +135,9 @@ func queryCommand() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } + cmd.AddCommand( authcmd.GetAccountCmd(), - flags.LineBreak, rpc.ValidatorCommand(), rpc.BlockCommand(), authcmd.QueryTxsByEventsCmd(), @@ -146,39 +160,34 @@ func txCommand() *cobra.Command { } cmd.AddCommand( - bankcmd.NewSendTxCmd(), - flags.LineBreak, authcmd.GetSignCommand(), authcmd.GetSignBatchCommand(), authcmd.GetMultiSignCommand(), + authcmd.GetMultiSignBatchCmd(), authcmd.GetValidateSignaturesCommand(), flags.LineBreak, authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - flags.LineBreak, - vestingcli.GetTxCmd(), ) - // add modules' tx commands app.ModuleBasics.AddTxCommands(cmd) - - // remove auth and bank commands as they're mounted under the root tx command - var cmdsToRemove []*cobra.Command - - for _, cmd := range cmd.Commands() { - if cmd.Use == authtypes.ModuleName || cmd.Use == banktypes.ModuleName { - cmdsToRemove = append(cmdsToRemove, cmd) - } - } - - cmd.RemoveCommand(cmdsToRemove...) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd } -func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { +type appCreator struct { + encCfg params.EncodingConfig +} + +func (ac appCreator) newApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + appOpts servertypes.AppOptions, +) servertypes.Application { + var cache sdk.MultiStorePersistentCache if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { @@ -212,6 +221,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty return app.NewWasmApp(logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), + ac.encCfg, app.GetEnabledProposals(), appOpts, wasmOpts, @@ -229,24 +239,42 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty ) } -func createWasmAppAndExport( - logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { +func (ac appCreator) appExport( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + height int64, + forZeroHeight bool, + jailAllowedAddrs []string, + appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { var wasmApp *app.WasmApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { - return servertypes.ExportedApp{}, errors.New("application home not set") + return servertypes.ExportedApp{}, errors.New("application home is not set") } - var emptyWasmOpts []wasm.Option - if height != -1 { - wasmApp = app.NewWasmApp(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), app.GetEnabledProposals(), appOpts, emptyWasmOpts) + loadLatest := height == -1 + var emptyWasmOpts []wasm.Option + wasmApp = app.NewWasmApp( + logger, + db, + traceStore, + loadLatest, + map[int64]bool{}, + homePath, + cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), + ac.encCfg, + app.GetEnabledProposals(), + appOpts, + emptyWasmOpts, + ) + + if height != -1 { if err := wasmApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } - } else { - wasmApp = app.NewWasmApp(logger, db, traceStore, true, map[int64]bool{}, homePath, uint(1), app.GetEnabledProposals(), appOpts, emptyWasmOpts) } return wasmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/contrib/local/01-accounts.sh b/contrib/local/01-accounts.sh index 0c275410..1cb4b0e5 100755 --- a/contrib/local/01-accounts.sh +++ b/contrib/local/01-accounts.sh @@ -12,7 +12,7 @@ NEW_ACCOUNT=$(wasmd keys show fred -a) wasmd q bank balances "$NEW_ACCOUNT" -o json || true echo "## Transfer tokens" -wasmd tx send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block | jq +wasmd tx bank send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json | jq echo "## Check balance again" wasmd q bank balances "$NEW_ACCOUNT" -o json | jq diff --git a/contrib/local/02-contracts.sh b/contrib/local/02-contracts.sh index 4df4cc5a..ecbadf31 100755 --- a/contrib/local/02-contracts.sh +++ b/contrib/local/02-contracts.sh @@ -6,7 +6,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" echo "-----------------------" echo "## Add new CosmWasm contract" RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/hackatom.wasm" \ - --from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b block) + --from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json) CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value') echo "* Code id: $CODE_ID" @@ -23,7 +23,7 @@ echo "## Create new contract instance" INIT="{\"verifier\":\"$(wasmd keys show validator -a)\", \"beneficiary\":\"$(wasmd keys show fred -a)\"}" wasmd tx wasm instantiate "$CODE_ID" "$INIT" --admin="$(wasmd keys show validator -a)" \ --from validator --amount="100ustake" --label "local0.1.0" \ - --gas 1000000 -y --chain-id=testing -b block | jq + --gas 1000000 -y --chain-id=testing -b block -o json | jq CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]') echo "* Contract address: $CONTRACT" @@ -41,28 +41,28 @@ echo "## Execute contract $CONTRACT" MSG='{"release":{}}' wasmd tx wasm execute "$CONTRACT" "$MSG" \ --from validator \ - --gas 1000000 -y --chain-id=testing -b block | jq + --gas 1000000 -y --chain-id=testing -b block -o json | jq echo "-----------------------" echo "## Set new admin" echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "### Update contract" wasmd tx wasm set-contract-admin "$CONTRACT" "$(wasmd keys show fred -a)" \ - --from validator -y --chain-id=testing -b block | jq -echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" + --from validator -y --chain-id=testing -b block -o json | jq +echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "-----------------------" echo "## Migrate contract" echo "### Upload new code" RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/burner.wasm" \ - --from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block) + --from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json) BURNER_CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value') echo "### Migrate to code id: $BURNER_CODE_ID" DEST_ACCOUNT=$(wasmd keys show fred -a) wasmd tx wasm migrate "$CONTRACT" "$BURNER_CODE_ID" "{\"payout\": \"$DEST_ACCOUNT\"}" --from fred \ - --chain-id=testing -b block -y | jq + --chain-id=testing -b block -y -o json | jq echo "### Query destination account: $BURNER_CODE_ID" wasmd q bank balances "$DEST_ACCOUNT" -o json | jq @@ -74,8 +74,8 @@ wasmd q wasm contract-history "$CONTRACT" -o json | jq echo "-----------------------" echo "## Clear contract admin" -echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" +echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "### Update contract" wasmd tx wasm clear-contract-admin "$CONTRACT" \ - --from fred -y --chain-id=testing -b block | jq -echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" + --from fred -y --chain-id=testing -b block -o json | jq +echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" diff --git a/go.mod b/go.mod index f1c442e4..b84d3a70 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,9 @@ go 1.17 require ( github.com/CosmWasm/wasmvm v1.0.0-beta5 - github.com/cosmos/cosmos-sdk v0.42.11 + github.com/cosmos/cosmos-sdk v0.45.0 github.com/cosmos/iavl v0.17.3 + github.com/cosmos/ibc-go/v2 v2.0.2 github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 @@ -16,32 +17,33 @@ require ( github.com/prometheus/client_golang v1.11.0 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 - github.com/rs/zerolog v1.26.0 github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa github.com/spf13/cast v1.4.1 - github.com/spf13/cobra v1.1.3 + github.com/spf13/cobra v1.2.1 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.9.0 + github.com/spf13/viper v1.10.1 github.com/stretchr/testify v1.7.0 github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca - github.com/tendermint/tendermint v0.34.14 - github.com/tendermint/tm-db v0.6.4 - google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 - google.golang.org/grpc v1.42.0 + github.com/tendermint/tendermint v0.34.15 + github.com/tendermint/tm-db v0.6.6 + google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa + google.golang.org/grpc v1.43.0 gopkg.in/yaml.v2 v2.4.0 ) require ( + filippo.io/edwards25519 v1.0.0-beta.2 // indirect github.com/99designs/keyring v1.1.6 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/DataDog/zstd v1.4.5 // indirect - github.com/Workiva/go-datastructures v1.0.52 // indirect - github.com/armon/go-metrics v0.3.8 // indirect + github.com/Workiva/go-datastructures v1.0.53 // indirect + github.com/armon/go-metrics v0.3.10 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect github.com/confio/ics23/go v0.6.6 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect @@ -49,14 +51,16 @@ require ( github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.2 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/go-kit/kit v0.10.0 // indirect - github.com/go-logfmt/logfmt v0.5.0 // indirect + github.com/go-kit/kit v0.12.0 // indirect + github.com/go-kit/log v0.2.0 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect github.com/golang/snappy v0.0.3 // indirect @@ -68,30 +72,33 @@ require ( 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-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect + github.com/improbable-eng/grpc-web v0.14.1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect - github.com/lib/pq v1.2.0 // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/lib/pq v1.10.4 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/magiconair/properties v1.8.5 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect - github.com/minio/highwayhash v1.0.1 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/mapstructure v1.4.2 // indirect + github.com/minio/highwayhash v1.0.2 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.26.0 // indirect - github.com/prometheus/procfs v0.6.0 // indirect + github.com/prometheus/common v0.30.0 // indirect + github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect - github.com/rs/cors v1.7.0 // indirect + github.com/rs/cors v1.8.0 // indirect + github.com/rs/zerolog v1.26.0 // indirect github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -101,24 +108,30 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/zondax/hid v0.9.0 // indirect - go.etcd.io/bbolt v1.3.5 // indirect - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect - golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect + go.etcd.io/bbolt v1.3.6 // indirect + golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect + golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b // indirect + golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect - golang.org/x/text v0.3.6 // indirect + golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/ini.v1 v1.63.2 // indirect + gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + nhooyr.io/websocket v1.8.6 // indirect ) replace ( + github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 github.com/confio/ics23/go => github.com/confio/ics23/go v0.6.6 - github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.42.11 + github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.0 github.com/cosmos/go-bip39 => github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl => github.com/cosmos/iavl v0.17.3 + // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. + // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 + github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 + // latest grpc doesn't work with with our modified proto compiler, so we need to enforce + // the following version across all dependencies. github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.14 - github.com/urfave/cli => github.com/urfave/cli v1.22.1 + github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.15 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 6b402cab..4ed403df 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= @@ -22,6 +23,9 @@ cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSU cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -32,6 +36,7 @@ cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7 cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/firestore v1.6.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU= +cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -42,12 +47,25 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= -github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= +filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= +github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= +github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= +github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= 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= @@ -57,8 +75,9 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= +github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= @@ -67,33 +86,46 @@ 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= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= 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/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/adlio/schema v1.1.13 h1:LeNMVg5Z1FX+Qgz8tJUijBLRdcpbFUElz+d1489On98= -github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= +github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= +github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= +github.com/adlio/schema v1.1.14 h1:lIjyp5/2wSuEOmeQGNPpaRsVGZRqz9A/B+PaMtEotaU= +github.com/adlio/schema v1.1.14/go.mod h1:hQveFEMiDlG/M9yz9RAajnH5DzT6nAfqOG9YkEQU2pg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= 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= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= 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.3.8 h1:oOxq3KPj0WhCuy50EhzwiyMyG2ovRQZpZLXQuOh2a/M= -github.com/armon/go-metrics v0.3.8/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= +github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/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.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= +github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= +github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +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= @@ -101,14 +133,17 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= +github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= +github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= @@ -121,13 +156,18 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -135,18 +175,25 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= +github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= +github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8= github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.2.0 h1:j/9Wnn+hrEWjLvHuIxUU1YI5JjEjVlT2AA68cse9rwY= +github.com/containerd/continuity v0.2.0/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+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= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -157,12 +204,16 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.42.11 h1:uSaDvWhrFEyulby+rvISy3BmXJXnwezOiq64l8wWm00= -github.com/cosmos/cosmos-sdk v0.42.11/go.mod h1:UdhCvr26SsMdhUlYCO3G7HCSTKpwzUg+MpGbQffb3os= +github.com/cosmos/cosmos-sdk v0.45.0 h1:DHD+CIRZ+cYgiLXuTEUL/aprnfPsWSwaww/fIZEsZlk= +github.com/cosmos/cosmos-sdk v0.45.0/go.mod h1:XXS/asyCqWNWkx2rW6pSuen+EVcpAFxq6khrhnZgHaQ= 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/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/ibc-go/v2 v2.0.2 h1:y7eUgggMEVe43wHLw9XrGbeaTWtfkJYMoL3m6YW4fIY= +github.com/cosmos/ibc-go/v2 v2.0.2/go.mod h1:XUmW7wmubCRhIEAGtMGS+5IjiSSmcAwihoN/yPGd6Kk= +github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= +github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -171,6 +222,7 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc 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.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 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/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= @@ -178,7 +230,10 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 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/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +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.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -189,67 +244,110 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 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.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= 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 v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= +github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= 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/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= 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.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= +github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= 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= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= 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.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= +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/pool v0.2.0/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/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= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= +github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -326,11 +424,14 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= @@ -339,11 +440,16 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 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-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -362,15 +468,20 @@ github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIv github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= 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-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-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= @@ -393,20 +504,40 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T 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/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= +github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 h1:uUjLpLt6bVvZ72SQc/B4dXcPBw4Vgd7soowdRl52qEM= +github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87/go.mod h1:XGsKKeXxeRr95aEOgipvluMPlgjr7dGlk9ZTWOjcUcg= +github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= +github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= +github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= +github.com/iancoleman/strcase v0.2.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.14.1 h1:NrN4PY71A6tAz2sKDvC5JCauENWp0ykG8Oq1H3cpFvw= +github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jhump/protoreflect v1.9.0 h1:npqHz788dryJiR/l6K/RUQAyh2SwV91+d1dnh4RjO9w= +github.com/jhump/protoreflect v1.9.0/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -418,16 +549,26 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= 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= @@ -436,41 +577,60 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= 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/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= +github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +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-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= +github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= 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.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +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= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= @@ -478,49 +638,71 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo= +github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= +github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= +github.com/nats-io/jwt/v2 v2.0.3/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats-server/v2 v2.5.0/go.mod h1:Kj86UtrXAL6LwYRA6H4RqzkHhK0Vcv2ZnKD5WbQ1t3g= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nats.go v1.12.1/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= +github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= 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/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/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/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 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +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.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 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 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= +github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +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.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -529,10 +711,12 @@ github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= 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/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= 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/otiai10/copy v1.6.0 h1:IinKAryFFuPONZ7cm6T6E2QX/vcJwSnlaA5lfoaXIiQ= @@ -545,14 +729,18 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= 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 v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= +github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= +github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= 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/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -572,8 +760,6 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= -github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -590,20 +776,22 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 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.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.23.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= -github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= +github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.30.0 h1:JEkYlQnpzrzQFxi6gnukFPdQ+ac82oRhzMcIduJu/Ug= +github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= 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.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 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.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= +github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= @@ -614,28 +802,34 @@ github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzy github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= +github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= +github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= +github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM= +github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= github.com/rs/zerolog v1.26.0 h1:ORM4ibhEZeTeQlCojCK2kPz1ogAY4bGs4tD+SaAdGaE= github.com/rs/zerolog v1.26.0/go.mod h1:yBiM87lvSqX8h0Ww4sdzNSkVYZ8dL2xjZJG1lAuGZEo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= +github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= +github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= +github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -651,7 +845,7 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= @@ -660,9 +854,9 @@ github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= -github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= +github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -671,13 +865,19 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= +github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= +github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= +github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= +github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= @@ -685,6 +885,7 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -701,19 +902,39 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.34.14 h1:GCXmlS8Bqd2Ix3TQCpwYLUNHe+Y+QyJsm5YE+S/FkPo= -github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ= +github.com/tendermint/tendermint v0.34.15 h1:45OEYTBD/TL0YFn8MF7yYJvC5iubyN4AbEjctPi1UqA= +github.com/tendermint/tendermint v0.34.15/go.mod h1:/7EDAw02rD7GT8syC317cX9ZhZTCdaFVvYjU8W+yJSs= github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= +github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM= +github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= +github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= +github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= +github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= +github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI= +github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -724,12 +945,17 @@ github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= +go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -739,40 +965,55 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= 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/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= 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/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= 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.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= 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-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/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-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= +golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 h1:3erb+vDS8lU1sxfDHF4/hhWyaXnhIaO+7RgL4fDZORA= +golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/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= +golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= @@ -780,6 +1021,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 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/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= 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-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -795,18 +1038,22 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 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.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -818,6 +1065,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -832,6 +1080,7 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -841,6 +1090,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -850,10 +1100,16 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b h1:SXy8Ld8oKlcogOvUAh0J5Pm5RKzgYBMMxLxt6n5XW50= +golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 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= @@ -865,10 +1121,13 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 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= @@ -913,6 +1172,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -926,6 +1186,7 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -935,18 +1196,20 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -962,9 +1225,16 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b h1:3Dq0eVHn0uaQJmPO+/aYPI/fRMqdrVDbu7MQcku54gg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/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-20210917161153-d61c044b1678/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-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/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 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -975,13 +1245,18 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -1008,6 +1283,7 @@ golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1022,15 +1298,19 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 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.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -1045,6 +1325,10 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= +gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -1067,12 +1351,18 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1120,7 +1410,7 @@ google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1137,8 +1427,18 @@ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKr google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs= google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1152,28 +1452,32 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= +gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1196,8 +1500,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 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= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/third_party/README.md b/third_party/README.md deleted file mode 100644 index 29ac5daa..00000000 --- a/third_party/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Third party -Contain the protobuf dependencies - -## Cosmos-SDK -* [/proto dir](https://github.com/cosmos/cosmos-sdk/tree/master/proto) -* [/third_party dir](https://github.com/cosmos/cosmos-sdk/tree/master/third_party/proto) - -Credits and :bouquet: to the original authors diff --git a/third_party/proto/cosmos/auth/v1beta1/query.proto b/third_party/proto/cosmos/auth/v1beta1/query.proto index a8857926..4d9759ca 100644 --- a/third_party/proto/cosmos/auth/v1beta1/query.proto +++ b/third_party/proto/cosmos/auth/v1beta1/query.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package cosmos.auth.v1beta1; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "google/api/annotations.proto"; @@ -11,6 +12,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; // Query defines the gRPC querier service. service Query { + // Accounts returns all the existing accounts + // + // Since: cosmos-sdk 0.43 + rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/accounts"; + } + // Account returns account details based on address. rpc Account(QueryAccountRequest) returns (QueryAccountResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/accounts/{address}"; @@ -22,6 +30,25 @@ service Query { } } +// QueryAccountsRequest is the request type for the Query/Accounts RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryAccountsRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAccountsResponse is the response type for the Query/Accounts RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryAccountsResponse { + // accounts are the existing accounts + repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryAccountRequest is the request type for the Query/Account RPC method. message QueryAccountRequest { option (gogoproto.equal) = false; diff --git a/third_party/proto/cosmos/authz/v1beta1/authz.proto b/third_party/proto/cosmos/authz/v1beta1/authz.proto new file mode 100644 index 00000000..2c376905 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/authz.proto @@ -0,0 +1,27 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; +option (gogoproto.goproto_getters_all) = false; + +// GenericAuthorization gives the grantee unrestricted permissions to execute +// the provided method on behalf of the granter's account. +message GenericAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; + + // Msg, identified by it's type URL, to grant unrestricted permissions to execute + string msg = 1; +} + +// Grant gives permissions to execute +// the provide method with expiration time. +message Grant { + google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/event.proto b/third_party/proto/cosmos/authz/v1beta1/event.proto new file mode 100644 index 00000000..7a3cf7c8 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/event.proto @@ -0,0 +1,25 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.authz.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; + +// EventGrant is emitted on Msg/Grant +message EventGrant { + // Msg type URL for which an autorization is granted + string msg_type_url = 2; + // Granter account address + string granter = 3; + // Grantee account address + string grantee = 4; +} + +// EventRevoke is emitted on Msg/Revoke +message EventRevoke { + // Msg type URL for which an autorization is revoked + string msg_type_url = 2; + // Granter account address + string granter = 3; + // Grantee account address + string grantee = 4; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/genesis.proto b/third_party/proto/cosmos/authz/v1beta1/genesis.proto new file mode 100644 index 00000000..ea898694 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/genesis.proto @@ -0,0 +1,24 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; + +// GenesisState defines the authz module's genesis state. +message GenesisState { + repeated GrantAuthorization authorization = 1 [(gogoproto.nullable) = false]; +} + +// GrantAuthorization defines the GenesisState/GrantAuthorization type. +message GrantAuthorization { + string granter = 1; + string grantee = 2; + + google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/query.proto b/third_party/proto/cosmos/authz/v1beta1/query.proto new file mode 100644 index 00000000..428210de --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/query.proto @@ -0,0 +1,35 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/authz/v1beta1/authz.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; + +// Query defines the gRPC querier service. +service Query { + // Returns list of `Authorization`, granted to the grantee by the granter. + rpc Grants(QueryGrantsRequest) returns (QueryGrantsResponse) { + option (google.api.http).get = "/cosmos/authz/v1beta1/grants"; + } +} + +// QueryGrantsRequest is the request type for the Query/Grants RPC method. +message QueryGrantsRequest { + string granter = 1; + string grantee = 2; + // Optional, msg_type_url, when set, will query only grants matching given msg type. + string msg_type_url = 3; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryGrantsResponse is the response type for the Query/Authorizations RPC method. +message QueryGrantsResponse { + // authorizations is a list of grants granted for grantee by granter. + repeated cosmos.authz.v1beta1.Grant grants = 1; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/tx.proto b/third_party/proto/cosmos/authz/v1beta1/tx.proto new file mode 100644 index 00000000..457f0d66 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/tx.proto @@ -0,0 +1,70 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos/authz/v1beta1/authz.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; +option (gogoproto.goproto_getters_all) = false; + +// Msg defines the authz Msg service. +service Msg { + // Grant grants the provided authorization to the grantee on the granter's + // account with the provided expiration time. If there is already a grant + // for the given (granter, grantee, Authorization) triple, then the grant + // will be overwritten. + rpc Grant(MsgGrant) returns (MsgGrantResponse); + + // Exec attempts to execute the provided messages using + // authorizations granted to the grantee. Each message should have only + // one signer corresponding to the granter of the authorization. + rpc Exec(MsgExec) returns (MsgExecResponse); + + // Revoke revokes any authorization corresponding to the provided method name on the + // granter's account that has been granted to the grantee. + rpc Revoke(MsgRevoke) returns (MsgRevokeResponse); +} + +// MsgGrant is a request type for Grant method. It declares authorization to the grantee +// on behalf of the granter with the provided expiration time. +message MsgGrant { + string granter = 1; + string grantee = 2; + + cosmos.authz.v1beta1.Grant grant = 3 [(gogoproto.nullable) = false]; +} + +// MsgExecResponse defines the Msg/MsgExecResponse response type. +message MsgExecResponse { + repeated bytes results = 1; +} + +// MsgExec attempts to execute the provided messages using +// authorizations granted to the grantee. Each message should have only +// one signer corresponding to the granter of the authorization. +message MsgExec { + string grantee = 1; + // Authorization Msg requests to execute. Each msg must implement Authorization interface + // The x/authz will try to find a grant matching (msg.signers[0], grantee, MsgTypeURL(msg)) + // triple and validate it. + repeated google.protobuf.Any msgs = 2 [(cosmos_proto.accepts_interface) = "sdk.Msg, authz.Authorization"]; +} + +// MsgGrantResponse defines the Msg/MsgGrant response type. +message MsgGrantResponse {} + +// MsgRevoke revokes any authorization with the provided sdk.Msg type on the +// granter's account with that has been granted to the grantee. +message MsgRevoke { + string granter = 1; + string grantee = 2; + string msg_type_url = 3; +} + +// MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. +message MsgRevokeResponse {} diff --git a/third_party/proto/cosmos/bank/v1beta1/authz.proto b/third_party/proto/cosmos/bank/v1beta1/authz.proto new file mode 100644 index 00000000..4f58b15e --- /dev/null +++ b/third_party/proto/cosmos/bank/v1beta1/authz.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package cosmos.bank.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; + +// SendAuthorization allows the grantee to spend up to spend_limit coins from +// the granter's account. +// +// Since: cosmos-sdk 0.43 +message SendAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; + + repeated cosmos.base.v1beta1.Coin spend_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} diff --git a/third_party/proto/cosmos/bank/v1beta1/bank.proto b/third_party/proto/cosmos/bank/v1beta1/bank.proto index 5a938336..df91008d 100644 --- a/third_party/proto/cosmos/bank/v1beta1/bank.proto +++ b/third_party/proto/cosmos/bank/v1beta1/bank.proto @@ -45,12 +45,14 @@ message Output { // Supply represents a struct that passively keeps track of the total supply // amounts in the network. +// This message is deprecated now that supply is indexed by denom. message Supply { - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; + option deprecated = true; - option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/exported.SupplyI"; + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + + option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/legacy/v040.SupplyI"; repeated cosmos.base.v1beta1.Coin total = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; @@ -82,4 +84,13 @@ message Metadata { // display indicates the suggested denom that should be // displayed in clients. string display = 4; + // name defines the name of the token (eg: Cosmos Atom) + // + // Since: cosmos-sdk 0.43 + string name = 5; + // symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + // be the same as the display. + // + // Since: cosmos-sdk 0.43 + string symbol = 6; } diff --git a/third_party/proto/cosmos/bank/v1beta1/genesis.proto b/third_party/proto/cosmos/bank/v1beta1/genesis.proto index 25c80a38..8fd7329a 100644 --- a/third_party/proto/cosmos/bank/v1beta1/genesis.proto +++ b/third_party/proto/cosmos/bank/v1beta1/genesis.proto @@ -15,7 +15,8 @@ message GenesisState { // balances is an array containing the balances of all the accounts. repeated Balance balances = 2 [(gogoproto.nullable) = false]; - // supply represents the total supply. + // supply represents the total supply. If it is left empty, then supply will be calculated based on the provided + // balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. repeated cosmos.base.v1beta1.Coin supply = 3 [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false]; diff --git a/third_party/proto/cosmos/bank/v1beta1/query.proto b/third_party/proto/cosmos/bank/v1beta1/query.proto index bc5e2913..520ba069 100644 --- a/third_party/proto/cosmos/bank/v1beta1/query.proto +++ b/third_party/proto/cosmos/bank/v1beta1/query.proto @@ -13,7 +13,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; service Query { // Balance queries the balance of a single coin for a single account. rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}/{denom}"; + option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}/by_denom"; } // AllBalances queries the balance of all coins for a single account. @@ -49,7 +49,7 @@ service Query { // QueryBalanceRequest is the request type for the Query/Balance RPC method. message QueryBalanceRequest { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address is the address to query balances for. @@ -67,7 +67,7 @@ message QueryBalanceResponse { // QueryBalanceRequest is the request type for the Query/AllBalances RPC method. message QueryAllBalancesRequest { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address is the address to query balances for. @@ -82,7 +82,7 @@ message QueryAllBalancesRequest { message QueryAllBalancesResponse { // balances is the balances of all the coins. repeated cosmos.base.v1beta1.Coin balances = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -90,14 +90,27 @@ message QueryAllBalancesResponse { // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. -message QueryTotalSupplyRequest {} +message QueryTotalSupplyRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // pagination defines an optional pagination for the request. + // + // Since: cosmos-sdk 0.43 + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} // QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC // method message QueryTotalSupplyResponse { // supply is the supply of the coins repeated cosmos.base.v1beta1.Coin supply = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + // + // Since: cosmos-sdk 0.43 + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. diff --git a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto index 72da2aac..e24ae7bd 100644 --- a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto +++ b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto @@ -39,6 +39,13 @@ message TxResponse { // the timestamps of the valid votes in the block.LastCommit. For height == 1, // it's genesis time. string timestamp = 12; + // Events defines all the events emitted by processing a transaction. Note, + // these events include those emitted by processing all the messages and those + // emitted from the ante handler. Whereas Logs contains the events, with + // additional metadata, emitted only by processing the messages. + // + // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + repeated tendermint.abci.Event events = 13 [(gogoproto.nullable) = false]; } // ABCIMessageLog defines a structure containing an indexed tx ABCI message log. diff --git a/third_party/proto/cosmos/base/query/v1beta1/pagination.proto b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto index 2a8cbcce..cd5eb066 100644 --- a/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +++ b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto @@ -30,6 +30,11 @@ message PageRequest { // count_total is only respected when offset is used. It is ignored when key // is set. bool count_total = 4; + + // reverse is set to true if results are to be returned in the descending order. + // + // Since: cosmos-sdk 0.43 + bool reverse = 5; } // PageResponse is to be embedded in gRPC response messages where the diff --git a/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto b/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto new file mode 100644 index 00000000..d5b04855 --- /dev/null +++ b/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto @@ -0,0 +1,218 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.base.reflection.v2alpha1; + +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1"; + +// AppDescriptor describes a cosmos-sdk based application +message AppDescriptor { + // AuthnDescriptor provides information on how to authenticate transactions on the application + // NOTE: experimental and subject to change in future releases. + AuthnDescriptor authn = 1; + // chain provides the chain descriptor + ChainDescriptor chain = 2; + // codec provides metadata information regarding codec related types + CodecDescriptor codec = 3; + // configuration provides metadata information regarding the sdk.Config type + ConfigurationDescriptor configuration = 4; + // query_services provides metadata information regarding the available queriable endpoints + QueryServicesDescriptor query_services = 5; + // tx provides metadata information regarding how to send transactions to the given application + TxDescriptor tx = 6; +} + +// TxDescriptor describes the accepted transaction type +message TxDescriptor { + // fullname is the protobuf fullname of the raw transaction type (for instance the tx.Tx type) + // it is not meant to support polymorphism of transaction types, it is supposed to be used by + // reflection clients to understand if they can handle a specific transaction type in an application. + string fullname = 1; + // msgs lists the accepted application messages (sdk.Msg) + repeated MsgDescriptor msgs = 2; +} + +// AuthnDescriptor provides information on how to sign transactions without relying +// on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures +message AuthnDescriptor { + // sign_modes defines the supported signature algorithm + repeated SigningModeDescriptor sign_modes = 1; +} + +// SigningModeDescriptor provides information on a signing flow of the application +// NOTE(fdymylja): here we could go as far as providing an entire flow on how +// to sign a message given a SigningModeDescriptor, but it's better to think about +// this another time +message SigningModeDescriptor { + // name defines the unique name of the signing mode + string name = 1; + // number is the unique int32 identifier for the sign_mode enum + int32 number = 2; + // authn_info_provider_method_fullname defines the fullname of the method to call to get + // the metadata required to authenticate using the provided sign_modes + string authn_info_provider_method_fullname = 3; +} + +// ChainDescriptor describes chain information of the application +message ChainDescriptor { + // id is the chain id + string id = 1; +} + +// CodecDescriptor describes the registered interfaces and provides metadata information on the types +message CodecDescriptor { + // interfaces is a list of the registerted interfaces descriptors + repeated InterfaceDescriptor interfaces = 1; +} + +// InterfaceDescriptor describes the implementation of an interface +message InterfaceDescriptor { + // fullname is the name of the interface + string fullname = 1; + // interface_accepting_messages contains information regarding the proto messages which contain the interface as + // google.protobuf.Any field + repeated InterfaceAcceptingMessageDescriptor interface_accepting_messages = 2; + // interface_implementers is a list of the descriptors of the interface implementers + repeated InterfaceImplementerDescriptor interface_implementers = 3; +} + +// InterfaceImplementerDescriptor describes an interface implementer +message InterfaceImplementerDescriptor { + // fullname is the protobuf queryable name of the interface implementer + string fullname = 1; + // type_url defines the type URL used when marshalling the type as any + // this is required so we can provide type safe google.protobuf.Any marshalling and + // unmarshalling, making sure that we don't accept just 'any' type + // in our interface fields + string type_url = 2; +} + +// InterfaceAcceptingMessageDescriptor describes a protobuf message which contains +// an interface represented as a google.protobuf.Any +message InterfaceAcceptingMessageDescriptor { + // fullname is the protobuf fullname of the type containing the interface + string fullname = 1; + // field_descriptor_names is a list of the protobuf name (not fullname) of the field + // which contains the interface as google.protobuf.Any (the interface is the same, but + // it can be in multiple fields of the same proto message) + repeated string field_descriptor_names = 2; +} + +// ConfigurationDescriptor contains metadata information on the sdk.Config +message ConfigurationDescriptor { + // bech32_account_address_prefix is the account address prefix + string bech32_account_address_prefix = 1; +} + +// MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction +message MsgDescriptor { + // msg_type_url contains the TypeURL of a sdk.Msg. + string msg_type_url = 1; +} + +// ReflectionService defines a service for application reflection. +service ReflectionService { + // GetAuthnDescriptor returns information on how to authenticate transactions in the application + // NOTE: this RPC is still experimental and might be subject to breaking changes or removal in + // future releases of the cosmos-sdk. + rpc GetAuthnDescriptor(GetAuthnDescriptorRequest) returns (GetAuthnDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/authn"; + } + // GetChainDescriptor returns the description of the chain + rpc GetChainDescriptor(GetChainDescriptorRequest) returns (GetChainDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/chain"; + }; + // GetCodecDescriptor returns the descriptor of the codec of the application + rpc GetCodecDescriptor(GetCodecDescriptorRequest) returns (GetCodecDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/codec"; + } + // GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application + rpc GetConfigurationDescriptor(GetConfigurationDescriptorRequest) returns (GetConfigurationDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/configuration"; + } + // GetQueryServicesDescriptor returns the available gRPC queryable services of the application + rpc GetQueryServicesDescriptor(GetQueryServicesDescriptorRequest) returns (GetQueryServicesDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/query_services"; + } + // GetTxDescriptor returns information on the used transaction object and available msgs that can be used + rpc GetTxDescriptor(GetTxDescriptorRequest) returns (GetTxDescriptorResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/tx_descriptor"; + } +} + +// GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC +message GetAuthnDescriptorRequest {} +// GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC +message GetAuthnDescriptorResponse { + // authn describes how to authenticate to the application when sending transactions + AuthnDescriptor authn = 1; +} + +// GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC +message GetChainDescriptorRequest {} +// GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC +message GetChainDescriptorResponse { + // chain describes application chain information + ChainDescriptor chain = 1; +} + +// GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC +message GetCodecDescriptorRequest {} +// GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC +message GetCodecDescriptorResponse { + // codec describes the application codec such as registered interfaces and implementations + CodecDescriptor codec = 1; +} + +// GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC +message GetConfigurationDescriptorRequest {} +// GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC +message GetConfigurationDescriptorResponse { + // config describes the application's sdk.Config + ConfigurationDescriptor config = 1; +} + +// GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC +message GetQueryServicesDescriptorRequest {} +// GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC +message GetQueryServicesDescriptorResponse { + // queries provides information on the available queryable services + QueryServicesDescriptor queries = 1; +} + +// GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC +message GetTxDescriptorRequest {} +// GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC +message GetTxDescriptorResponse { + // tx provides information on msgs that can be forwarded to the application + // alongside the accepted transaction protobuf type + TxDescriptor tx = 1; +} + +// QueryServicesDescriptor contains the list of cosmos-sdk queriable services +message QueryServicesDescriptor { + // query_services is a list of cosmos-sdk QueryServiceDescriptor + repeated QueryServiceDescriptor query_services = 1; +} + +// QueryServiceDescriptor describes a cosmos-sdk queryable service +message QueryServiceDescriptor { + // fullname is the protobuf fullname of the service descriptor + string fullname = 1; + // is_module describes if this service is actually exposed by an application's module + bool is_module = 2; + // methods provides a list of query service methods + repeated QueryMethodDescriptor methods = 3; +} + +// QueryMethodDescriptor describes a queryable method of a query service +// no other info is provided beside method name and tendermint queryable path +// because it would be redundant with the grpc reflection service +message QueryMethodDescriptor { + // name is the protobuf name (not fullname) of the method + string name = 1; + // full_query_path is the path that can be used to query + // this method via tendermint abci.Query + string full_query_path = 2; +} diff --git a/third_party/proto/cosmos/base/store/v1beta1/listening.proto b/third_party/proto/cosmos/base/store/v1beta1/listening.proto new file mode 100644 index 00000000..35999710 --- /dev/null +++ b/third_party/proto/cosmos/base/store/v1beta1/listening.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.base.store.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/store/types"; + +// StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) +// It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and +// Deletes +// +// Since: cosmos-sdk 0.43 +message StoreKVPair { + string store_key = 1; // the store key for the KVStore this pair originates from + bool delete = 2; // true indicates a delete operation, false indicates a set operation + bytes key = 3; + bytes value = 4; +} diff --git a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto index 50cb5852..3c31877a 100644 --- a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto +++ b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto @@ -116,13 +116,15 @@ message GetNodeInfoResponse { // VersionInfo is the type for the GetNodeInfoResponse message. message VersionInfo { - string name = 1; - string app_name = 2; - string version = 3; - string git_commit = 4; - string build_tags = 5; - string go_version = 6; - repeated Module build_deps = 7; + string name = 1; + string app_name = 2; + string version = 3; + string git_commit = 4; + string build_tags = 5; + string go_version = 6; + repeated Module build_deps = 7; + // Since: cosmos-sdk 0.43 + string cosmos_sdk_version = 8; } // Module is the type for VersionInfo diff --git a/third_party/proto/cosmos/crypto/ed25519/keys.proto b/third_party/proto/cosmos/crypto/ed25519/keys.proto index bed9c29c..6ffec344 100644 --- a/third_party/proto/cosmos/crypto/ed25519/keys.proto +++ b/third_party/proto/cosmos/crypto/ed25519/keys.proto @@ -5,18 +5,19 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"; -// PubKey defines a ed25519 public key -// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte -// if the y-coordinate is the lexicographically largest of the two associated with -// the x-coordinate. Otherwise the first byte is a 0x03. -// This prefix is followed with the x-coordinate. +// PubKey is an ed25519 public key for handling Tendermint keys in SDK. +// It's needed for Any serialization and SDK compatibility. +// It must not be used in a non Tendermint key context because it doesn't implement +// ADR-28. Nevertheless, you will like to use ed25519 in app user level +// then you must create a new proto message and follow ADR-28 for Address construction. message PubKey { option (gogoproto.goproto_stringer) = false; bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; } -// PrivKey defines a ed25519 private key. +// Deprecated: PrivKey defines a ed25519 private key. +// NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. message PrivKey { bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"]; } diff --git a/third_party/proto/cosmos/crypto/secp256r1/keys.proto b/third_party/proto/cosmos/crypto/secp256r1/keys.proto new file mode 100644 index 00000000..2e96c6e3 --- /dev/null +++ b/third_party/proto/cosmos/crypto/secp256r1/keys.proto @@ -0,0 +1,23 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.crypto.secp256r1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1"; +option (gogoproto.messagename_all) = true; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.goproto_getters_all) = false; + +// PubKey defines a secp256r1 ECDSA public key. +message PubKey { + // Point on secp256r1 curve in a compressed representation as specified in section + // 4.3.6 of ANSI X9.62: https://webstore.ansi.org/standards/ascx9/ansix9621998 + bytes key = 1 [(gogoproto.customtype) = "ecdsaPK"]; +} + +// PrivKey defines a secp256r1 ECDSA private key. +message PrivKey { + // secret number serialized using big-endian encoding + bytes secret = 1 [(gogoproto.customtype) = "ecdsaSK"]; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto b/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto new file mode 100644 index 00000000..a86691f9 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -0,0 +1,78 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant"; + +// BasicAllowance implements Allowance with a one-time grant of tokens +// that optionally expires. The grantee can use up to SpendLimit to cover fees. +message BasicAllowance { + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + // spend_limit specifies the maximum amount of tokens that can be spent + // by this allowance and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. + repeated cosmos.base.v1beta1.Coin spend_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // expiration specifies an optional time when this allowance expires + google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true]; +} + +// PeriodicAllowance extends Allowance to allow for both a maximum cap, +// as well as a limit per time period. +message PeriodicAllowance { + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + // basic specifies a struct of `BasicAllowance` + BasicAllowance basic = 1 [(gogoproto.nullable) = false]; + + // period specifies the time duration in which period_spend_limit coins can + // be spent before that allowance is reset + google.protobuf.Duration period = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + // period_spend_limit specifies the maximum number of coins that can be spent + // in the period + repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // period_can_spend is the number of coins left to be spent before the period_reset time + repeated cosmos.base.v1beta1.Coin period_can_spend = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // period_reset is the time at which this period resets and a new one begins, + // it is calculated from the start time of the first transaction after the + // last period ended + google.protobuf.Timestamp period_reset = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} + +// AllowedMsgAllowance creates allowance only for specified message types. +message AllowedMsgAllowance { + option (gogoproto.goproto_getters) = false; + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + // allowance can be any of basic and filtered fee allowance. + google.protobuf.Any allowance = 1 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; + + // allowed_messages are the messages for which the grantee has the access. + repeated string allowed_messages = 2; +} + +// Grant is stored in the KVStore to record a grant with full context +message Grant { + // granter is the address of the user granting an allowance of their funds. + string granter = 1; + + // grantee is the address of the user being granted an allowance of another user's funds. + string grantee = 2; + + // allowance can be any of basic and filtered fee allowance. + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto b/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto new file mode 100644 index 00000000..5b1ac4ca --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -0,0 +1,13 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant"; + +// GenesisState contains a set of fee allowances, persisted from the store +message GenesisState { + repeated Grant allowances = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/query.proto b/third_party/proto/cosmos/feegrant/v1beta1/query.proto new file mode 100644 index 00000000..9cf2a498 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/query.proto @@ -0,0 +1,55 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "cosmos/feegrant/v1beta1/feegrant.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant"; + +// Query defines the gRPC querier service. +service Query { + + // Allowance returns fee granted to the grantee by the granter. + rpc Allowance(QueryAllowanceRequest) returns (QueryAllowanceResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowance/{granter}/{grantee}"; + } + + // Allowances returns all the grants for address. + rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}"; + } +} + +// QueryAllowanceRequest is the request type for the Query/Allowance RPC method. +message QueryAllowanceRequest { + // granter is the address of the user granting an allowance of their funds. + string granter = 1; + + // grantee is the address of the user being granted an allowance of another user's funds. + string grantee = 2; +} + +// QueryAllowanceResponse is the response type for the Query/Allowance RPC method. +message QueryAllowanceResponse { + // allowance is a allowance granted for grantee by granter. + cosmos.feegrant.v1beta1.Grant allowance = 1; +} + +// QueryAllowancesRequest is the request type for the Query/Allowances RPC method. +message QueryAllowancesRequest { + string grantee = 1; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryAllowancesResponse is the response type for the Query/Allowances RPC method. +message QueryAllowancesResponse { + // allowances are allowance's granted for grantee by granter. + repeated cosmos.feegrant.v1beta1.Grant allowances = 1; + + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/tx.proto b/third_party/proto/cosmos/feegrant/v1beta1/tx.proto new file mode 100644 index 00000000..2d875e92 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/tx.proto @@ -0,0 +1,49 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant"; + +// Msg defines the feegrant msg service. +service Msg { + + // GrantAllowance grants fee allowance to the grantee on the granter's + // account with the provided expiration time. + rpc GrantAllowance(MsgGrantAllowance) returns (MsgGrantAllowanceResponse); + + // RevokeAllowance revokes any fee allowance of granter's account that + // has been granted to the grantee. + rpc RevokeAllowance(MsgRevokeAllowance) returns (MsgRevokeAllowanceResponse); +} + +// MsgGrantAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +message MsgGrantAllowance { + // granter is the address of the user granting an allowance of their funds. + string granter = 1; + + // grantee is the address of the user being granted an allowance of another user's funds. + string grantee = 2; + + // allowance can be any of basic and filtered fee allowance. + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} + +// MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type. +message MsgGrantAllowanceResponse {} + +// MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. +message MsgRevokeAllowance { + // granter is the address of the user granting an allowance of their funds. + string granter = 1; + + // grantee is the address of the user being granted an allowance of another user's funds. + string grantee = 2; +} + +// MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type. +message MsgRevokeAllowanceResponse {} diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto index 1d72e643..344b5ada 100644 --- a/third_party/proto/cosmos/gov/v1beta1/gov.proto +++ b/third_party/proto/cosmos/gov/v1beta1/gov.proto @@ -29,6 +29,18 @@ enum VoteOption { VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"]; } +// WeightedVoteOption defines a unit of vote for vote split. +// +// Since: cosmos-sdk 0.43 +message WeightedVoteOption { + VoteOption option = 1; + string weight = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"weight\"" + ]; +} + // TextProposal defines a standard text proposal whose changes need to be // manually updated in case of approval. message TextProposal { @@ -119,9 +131,14 @@ message Vote { option (gogoproto.goproto_stringer) = false; option (gogoproto.equal) = false; - uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; - string voter = 2; - VoteOption option = 3; + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + // Deprecated: Prefer to use `options` instead. This field is set in queries + // if and only if `len(options) == 1` and that option has weight 1. In all + // other cases, this field will default to VOTE_OPTION_UNSPECIFIED. + VoteOption option = 3 [deprecated = true]; + // Since: cosmos-sdk 0.43 + repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false]; } // DepositParams defines the params for deposits on governance proposals. diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto index d4f0c1f9..36c0a95d 100644 --- a/third_party/proto/cosmos/gov/v1beta1/tx.proto +++ b/third_party/proto/cosmos/gov/v1beta1/tx.proto @@ -17,6 +17,11 @@ service Msg { // Vote defines a method to add a vote on a specific proposal. rpc Vote(MsgVote) returns (MsgVoteResponse); + // VoteWeighted defines a method to add a weighted vote on a specific proposal. + // + // Since: cosmos-sdk 0.43 + rpc VoteWeighted(MsgVoteWeighted) returns (MsgVoteWeightedResponse); + // Deposit defines a method to add deposit on a specific proposal. rpc Deposit(MsgDeposit) returns (MsgDepositResponse); } @@ -58,6 +63,25 @@ message MsgVote { // MsgVoteResponse defines the Msg/Vote response type. message MsgVoteResponse {} +// MsgVoteWeighted defines a message to cast a vote. +// +// Since: cosmos-sdk 0.43 +message MsgVoteWeighted { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false]; +} + +// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. +// +// Since: cosmos-sdk 0.43 +message MsgVoteWeightedResponse {} + // MsgDeposit defines a message to submit a deposit to an existing proposal. message MsgDeposit { option (gogoproto.equal) = false; diff --git a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto index c8135613..a7aebcfb 100644 --- a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto +++ b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto @@ -16,7 +16,7 @@ message GenesisState { repeated SigningInfo signing_infos = 2 [(gogoproto.moretags) = "yaml:\"signing_infos\"", (gogoproto.nullable) = false]; - // signing_infos represents a map between validator addresses and their + // missed_blocks represents a map between validator addresses and their // missed blocks. repeated ValidatorMissedBlocks missed_blocks = 3 [(gogoproto.moretags) = "yaml:\"missed_blocks\"", (gogoproto.nullable) = false]; diff --git a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto index 657a90f1..882a0fb6 100644 --- a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto +++ b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto @@ -15,17 +15,20 @@ message ValidatorSigningInfo { option (gogoproto.goproto_stringer) = false; string address = 1; - // height at which validator was first a candidate OR was unjailed + // Height at which validator was first a candidate OR was unjailed int64 start_height = 2 [(gogoproto.moretags) = "yaml:\"start_height\""]; - // index offset into signed block bit array + // Index which is incremented each time the validator was a bonded + // in a block and may have signed a precommit or not. This in conjunction with the + // `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. int64 index_offset = 3 [(gogoproto.moretags) = "yaml:\"index_offset\""]; - // timestamp validator cannot be unjailed until + // Timestamp until which the validator is jailed due to liveness downtime. google.protobuf.Timestamp jailed_until = 4 [(gogoproto.moretags) = "yaml:\"jailed_until\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - // whether or not a validator has been tombstoned (killed out of validator - // set) + // Whether or not a validator has been tombstoned (killed out of validator set). It is set + // once the validator commits an equivocation or for any other configured misbehiavor. bool tombstoned = 5; - // missed blocks counter (to avoid scanning the array every time) + // A counter kept to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. int64 missed_blocks_counter = 6 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""]; } diff --git a/third_party/proto/cosmos/staking/v1beta1/authz.proto b/third_party/proto/cosmos/staking/v1beta1/authz.proto new file mode 100644 index 00000000..d50c329c --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/authz.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// StakeAuthorization defines authorization for delegate/undelegate/redelegate. +// +// Since: cosmos-sdk 0.43 +message StakeAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; + + // max_tokens specifies the maximum amount of tokens can be delegate to a validator. If it is + // empty, there is no spend limit and any amount of coins can be delegated. + cosmos.base.v1beta1.Coin max_tokens = 1 [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"]; + // validators is the oneof that represents either allow_list or deny_list + oneof validators { + // allow_list specifies list of validator addresses to whom grantee can delegate tokens on behalf of granter's + // account. + Validators allow_list = 2; + // deny_list specifies list of validator addresses to whom grantee can not delegate tokens. + Validators deny_list = 3; + } + // Validators defines list of validator addresses. + message Validators { + repeated string address = 1; + } + // authorization_type defines one of AuthorizationType. + AuthorizationType authorization_type = 4; +} + +// AuthorizationType defines the type of staking module authorization type +// +// Since: cosmos-sdk 0.43 +enum AuthorizationType { + // AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type + AUTHORIZATION_TYPE_UNSPECIFIED = 0; + // AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate + AUTHORIZATION_TYPE_DELEGATE = 1; + // AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate + AUTHORIZATION_TYPE_UNDELEGATE = 2; + // AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate + AUTHORIZATION_TYPE_REDELEGATE = 3; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/staking.proto b/third_party/proto/cosmos/staking/v1beta1/staking.proto index e37b28b6..76e9599e 100644 --- a/third_party/proto/cosmos/staking/v1beta1/staking.proto +++ b/third_party/proto/cosmos/staking/v1beta1/staking.proto @@ -28,7 +28,7 @@ message CommissionRates { option (gogoproto.goproto_stringer) = false; // rate is the commission rate charged to delegators, as a fraction. - string rate = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string rate = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; // max_rate defines the maximum commission rate which validator can ever charge, as a fraction. string max_rate = 2 [ (gogoproto.moretags) = "yaml:\"max_rate\"", @@ -49,9 +49,9 @@ message Commission { option (gogoproto.goproto_stringer) = false; // commission_rates defines the initial commission rates to be used for creating a validator. - CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; // update_time is the last time the commission rate was changed. - google.protobuf.Timestamp update_time = 2 + google.protobuf.Timestamp update_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\""]; } @@ -61,15 +61,15 @@ message Description { option (gogoproto.goproto_stringer) = false; // moniker defines a human-readable name for the validator. - string moniker = 1; + string moniker = 1; // identity defines an optional identity signature (ex. UPort or Keybase). - string identity = 2; + string identity = 2; // website defines an optional website link. - string website = 3; + string website = 3; // security_contact defines an optional email for security contact. string security_contact = 4 [(gogoproto.moretags) = "yaml:\"security_contact\""]; // details define other optional details. - string details = 5; + string details = 5; } // Validator defines a validator, together with the total amount of the @@ -86,12 +86,12 @@ message Validator { option (gogoproto.goproto_getters) = false; // operator_address defines the address of the validator's operator; bech encoded in JSON. - string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; + string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; // consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. google.protobuf.Any consensus_pubkey = 2 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", (gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; // jailed defined whether the validator has been jailed from bonded status or not. - bool jailed = 3; + bool jailed = 3; // status is the validator status (bonded/unbonding/unbonded). BondStatus status = 4; // tokens define the delegated tokens (incl. self-delegation). @@ -103,16 +103,16 @@ message Validator { (gogoproto.nullable) = false ]; // description defines the description terms for the validator. - Description description = 7 [(gogoproto.nullable) = false]; + Description description = 7 [(gogoproto.nullable) = false]; // unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. - int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; + int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; // unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. - google.protobuf.Timestamp unbonding_time = 9 + google.protobuf.Timestamp unbonding_time = 9 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; // commission defines the commission parameters. - Commission commission = 10 [(gogoproto.nullable) = false]; + Commission commission = 10 [(gogoproto.nullable) = false]; // min_self_delegation is the validator's self declared minimum self delegation. - string min_self_delegation = 11 [ + string min_self_delegation = 11 [ (gogoproto.moretags) = "yaml:\"min_self_delegation\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false @@ -201,9 +201,9 @@ message UnbondingDelegation { option (gogoproto.goproto_stringer) = false; // delegator_address is the bech32-encoded address of the delegator. - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; // validator_address is the bech32-encoded address of the validator. - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; // entries are the unbonding delegation entries. repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries } @@ -214,7 +214,7 @@ message UnbondingDelegationEntry { option (gogoproto.goproto_stringer) = false; // creation_height is the height which the unbonding took place. - int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; // completion_time is the unix time for unbonding completion. google.protobuf.Timestamp completion_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; @@ -234,7 +234,7 @@ message RedelegationEntry { option (gogoproto.goproto_stringer) = false; // creation_height defines the height which the redelegation took place. - int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; // completion_time defines the unix time for redelegation completion. google.protobuf.Timestamp completion_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; @@ -257,13 +257,13 @@ message Redelegation { option (gogoproto.goproto_stringer) = false; // delegator_address is the bech32-encoded address of the delegator. - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; // validator_src_address is the validator redelegation source operator address. - string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; // validator_dst_address is the validator redelegation destination operator address. - string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; // entries are the redelegation entries. - repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries + repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries } // Params defines the parameters for the staking module. @@ -275,13 +275,13 @@ message Params { google.protobuf.Duration unbonding_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; // max_validators is the maximum number of validators. - uint32 max_validators = 2 [(gogoproto.moretags) = "yaml:\"max_validators\""]; + uint32 max_validators = 2 [(gogoproto.moretags) = "yaml:\"max_validators\""]; // max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). - uint32 max_entries = 3 [(gogoproto.moretags) = "yaml:\"max_entries\""]; + uint32 max_entries = 3 [(gogoproto.moretags) = "yaml:\"max_entries\""]; // historical_entries is the number of historical entries to persist. uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""]; // bond_denom defines the bondable coin denomination. - string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""]; + string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""]; } // DelegationResponse is equivalent to Delegation except that it contains a diff --git a/third_party/proto/cosmos/tx/v1beta1/service.proto b/third_party/proto/cosmos/tx/v1beta1/service.proto index 59df75ba..acfbf15b 100644 --- a/third_party/proto/cosmos/tx/v1beta1/service.proto +++ b/third_party/proto/cosmos/tx/v1beta1/service.proto @@ -7,7 +7,8 @@ import "cosmos/tx/v1beta1/tx.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; +option (gogoproto.goproto_registration) = true; +option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; // Service defines a gRPC service for interacting with transactions. service Service { @@ -42,6 +43,17 @@ message GetTxsEventRequest { repeated string events = 1; // pagination defines an pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 2; + OrderBy order_by = 3; +} + +// OrderBy defines the sorting order +enum OrderBy { + // ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. + ORDER_BY_UNSPECIFIED = 0; + // ORDER_BY_ASC defines ascending order + ORDER_BY_ASC = 1; + // ORDER_BY_DESC defines descending order + ORDER_BY_DESC = 2; } // GetTxsEventResponse is the response type for the Service.TxsByEvents @@ -89,7 +101,12 @@ message BroadcastTxResponse { // RPC method. message SimulateRequest { // tx is the transaction to simulate. - cosmos.tx.v1beta1.Tx tx = 1; + // Deprecated. Send raw tx bytes instead. + cosmos.tx.v1beta1.Tx tx = 1 [deprecated = true]; + // tx_bytes is the raw transaction. + // + // Since: cosmos-sdk 0.43 + bytes tx_bytes = 2; } // SimulateResponse is the response type for the diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto index 2b02874c..6d5caf12 100644 --- a/third_party/proto/cosmos/tx/v1beta1/tx.proto +++ b/third_party/proto/cosmos/tx/v1beta1/tx.proto @@ -74,7 +74,9 @@ message TxBody { // transaction. repeated google.protobuf.Any messages = 1; - // memo is any arbitrary memo to be added to the transaction + // memo is any arbitrary note/comment to be added to the transaction. + // WARNING: in clients, any publicly exposed text should not be called memo, + // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). string memo = 2; // timeout is the block height after which this transaction will not diff --git a/third_party/proto/cosmos/upgrade/v1beta1/query.proto b/third_party/proto/cosmos/upgrade/v1beta1/query.proto index 9eab27e7..dd14ba64 100644 --- a/third_party/proto/cosmos/upgrade/v1beta1/query.proto +++ b/third_party/proto/cosmos/upgrade/v1beta1/query.proto @@ -23,9 +23,19 @@ service Query { // as a trusted kernel for the next version of this chain. It will only be // stored at the last height of this chain. // UpgradedConsensusState RPC not supported with legacy querier + // This rpc is deprecated now that IBC has its own replacement + // (https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) { + option deprecated = true; option (google.api.http).get = "/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}"; } + + // ModuleVersions queries the list of module versions from state. + // + // Since: cosmos-sdk 0.43 + rpc ModuleVersions(QueryModuleVersionsRequest) returns (QueryModuleVersionsResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/module_versions"; + } } // QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC @@ -56,6 +66,8 @@ message QueryAppliedPlanResponse { // QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState // RPC method. message QueryUpgradedConsensusStateRequest { + option deprecated = true; + // last height of the current chain must be sent in request // as this is the height under which next consensus state is stored int64 last_height = 1; @@ -64,5 +76,29 @@ message QueryUpgradedConsensusStateRequest { // QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState // RPC method. message QueryUpgradedConsensusStateResponse { - google.protobuf.Any upgraded_consensus_state = 1; + option deprecated = true; + reserved 1; + + // Since: cosmos-sdk 0.43 + bytes upgraded_consensus_state = 2; +} + +// QueryModuleVersionsRequest is the request type for the Query/ModuleVersions +// RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryModuleVersionsRequest { + // module_name is a field to query a specific module + // consensus version from state. Leaving this empty will + // fetch the full list of module versions from state + string module_name = 1; +} + +// QueryModuleVersionsResponse is the response type for the Query/ModuleVersions +// RPC method. +// +// Since: cosmos-sdk 0.43 +message QueryModuleVersionsResponse { + // module_versions is a list of module names with their consensus versions. + repeated ModuleVersion module_versions = 1; } diff --git a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto index 6d6839ca..e888b393 100644 --- a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -5,13 +5,13 @@ import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.goproto_getters_all) = false; +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; +option (gogoproto.goproto_getters_all) = false; // Plan specifies information about a planned upgrade and when it should occur. message Plan { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; // Sets the name for the upgrade. This name will be used by the upgraded // version of the software to apply any special "on-upgrade" commands during @@ -22,9 +22,10 @@ message Plan { // reached and the software will exit. string name = 1; - // The time after which the upgrade must be performed. - // Leave set to its zero value to use a pre-defined Height instead. - google.protobuf.Timestamp time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + // Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + // has been removed from the SDK. + // If this field is not empty, an error will be thrown. + google.protobuf.Timestamp time = 2 [deprecated = true, (gogoproto.stdtime) = true, (gogoproto.nullable) = false]; // The height at which the upgrade must be performed. // Only used if Time is not set. @@ -34,18 +35,18 @@ message Plan { // such as a git commit that validators could automatically upgrade to string info = 4; - // IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan - // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, - // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the - // previous version of the chain. - // This will allow IBC connections to persist smoothly across planned chain upgrades - google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; + // Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + // moved to the IBC module in the sub module 02-client. + // If this field is not empty, an error will be thrown. + google.protobuf.Any upgraded_client_state = 5 + [deprecated = true, (gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; } // SoftwareUpgradeProposal is a gov Content type for initiating a software // upgrade. message SoftwareUpgradeProposal { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; string title = 1; string description = 2; @@ -55,8 +56,23 @@ message SoftwareUpgradeProposal { // CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software // upgrade. message CancelSoftwareUpgradeProposal { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; string title = 1; string description = 2; } + +// ModuleVersion specifies a module and its consensus version. +// +// Since: cosmos-sdk 0.43 +message ModuleVersion { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // name of the app module + string name = 1; + + // consensus version of the app module + uint64 version = 2; +} diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto index 6bdbbf08..e9f661f9 100644 --- a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto +++ b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto @@ -71,3 +71,15 @@ message PeriodicVestingAccount { int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; repeated Period vesting_periods = 3 [(gogoproto.moretags) = "yaml:\"vesting_periods\"", (gogoproto.nullable) = false]; } + +// PermanentLockedAccount implements the VestingAccount interface. It does +// not ever release coins, locking them indefinitely. Coins in this account can +// still be used for delegating and for governance votes even while locked. +// +// Since: cosmos-sdk 0.43 +message PermanentLockedAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; +} diff --git a/third_party/proto/google/protobuf/any.proto b/third_party/proto/google/protobuf/any.proto index 1431810e..58b51158 100644 --- a/third_party/proto/google/protobuf/any.proto +++ b/third_party/proto/google/protobuf/any.proto @@ -156,6 +156,9 @@ message Any { bytes value = 2; option (gogoproto.typedecl) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.gostring) = false; + option (gogoproto.stringer) = false; } option (gogoproto.goproto_registration) = false; diff --git a/third_party/proto/ibc/applications/transfer/v1/genesis.proto b/third_party/proto/ibc/applications/transfer/v1/genesis.proto deleted file mode 100644 index 98cf2296..00000000 --- a/third_party/proto/ibc/applications/transfer/v1/genesis.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; - -import "gogoproto/gogo.proto"; -import "ibc/applications/transfer/v1/transfer.proto"; - -// GenesisState defines the ibc-transfer genesis state -message GenesisState { - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - repeated DenomTrace denom_traces = 2 [ - (gogoproto.castrepeated) = "Traces", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"denom_traces\"" - ]; - Params params = 3 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/ibc/applications/transfer/v1/query.proto b/third_party/proto/ibc/applications/transfer/v1/query.proto deleted file mode 100644 index e9cbd02a..00000000 --- a/third_party/proto/ibc/applications/transfer/v1/query.proto +++ /dev/null @@ -1,66 +0,0 @@ -syntax = "proto3"; -package ibc.applications.transfer.v1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "ibc/applications/transfer/v1/transfer.proto"; -import "google/api/annotations.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; - -// Query provides defines the gRPC querier service. -service Query { - // DenomTrace queries a denomination trace information. - rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { - option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces/{hash}"; - } - - // DenomTraces queries all denomination traces. - rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) { - option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces"; - } - - // Params queries all parameters of the ibc-transfer module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/ibc/applications/transfer/v1beta1/params"; - } -} - -// QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC -// method -message QueryDenomTraceRequest { - // hash (in hex format) of the denomination trace information. - string hash = 1; -} - -// QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC -// method. -message QueryDenomTraceResponse { - // denom_trace returns the requested denomination trace information. - DenomTrace denom_trace = 1; -} - -// QueryConnectionsRequest is the request type for the Query/DenomTraces RPC -// method -message QueryDenomTracesRequest { - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryConnectionsResponse is the response type for the Query/DenomTraces RPC -// method. -message QueryDenomTracesResponse { - // denom_traces returns all denominations trace information. - repeated DenomTrace denom_traces = 1 [(gogoproto.castrepeated) = "Traces", (gogoproto.nullable) = false]; - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - // params defines the parameters of the module. - Params params = 1; -} diff --git a/third_party/proto/ibc/applications/transfer/v1/transfer.proto b/third_party/proto/ibc/applications/transfer/v1/transfer.proto deleted file mode 100644 index b388c3b8..00000000 --- a/third_party/proto/ibc/applications/transfer/v1/transfer.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; - -import "gogoproto/gogo.proto"; - -// FungibleTokenPacketData defines a struct for the packet payload -// See FungibleTokenPacketData spec: -// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures -message FungibleTokenPacketData { - // the token denomination to be transferred - string denom = 1; - // the token amount to be transferred - uint64 amount = 2; - // the sender address - string sender = 3; - // the recipient address on the destination chain - string receiver = 4; -} - -// DenomTrace contains the base denomination for ICS20 fungible tokens and the -// source tracing information path. -message DenomTrace { - // path defines the chain of port/channel identifiers used for tracing the - // source of the fungible token. - string path = 1; - // base denomination of the relayed fungible token. - string base_denom = 2; -} - -// Params defines the set of IBC transfer parameters. -// NOTE: To prevent a single token from being transferred, set the -// TransfersEnabled parameter to true and then set the bank module's SendEnabled -// parameter for the denomination to false. -message Params { - // send_enabled enables or disables all cross-chain token transfers from this - // chain. - bool send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled\""]; - // receive_enabled enables or disables all cross-chain token transfers to this - // chain. - bool receive_enabled = 2 [(gogoproto.moretags) = "yaml:\"receive_enabled\""]; -} diff --git a/third_party/proto/ibc/applications/transfer/v1/tx.proto b/third_party/proto/ibc/applications/transfer/v1/tx.proto deleted file mode 100644 index a0f0827a..00000000 --- a/third_party/proto/ibc/applications/transfer/v1/tx.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "ibc/core/client/v1/client.proto"; - -// Msg defines the ibc/transfer Msg service. -service Msg { - // Transfer defines a rpc handler method for MsgTransfer. - rpc Transfer(MsgTransfer) returns (MsgTransferResponse); -} - -// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between -// ICS20 enabled chains. See ICS Spec here: -// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures -message MsgTransfer { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // the port on which the packet will be sent - string source_port = 1 [(gogoproto.moretags) = "yaml:\"source_port\""]; - // the channel by which the packet will be sent - string source_channel = 2 [(gogoproto.moretags) = "yaml:\"source_channel\""]; - // the tokens to be transferred - cosmos.base.v1beta1.Coin token = 3 [(gogoproto.nullable) = false]; - // the sender address - string sender = 4; - // the recipient address on the destination chain - string receiver = 5; - // Timeout height relative to the current block height. - // The timeout is disabled when set to 0. - ibc.core.client.v1.Height timeout_height = 6 - [(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false]; - // Timeout timestamp (in nanoseconds) relative to the current block timestamp. - // The timeout is disabled when set to 0. - uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; -} - -// MsgTransferResponse defines the Msg/Transfer response type. -message MsgTransferResponse {} diff --git a/third_party/proto/ibc/core/channel/v1/channel.proto b/third_party/proto/ibc/core/channel/v1/channel.proto deleted file mode 100644 index 302a4806..00000000 --- a/third_party/proto/ibc/core/channel/v1/channel.proto +++ /dev/null @@ -1,147 +0,0 @@ -syntax = "proto3"; -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/client.proto"; - -// Channel defines pipeline for exactly-once packet delivery between specific -// modules on separate blockchains, which has at least one end capable of -// sending packets and one end capable of receiving packets. -message Channel { - option (gogoproto.goproto_getters) = false; - - // current state of the channel end - State state = 1; - // whether the channel is ordered or unordered - Order ordering = 2; - // counterparty channel end - Counterparty counterparty = 3 [(gogoproto.nullable) = false]; - // list of connection identifiers, in order, along which packets sent on - // this channel will travel - repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; - // opaque channel version, which is agreed upon during the handshake - string version = 5; -} - -// IdentifiedChannel defines a channel with additional port and channel -// identifier fields. -message IdentifiedChannel { - option (gogoproto.goproto_getters) = false; - - // current state of the channel end - State state = 1; - // whether the channel is ordered or unordered - Order ordering = 2; - // counterparty channel end - Counterparty counterparty = 3 [(gogoproto.nullable) = false]; - // list of connection identifiers, in order, along which packets sent on - // this channel will travel - repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; - // opaque channel version, which is agreed upon during the handshake - string version = 5; - // port identifier - string port_id = 6; - // channel identifier - string channel_id = 7; -} - -// State defines if a channel is in one of the following states: -// CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. -enum State { - option (gogoproto.goproto_enum_prefix) = false; - - // Default State - STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"]; - // A channel has just started the opening handshake. - STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"]; - // A channel has acknowledged the handshake step on the counterparty chain. - STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"]; - // A channel has completed the handshake. Open channels are - // ready to send and receive packets. - STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"]; - // A channel has been closed and can no longer be used to send or receive - // packets. - STATE_CLOSED = 4 [(gogoproto.enumvalue_customname) = "CLOSED"]; -} - -// Order defines if a channel is ORDERED or UNORDERED -enum Order { - option (gogoproto.goproto_enum_prefix) = false; - - // zero-value for channel ordering - ORDER_NONE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; - // packets can be delivered in any order, which may differ from the order in - // which they were sent. - ORDER_UNORDERED = 1 [(gogoproto.enumvalue_customname) = "UNORDERED"]; - // packets are delivered exactly in the order which they were sent - ORDER_ORDERED = 2 [(gogoproto.enumvalue_customname) = "ORDERED"]; -} - -// Counterparty defines a channel end counterparty -message Counterparty { - option (gogoproto.goproto_getters) = false; - - // port on the counterparty chain which owns the other end of the channel. - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - // channel end on the counterparty chain - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; -} - -// Packet defines a type that carries data across different chains through IBC -message Packet { - option (gogoproto.goproto_getters) = false; - - // number corresponds to the order of sends and receives, where a Packet - // with an earlier sequence number must be sent and received before a Packet - // with a later sequence number. - uint64 sequence = 1; - // identifies the port on the sending chain. - string source_port = 2 [(gogoproto.moretags) = "yaml:\"source_port\""]; - // identifies the channel end on the sending chain. - string source_channel = 3 [(gogoproto.moretags) = "yaml:\"source_channel\""]; - // identifies the port on the receiving chain. - string destination_port = 4 [(gogoproto.moretags) = "yaml:\"destination_port\""]; - // identifies the channel end on the receiving chain. - string destination_channel = 5 [(gogoproto.moretags) = "yaml:\"destination_channel\""]; - // actual opaque bytes transferred directly to the application module - bytes data = 6; - // block height after which the packet times out - ibc.core.client.v1.Height timeout_height = 7 - [(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false]; - // block timestamp (in nanoseconds) after which the packet times out - uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; -} - -// PacketState defines the generic type necessary to retrieve and store -// packet commitments, acknowledgements, and receipts. -// Caller is responsible for knowing the context necessary to interpret this -// state as a commitment, acknowledgement, or a receipt. -message PacketState { - option (gogoproto.goproto_getters) = false; - - // channel port identifier. - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - // channel unique identifier. - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - // packet sequence. - uint64 sequence = 3; - // embedded data that represents packet state. - bytes data = 4; -} - -// Acknowledgement is the recommended acknowledgement format to be used by -// app-specific protocols. -// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental -// conflicts with other protobuf message formats used for acknowledgements. -// The first byte of any message with this format will be the non-ASCII values -// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -// https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope -message Acknowledgement { - // response contains either a result or an error and must be non-empty - oneof response { - bytes result = 21; - string error = 22; - } -} diff --git a/third_party/proto/ibc/core/channel/v1/genesis.proto b/third_party/proto/ibc/core/channel/v1/genesis.proto deleted file mode 100644 index d3b2c042..00000000 --- a/third_party/proto/ibc/core/channel/v1/genesis.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/channel/v1/channel.proto"; - -// GenesisState defines the ibc channel submodule's genesis state. -message GenesisState { - repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; - repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; - repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; - repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; - repeated PacketSequence send_sequences = 5 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"send_sequences\""]; - repeated PacketSequence recv_sequences = 6 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"recv_sequences\""]; - repeated PacketSequence ack_sequences = 7 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"ack_sequences\""]; - // the sequence for the next generated channel identifier - uint64 next_channel_sequence = 8 [(gogoproto.moretags) = "yaml:\"next_channel_sequence\""]; -} - -// PacketSequence defines the genesis type necessary to retrieve and store -// next send and receive sequences. -message PacketSequence { - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - uint64 sequence = 3; -} diff --git a/third_party/proto/ibc/core/channel/v1/query.proto b/third_party/proto/ibc/core/channel/v1/query.proto deleted file mode 100644 index d9e3ceb8..00000000 --- a/third_party/proto/ibc/core/channel/v1/query.proto +++ /dev/null @@ -1,367 +0,0 @@ -syntax = "proto3"; -package ibc.core.channel.v1; - -import "ibc/core/client/v1/client.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "ibc/core/channel/v1/channel.proto"; -import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; - -// Query provides defines the gRPC querier service -service Query { - // Channel queries an IBC Channel. - rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}"; - } - - // Channels queries all the IBC channels of a chain. - rpc Channels(QueryChannelsRequest) returns (QueryChannelsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels"; - } - - // ConnectionChannels queries all the channels associated with a connection - // end. - rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/connections/{connection}/channels"; - } - - // ChannelClientState queries for the client state for the channel associated - // with the provided channel identifiers. - rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state"; - } - - // ChannelConsensusState queries for the consensus state for the channel - // associated with the provided channel identifiers. - rpc ChannelConsensusState(QueryChannelConsensusStateRequest) returns (QueryChannelConsensusStateResponse) { - option (google.api.http).get = - "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/" - "{revision_number}/height/{revision_height}"; - } - - // PacketCommitment queries a stored packet commitment hash. - rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { - option (google.api.http).get = - "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}"; - } - - // PacketCommitments returns all the packet commitments hashes associated - // with a channel. - rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments"; - } - - // PacketReceipt queries if a given packet sequence has been received on the queried chain - rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { - option (google.api.http).get = - "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}"; - } - - // PacketAcknowledgement queries a stored packet acknowledgement hash. - rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { - option (google.api.http).get = - "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}"; - } - - // PacketAcknowledgements returns all the packet acknowledgements associated - // with a channel. - rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) { - option (google.api.http).get = - "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements"; - } - - // UnreceivedPackets returns all the unreceived IBC packets associated with a - // channel and sequences. - rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" - "{packet_commitment_sequences}/unreceived_packets"; - } - - // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a - // channel and sequences. - rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" - "{packet_ack_sequences}/unreceived_acks"; - } - - // NextSequenceReceive returns the next receive sequence for a given channel. - rpc NextSequenceReceive(QueryNextSequenceReceiveRequest) returns (QueryNextSequenceReceiveResponse) { - option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence"; - } -} - -// QueryChannelRequest is the request type for the Query/Channel RPC method -message QueryChannelRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; -} - -// QueryChannelResponse is the response type for the Query/Channel RPC method. -// Besides the Channel end, it includes a proof and the height from which the -// proof was retrieved. -message QueryChannelResponse { - // channel associated with the request identifiers - ibc.core.channel.v1.Channel channel = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryChannelsRequest is the request type for the Query/Channels RPC method -message QueryChannelsRequest { - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryChannelsResponse is the response type for the Query/Channels RPC method. -message QueryChannelsResponse { - // list of stored channels of the chain. - repeated ibc.core.channel.v1.IdentifiedChannel channels = 1; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; - // query block height - ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; -} - -// QueryConnectionChannelsRequest is the request type for the -// Query/QueryConnectionChannels RPC method -message QueryConnectionChannelsRequest { - // connection unique identifier - string connection = 1; - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryConnectionChannelsResponse is the Response type for the -// Query/QueryConnectionChannels RPC method -message QueryConnectionChannelsResponse { - // list of channels associated with a connection. - repeated ibc.core.channel.v1.IdentifiedChannel channels = 1; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; - // query block height - ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; -} - -// QueryChannelClientStateRequest is the request type for the Query/ClientState -// RPC method -message QueryChannelClientStateRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; -} - -// QueryChannelClientStateResponse is the Response type for the -// Query/QueryChannelClientState RPC method -message QueryChannelClientStateResponse { - // client state associated with the channel - ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryChannelConsensusStateRequest is the request type for the -// Query/ConsensusState RPC method -message QueryChannelConsensusStateRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // revision number of the consensus state - uint64 revision_number = 3; - // revision height of the consensus state - uint64 revision_height = 4; -} - -// QueryChannelClientStateResponse is the Response type for the -// Query/QueryChannelClientState RPC method -message QueryChannelConsensusStateResponse { - // consensus state associated with the channel - google.protobuf.Any consensus_state = 1; - // client ID associated with the consensus state - string client_id = 2; - // merkle proof of existence - bytes proof = 3; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; -} - -// QueryPacketCommitmentRequest is the request type for the -// Query/PacketCommitment RPC method -message QueryPacketCommitmentRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // packet sequence - uint64 sequence = 3; -} - -// QueryPacketCommitmentResponse defines the client query response for a packet -// which also includes a proof and the height from which the proof was -// retrieved -message QueryPacketCommitmentResponse { - // packet associated with the request fields - bytes commitment = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryPacketCommitmentsRequest is the request type for the -// Query/QueryPacketCommitments RPC method -message QueryPacketCommitmentsRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 3; -} - -// QueryPacketCommitmentsResponse is the request type for the -// Query/QueryPacketCommitments RPC method -message QueryPacketCommitmentsResponse { - repeated ibc.core.channel.v1.PacketState commitments = 1; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; - // query block height - ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; -} - -// QueryPacketReceiptRequest is the request type for the -// Query/PacketReceipt RPC method -message QueryPacketReceiptRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // packet sequence - uint64 sequence = 3; -} - -// QueryPacketReceiptResponse defines the client query response for a packet receipt -// which also includes a proof, and the height from which the proof was -// retrieved -message QueryPacketReceiptResponse { - // success flag for if receipt exists - bool received = 2; - // merkle proof of existence - bytes proof = 3; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; -} - -// QueryPacketAcknowledgementRequest is the request type for the -// Query/PacketAcknowledgement RPC method -message QueryPacketAcknowledgementRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // packet sequence - uint64 sequence = 3; -} - -// QueryPacketAcknowledgementResponse defines the client query response for a -// packet which also includes a proof and the height from which the -// proof was retrieved -message QueryPacketAcknowledgementResponse { - // packet associated with the request fields - bytes acknowledgement = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryPacketAcknowledgementsRequest is the request type for the -// Query/QueryPacketCommitments RPC method -message QueryPacketAcknowledgementsRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 3; -} - -// QueryPacketAcknowledgemetsResponse is the request type for the -// Query/QueryPacketAcknowledgements RPC method -message QueryPacketAcknowledgementsResponse { - repeated ibc.core.channel.v1.PacketState acknowledgements = 1; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; - // query block height - ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; -} - -// QueryUnreceivedPacketsRequest is the request type for the -// Query/UnreceivedPackets RPC method -message QueryUnreceivedPacketsRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // list of packet sequences - repeated uint64 packet_commitment_sequences = 3; -} - -// QueryUnreceivedPacketsResponse is the response type for the -// Query/UnreceivedPacketCommitments RPC method -message QueryUnreceivedPacketsResponse { - // list of unreceived packet sequences - repeated uint64 sequences = 1; - // query block height - ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; -} - -// QueryUnreceivedAcks is the request type for the -// Query/UnreceivedAcks RPC method -message QueryUnreceivedAcksRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; - // list of acknowledgement sequences - repeated uint64 packet_ack_sequences = 3; -} - -// QueryUnreceivedAcksResponse is the response type for the -// Query/UnreceivedAcks RPC method -message QueryUnreceivedAcksResponse { - // list of unreceived acknowledgement sequences - repeated uint64 sequences = 1; - // query block height - ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; -} - -// QueryNextSequenceReceiveRequest is the request type for the -// Query/QueryNextSequenceReceiveRequest RPC method -message QueryNextSequenceReceiveRequest { - // port unique identifier - string port_id = 1; - // channel unique identifier - string channel_id = 2; -} - -// QuerySequenceResponse is the request type for the -// Query/QueryNextSequenceReceiveResponse RPC method -message QueryNextSequenceReceiveResponse { - // next sequence receive number - uint64 next_sequence_receive = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/ibc/core/channel/v1/tx.proto b/third_party/proto/ibc/core/channel/v1/tx.proto deleted file mode 100644 index 5f842641..00000000 --- a/third_party/proto/ibc/core/channel/v1/tx.proto +++ /dev/null @@ -1,207 +0,0 @@ -syntax = "proto3"; -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/client.proto"; -import "ibc/core/channel/v1/channel.proto"; - -// Msg defines the ibc/channel Msg service. -service Msg { - // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. - rpc ChannelOpenInit(MsgChannelOpenInit) returns (MsgChannelOpenInitResponse); - - // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. - rpc ChannelOpenTry(MsgChannelOpenTry) returns (MsgChannelOpenTryResponse); - - // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. - rpc ChannelOpenAck(MsgChannelOpenAck) returns (MsgChannelOpenAckResponse); - - // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. - rpc ChannelOpenConfirm(MsgChannelOpenConfirm) returns (MsgChannelOpenConfirmResponse); - - // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. - rpc ChannelCloseInit(MsgChannelCloseInit) returns (MsgChannelCloseInitResponse); - - // ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. - rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse); - - // RecvPacket defines a rpc handler method for MsgRecvPacket. - rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); - - // Timeout defines a rpc handler method for MsgTimeout. - rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); - - // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. - rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); - - // Acknowledgement defines a rpc handler method for MsgAcknowledgement. - rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); -} - -// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It -// is called by a relayer on Chain A. -message MsgChannelOpenInit { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - Channel channel = 2 [(gogoproto.nullable) = false]; - string signer = 3; -} - -// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. -message MsgChannelOpenInitResponse {} - -// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel -// on Chain B. -message MsgChannelOpenTry { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - // in the case of crossing hello's, when both chains call OpenInit, we need the channel identifier - // of the previous channel in state INIT - string previous_channel_id = 2 [(gogoproto.moretags) = "yaml:\"previous_channel_id\""]; - Channel channel = 3 [(gogoproto.nullable) = false]; - string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; - ibc.core.client.v1.Height proof_height = 6 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 7; -} - -// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. -message MsgChannelOpenTryResponse {} - -// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge -// the change of channel state to TRYOPEN on Chain B. -message MsgChannelOpenAck { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - string counterparty_channel_id = 3 [(gogoproto.moretags) = "yaml:\"counterparty_channel_id\""]; - string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - bytes proof_try = 5 [(gogoproto.moretags) = "yaml:\"proof_try\""]; - ibc.core.client.v1.Height proof_height = 6 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 7; -} - -// MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. -message MsgChannelOpenAckResponse {} - -// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to -// acknowledge the change of channel state to OPEN on Chain A. -message MsgChannelOpenConfirm { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; - ibc.core.client.v1.Height proof_height = 4 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 5; -} - -// MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type. -message MsgChannelOpenConfirmResponse {} - -// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A -// to close a channel with Chain B. -message MsgChannelCloseInit { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - string signer = 3; -} - -// MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. -message MsgChannelCloseInitResponse {} - -// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B -// to acknowledge the change of channel state to CLOSED on Chain A. -message MsgChannelCloseConfirm { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; - bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""]; - ibc.core.client.v1.Height proof_height = 4 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 5; -} - -// MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type. -message MsgChannelCloseConfirmResponse {} - -// MsgRecvPacket receives incoming IBC packet -message MsgRecvPacket { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof_commitment = 2 [(gogoproto.moretags) = "yaml:\"proof_commitment\""]; - ibc.core.client.v1.Height proof_height = 3 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 4; -} - -// MsgRecvPacketResponse defines the Msg/RecvPacket response type. -message MsgRecvPacketResponse {} - -// MsgTimeout receives timed-out packet -message MsgTimeout { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; - ibc.core.client.v1.Height proof_height = 3 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; - string signer = 5; -} - -// MsgTimeoutResponse defines the Msg/Timeout response type. -message MsgTimeoutResponse {} - -// MsgTimeoutOnClose timed-out packet upon counterparty channel closure. -message MsgTimeoutOnClose { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; - bytes proof_close = 3 [(gogoproto.moretags) = "yaml:\"proof_close\""]; - ibc.core.client.v1.Height proof_height = 4 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - uint64 next_sequence_recv = 5 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; - string signer = 6; -} - -// MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. -message MsgTimeoutOnCloseResponse {} - -// MsgAcknowledgement receives incoming IBC acknowledgement -message MsgAcknowledgement { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Packet packet = 1 [(gogoproto.nullable) = false]; - bytes acknowledgement = 2; - bytes proof_acked = 3 [(gogoproto.moretags) = "yaml:\"proof_acked\""]; - ibc.core.client.v1.Height proof_height = 4 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 5; -} - -// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. -message MsgAcknowledgementResponse {} diff --git a/third_party/proto/ibc/core/client/v1/client.proto b/third_party/proto/ibc/core/client/v1/client.proto deleted file mode 100644 index 11d2195a..00000000 --- a/third_party/proto/ibc/core/client/v1/client.proto +++ /dev/null @@ -1,74 +0,0 @@ -syntax = "proto3"; -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; - -// IdentifiedClientState defines a client state with an additional client -// identifier field. -message IdentifiedClientState { - // client identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // client state - google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; -} - -// ConsensusStateWithHeight defines a consensus state with an additional height field. -message ConsensusStateWithHeight { - // consensus state height - Height height = 1 [(gogoproto.nullable) = false]; - // consensus state - google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml\"consensus_state\""]; -} - -// ClientConsensusStates defines all the stored consensus states for a given -// client. -message ClientConsensusStates { - // client identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // consensus states and their heights associated with the client - repeated ConsensusStateWithHeight consensus_states = 2 - [(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false]; -} - -// ClientUpdateProposal is a governance proposal. If it passes, the client is -// updated with the provided header. The update may fail if the header is not -// valid given certain conditions specified by the client implementation. -message ClientUpdateProposal { - option (gogoproto.goproto_getters) = false; - // the title of the update proposal - string title = 1; - // the description of the proposal - string description = 2; - // the client identifier for the client to be updated if the proposal passes - string client_id = 3 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // the header used to update the client if the proposal passes - google.protobuf.Any header = 4; -} - -// Height is a monotonically increasing data type -// that can be compared against another Height for the purposes of updating and -// freezing clients -// -// Normally the RevisionHeight is incremented at each height while keeping RevisionNumber -// the same. However some consensus algorithms may choose to reset the -// height in certain conditions e.g. hard forks, state-machine breaking changes -// In these cases, the RevisionNumber is incremented so that height continues to -// be monitonically increasing even as the RevisionHeight gets reset -message Height { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - // the revision that the client is currently on - uint64 revision_number = 1 [(gogoproto.moretags) = "yaml:\"revision_number\""]; - // the height within the given revision - uint64 revision_height = 2 [(gogoproto.moretags) = "yaml:\"revision_height\""]; -} - -// Params defines the set of IBC light client parameters. -message Params { - // allowed_clients defines the list of allowed client state types. - repeated string allowed_clients = 1 [(gogoproto.moretags) = "yaml:\"allowed_clients\""]; -} diff --git a/third_party/proto/ibc/core/client/v1/genesis.proto b/third_party/proto/ibc/core/client/v1/genesis.proto deleted file mode 100644 index 16febbce..00000000 --- a/third_party/proto/ibc/core/client/v1/genesis.proto +++ /dev/null @@ -1,46 +0,0 @@ -syntax = "proto3"; -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; - -import "ibc/core/client/v1/client.proto"; -import "gogoproto/gogo.proto"; - -// GenesisState defines the ibc client submodule's genesis state. -message GenesisState { - // client states with their corresponding identifiers - repeated IdentifiedClientState clients = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; - // consensus states from each client - repeated ClientConsensusStates clients_consensus = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "ClientsConsensusStates", - (gogoproto.moretags) = "yaml:\"clients_consensus\"" - ]; - // metadata from each client - repeated IdentifiedGenesisMetadata clients_metadata = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"clients_metadata\""]; - Params params = 4 [(gogoproto.nullable) = false]; - // create localhost on initialization - bool create_localhost = 5 [(gogoproto.moretags) = "yaml:\"create_localhost\""]; - // the sequence for the next generated client identifier - uint64 next_client_sequence = 6 [(gogoproto.moretags) = "yaml:\"next_client_sequence\""]; -} - -// GenesisMetadata defines the genesis type for metadata that clients may return -// with ExportMetadata -message GenesisMetadata { - option (gogoproto.goproto_getters) = false; - - // store key of metadata without clientID-prefix - bytes key = 1; - // metadata value - bytes value = 2; -} - -// IdentifiedGenesisMetadata has the client metadata with the corresponding client id. -message IdentifiedGenesisMetadata { - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - repeated GenesisMetadata client_metadata = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_metadata\""]; -} \ No newline at end of file diff --git a/third_party/proto/ibc/core/client/v1/query.proto b/third_party/proto/ibc/core/client/v1/query.proto deleted file mode 100644 index 97f3acd6..00000000 --- a/third_party/proto/ibc/core/client/v1/query.proto +++ /dev/null @@ -1,130 +0,0 @@ -syntax = "proto3"; -package ibc.core.client.v1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "ibc/core/client/v1/client.proto"; -import "google/protobuf/any.proto"; -import "google/api/annotations.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; - -// Query provides defines the gRPC querier service -service Query { - // ClientState queries an IBC light client. - rpc ClientState(QueryClientStateRequest) returns (QueryClientStateResponse) { - option (google.api.http).get = "/ibc/core/client/v1beta1/client_states/{client_id}"; - } - - // ClientStates queries all the IBC light clients of a chain. - rpc ClientStates(QueryClientStatesRequest) returns (QueryClientStatesResponse) { - option (google.api.http).get = "/ibc/core/client/v1beta1/client_states"; - } - - // ConsensusState queries a consensus state associated with a client state at - // a given height. - rpc ConsensusState(QueryConsensusStateRequest) returns (QueryConsensusStateResponse) { - option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/" - "height/{revision_height}"; - } - - // ConsensusStates queries all the consensus state associated with a given - // client. - rpc ConsensusStates(QueryConsensusStatesRequest) returns (QueryConsensusStatesResponse) { - option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}"; - } - - // ClientParams queries all parameters of the ibc client. - rpc ClientParams(QueryClientParamsRequest) returns (QueryClientParamsResponse) { - option (google.api.http).get = "/ibc/client/v1beta1/params"; - } -} - -// QueryClientStateRequest is the request type for the Query/ClientState RPC -// method -message QueryClientStateRequest { - // client state unique identifier - string client_id = 1; -} - -// QueryClientStateResponse is the response type for the Query/ClientState RPC -// method. Besides the client state, it includes a proof and the height from -// which the proof was retrieved. -message QueryClientStateResponse { - // client state associated with the request identifier - google.protobuf.Any client_state = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryClientStatesRequest is the request type for the Query/ClientStates RPC -// method -message QueryClientStatesRequest { - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryClientStatesResponse is the response type for the Query/ClientStates RPC -// method. -message QueryClientStatesResponse { - // list of stored ClientStates of the chain. - repeated IdentifiedClientState client_states = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryConsensusStateRequest is the request type for the Query/ConsensusState -// RPC method. Besides the consensus state, it includes a proof and the height -// from which the proof was retrieved. -message QueryConsensusStateRequest { - // client identifier - string client_id = 1; - // consensus state revision number - uint64 revision_number = 2; - // consensus state revision height - uint64 revision_height = 3; - // latest_height overrrides the height field and queries the latest stored - // ConsensusState - bool latest_height = 4; -} - -// QueryConsensusStateResponse is the response type for the Query/ConsensusState -// RPC method -message QueryConsensusStateResponse { - // consensus state associated with the client identifier at the given height - google.protobuf.Any consensus_state = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryConsensusStatesRequest is the request type for the Query/ConsensusStates -// RPC method. -message QueryConsensusStatesRequest { - // client identifier - string client_id = 1; - // pagination request - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryConsensusStatesResponse is the response type for the -// Query/ConsensusStates RPC method -message QueryConsensusStatesResponse { - // consensus states associated with the identifier - repeated ConsensusStateWithHeight consensus_states = 1 [(gogoproto.nullable) = false]; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. -message QueryClientParamsRequest {} - -// QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. -message QueryClientParamsResponse { - // params defines the parameters of the module. - Params params = 1; -} diff --git a/third_party/proto/ibc/core/client/v1/tx.proto b/third_party/proto/ibc/core/client/v1/tx.proto deleted file mode 100644 index a30ec8bb..00000000 --- a/third_party/proto/ibc/core/client/v1/tx.proto +++ /dev/null @@ -1,96 +0,0 @@ -syntax = "proto3"; -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "ibc/core/client/v1/client.proto"; - -// Msg defines the ibc/client Msg service. -service Msg { - // CreateClient defines a rpc handler method for MsgCreateClient. - rpc CreateClient(MsgCreateClient) returns (MsgCreateClientResponse); - - // UpdateClient defines a rpc handler method for MsgUpdateClient. - rpc UpdateClient(MsgUpdateClient) returns (MsgUpdateClientResponse); - - // UpgradeClient defines a rpc handler method for MsgUpgradeClient. - rpc UpgradeClient(MsgUpgradeClient) returns (MsgUpgradeClientResponse); - - // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. - rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse); -} - -// MsgCreateClient defines a message to create an IBC client -message MsgCreateClient { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // light client state - google.protobuf.Any client_state = 1 [(gogoproto.moretags) = "yaml:\"client_state\""]; - // consensus state associated with the client that corresponds to a given - // height. - google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; - // signer address - string signer = 3; -} - -// MsgCreateClientResponse defines the Msg/CreateClient response type. -message MsgCreateClientResponse {} - -// MsgUpdateClient defines an sdk.Msg to update a IBC client state using -// the given header. -message MsgUpdateClient { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // header to update the light client - google.protobuf.Any header = 2; - // signer address - string signer = 3; -} - -// MsgUpdateClientResponse defines the Msg/UpdateClient response type. -message MsgUpdateClientResponse {} - -// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state -message MsgUpgradeClient { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // upgraded client state - google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; - // upgraded consensus state, only contains enough information to serve as a basis of trust in update logic - google.protobuf.Any consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; - // proof that old chain committed to new client - bytes proof_upgrade_client = 4 [(gogoproto.moretags) = "yaml:\"proof_upgrade_client\""]; - // proof that old chain committed to new consensus state - bytes proof_upgrade_consensus_state = 5 [(gogoproto.moretags) = "yaml:\"proof_upgrade_consensus_state\""]; - // signer address - string signer = 6; -} - -// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. -message MsgUpgradeClientResponse {} - -// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for -// light client misbehaviour. -message MsgSubmitMisbehaviour { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // misbehaviour used for freezing the light client - google.protobuf.Any misbehaviour = 2; - // signer address - string signer = 3; -} - -// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. -message MsgSubmitMisbehaviourResponse {} diff --git a/third_party/proto/ibc/core/commitment/v1/commitment.proto b/third_party/proto/ibc/core/commitment/v1/commitment.proto deleted file mode 100644 index 51c10273..00000000 --- a/third_party/proto/ibc/core/commitment/v1/commitment.proto +++ /dev/null @@ -1,40 +0,0 @@ -syntax = "proto3"; -package ibc.core.commitment.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"; - -import "gogoproto/gogo.proto"; -import "confio/proofs.proto"; - -// MerkleRoot defines a merkle root hash. -// In the Cosmos SDK, the AppHash of a block header becomes the root. -message MerkleRoot { - option (gogoproto.goproto_getters) = false; - - bytes hash = 1; -} - -// MerklePrefix is merkle path prefixed to the key. -// The constructed key from the Path and the key will be append(Path.KeyPath, -// append(Path.KeyPrefix, key...)) -message MerklePrefix { - bytes key_prefix = 1 [(gogoproto.moretags) = "yaml:\"key_prefix\""]; -} - -// MerklePath is the path used to verify commitment proofs, which can be an -// arbitrary structured object (defined by a commitment type). -// MerklePath is represented from root-to-leaf -message MerklePath { - option (gogoproto.goproto_stringer) = false; - - repeated string key_path = 1 [(gogoproto.moretags) = "yaml:\"key_path\""]; -} - -// MerkleProof is a wrapper type over a chain of CommitmentProofs. -// It demonstrates membership or non-membership for an element or set of -// elements, verifiable in conjunction with a known commitment root. Proofs -// should be succinct. -// MerkleProofs are ordered from leaf-to-root -message MerkleProof { - repeated ics23.CommitmentProof proofs = 1; -} \ No newline at end of file diff --git a/third_party/proto/ibc/core/connection/v1/connection.proto b/third_party/proto/ibc/core/connection/v1/connection.proto deleted file mode 100644 index d21e5951..00000000 --- a/third_party/proto/ibc/core/connection/v1/connection.proto +++ /dev/null @@ -1,104 +0,0 @@ -syntax = "proto3"; -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/commitment/v1/commitment.proto"; - -// ICS03 - Connection Data Structures as defined in -// https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#data-structures - -// ConnectionEnd defines a stateful object on a chain connected to another -// separate one. -// NOTE: there must only be 2 defined ConnectionEnds to establish -// a connection between two chains. -message ConnectionEnd { - option (gogoproto.goproto_getters) = false; - // client associated with this connection. - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // IBC version which can be utilised to determine encodings or protocols for - // channels or packets utilising this connection. - repeated Version versions = 2; - // current state of the connection end. - State state = 3; - // counterparty chain associated with this connection. - Counterparty counterparty = 4 [(gogoproto.nullable) = false]; - // delay period that must pass before a consensus state can be used for packet-verification - // NOTE: delay period logic is only implemented by some clients. - uint64 delay_period = 5 [(gogoproto.moretags) = "yaml:\"delay_period\""]; -} - -// IdentifiedConnection defines a connection with additional connection -// identifier field. -message IdentifiedConnection { - option (gogoproto.goproto_getters) = false; - // connection identifier. - string id = 1 [(gogoproto.moretags) = "yaml:\"id\""]; - // client associated with this connection. - string client_id = 2 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // IBC version which can be utilised to determine encodings or protocols for - // channels or packets utilising this connection - repeated Version versions = 3; - // current state of the connection end. - State state = 4; - // counterparty chain associated with this connection. - Counterparty counterparty = 5 [(gogoproto.nullable) = false]; - // delay period associated with this connection. - uint64 delay_period = 6 [(gogoproto.moretags) = "yaml:\"delay_period\""]; -} - -// State defines if a connection is in one of the following states: -// INIT, TRYOPEN, OPEN or UNINITIALIZED. -enum State { - option (gogoproto.goproto_enum_prefix) = false; - - // Default State - STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"]; - // A connection end has just started the opening handshake. - STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"]; - // A connection end has acknowledged the handshake step on the counterparty - // chain. - STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"]; - // A connection end has completed the handshake. - STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"]; -} - -// Counterparty defines the counterparty chain associated with a connection end. -message Counterparty { - option (gogoproto.goproto_getters) = false; - - // identifies the client on the counterparty chain associated with a given - // connection. - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // identifies the connection end on the counterparty chain associated with a - // given connection. - string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - // commitment merkle prefix of the counterparty chain. - ibc.core.commitment.v1.MerklePrefix prefix = 3 [(gogoproto.nullable) = false]; -} - -// ClientPaths define all the connection paths for a client state. -message ClientPaths { - // list of connection paths - repeated string paths = 1; -} - -// ConnectionPaths define all the connection paths for a given client state. -message ConnectionPaths { - // client state unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // list of connection paths - repeated string paths = 2; -} - -// Version defines the versioning scheme used to negotiate the IBC verison in -// the connection handshake. -message Version { - option (gogoproto.goproto_getters) = false; - - // unique version identifier - string identifier = 1; - // list of features compatible with the specified identifier - repeated string features = 2; -} diff --git a/third_party/proto/ibc/core/connection/v1/genesis.proto b/third_party/proto/ibc/core/connection/v1/genesis.proto deleted file mode 100644 index 11df4ba1..00000000 --- a/third_party/proto/ibc/core/connection/v1/genesis.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/connection/v1/connection.proto"; - -// GenesisState defines the ibc connection submodule's genesis state. -message GenesisState { - repeated IdentifiedConnection connections = 1 [(gogoproto.nullable) = false]; - repeated ConnectionPaths client_connection_paths = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_connection_paths\""]; - // the sequence for the next generated connection identifier - uint64 next_connection_sequence = 3 [(gogoproto.moretags) = "yaml:\"next_connection_sequence\""]; -} diff --git a/third_party/proto/ibc/core/connection/v1/query.proto b/third_party/proto/ibc/core/connection/v1/query.proto deleted file mode 100644 index c5085a13..00000000 --- a/third_party/proto/ibc/core/connection/v1/query.proto +++ /dev/null @@ -1,137 +0,0 @@ -syntax = "proto3"; -package ibc.core.connection.v1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "ibc/core/client/v1/client.proto"; -import "ibc/core/connection/v1/connection.proto"; -import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; - -// Query provides defines the gRPC querier service -service Query { - // Connection queries an IBC connection end. - rpc Connection(QueryConnectionRequest) returns (QueryConnectionResponse) { - option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}"; - } - - // Connections queries all the IBC connections of a chain. - rpc Connections(QueryConnectionsRequest) returns (QueryConnectionsResponse) { - option (google.api.http).get = "/ibc/core/connection/v1beta1/connections"; - } - - // ClientConnections queries the connection paths associated with a client - // state. - rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) { - option (google.api.http).get = "/ibc/core/connection/v1beta1/client_connections/{client_id}"; - } - - // ConnectionClientState queries the client state associated with the - // connection. - rpc ConnectionClientState(QueryConnectionClientStateRequest) returns (QueryConnectionClientStateResponse) { - option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/client_state"; - } - - // ConnectionConsensusState queries the consensus state associated with the - // connection. - rpc ConnectionConsensusState(QueryConnectionConsensusStateRequest) returns (QueryConnectionConsensusStateResponse) { - option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/consensus_state/" - "revision/{revision_number}/height/{revision_height}"; - } -} - -// QueryConnectionRequest is the request type for the Query/Connection RPC -// method -message QueryConnectionRequest { - // connection unique identifier - string connection_id = 1; -} - -// QueryConnectionResponse is the response type for the Query/Connection RPC -// method. Besides the connection end, it includes a proof and the height from -// which the proof was retrieved. -message QueryConnectionResponse { - // connection associated with the request identifier - ibc.core.connection.v1.ConnectionEnd connection = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryConnectionsRequest is the request type for the Query/Connections RPC -// method -message QueryConnectionsRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryConnectionsResponse is the response type for the Query/Connections RPC -// method. -message QueryConnectionsResponse { - // list of stored connections of the chain. - repeated ibc.core.connection.v1.IdentifiedConnection connections = 1; - // pagination response - cosmos.base.query.v1beta1.PageResponse pagination = 2; - // query block height - ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; -} - -// QueryClientConnectionsRequest is the request type for the -// Query/ClientConnections RPC method -message QueryClientConnectionsRequest { - // client identifier associated with a connection - string client_id = 1; -} - -// QueryClientConnectionsResponse is the response type for the -// Query/ClientConnections RPC method -message QueryClientConnectionsResponse { - // slice of all the connection paths associated with a client. - repeated string connection_paths = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was generated - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryConnectionClientStateRequest is the request type for the -// Query/ConnectionClientState RPC method -message QueryConnectionClientStateRequest { - // connection identifier - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; -} - -// QueryConnectionClientStateResponse is the response type for the -// Query/ConnectionClientState RPC method -message QueryConnectionClientStateResponse { - // client state associated with the channel - ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; - // merkle proof of existence - bytes proof = 2; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; -} - -// QueryConnectionConsensusStateRequest is the request type for the -// Query/ConnectionConsensusState RPC method -message QueryConnectionConsensusStateRequest { - // connection identifier - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - uint64 revision_number = 2; - uint64 revision_height = 3; -} - -// QueryConnectionConsensusStateResponse is the response type for the -// Query/ConnectionConsensusState RPC method -message QueryConnectionConsensusStateResponse { - // consensus state associated with the channel - google.protobuf.Any consensus_state = 1; - // client ID associated with the consensus state - string client_id = 2; - // merkle proof of existence - bytes proof = 3; - // height at which the proof was retrieved - ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/ibc/core/connection/v1/tx.proto b/third_party/proto/ibc/core/connection/v1/tx.proto deleted file mode 100644 index 19b40c69..00000000 --- a/third_party/proto/ibc/core/connection/v1/tx.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto3"; -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "ibc/core/client/v1/client.proto"; -import "ibc/core/connection/v1/connection.proto"; - -// Msg defines the ibc/connection Msg service. -service Msg { - // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. - rpc ConnectionOpenInit(MsgConnectionOpenInit) returns (MsgConnectionOpenInitResponse); - - // ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. - rpc ConnectionOpenTry(MsgConnectionOpenTry) returns (MsgConnectionOpenTryResponse); - - // ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. - rpc ConnectionOpenAck(MsgConnectionOpenAck) returns (MsgConnectionOpenAckResponse); - - // ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. - rpc ConnectionOpenConfirm(MsgConnectionOpenConfirm) returns (MsgConnectionOpenConfirmResponse); -} - -// MsgConnectionOpenInit defines the msg sent by an account on Chain A to -// initialize a connection with Chain B. -message MsgConnectionOpenInit { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - Counterparty counterparty = 2 [(gogoproto.nullable) = false]; - Version version = 3; - uint64 delay_period = 4 [(gogoproto.moretags) = "yaml:\"delay_period\""]; - string signer = 5; -} - -// MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. -message MsgConnectionOpenInitResponse {} - -// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a -// connection on Chain B. -message MsgConnectionOpenTry { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // in the case of crossing hello's, when both chains call OpenInit, we need the connection identifier - // of the previous connection in state INIT - string previous_connection_id = 2 [(gogoproto.moretags) = "yaml:\"previous_connection_id\""]; - google.protobuf.Any client_state = 3 [(gogoproto.moretags) = "yaml:\"client_state\""]; - Counterparty counterparty = 4 [(gogoproto.nullable) = false]; - uint64 delay_period = 5 [(gogoproto.moretags) = "yaml:\"delay_period\""]; - repeated Version counterparty_versions = 6 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; - ibc.core.client.v1.Height proof_height = 7 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - // proof of the initialization the connection on Chain A: `UNITIALIZED -> - // INIT` - bytes proof_init = 8 [(gogoproto.moretags) = "yaml:\"proof_init\""]; - // proof of client state included in message - bytes proof_client = 9 [(gogoproto.moretags) = "yaml:\"proof_client\""]; - // proof of client consensus state - bytes proof_consensus = 10 [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; - ibc.core.client.v1.Height consensus_height = 11 - [(gogoproto.moretags) = "yaml:\"consensus_height\"", (gogoproto.nullable) = false]; - string signer = 12; -} - -// MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. -message MsgConnectionOpenTryResponse {} - -// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to -// acknowledge the change of connection state to TRYOPEN on Chain B. -message MsgConnectionOpenAck { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - string counterparty_connection_id = 2 [(gogoproto.moretags) = "yaml:\"counterparty_connection_id\""]; - Version version = 3; - google.protobuf.Any client_state = 4 [(gogoproto.moretags) = "yaml:\"client_state\""]; - ibc.core.client.v1.Height proof_height = 5 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - // proof of the initialization the connection on Chain B: `UNITIALIZED -> - // TRYOPEN` - bytes proof_try = 6 [(gogoproto.moretags) = "yaml:\"proof_try\""]; - // proof of client state included in message - bytes proof_client = 7 [(gogoproto.moretags) = "yaml:\"proof_client\""]; - // proof of client consensus state - bytes proof_consensus = 8 [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; - ibc.core.client.v1.Height consensus_height = 9 - [(gogoproto.moretags) = "yaml:\"consensus_height\"", (gogoproto.nullable) = false]; - string signer = 10; -} - -// MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. -message MsgConnectionOpenAckResponse {} - -// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to -// acknowledge the change of connection state to OPEN on Chain A. -message MsgConnectionOpenConfirm { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - // proof for the change of the connection state on Chain A: `INIT -> OPEN` - bytes proof_ack = 2 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; - ibc.core.client.v1.Height proof_height = 3 - [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; - string signer = 4; -} - -// MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm response type. -message MsgConnectionOpenConfirmResponse {} diff --git a/third_party/proto/ibc/core/types/v1/genesis.proto b/third_party/proto/ibc/core/types/v1/genesis.proto deleted file mode 100644 index ace50859..00000000 --- a/third_party/proto/ibc/core/types/v1/genesis.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; -package ibc.core.types.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/genesis.proto"; -import "ibc/core/connection/v1/genesis.proto"; -import "ibc/core/channel/v1/genesis.proto"; - -// GenesisState defines the ibc module's genesis state. -message GenesisState { - // ICS002 - Clients genesis state - ibc.core.client.v1.GenesisState client_genesis = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_genesis\""]; - // ICS003 - Connections genesis state - ibc.core.connection.v1.GenesisState connection_genesis = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"connection_genesis\""]; - // ICS004 - Channel genesis state - ibc.core.channel.v1.GenesisState channel_genesis = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"channel_genesis\""]; -} diff --git a/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto b/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto deleted file mode 100644 index d48a1c00..00000000 --- a/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package ibc.lightclients.localhost.v1; - -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/client.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/09-localhost/types"; - -// ClientState defines a loopback (localhost) client. It requires (read-only) -// access to keys outside the client prefix. -message ClientState { - option (gogoproto.goproto_getters) = false; - // self chain ID - string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""]; - // self latest block height - ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto deleted file mode 100644 index 89686f3b..00000000 --- a/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ /dev/null @@ -1,186 +0,0 @@ -syntax = "proto3"; -package ibc.lightclients.solomachine.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types"; - -import "ibc/core/connection/v1/connection.proto"; -import "ibc/core/channel/v1/channel.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; - -// ClientState defines a solo machine client that tracks the current consensus -// state and if the client is frozen. -message ClientState { - option (gogoproto.goproto_getters) = false; - // latest sequence of the client state - uint64 sequence = 1; - // frozen sequence of the solo machine - uint64 frozen_sequence = 2 [(gogoproto.moretags) = "yaml:\"frozen_sequence\""]; - ConsensusState consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; - // when set to true, will allow governance to update a solo machine client. - // The client will be unfrozen if it is frozen. - bool allow_update_after_proposal = 4 [(gogoproto.moretags) = "yaml:\"allow_update_after_proposal\""]; -} - -// ConsensusState defines a solo machine consensus state. The sequence of a consensus state -// is contained in the "height" key used in storing the consensus state. -message ConsensusState { - option (gogoproto.goproto_getters) = false; - // public key of the solo machine - google.protobuf.Any public_key = 1 [(gogoproto.moretags) = "yaml:\"public_key\""]; - // diversifier allows the same public key to be re-used across different solo machine clients - // (potentially on different chains) without being considered misbehaviour. - string diversifier = 2; - uint64 timestamp = 3; -} - -// Header defines a solo machine consensus header -message Header { - option (gogoproto.goproto_getters) = false; - // sequence to update solo machine public key at - uint64 sequence = 1; - uint64 timestamp = 2; - bytes signature = 3; - google.protobuf.Any new_public_key = 4 [(gogoproto.moretags) = "yaml:\"new_public_key\""]; - string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; -} - -// Misbehaviour defines misbehaviour for a solo machine which consists -// of a sequence and two signatures over different messages at that sequence. -message Misbehaviour { - option (gogoproto.goproto_getters) = false; - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - uint64 sequence = 2; - SignatureAndData signature_one = 3 [(gogoproto.moretags) = "yaml:\"signature_one\""]; - SignatureAndData signature_two = 4 [(gogoproto.moretags) = "yaml:\"signature_two\""]; -} - -// SignatureAndData contains a signature and the data signed over to create that -// signature. -message SignatureAndData { - option (gogoproto.goproto_getters) = false; - bytes signature = 1; - DataType data_type = 2 [(gogoproto.moretags) = "yaml:\"data_type\""]; - bytes data = 3; - uint64 timestamp = 4; -} - -// TimestampedSignatureData contains the signature data and the timestamp of the -// signature. -message TimestampedSignatureData { - option (gogoproto.goproto_getters) = false; - bytes signature_data = 1 [(gogoproto.moretags) = "yaml:\"signature_data\""]; - uint64 timestamp = 2; -} - -// SignBytes defines the signed bytes used for signature verification. -message SignBytes { - option (gogoproto.goproto_getters) = false; - - uint64 sequence = 1; - uint64 timestamp = 2; - string diversifier = 3; - // type of the data used - DataType data_type = 4 [(gogoproto.moretags) = "yaml:\"data_type\""]; - // marshaled data - bytes data = 5; -} - -// DataType defines the type of solo machine proof being created. This is done to preserve uniqueness of different -// data sign byte encodings. -enum DataType { - option (gogoproto.goproto_enum_prefix) = false; - - // Default State - DATA_TYPE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; - // Data type for client state verification - DATA_TYPE_CLIENT_STATE = 1 [(gogoproto.enumvalue_customname) = "CLIENT"]; - // Data type for consensus state verification - DATA_TYPE_CONSENSUS_STATE = 2 [(gogoproto.enumvalue_customname) = "CONSENSUS"]; - // Data type for connection state verification - DATA_TYPE_CONNECTION_STATE = 3 [(gogoproto.enumvalue_customname) = "CONNECTION"]; - // Data type for channel state verification - DATA_TYPE_CHANNEL_STATE = 4 [(gogoproto.enumvalue_customname) = "CHANNEL"]; - // Data type for packet commitment verification - DATA_TYPE_PACKET_COMMITMENT = 5 [(gogoproto.enumvalue_customname) = "PACKETCOMMITMENT"]; - // Data type for packet acknowledgement verification - DATA_TYPE_PACKET_ACKNOWLEDGEMENT = 6 [(gogoproto.enumvalue_customname) = "PACKETACKNOWLEDGEMENT"]; - // Data type for packet receipt absence verification - DATA_TYPE_PACKET_RECEIPT_ABSENCE = 7 [(gogoproto.enumvalue_customname) = "PACKETRECEIPTABSENCE"]; - // Data type for next sequence recv verification - DATA_TYPE_NEXT_SEQUENCE_RECV = 8 [(gogoproto.enumvalue_customname) = "NEXTSEQUENCERECV"]; - // Data type for header verification - DATA_TYPE_HEADER = 9 [(gogoproto.enumvalue_customname) = "HEADER"]; -} - -// HeaderData returns the SignBytes data for update verification. -message HeaderData { - option (gogoproto.goproto_getters) = false; - - // header public key - google.protobuf.Any new_pub_key = 1 [(gogoproto.moretags) = "yaml:\"new_pub_key\""]; - // header diversifier - string new_diversifier = 2 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; -} - -// ClientStateData returns the SignBytes data for client state verification. -message ClientStateData { - option (gogoproto.goproto_getters) = false; - - bytes path = 1; - google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; -} - -// ConsensusStateData returns the SignBytes data for consensus state -// verification. -message ConsensusStateData { - option (gogoproto.goproto_getters) = false; - - bytes path = 1; - google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; -} - -// ConnectionStateData returns the SignBytes data for connection state -// verification. -message ConnectionStateData { - option (gogoproto.goproto_getters) = false; - - bytes path = 1; - ibc.core.connection.v1.ConnectionEnd connection = 2; -} - -// ChannelStateData returns the SignBytes data for channel state -// verification. -message ChannelStateData { - option (gogoproto.goproto_getters) = false; - - bytes path = 1; - ibc.core.channel.v1.Channel channel = 2; -} - -// PacketCommitmentData returns the SignBytes data for packet commitment -// verification. -message PacketCommitmentData { - bytes path = 1; - bytes commitment = 2; -} - -// PacketAcknowledgementData returns the SignBytes data for acknowledgement -// verification. -message PacketAcknowledgementData { - bytes path = 1; - bytes acknowledgement = 2; -} - -// PacketReceiptAbsenceData returns the SignBytes data for -// packet receipt absence verification. -message PacketReceiptAbsenceData { - bytes path = 1; -} - -// NextSequenceRecvData returns the SignBytes data for verification of the next -// sequence to be received. -message NextSequenceRecvData { - bytes path = 1; - uint64 next_seq_recv = 2 [(gogoproto.moretags) = "yaml:\"next_seq_recv\""]; -} diff --git a/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto b/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto deleted file mode 100644 index a6882bf4..00000000 --- a/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto +++ /dev/null @@ -1,111 +0,0 @@ -syntax = "proto3"; -package ibc.lightclients.tendermint.v1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"; - -import "tendermint/types/validator.proto"; -import "tendermint/types/types.proto"; -import "confio/proofs.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "ibc/core/client/v1/client.proto"; -import "ibc/core/commitment/v1/commitment.proto"; -import "gogoproto/gogo.proto"; - -// ClientState from Tendermint tracks the current validator set, latest height, -// and a possible frozen height. -message ClientState { - option (gogoproto.goproto_getters) = false; - - string chain_id = 1; - Fraction trust_level = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"trust_level\""]; - // duration of the period since the LastestTimestamp during which the - // submitted headers are valid for upgrade - google.protobuf.Duration trusting_period = 3 - [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"trusting_period\""]; - // duration of the staking unbonding period - google.protobuf.Duration unbonding_period = 4 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.moretags) = "yaml:\"unbonding_period\"" - ]; - // defines how much new (untrusted) header's Time can drift into the future. - google.protobuf.Duration max_clock_drift = 5 - [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"max_clock_drift\""]; - // Block height when the client was frozen due to a misbehaviour - ibc.core.client.v1.Height frozen_height = 6 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"frozen_height\""]; - // Latest height the client was updated to - ibc.core.client.v1.Height latest_height = 7 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"latest_height\""]; - - // Proof specifications used in verifying counterparty state - repeated ics23.ProofSpec proof_specs = 8 [(gogoproto.moretags) = "yaml:\"proof_specs\""]; - - // Path at which next upgraded client will be committed. - // Each element corresponds to the key for a single CommitmentProof in the chained proof. - // NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` - // ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` - // For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` - repeated string upgrade_path = 9 [(gogoproto.moretags) = "yaml:\"upgrade_path\""]; - - // This flag, when set to true, will allow governance to recover a client - // which has expired - bool allow_update_after_expiry = 10 [(gogoproto.moretags) = "yaml:\"allow_update_after_expiry\""]; - // This flag, when set to true, will allow governance to unfreeze a client - // whose chain has experienced a misbehaviour event - bool allow_update_after_misbehaviour = 11 [(gogoproto.moretags) = "yaml:\"allow_update_after_misbehaviour\""]; -} - -// ConsensusState defines the consensus state from Tendermint. -message ConsensusState { - option (gogoproto.goproto_getters) = false; - - // timestamp that corresponds to the block height in which the ConsensusState - // was stored. - google.protobuf.Timestamp timestamp = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - // commitment root (i.e app hash) - ibc.core.commitment.v1.MerkleRoot root = 2 [(gogoproto.nullable) = false]; - bytes next_validators_hash = 3 [ - (gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes", - (gogoproto.moretags) = "yaml:\"next_validators_hash\"" - ]; -} - -// Misbehaviour is a wrapper over two conflicting Headers -// that implements Misbehaviour interface expected by ICS-02 -message Misbehaviour { - option (gogoproto.goproto_getters) = false; - - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - Header header_1 = 2 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; - Header header_2 = 3 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; -} - -// Header defines the Tendermint client consensus Header. -// It encapsulates all the information necessary to update from a trusted -// Tendermint ConsensusState. The inclusion of TrustedHeight and -// TrustedValidators allows this update to process correctly, so long as the -// ConsensusState for the TrustedHeight exists, this removes race conditions -// among relayers The SignedHeader and ValidatorSet are the new untrusted update -// fields for the client. The TrustedHeight is the height of a stored -// ConsensusState on the client that will be used to verify the new untrusted -// header. The Trusted ConsensusState must be within the unbonding period of -// current time in order to correctly verify, and the TrustedValidators must -// hash to TrustedConsensusState.NextValidatorsHash since that is the last -// trusted validator set at the TrustedHeight. -message Header { - .tendermint.types.SignedHeader signed_header = 1 - [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"signed_header\""]; - - .tendermint.types.ValidatorSet validator_set = 2 [(gogoproto.moretags) = "yaml:\"validator_set\""]; - ibc.core.client.v1.Height trusted_height = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"trusted_height\""]; - .tendermint.types.ValidatorSet trusted_validators = 4 [(gogoproto.moretags) = "yaml:\"trusted_validators\""]; -} - -// Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. -message Fraction { - uint64 numerator = 1; - uint64 denominator = 2; -} diff --git a/x/wasm/README.md b/x/wasm/README.md index ad5fb1f5..cba9c5cf 100644 --- a/x/wasm/README.md +++ b/x/wasm/README.md @@ -53,7 +53,7 @@ was sent: }, { "key": "_contract_address", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" } ] } @@ -70,7 +70,7 @@ provide a initial balance in the same `MsgInstantiateContract`. We see the follo "Attr": [ { "key": "recipient", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" }, { "key": "sender", @@ -97,7 +97,7 @@ Here is an example from the escrow contract successfully releasing funds to the "Attr": [ { "key": "_contract_address", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" }, { "key": "action", @@ -131,7 +131,7 @@ was executed (which always appears, while 2 is optional and has information as r "Attr": [ { "key": "recipient", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" }, { "key": "sender", @@ -148,7 +148,7 @@ was executed (which always appears, while 2 is optional and has information as r "Attr": [ { "key": "_contract_address", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" }, { "key": "action", @@ -169,7 +169,7 @@ was executed (which always appears, while 2 is optional and has information as r }, { "key": "sender", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" }, { "key": "amount", @@ -194,7 +194,7 @@ was executed (which always appears, while 2 is optional and has information as r }, { "key": "_contract_address", - "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + "value": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" } ] } diff --git a/x/wasm/alias.go b/x/wasm/alias.go index db179228..610ce972 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -12,7 +12,6 @@ import ( const ( firstCodeID = 1 - DefaultParamspace = types.DefaultParamspace ModuleName = types.ModuleName StoreKey = types.StoreKey TStoreKey = types.TStoreKey diff --git a/x/wasm/client/cli/genesis_msg.go b/x/wasm/client/cli/genesis_msg.go index aa2090e9..1795db12 100644 --- a/x/wasm/client/cli/genesis_msg.go +++ b/x/wasm/client/cli/genesis_msg.go @@ -337,7 +337,7 @@ func hasAccountBalance(cmd *cobra.Command, appState map[string]json.RawMessage, if err != nil { return false, err } - cdc := clientCtx.JSONMarshaler + cdc := clientCtx.Codec var genBalIterator banktypes.GenesisBalancesIterator err = genutil.ValidateAccountInGenesis(appState, genBalIterator, sender, coins, cdc) if err != nil { @@ -392,7 +392,7 @@ func (d DefaultGenesisReader) ReadWasmGenesis(cmd *cobra.Command) (*GenesisData, var wasmGenesisState types.GenesisState if appState[types.ModuleName] != nil { clientCtx := client.GetClientContextFromCmd(cmd) - clientCtx.JSONMarshaler.MustUnmarshalJSON(appState[types.ModuleName], &wasmGenesisState) + clientCtx.Codec.MustUnmarshalJSON(appState[types.ModuleName], &wasmGenesisState) } return NewGenesisData( @@ -434,7 +434,7 @@ func (x DefaultGenesisIO) AlterWasmModuleState(cmd *cobra.Command, callback func return err } clientCtx := client.GetClientContextFromCmd(cmd) - wasmGenStateBz, err := clientCtx.JSONMarshaler.MarshalJSON(g.WasmModuleState) + wasmGenStateBz, err := clientCtx.Codec.MarshalJSON(g.WasmModuleState) if err != nil { return sdkerrors.Wrap(err, "marshal wasm genesis state") } diff --git a/x/wasm/client/cli/genesis_msg_test.go b/x/wasm/client/cli/genesis_msg_test.go index 57be9a30..b11572ee 100644 --- a/x/wasm/client/cli/genesis_msg_test.go +++ b/x/wasm/client/cli/genesis_msg_test.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/testutil" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -303,7 +304,7 @@ func TestInstantiateContractCmd(t *testing.T) { } func TestExecuteContractCmd(t *testing.T) { - const firstContractAddress = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + const firstContractAddress = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" minimalWasmGenesis := types.GenesisState{ Params: types.DefaultParams(), } @@ -385,7 +386,7 @@ func TestExecuteContractCmd(t *testing.T) { }, mutator: func(cmd *cobra.Command) { // See TestBuildContractAddress in keeper_test.go - cmd.SetArgs([]string{"cosmos1mujpjkwhut9yjw4xueyugc02evfv46y04aervg", `{}`}) + cmd.SetArgs([]string{"cosmos1mujpjkwhut9yjw4xueyugc02evfv46y0dtmnz4lh8xxkkdapym9stu5qm8", `{}`}) flagSet := cmd.Flags() flagSet.Set("run-as", myWellFundedAccount) }, @@ -638,7 +639,7 @@ func executeCmdWithContext(t *testing.T, homeDir string, cmd *cobra.Command) err require.NoError(t, err) appCodec := keeper.MakeEncodingConfig(t).Marshaler serverCtx := server.NewContext(viper.New(), cfg, logger) - clientCtx := client.Context{}.WithJSONMarshaler(appCodec).WithHomeDir(homeDir) + clientCtx := client.Context{}.WithCodec(appCodec).WithHomeDir(homeDir) ctx := context.Background() ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) @@ -650,7 +651,7 @@ func executeCmdWithContext(t *testing.T, homeDir string, cmd *cobra.Command) err mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, homeDir, mockIn) require.NoError(t, err) - _, err = kb.NewAccount(defaultTestKeyName, testutil.TestMnemonic, "", sdk.FullFundraiserPath, hd.Secp256k1) + _, err = kb.NewAccount(defaultTestKeyName, testdata.TestMnemonic, "", sdk.FullFundraiserPath, hd.Secp256k1) require.NoError(t, err) return cmd.ExecuteContext(ctx) } diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 9ab667d4..267342f7 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -413,15 +413,15 @@ func ProposalPinCodesCmd() *cobra.Command { } func parsePinCodesArgs(args []string) ([]uint64, error) { - var codeIds []uint64 - for _, c := range args { + codeIDs := make([]uint64, len(args)) + for i, c := range args { codeID, err := strconv.ParseUint(c, 10, 64) if err != nil { - return codeIds, fmt.Errorf("code IDs: %s", err) + return codeIDs, fmt.Errorf("code IDs: %s", err) } - codeIds = append(codeIds, codeID) + codeIDs[i] = codeID } - return codeIds, nil + return codeIDs, nil } func ProposalUnpinCodesCmd() *cobra.Command { diff --git a/x/wasm/client/codec/marshaller.go b/x/wasm/client/codec/marshaller.go index f76bcbcd..9f02a3f5 100644 --- a/x/wasm/client/codec/marshaller.go +++ b/x/wasm/client/codec/marshaller.go @@ -10,18 +10,18 @@ import ( "github.com/gogo/protobuf/proto" ) -var _ codec.Marshaler = (*ProtoCodec)(nil) +var _ codec.Codec = (*ProtoCodec)(nil) // ProtoCodec that omits empty values. // This Marshaler can be used globally when setting up the client context or individually // for each command via `clientCtx.WithJSONMarshaler(myMarshaler)`. type ProtoCodec struct { - codec.Marshaler + codec.Codec interfaceRegistry types.InterfaceRegistry } -func NewProtoCodec(marshaler codec.Marshaler, registry types.InterfaceRegistry) *ProtoCodec { - return &ProtoCodec{Marshaler: marshaler, interfaceRegistry: registry} +func NewProtoCodec(marshaler codec.Codec, registry types.InterfaceRegistry) *ProtoCodec { + return &ProtoCodec{Codec: marshaler, interfaceRegistry: registry} } // MarshalJSON implements JSONMarshaler.MarshalJSON method, diff --git a/x/wasm/client/proposal_handler_test.go b/x/wasm/client/proposal_handler_test.go index 4376bfbe..f433122d 100644 --- a/x/wasm/client/proposal_handler_test.go +++ b/x/wasm/client/proposal_handler_test.go @@ -33,7 +33,7 @@ func TestGovRestHandlers(t *testing.T) { ) encodingConfig := keeper.MakeEncodingConfig(t) clientCtx := client.Context{}. - WithJSONMarshaler(encodingConfig.Marshaler). + WithCodec(encodingConfig.Marshaler). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). @@ -173,7 +173,7 @@ func TestGovRestHandlers(t *testing.T) { "title": "Test Proposal", "description": "My proposal", "type": "migrate", - "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", + "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "code_id": "1", "msg": dict{"foo": "bar"}, "run_as": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz", @@ -189,7 +189,7 @@ func TestGovRestHandlers(t *testing.T) { "title": "Test Proposal", "description": "My proposal", "type": "migrate", - "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", + "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "new_admin": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz", "deposit": []dict{{"denom": "ustake", "amount": "10"}}, "proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np", @@ -203,7 +203,7 @@ func TestGovRestHandlers(t *testing.T) { "title": "Test Proposal", "description": "My proposal", "type": "migrate", - "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", + "contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "deposit": []dict{{"denom": "ustake", "amount": "10"}}, "proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np", "base_req": aBaseReq, diff --git a/x/wasm/genesis_test.go b/x/wasm/genesis_test.go index 0c82182b..ea97c97f 100644 --- a/x/wasm/genesis_test.go +++ b/x/wasm/genesis_test.go @@ -13,8 +13,8 @@ func TestInitGenesis(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, topUp) + creator := data.faucet.NewFundedAccount(data.ctx, deposit.Add(deposit...)...) + fred := data.faucet.NewFundedAccount(data.ctx, topUp...) h := data.module.Route().Handler() q := data.module.LegacyQuerierHandler(nil) diff --git a/x/wasm/ibc.go b/x/wasm/ibc.go index 184dfa2c..2e9e9b71 100644 --- a/x/wasm/ibc.go +++ b/x/wasm/ibc.go @@ -3,13 +3,15 @@ package wasm import ( "math" + ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" types "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -219,27 +221,42 @@ func toWasmVMChannel(portID, channelID string, channelInfo channeltypes.Channel) func (i IBCHandler) OnRecvPacket( ctx sdk.Context, packet channeltypes.Packet, -) (*sdk.Result, []byte, error) { + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { contractAddr, err := ContractFromPortID(packet.DestinationPort) if err != nil { - return nil, nil, sdkerrors.Wrapf(err, "contract port id") + return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(err, "contract port id").Error()) } msg := wasmvmtypes.IBCPacketReceiveMsg{Packet: newIBCPacket(packet)} ack, err := i.keeper.OnRecvPacket(ctx, contractAddr, msg) if err != nil { - return nil, nil, err + return channeltypes.NewErrorAcknowledgement(err.Error()) } + return ContractConfirmStateAck(ack) +} - return &sdk.Result{ // the response is ignored - Events: ctx.EventManager().Events().ToABCIEvents(), - }, ack, nil +var _ ibcexported.Acknowledgement = ContractConfirmStateAck{} + +type ContractConfirmStateAck []byte + +func (w ContractConfirmStateAck) Success() bool { + return true // always commit state +} + +func (w ContractConfirmStateAck) Acknowledgement() []byte { + return w } // OnAcknowledgementPacket implements the IBCModule interface -func (i IBCHandler) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte) (*sdk.Result, error) { +func (i IBCHandler) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { contractAddr, err := ContractFromPortID(packet.SourcePort) if err != nil { - return nil, sdkerrors.Wrapf(err, "contract port id") + return sdkerrors.Wrapf(err, "contract port id") } err = i.keeper.OnAckPacket(ctx, contractAddr, wasmvmtypes.IBCPacketAckMsg{ @@ -247,31 +264,34 @@ func (i IBCHandler) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes OriginalPacket: newIBCPacket(packet), }) if err != nil { - return nil, err + return sdkerrors.Wrap(err, "on ack") } - - return &sdk.Result{ - Events: ctx.EventManager().Events().ToABCIEvents(), - }, nil - + return nil } // OnTimeoutPacket implements the IBCModule interface -func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) (*sdk.Result, error) { +func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error { contractAddr, err := ContractFromPortID(packet.SourcePort) if err != nil { - return nil, sdkerrors.Wrapf(err, "contract port id") + return sdkerrors.Wrapf(err, "contract port id") } msg := wasmvmtypes.IBCPacketTimeoutMsg{Packet: newIBCPacket(packet)} err = i.keeper.OnTimeoutPacket(ctx, contractAddr, msg) if err != nil { - return nil, err + return sdkerrors.Wrap(err, "on timeout") } + return nil +} - return &sdk.Result{ - Events: ctx.EventManager().Events().ToABCIEvents(), - }, nil - +func (i IBCHandler) NegotiateAppVersion( + ctx sdk.Context, + order channeltypes.Order, + connectionID string, + portID string, + counterparty channeltypes.Counterparty, + proposedVersion string, +) (version string, err error) { + return proposedVersion, nil // accept all } func newIBCPacket(packet channeltypes.Packet) wasmvmtypes.IBCPacket { diff --git a/x/wasm/ibc_reflect_test.go b/x/wasm/ibc_reflect_test.go index e3b8e424..91a0647f 100644 --- a/x/wasm/ibc_reflect_test.go +++ b/x/wasm/ibc_reflect_test.go @@ -3,13 +3,15 @@ package wasm_test import ( "testing" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/stretchr/testify/assert" + + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v2/testing" + + wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/stretchr/testify/require" - "github.com/CosmWasm/wasmd/x/wasm/ibctesting" + wasmibctesting "github.com/CosmWasm/wasmd/x/wasm/ibctesting" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) @@ -22,9 +24,9 @@ func TestIBCReflectContract(t *testing.T) { // "ibc_reflect" sends a submessage to "reflect" which is returned as submessage. var ( - coordinator = ibctesting.NewCoordinator(t, 2, nil, nil) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) + coordinator = wasmibctesting.NewCoordinator(t, 2) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) coordinator.CommitBlock(chainA, chainB) @@ -43,11 +45,24 @@ func TestIBCReflectContract(t *testing.T) { sourcePortID = chainA.ContractInfo(sendContractAddr).IBCPortID counterpartPortID = chainB.ContractInfo(reflectContractAddr).IBCPortID ) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - connA.NextChannelVersion = "ibc-reflect-v1" - connB.NextChannelVersion = "ibc-reflect-v1" - // flip instantiation so that we do not run into https://github.com/cosmos/cosmos-sdk/issues/8334 - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.ORDERED) + coordinator.CommitBlock(chainA, chainB) + coordinator.UpdateTime() + + require.Equal(t, chainA.CurrentHeader.Time, chainB.CurrentHeader.Time) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: sourcePortID, + Version: "ibc-reflect-v1", + Order: channeltypes.ORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: counterpartPortID, + Version: "ibc-reflect-v1", + Order: channeltypes.ORDERED, + } + + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) // TODO: query both contracts directly to ensure they have registered the proper connection // (and the chainB has created a reflect contract) @@ -69,13 +84,13 @@ func TestIBCReflectContract(t *testing.T) { // ensure the expected packet was prepared, and relay it require.Equal(t, 1, len(chainA.PendingSendPackets)) require.Equal(t, 0, len(chainB.PendingSendPackets)) - err := coordinator.RelayAndAckPendingPackets(chainA, chainB, clientA, clientB) + err := coordinator.RelayAndAckPendingPackets(path) require.NoError(t, err) require.Equal(t, 0, len(chainA.PendingSendPackets)) require.Equal(t, 0, len(chainB.PendingSendPackets)) // let's query the source contract and make sure it registered an address - query := ReflectSendQueryMsg{Account: &AccountQuery{ChannelID: channelA.ID}} + query := ReflectSendQueryMsg{Account: &AccountQuery{ChannelID: path.EndpointA.ChannelID}} var account AccountResponse err = chainA.SmartQuery(sendContractAddr.String(), query, &account) require.NoError(t, err) @@ -83,15 +98,13 @@ func TestIBCReflectContract(t *testing.T) { require.Empty(t, account.RemoteBalance) // close channel - coordinator.CloseChannel(chainA, chainB, channelA, channelB) + coordinator.CloseChannel(path) // let's query the source contract and make sure it registered an address account = AccountResponse{} err = chainA.SmartQuery(sendContractAddr.String(), query, &account) require.Error(t, err) assert.Contains(t, err.Error(), "not found") - - _ = clientB } type ReflectSendQueryMsg struct { diff --git a/x/wasm/ibc_test.go b/x/wasm/ibc_test.go index ca66992e..7540b523 100644 --- a/x/wasm/ibc_test.go +++ b/x/wasm/ibc_test.go @@ -4,8 +4,8 @@ import ( "testing" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/stretchr/testify/assert" ) diff --git a/x/wasm/ibctesting/chain.go b/x/wasm/ibctesting/chain.go index 512df1ab..f7f468b3 100644 --- a/x/wasm/ibctesting/chain.go +++ b/x/wasm/ibctesting/chain.go @@ -3,24 +3,10 @@ package ibctesting import ( "bytes" "fmt" - "io/ioutil" - "os" - "strconv" - "strings" "testing" "time" - wasmd "github.com/CosmWasm/wasmd/app" - "github.com/CosmWasm/wasmd/x/wasm/keeper" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/tmhash" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmprotoversion "github.com/tendermint/tendermint/proto/tendermint/version" - tmtypes "github.com/tendermint/tendermint/types" - tmversion "github.com/tendermint/tendermint/version" - + "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" @@ -29,57 +15,31 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" 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" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" - "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/core/types" - ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" - ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" - "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/teststaking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v2/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" + "github.com/cosmos/ibc-go/v2/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper" + "github.com/cosmos/ibc-go/v2/modules/core/types" + ibctmtypes "github.com/cosmos/ibc-go/v2/modules/light-clients/07-tendermint/types" + ibctesting "github.com/cosmos/ibc-go/v2/testing" + "github.com/cosmos/ibc-go/v2/testing/mock" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto/tmhash" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmprotoversion "github.com/tendermint/tendermint/proto/tendermint/version" + tmtypes "github.com/tendermint/tendermint/types" + tmversion "github.com/tendermint/tendermint/version" -const ( - // Default params constants used to create a TM client - TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 - UnbondingPeriod time.Duration = time.Hour * 24 * 7 * 3 - MaxClockDrift time.Duration = time.Second * 10 - DefaultDelayPeriod uint64 = 0 - - DefaultChannelVersion = ibctransfertypes.Version - InvalidID = "IDisInvalid" - - ConnectionIDPrefix = "conn" - ChannelIDPrefix = "chan" - - TransferPort = ibctransfertypes.ModuleName - MockPort = mock.ModuleName - - // used for testing UpdateClientProposal - Title = "title" - Description = "description" -) - -var ( - DefaultOpenInitVersion *connectiontypes.Version - - // Default params variables used to create a TM client - DefaultTrustLevel ibctmtypes.Fraction = ibctmtypes.DefaultTrustLevel - TestHash = tmhash.Sum([]byte("TESTING HASH")) - TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - - UpgradePath = []string{"upgrade", "upgradedIBCState"} - - ConnectionVersion = connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions())[0] - - MockAcknowledgement = mock.MockAcknowledgement - MockCommitment = mock.MockCommitment + wasmd "github.com/CosmWasm/wasmd/app" + "github.com/CosmWasm/wasmd/x/wasm" ) // TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI @@ -90,13 +50,14 @@ var ( type TestChain struct { t *testing.T - App *wasmd.WasmApp + Coordinator *Coordinator + App ibctesting.TestingApp ChainID string LastHeader *ibctmtypes.Header // header for last block height committed CurrentHeader tmproto.Header // header for current block height QueryServer types.QueryServer TxConfig client.TxConfig - Codec codec.BinaryMarshaler + Codec codec.BinaryCodec Vals *tmtypes.ValidatorSet Signers []tmtypes.PrivValidator @@ -104,10 +65,6 @@ type TestChain struct { senderPrivKey cryptotypes.PrivKey SenderAccount authtypes.AccountI - // IBC specific helpers - ClientIDs []string // ClientID's used on this chain - Connections []*ibctesting.TestConnection // track connectionID's created for this chain - PendingSendPackets []channeltypes.Packet PendingAckPackets []PacketAck } @@ -125,7 +82,7 @@ type PacketAck struct { // // Time management is handled by the Coordinator in order to ensure synchrony between chains. // Each update of any chain increments the block header time for all chains by 5 seconds. -func NewTestChain(t *testing.T, chainID string, opt ...keeper.Option) *TestChain { +func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm.Option) *TestChain { // generate validator private/public key privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() @@ -139,68 +96,63 @@ func NewTestChain(t *testing.T, chainID string, opt ...keeper.Option) *TestChain // generate genesis account senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) + amount, ok := sdk.NewIntFromString("10000000000000000000") + require.True(t, ok) + balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)), } - // make a temp dir for the wasm files for this chain - tempDir, err := ioutil.TempDir("", "wasm") - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { os.RemoveAll(tempDir) }) - - app := wasmd.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opt, balance) + app := NewTestingAppDecorator(t, wasmd.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opts, balance)) // create current header and call begin block header := tmproto.Header{ ChainID: chainID, Height: 1, - Time: globalStartTime, + Time: coord.CurrentTime.UTC(), } - txConfig := wasmd.MakeEncodingConfig().TxConfig + txConfig := app.GetTxConfig() - testScope := wasmd.NewTestSupport(t, app) - ibcKeeper := testScope.IBCKeeper() + // create an account to send transactions from chain := &TestChain{ t: t, + Coordinator: coord, ChainID: chainID, App: app, CurrentHeader: header, - QueryServer: ibcKeeper, + QueryServer: app.GetIBCKeeper(), TxConfig: txConfig, - Codec: testScope.AppCodec(), + Codec: app.AppCodec(), Vals: valSet, Signers: signers, senderPrivKey: senderPrivKey, SenderAccount: acc, - ClientIDs: make([]string, 0), - Connections: make([]*ibctesting.TestConnection, 0), } - portKeeper := &ibcKeeper.PortKeeper - cap := portKeeper.BindPort(chain.GetContext(), MockPort) - err = testScope.ScopedWasmIBCKeeper().ClaimCapability(chain.GetContext(), cap, host.PortPath(MockPort)) - require.NoError(t, err) - - chain.NextBlock() + coord.CommitBlock(chain) return chain } // GetContext returns the current context for the application. func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, chain.CurrentHeader) + return chain.App.GetBaseApp().NewContext(false, chain.CurrentHeader) } // QueryProof 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) QueryProof(key []byte) ([]byte, clienttypes.Height) { + return chain.QueryProofAtHeight(key, chain.App.LastBlockHeight()) +} + +// QueryProof 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) QueryProofAtHeight(key []byte, height int64) ([]byte, clienttypes.Height) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), - Height: chain.App.LastBlockHeight() - 1, + Height: height - 1, Data: key, Prove: true, }) @@ -208,7 +160,7 @@ func (chain *TestChain) QueryProof(key []byte) ([]byte, clienttypes.Height) { merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) require.NoError(chain.t, err) - proof, err := chain.Codec.MarshalBinaryBare(&merkleProof) + proof, err := chain.App.AppCodec().Marshal(&merkleProof) require.NoError(chain.t, err) revision := clienttypes.ParseChainID(chain.ChainID) @@ -232,7 +184,7 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) require.NoError(chain.t, err) - proof, err := chain.Codec.MarshalBinaryBare(&merkleProof) + proof, err := chain.App.AppCodec().Marshal(&merkleProof) require.NoError(chain.t, err) revision := clienttypes.ParseChainID(chain.ChainID) @@ -243,19 +195,6 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl return proof, clienttypes.NewHeight(revision, uint64(res.Height+1)) } -// QueryClientStateProof performs and abci query for a client state -// stored with a given clientID and returns the ClientState along with the proof -func (chain *TestChain) QueryClientStateProof(clientID string) (exported.ClientState, []byte) { - // retrieve client state to provide proof for - clientState, found := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID) - require.True(chain.t, found) - - clientKey := host.FullClientStateKey(clientID) - proofClient, _ := chain.QueryProof(clientKey) - - return clientState, proofClient -} - // QueryConsensusStateProof performs an abci query for a consensus state // stored on the given clientID. The proof and consensusHeight are returned. func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height) { @@ -290,7 +229,6 @@ func (chain *TestChain) NextBlock() { } chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) - } // sendMsgs delivers a transaction through the application without returning the result. @@ -303,10 +241,14 @@ func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { // 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) { - _, r, err := wasmd.SignCheckDeliver( + + // ensure the chain has the latest time + chain.Coordinator.UpdateTimeForChain(chain) + + _, r, err := wasmd.SignAndDeliver( chain.t, chain.TxConfig, - chain.App.BaseApp, + chain.App.GetBaseApp(), chain.GetContext().BlockHeader(), msgs, chain.ChainID, @@ -318,7 +260,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { return nil, err } - // SignCheckDeliver calls app.Commit() + // SignAndDeliver calls app.Commit() chain.NextBlock() // increment sequence for successful transaction execution @@ -327,7 +269,14 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { return nil, err } - // TODO: also return acks needed to send + chain.Coordinator.IncrementTime() + + chain.captureIBCEvents(r) + + return r, nil +} + +func (chain *TestChain) captureIBCEvents(r *sdk.Result) { toSend := getSendPackets(r.Events) if len(toSend) > 0 { // Keep a queue on the chain that we can relay in tests @@ -338,95 +287,12 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { // Keep a queue on the chain that we can relay in tests chain.PendingAckPackets = append(chain.PendingAckPackets, toAck...) } - - return r, nil -} - -func getSendPackets(evts []abci.Event) []channeltypes.Packet { - var res []channeltypes.Packet - for _, evt := range evts { - if evt.Type == "send_packet" { - packet := parsePacketFromEvent(evt) - res = append(res, packet) - } - } - return res -} - -func getAckPackets(evts []abci.Event) []PacketAck { - var res []PacketAck - for _, evt := range evts { - if evt.Type == "write_acknowledgement" { - packet := parsePacketFromEvent(evt) - ack := PacketAck{ - Packet: packet, - Ack: []byte(getField(evt, "packet_ack")), - } - res = append(res, ack) - } - } - return res -} - -// Used for various debug statements above when needed... do not remove -// func showEvent(evt abci.Event) { -// fmt.Printf("evt.Type: %s\n", evt.Type) -// for _, attr := range evt.Attributes { -// fmt.Printf(" %s = %s\n", string(attr.Key), string(attr.Value)) -// } -//} - -func parsePacketFromEvent(evt abci.Event) channeltypes.Packet { - return channeltypes.Packet{ - Sequence: getUintField(evt, "packet_sequence"), - SourcePort: getField(evt, "packet_src_port"), - SourceChannel: getField(evt, "packet_src_channel"), - DestinationPort: getField(evt, "packet_dst_port"), - DestinationChannel: getField(evt, "packet_dst_channel"), - Data: []byte(getField(evt, "packet_data")), - TimeoutHeight: parseTimeoutHeight(getField(evt, "packet_timeout_height")), - TimeoutTimestamp: getUintField(evt, "packet_timeout_timestamp"), - } -} - -// return the value for the attribute with the given name -func getField(evt abci.Event, key string) string { - for _, attr := range evt.Attributes { - if string(attr.Key) == key { - return string(attr.Value) - } - } - return "" -} - -func getUintField(evt abci.Event, key string) uint64 { - raw := getField(evt, key) - return toUint64(raw) -} - -func toUint64(raw string) uint64 { - if raw == "" { - return 0 - } - i, err := strconv.ParseUint(raw, 10, 64) - if err != nil { - panic(err) - } - return i -} - -func parseTimeoutHeight(raw string) clienttypes.Height { - chunks := strings.Split(raw, "-") - return clienttypes.Height{ - RevisionNumber: toUint64(chunks[0]), - RevisionHeight: toUint64(chunks[1]), - } } // GetClientState retrieves the client state for the provided clientID. The client is // expected to exist otherwise testing will fail. func (chain *TestChain) GetClientState(clientID string) exported.ClientState { - clientState, found := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID) + clientState, found := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID) require.True(chain.t, found) return clientState @@ -435,48 +301,30 @@ func (chain *TestChain) GetClientState(clientID string) exported.ClientState { // GetConsensusState retrieves the consensus state for the provided clientID and height. // It will return a success boolean depending on if consensus state exists or not. func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool) { - return wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height) + return chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height) } // 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 := wasmd.NewTestSupport(chain.t, chain.App).StakingKeeper().GetHistoricalInfo(chain.GetContext(), height) + histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) if !ok { return nil, false } valSet := stakingtypes.Validators(histInfo.Valset) - tmValidators, err := teststaking.ToTmValidators(valSet) + tmValidators, err := teststaking.ToTmValidators(valSet, sdk.DefaultPowerReduction) if err != nil { panic(err) } return tmtypes.NewValidatorSet(tmValidators), true } -// GetConnection retrieves an IBC Connection for the provided TestConnection. The -// connection is expected to exist otherwise testing will fail. -func (chain *TestChain) GetConnection(testConnection *ibctesting.TestConnection) connectiontypes.ConnectionEnd { - connection, found := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ConnectionKeeper.GetConnection(chain.GetContext(), testConnection.ID) - require.True(chain.t, found) - - return connection -} - -// GetChannel retrieves an IBC Channel for the provided ibctesting.TestChannel. The channel -// is expected to exist otherwise testing will fail. -func (chain *TestChain) GetChannel(testChannel ibctesting.TestChannel) channeltypes.Channel { - channel, found := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ChannelKeeper.GetChannel(chain.GetContext(), testChannel.PortID, testChannel.ID) - require.True(chain.t, found) - - return channel -} - // GetAcknowledgement retrieves an acknowledgement for the provided packet. If the // acknowledgement does not exist then testing will fail. func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte { - ack, found := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + ack, found := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) require.True(chain.t, found) return ack @@ -484,138 +332,23 @@ func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte { // GetPrefix returns the prefix for used by a chain in connection creation func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix { - return commitmenttypes.NewMerklePrefix(wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ConnectionKeeper.GetCommitmentPrefix().Bytes()) -} - -// NewClientID appends a new clientID string in the format: -// ClientFor -func (chain *TestChain) NewClientID(clientType string) string { - clientID := fmt.Sprintf("%s-%s", clientType, strconv.Itoa(len(chain.ClientIDs))) - chain.ClientIDs = append(chain.ClientIDs, clientID) - return clientID -} - -// AddTestConnection appends a new TestConnection which contains references -// to the connection id, client id and counterparty client id. -func (chain *TestChain) AddTestConnection(clientID, counterpartyClientID string) *ibctesting.TestConnection { - conn := chain.ConstructNextTestConnection(clientID, counterpartyClientID) - - chain.Connections = append(chain.Connections, conn) - return conn -} - -// ConstructNextTestConnection constructs the next test connection to be -// created given a clientID and counterparty clientID. The connection id -// format: -conn -func (chain *TestChain) ConstructNextTestConnection(clientID, counterpartyClientID string) *ibctesting.TestConnection { - connectionID := connectiontypes.FormatConnectionIdentifier(uint64(len(chain.Connections))) - return &ibctesting.TestConnection{ - ID: connectionID, - ClientID: clientID, - NextChannelVersion: DefaultChannelVersion, - CounterpartyClientID: counterpartyClientID, - } -} - -// GetFirstTestConnection returns the first test connection for a given clientID. -// The connection may or may not exist in the chain state. -func (chain *TestChain) GetFirstTestConnection(clientID, counterpartyClientID string) *ibctesting.TestConnection { - if len(chain.Connections) > 0 { - return chain.Connections[0] - } - - return chain.ConstructNextTestConnection(clientID, counterpartyClientID) -} - -// AddTestChannel Add ibctesting.TestChannel appends a new ibctesting.TestChannel which contains references to the port and channel ID -// used for channel creation and interaction. See 'Next ibctesting.TestChannel' for channel ID naming format. -func (chain *TestChain) AddTestChannel(conn *ibctesting.TestConnection, portID string) ibctesting.TestChannel { - channel := chain.NextChannel(conn, portID) - conn.Channels = append(conn.Channels, channel) - return channel -} - -// NextChannel Next ibctesting.TestChannel returns the next test channel to be created on this connection, but does not -// add it to the list of created channels. This function is expected to be used when the caller -// has not created the associated channel in app state, but would still like to refer to the -// non-existent channel usually to test for its non-existence. -// -// channel ID format: -chan -// -// The port is passed in by the caller. -func (chain *TestChain) NextChannel(conn *ibctesting.TestConnection, portID string) ibctesting.TestChannel { - nextChanSeq := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ChannelKeeper.GetNextChannelSequence(chain.GetContext()) - channelID := channeltypes.FormatChannelIdentifier(nextChanSeq) - return ibctesting.TestChannel{ - PortID: portID, - ID: channelID, - ClientID: conn.ClientID, - CounterpartyClientID: conn.CounterpartyClientID, - Version: conn.NextChannelVersion, - } -} - -// ConstructMsgCreateClient constructs a message to create a new client state (tendermint or solomachine). -// NOTE: a solo machine client will be created with an empty diversifier. -func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, clientID string, clientType string) *clienttypes.MsgCreateClient { - var ( - clientState exported.ClientState - consensusState exported.ConsensusState - ) - - switch clientType { - case exported.Tendermint: - height := counterparty.LastHeader.GetHeight().(clienttypes.Height) - clientState = ibctmtypes.NewClientState( - counterparty.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift, - height, commitmenttypes.GetSDKSpecs(), UpgradePath, false, false, - ) - consensusState = counterparty.LastHeader.ConsensusState() - case exported.Solomachine: - solo := ibctesting.NewSolomachine(chain.t, chain.Codec, clientID, "", 1) - clientState = solo.ClientState() - consensusState = solo.ConsensusState() - default: - chain.t.Fatalf("unsupported client state type %s", clientType) - } - - msg, err := clienttypes.NewMsgCreateClient( - clientState, consensusState, chain.SenderAccount.GetAddress(), - ) - require.NoError(chain.t, err) - return msg -} - -// CreateTMClient will construct and execute a 07-tendermint MsgCreateClient. A counterparty -// client will be created on the (target) chain. -func (chain *TestChain) CreateTMClient(counterparty *TestChain, clientID string) error { - // construct MsgCreateClient using counterparty - msg := chain.ConstructMsgCreateClient(counterparty, clientID, exported.Tendermint) - return chain.sendMsgs(msg) -} - -// UpdateTMClient will construct and execute a 07-tendermint MsgUpdateClient. The counterparty -// client will be updated on the (target) chain. UpdateTMClient mocks the relayer flow -// necessary for updating a Tendermint client. -func (chain *TestChain) UpdateTMClient(counterparty *TestChain, clientID string) error { - header, err := chain.ConstructUpdateTMClientHeader(counterparty, clientID) - require.NoError(chain.t, err) - - msg, err := clienttypes.NewMsgUpdateClient( - clientID, header, - chain.SenderAccount.GetAddress(), - ) - require.NoError(chain.t, err) - - return chain.sendMsgs(msg) + return commitmenttypes.NewMerklePrefix(chain.App.GetIBCKeeper().ConnectionKeeper.GetCommitmentPrefix().Bytes()) } // 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) (*ibctmtypes.Header, error) { + return chain.ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty, clientID, clienttypes.ZeroHeight()) +} + +// ConstructUpdateTMClientHeader 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) (*ibctmtypes.Header, error) { header := counterparty.LastHeader - // Relayer must query for LatestHeight on client to get TrustedHeight - trustedHeight := chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height) + // 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 @@ -652,7 +385,7 @@ func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty *TestChain, c // ExpireClient fast forwards the chain's block time by the provided amount of time which will // expire any clients with a trusting period less than or equal to this amount of time. func (chain *TestChain) ExpireClient(amount time.Duration) { - chain.CurrentHeader.Time = chain.CurrentHeader.Time.Add(amount) + chain.Coordinator.IncrementTimeBy(amount) } // CurrentTMClientHeader creates a TM header using the current header parameters @@ -753,105 +486,21 @@ func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator, } } -// ConnectionOpenInit will construct and execute a MsgConnectionOpenInit. -func (chain *TestChain) ConnectionOpenInit( - counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, -) error { - msg := connectiontypes.NewMsgConnectionOpenInit( - connection.ClientID, - connection.CounterpartyClientID, - counterparty.GetPrefix(), DefaultOpenInitVersion, DefaultDelayPeriod, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) -} - -// ConnectionOpenTry will construct and execute a MsgConnectionOpenTry. -func (chain *TestChain) ConnectionOpenTry( - counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, -) error { - counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID) - - connectionKey := host.ConnectionKey(counterpartyConnection.ID) - proofInit, proofHeight := counterparty.QueryProof(connectionKey) - - proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) - - msg := connectiontypes.NewMsgConnectionOpenTry( - "", connection.ClientID, // does not support handshake continuation - counterpartyConnection.ID, counterpartyConnection.ClientID, - counterpartyClient, counterparty.GetPrefix(), []*connectiontypes.Version{ConnectionVersion}, DefaultDelayPeriod, - proofInit, proofClient, proofConsensus, - proofHeight, consensusHeight, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) -} - -// ConnectionOpenAck will construct and execute a MsgConnectionOpenAck. -func (chain *TestChain) ConnectionOpenAck( - counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, -) error { - counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID) - - connectionKey := host.ConnectionKey(counterpartyConnection.ID) - proofTry, proofHeight := counterparty.QueryProof(connectionKey) - - proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) - - msg := connectiontypes.NewMsgConnectionOpenAck( - connection.ID, counterpartyConnection.ID, counterpartyClient, // testing doesn't use flexible selection - proofTry, proofClient, proofConsensus, - proofHeight, consensusHeight, - ConnectionVersion, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) -} - -// ConnectionOpenConfirm will construct and execute a MsgConnectionOpenConfirm. -func (chain *TestChain) ConnectionOpenConfirm( - counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, -) error { - connectionKey := host.ConnectionKey(counterpartyConnection.ID) - proof, height := counterparty.QueryProof(connectionKey) - - msg := connectiontypes.NewMsgConnectionOpenConfirm( - connection.ID, - proof, height, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) -} - // CreatePortCapability binds and claims a capability for the given portID if it does not // already exist. This function will fail testing on any resulting error. // NOTE: only creation of a capbility for a transfer or mock port is supported // Other applications must bind to the port in InitGenesis or modify this code. -func (chain *TestChain) CreatePortCapability(portID string) { +func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string) { // check if the portId is already binded, if not bind it - _, ok := chain.TestSupport().ScopeIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) if !ok { // create capability using the IBC capability keeper - cap, err := chain.TestSupport().ScopeIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) + cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) require.NoError(chain.t, err) - switch portID { - case MockPort: - // claim capability using the mock capability keeper - err = wasmd.NewTestSupport(chain.t, chain.App).ScopedWasmIBCKeeper().ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) - require.NoError(chain.t, err) - case TransferPort: - // claim capability using the transfer capability keeper - err = chain.TestSupport().ScopedTransferKeeper().ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) - require.NoError(chain.t, err) - default: - panic(fmt.Sprintf("unsupported ibc testing package port ID %s", portID)) - } + // claim capability using the scopedKeeper + err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) + require.NoError(chain.t, err) } chain.App.Commit() @@ -862,22 +511,23 @@ func (chain *TestChain) CreatePortCapability(portID string) { // GetPortCapability returns the port capability for the given portID. The capability must // exist, otherwise testing will fail. func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability { - cap, ok := chain.TestSupport().ScopeIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) require.True(chain.t, ok) return cap } // CreateChannelCapability binds and claims a capability for the given portID and channelID -// if it does not already exist. This function will fail testing on any resulting error. -func (chain *TestChain) CreateChannelCapability(portID, channelID string) { +// if it does not already exist. This function will fail testing on any resulting error. The +// scoped keeper passed in will claim the new capability. +func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string) { capName := host.ChannelCapabilityPath(portID, channelID) // check if the portId is already binded, if not bind it - _, ok := chain.TestSupport().ScopeIBCKeeper().GetCapability(chain.GetContext(), capName) + _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName) if !ok { - cap, err := chain.TestSupport().ScopeIBCKeeper().NewCapability(chain.GetContext(), capName) + cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) require.NoError(chain.t, err) - err = chain.TestSupport().ScopedTransferKeeper().ClaimCapability(chain.GetContext(), cap, capName) + err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) require.NoError(chain.t, err) } @@ -889,139 +539,55 @@ func (chain *TestChain) CreateChannelCapability(portID, channelID string) { // GetChannelCapability returns the channel capability for the given portID and channelID. // The capability must exist, otherwise testing will fail. func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { - cap, ok := chain.TestSupport().ScopeIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) + cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) require.True(chain.t, ok) return cap } -// ChanOpenInit will construct and execute a MsgChannelOpenInit. -func (chain *TestChain) ChanOpenInit( - ch, counterparty ibctesting.TestChannel, - order channeltypes.Order, - connectionID string, -) error { - msg := channeltypes.NewMsgChannelOpenInit( - ch.PortID, - ch.Version, order, []string{connectionID}, - counterparty.PortID, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) +func (chain *TestChain) Balance(acc sdk.AccAddress, denom string) sdk.Coin { + return chain.GetTestSupport().BankKeeper().GetBalance(chain.GetContext(), acc, denom) } -// ChanOpenTry will construct and execute a MsgChannelOpenTry. -func (chain *TestChain) ChanOpenTry( - counterparty *TestChain, - ch, counterpartyCh ibctesting.TestChannel, - order channeltypes.Order, - connectionID string, -) error { - proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) - - msg := channeltypes.NewMsgChannelOpenTry( - ch.PortID, "", // does not support handshake continuation - ch.Version, order, []string{connectionID}, - counterpartyCh.PortID, counterpartyCh.ID, counterpartyCh.Version, - proof, height, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) +func (chain *TestChain) AllBalances(acc sdk.AccAddress) sdk.Coins { + return chain.GetTestSupport().BankKeeper().GetAllBalances(chain.GetContext(), acc) } -// ChanOpenAck will construct and execute a MsgChannelOpenAck. -func (chain *TestChain) ChanOpenAck( - counterparty *TestChain, - ch, counterpartyCh ibctesting.TestChannel, -) error { - proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) - - msg := channeltypes.NewMsgChannelOpenAck( - ch.PortID, ch.ID, - counterpartyCh.ID, counterpartyCh.Version, // testing doesn't use flexible selection - proof, height, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) +func (chain TestChain) GetTestSupport() *wasmd.TestSupport { + return chain.App.(*TestingAppDecorator).TestSupport() } -// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm. -func (chain *TestChain) ChanOpenConfirm( - counterparty *TestChain, - ch, counterpartyCh ibctesting.TestChannel, -) error { - proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) +var _ ibctesting.TestingApp = TestingAppDecorator{} - msg := channeltypes.NewMsgChannelOpenConfirm( - ch.PortID, ch.ID, - proof, height, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) +type TestingAppDecorator struct { + *wasmd.WasmApp + t *testing.T } -// ChanCloseInit will construct and execute a MsgChannelCloseInit. -// -// NOTE: does not work with ibc-transfer module -func (chain *TestChain) ChanCloseInit( - counterparty *TestChain, - channel ibctesting.TestChannel, -) error { - msg := channeltypes.NewMsgChannelCloseInit( - channel.PortID, channel.ID, - chain.SenderAccount.GetAddress(), - ) - return chain.sendMsgs(msg) +func NewTestingAppDecorator(t *testing.T, wasmApp *wasmd.WasmApp) *TestingAppDecorator { + return &TestingAppDecorator{WasmApp: wasmApp, t: t} } -// GetPacketData returns a ibc-transfer marshalled packet to be used for -// callback testing. -func (chain *TestChain) GetPacketData(counterparty *TestChain) []byte { - packet := ibctransfertypes.FungibleTokenPacketData{ - Denom: TestCoin.Denom, - Amount: TestCoin.Amount.Uint64(), - Sender: chain.SenderAccount.GetAddress().String(), - Receiver: counterparty.SenderAccount.GetAddress().String(), - } - - return packet.GetBytes() +func (a TestingAppDecorator) GetBaseApp() *baseapp.BaseApp { + return a.TestSupport().GetBaseApp() } -// SendPacket simulates sending a packet through the channel keeper. No message needs to be -// passed since this call is made from a module. -func (chain *TestChain) SendPacket( - packet exported.PacketI, -) error { - channelCap := chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel()) - - // no need to send message, acting as a module - err := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ChannelKeeper.SendPacket(chain.GetContext(), channelCap, packet) - if err != nil { - return err - } - - // commit changes - chain.App.Commit() - chain.NextBlock() - - return nil +func (a TestingAppDecorator) GetStakingKeeper() stakingkeeper.Keeper { + return a.TestSupport().StakingKeeper() } -// WriteAcknowledgement simulates writing an acknowledgement to the chain. -func (chain *TestChain) WriteAcknowledgement( - packet exported.PacketI, -) error { - channelCap := chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel()) - - // no need to send message, acting as a handler - err := wasmd.NewTestSupport(chain.t, chain.App).IBCKeeper().ChannelKeeper.WriteAcknowledgement(chain.GetContext(), channelCap, packet, TestHash) - if err != nil { - return err - } - - // commit changes - chain.App.Commit() - chain.NextBlock() - - return nil +func (a TestingAppDecorator) GetIBCKeeper() *ibckeeper.Keeper { + return a.TestSupport().IBCKeeper() +} + +func (a TestingAppDecorator) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { + return a.TestSupport().ScopeIBCKeeper() +} + +func (a TestingAppDecorator) GetTxConfig() client.TxConfig { + return a.TestSupport().GetTxConfig() +} + +func (a TestingAppDecorator) TestSupport() *wasmd.TestSupport { + return wasmd.NewTestSupport(a.t, a.WasmApp) } diff --git a/x/wasm/ibctesting/coordinator.go b/x/wasm/ibctesting/coordinator.go index 2549bc0c..13a0fcbc 100644 --- a/x/wasm/ibctesting/coordinator.go +++ b/x/wasm/ibctesting/coordinator.go @@ -6,21 +6,19 @@ import ( "testing" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" - "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" - ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" - + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/v2/testing" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) +const ChainIDPrefix = "testchain" + var ( - ChainIDPrefix = "testchain" - globalStartTime = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) + globalStartTime = time.Date(2020, 12, 4, 10, 30, 0, 0, time.UTC) TimeIncrement = time.Second * 5 ) @@ -29,401 +27,152 @@ var ( type Coordinator struct { t *testing.T - Chains map[string]*TestChain + CurrentTime time.Time + Chains map[string]*TestChain } // NewCoordinator initializes Coordinator with N TestChain's -func NewCoordinator(t *testing.T, n int, opts ...[]keeper.Option) *Coordinator { +func NewCoordinator(t *testing.T, n int, opts ...[]wasmkeeper.Option) *Coordinator { chains := make(map[string]*TestChain) - if len(opts) != 0 && len(opts) != n { - t.Fatalf("opts not matching number of instances: %d", len(opts)) + coord := &Coordinator{ + t: t, + CurrentTime: globalStartTime, } + for i := 0; i < n; i++ { chainID := GetChainID(i) - var iOpts []keeper.Option - if len(opts) != 0 { - iOpts = opts[i] + var x []wasmkeeper.Option + if len(opts) > i { + x = opts[i] } - chains[chainID] = NewTestChain(t, chainID, iOpts...) + chains[chainID] = NewTestChain(t, coord, chainID, x...) } - return &Coordinator{ - t: t, - Chains: chains, + coord.Chains = chains + + return coord +} + +// IncrementTime iterates through all the TestChain's and increments their current header time +// by 5 seconds. +// +// CONTRACT: this function must be called after every Commit on any TestChain. +func (coord *Coordinator) IncrementTime() { + coord.IncrementTimeBy(TimeIncrement) +} + +// IncrementTimeBy iterates through all the TestChain's and increments their current header time +// by specified time. +func (coord *Coordinator) IncrementTimeBy(increment time.Duration) { + coord.CurrentTime = coord.CurrentTime.Add(increment).UTC() + coord.UpdateTime() + +} + +// UpdateTime updates all clocks for the TestChains to the current global time. +func (coord *Coordinator) UpdateTime() { + for _, chain := range coord.Chains { + coord.UpdateTimeForChain(chain) } } +// 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 // fail if any error occurs. The clientID's, TestConnections, and TestChannels are returned // for both chains. The channels created are connected to the ibc-transfer application. -func (coord *Coordinator) Setup( - chainA, chainB *TestChain, order channeltypes.Order, -) (string, string, *ibctesting.TestConnection, *ibctesting.TestConnection, ibctesting.TestChannel, ibctesting.TestChannel) { - clientA, clientB, connA, connB := coord.SetupClientConnections(chainA, chainB, exported.Tendermint) +func (coord *Coordinator) Setup(path *Path) { + coord.SetupConnections(path) // channels can also be referenced through the returned connections - channelA, channelB := coord.CreateMockChannels(chainA, chainB, connA, connB, order) - - return clientA, clientB, connA, connB, channelA, channelB + coord.CreateChannels(path) } // SetupClients is a helper function to create clients on both chains. It assumes the // caller does not anticipate any errors. -func (coord *Coordinator) SetupClients( - chainA, chainB *TestChain, - clientType string, -) (string, string) { - - clientA, err := coord.CreateClient(chainA, chainB, clientType) +func (coord *Coordinator) SetupClients(path *Path) { + err := path.EndpointA.CreateClient() require.NoError(coord.t, err) - clientB, err := coord.CreateClient(chainB, chainA, clientType) + err = path.EndpointB.CreateClient() require.NoError(coord.t, err) - - return clientA, clientB } // SetupClientConnections is a helper function to create clients and the appropriate // connections on both the source and counterparty chain. It assumes the caller does not // anticipate any errors. -func (coord *Coordinator) SetupClientConnections( - chainA, chainB *TestChain, - clientType string, -) (string, string, *ibctesting.TestConnection, *ibctesting.TestConnection) { +func (coord *Coordinator) SetupConnections(path *Path) { + coord.SetupClients(path) - clientA, clientB := coord.SetupClients(chainA, chainB, clientType) - - connA, connB := coord.CreateConnection(chainA, chainB, clientA, clientB) - - return clientA, clientB, connA, connB -} - -// CreateClient creates a counterparty client on the source chain and returns the clientID. -func (coord *Coordinator) CreateClient( - source, counterparty *TestChain, - clientType string, -) (clientID string, err error) { - coord.CommitBlock(source, counterparty) - - clientID = source.NewClientID(clientType) - - switch clientType { - case exported.Tendermint: - err = source.CreateTMClient(counterparty, clientID) - - default: - err = fmt.Errorf("client type %s is not supported", clientType) - } - - if err != nil { - return "", err - } - - coord.IncrementTime() - - return clientID, nil -} - -// UpdateClient updates a counterparty client on the source chain. -func (coord *Coordinator) UpdateClient( - source, counterparty *TestChain, - clientID string, - clientType string, -) (err error) { - coord.CommitBlock(source, counterparty) - - switch clientType { - case exported.Tendermint: - err = source.UpdateTMClient(counterparty, clientID) - - default: - err = fmt.Errorf("client type %s is not supported", clientType) - } - - if err != nil { - return err - } - - coord.IncrementTime() - - return nil + coord.CreateConnections(path) } // CreateConnection constructs and executes connection handshake messages in order to create // OPEN channels on chainA and chainB. The connection information of for chainA and chainB // are returned within a TestConnection struct. The function expects the connections to be // successfully opened otherwise testing will fail. -func (coord *Coordinator) CreateConnection( - chainA, chainB *TestChain, - clientA, clientB string, -) (*ibctesting.TestConnection, *ibctesting.TestConnection) { +func (coord *Coordinator) CreateConnections(path *Path) { - connA, connB, err := coord.ConnOpenInit(chainA, chainB, clientA, clientB) + err := path.EndpointA.ConnOpenInit() require.NoError(coord.t, err) - err = coord.ConnOpenTry(chainB, chainA, connB, connA) + err = path.EndpointB.ConnOpenTry() require.NoError(coord.t, err) - err = coord.ConnOpenAck(chainA, chainB, connA, connB) + err = path.EndpointA.ConnOpenAck() require.NoError(coord.t, err) - err = coord.ConnOpenConfirm(chainB, chainA, connB, connA) + err = path.EndpointB.ConnOpenConfirm() require.NoError(coord.t, err) - return connA, connB + // ensure counterparty is up to date + err = path.EndpointA.UpdateClient() + require.NoError(coord.t, err) } // CreateMockChannels constructs and executes channel handshake messages to create OPEN // channels that use a mock application module that returns nil on all callbacks. This // function is expects the channels to be successfully opened otherwise testing will // fail. -func (coord *Coordinator) CreateMockChannels( - chainA, chainB *TestChain, - connA, connB *ibctesting.TestConnection, - order channeltypes.Order, -) (ibctesting.TestChannel, ibctesting.TestChannel) { - return coord.CreateChannel(chainA, chainB, connA, connB, MockPort, MockPort, order) +func (coord *Coordinator) CreateMockChannels(path *Path) { + path.EndpointA.ChannelConfig.PortID = ibctesting.MockPort + path.EndpointB.ChannelConfig.PortID = ibctesting.MockPort + + coord.CreateChannels(path) } // CreateTransferChannels constructs and executes channel handshake messages to create OPEN // ibc-transfer channels on chainA and chainB. The function expects the channels to be // successfully opened otherwise testing will fail. -func (coord *Coordinator) CreateTransferChannels( - chainA, chainB *TestChain, - connA, connB *ibctesting.TestConnection, - order channeltypes.Order, -) (ibctesting.TestChannel, ibctesting.TestChannel) { - return coord.CreateChannel(chainA, chainB, connA, connB, TransferPort, TransferPort, order) +func (coord *Coordinator) CreateTransferChannels(path *Path) { + path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort + path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort + + coord.CreateChannels(path) } // CreateChannel constructs and executes channel handshake messages in order to create // OPEN channels on chainA and chainB. The function expects the channels to be successfully // opened otherwise testing will fail. -func (coord *Coordinator) CreateChannel( - chainA, chainB *TestChain, - connA, connB *ibctesting.TestConnection, - sourcePortID, counterpartyPortID string, - order channeltypes.Order, -) (ibctesting.TestChannel, ibctesting.TestChannel) { - - channelA, channelB, err := coord.ChanOpenInit(chainA, chainB, connA, connB, sourcePortID, counterpartyPortID, order) +func (coord *Coordinator) CreateChannels(path *Path) { + err := path.EndpointA.ChanOpenInit() require.NoError(coord.t, err) - err = coord.ChanOpenTry(chainB, chainA, channelB, channelA, connB, order) + err = path.EndpointB.ChanOpenTry() require.NoError(coord.t, err) - err = coord.ChanOpenAck(chainA, chainB, channelA, channelB) + err = path.EndpointA.ChanOpenAck() require.NoError(coord.t, err) - err = coord.ChanOpenConfirm(chainB, chainA, channelB, channelA) + err = path.EndpointB.ChanOpenConfirm() require.NoError(coord.t, err) - return channelA, channelB -} - -// SendPacket sends a packet through the channel keeper on the source chain and updates the -// counterparty client for the source chain. -func (coord *Coordinator) SendPacket( - source, counterparty *TestChain, - packet exported.PacketI, - counterpartyClientID string, -) error { - if err := source.SendPacket(packet); err != nil { - return err - } - coord.IncrementTime() - - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyClientID, exported.Tendermint, - ) -} - -// RecvPacket receives a channel packet on the counterparty chain and updates -// the client on the source chain representing the counterparty. -func (coord *Coordinator) RecvPacket( - source, counterparty *TestChain, - sourceClient string, - packet channeltypes.Packet, -) error { - // get proof of packet commitment on source - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := source.QueryProof(packetKey) - - // Increment time and commit block so that 5 second delay period passes between send and receive - coord.IncrementTime() - coord.CommitBlock(source, counterparty) - - recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, counterparty.SenderAccount.GetAddress()) - - // receive on counterparty and update source client - return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg}) -} - -// TimeoutPacket returns the package to source chain to let the IBC app revert any operation. -func (coord *Coordinator) TimeoutPacket( - source, counterparty *TestChain, - counterpartyClient string, - packet channeltypes.Packet, -) error { - // get proof of packet unreceived on dest - packetKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proofUnreceived, proofHeight := counterparty.QueryProof(packetKey) - - // Increment time and commit block so that 5 second delay period passes between send and receive - coord.IncrementTime() - coord.CommitBlock(source, counterparty) - - timeoutMsg := channeltypes.NewMsgTimeout(packet, packet.Sequence, proofUnreceived, proofHeight, source.SenderAccount.GetAddress()) - return coord.SendMsgs(source, counterparty, counterpartyClient, []sdk.Msg{timeoutMsg}) -} - -// WriteAcknowledgement writes an acknowledgement to the channel keeper on the source chain and updates the -// counterparty client for the source chain. -func (coord *Coordinator) WriteAcknowledgement( - source, counterparty *TestChain, - packet exported.PacketI, - counterpartyClientID string, -) error { - if err := source.WriteAcknowledgement(packet); err != nil { - return err - } - coord.IncrementTime() - - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyClientID, exported.Tendermint, - ) -} - -// AcknowledgePacket acknowledges on the source chain the packet received on -// the counterparty chain and updates the client on the counterparty representing -// the source chain. -// TODO: add a query for the acknowledgement by events -// - https://github.com/cosmos/cosmos-sdk/issues/6509 -func (coord *Coordinator) AcknowledgePacket( - source, counterparty *TestChain, - counterpartyClient string, - packet channeltypes.Packet, ack []byte, -) error { - // get proof of acknowledgement on counterparty - packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := counterparty.QueryProof(packetKey) - - // Increment time and commit block so that 5 second delay period passes between send and receive - coord.IncrementTime() - coord.CommitBlock(source, counterparty) - - ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress()) - return coord.SendMsgs(source, counterparty, counterpartyClient, []sdk.Msg{ackMsg}) -} - -// RelayPacket receives a channel packet on counterparty, queries the ack -// and acknowledges the packet on source. The clients are updated as needed. -func (coord *Coordinator) RelayPacket( - source, counterparty *TestChain, - sourceClient, counterpartyClient string, - packet channeltypes.Packet, ack []byte, -) error { - // Increment time and commit block so that 5 second delay period passes between send and receive - coord.IncrementTime() - coord.CommitBlock(counterparty) - - if err := coord.RecvPacket(source, counterparty, sourceClient, packet); err != nil { - return err - } - - // Increment time and commit block so that 5 second delay period passes between send and receive - coord.IncrementTime() - coord.CommitBlock(source) - - return coord.AcknowledgePacket(source, counterparty, counterpartyClient, packet, ack) -} - -// IncrementTime iterates through all the TestChain's and increments their current header time -// by 5 seconds. -// -// CONTRACT: this function must be called after every commit on any TestChain. -func (coord *Coordinator) IncrementTime() { - for _, chain := range coord.Chains { - chain.CurrentHeader.Time = chain.CurrentHeader.Time.Add(TimeIncrement) - chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) - } -} - -// IncrementTimeBy iterates through all the TestChain's and increments their current header time -// by specified time. -func (coord *Coordinator) IncrementTimeBy(increment time.Duration) { - for _, chain := range coord.Chains { - chain.CurrentHeader.Time = chain.CurrentHeader.Time.Add(increment) - chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) - } -} - -// SendMsg delivers a single provided message to the chain. The counterparty -// client is update with the new source consensus state. -func (coord *Coordinator) SendMsg(source, counterparty *TestChain, counterpartyClientID string, msg sdk.Msg) error { - return coord.SendMsgs(source, counterparty, counterpartyClientID, []sdk.Msg{msg}) -} - -// SendMsgs delivers the provided messages to the chain. The counterparty -// client is updated with the new source consensus state. -func (coord *Coordinator) SendMsgs(source, counterparty *TestChain, counterpartyClientID string, msgs []sdk.Msg) error { - if err := source.sendMsgs(msgs...); err != nil { - return err - } - - coord.IncrementTime() - - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyClientID, exported.Tendermint, - ) -} - -func (coord *Coordinator) RelayAndAckPendingPackets(src, dest *TestChain, srcClientID, dstClientID string) error { - // get all the packet to relay src->dest - toSend := src.PendingSendPackets - src.PendingSendPackets = nil - fmt.Printf("Relay %d Packets A->B\n", len(toSend)) - - // send this to the other side - coord.IncrementTime() - coord.CommitBlock(src) - err := coord.UpdateClient(dest, src, dstClientID, exported.Tendermint) - if err != nil { - return err - } - for _, packet := range toSend { - err := coord.RecvPacket(src, dest, srcClientID, packet) - if err != nil { - return err - } - } - - // get all the acks to relay dest->src - toAck := dest.PendingAckPackets - dest.PendingAckPackets = nil - // TODO: assert >= len(toSend)? - fmt.Printf("Ack %d Packets B->A\n", len(toAck)) - - // send the ack back from dest -> src - coord.IncrementTime() - coord.CommitBlock(dest) - err = coord.UpdateClient(src, dest, srcClientID, exported.Tendermint) - if err != nil { - return err - } - for _, ack := range toAck { - err = coord.AcknowledgePacket(src, dest, srcClientID, ack.Packet, ack.Ack) - if err != nil { - return err - } - } - - return nil + // ensure counterparty is up to date + err = path.EndpointA.UpdateClient() + require.NoError(coord.t, err) } // GetChain returns the TestChain using the given chainID and returns an error if it does @@ -460,345 +209,135 @@ func (coord *Coordinator) CommitNBlocks(chain *TestChain, n uint64) { } } -// ConnOpenInit initializes a connection on the source chain with the state INIT +// ConnOpenInitOnBothChains initializes a connection on both endpoints with the state INIT // using the OpenInit handshake call. -// -// NOTE: The counterparty testing connection will be created even if it is not created in the -// application state. -func (coord *Coordinator) ConnOpenInit( - source, counterparty *TestChain, - clientID, counterpartyClientID string, -) (*ibctesting.TestConnection, *ibctesting.TestConnection, error) { - sourceConnection := source.AddTestConnection(clientID, counterpartyClientID) - counterpartyConnection := counterparty.AddTestConnection(counterpartyClientID, clientID) - - // initialize connection on source - if err := source.ConnectionOpenInit(counterparty, sourceConnection, counterpartyConnection); err != nil { - return sourceConnection, counterpartyConnection, err - } - coord.IncrementTime() - - // update source client on counterparty connection - if err := coord.UpdateClient( - counterparty, source, - counterpartyClientID, exported.Tendermint, - ); err != nil { - return sourceConnection, counterpartyConnection, err - } - - return sourceConnection, counterpartyConnection, nil -} - -// ConnOpenInitOnBothChains initializes a connection on the source chain with the state INIT -// using the OpenInit handshake call. -func (coord *Coordinator) ConnOpenInitOnBothChains( - source, counterparty *TestChain, - clientID, counterpartyClientID string, -) (*ibctesting.TestConnection, *ibctesting.TestConnection, error) { - sourceConnection := source.AddTestConnection(clientID, counterpartyClientID) - counterpartyConnection := counterparty.AddTestConnection(counterpartyClientID, clientID) - - // initialize connection on source - if err := source.ConnectionOpenInit(counterparty, sourceConnection, counterpartyConnection); err != nil { - return sourceConnection, counterpartyConnection, err - } - coord.IncrementTime() - - // initialize connection on counterparty - if err := counterparty.ConnectionOpenInit(source, counterpartyConnection, sourceConnection); err != nil { - return sourceConnection, counterpartyConnection, err - } - coord.IncrementTime() - - // update counterparty client on source connection - if err := coord.UpdateClient( - source, counterparty, - clientID, exported.Tendermint, - ); err != nil { - return sourceConnection, counterpartyConnection, err - } - - // update source client on counterparty connection - if err := coord.UpdateClient( - counterparty, source, - counterpartyClientID, exported.Tendermint, - ); err != nil { - return sourceConnection, counterpartyConnection, err - } - - return sourceConnection, counterpartyConnection, nil -} - -// ConnOpenTry initializes a connection on the source chain with the state TRYOPEN -// using the OpenTry handshake call. -func (coord *Coordinator) ConnOpenTry( - source, counterparty *TestChain, - sourceConnection, counterpartyConnection *ibctesting.TestConnection, -) error { - // initialize TRYOPEN connection on source - if err := source.ConnectionOpenTry(counterparty, sourceConnection, counterpartyConnection); err != nil { +func (coord *Coordinator) ConnOpenInitOnBothChains(path *Path) error { + if err := path.EndpointA.ConnOpenInit(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyConnection.ClientID, exported.Tendermint, - ) -} - -// ConnOpenAck initializes a connection on the source chain with the state OPEN -// using the OpenAck handshake call. -func (coord *Coordinator) ConnOpenAck( - source, counterparty *TestChain, - sourceConnection, counterpartyConnection *ibctesting.TestConnection, -) error { - // set OPEN connection on source using OpenAck - if err := source.ConnectionOpenAck(counterparty, sourceConnection, counterpartyConnection); err != nil { + if err := path.EndpointB.ConnOpenInit(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyConnection.ClientID, exported.Tendermint, - ) -} - -// ConnOpenConfirm initializes a connection on the source chain with the state OPEN -// using the OpenConfirm handshake call. -func (coord *Coordinator) ConnOpenConfirm( - source, counterparty *TestChain, - sourceConnection, counterpartyConnection *ibctesting.TestConnection, -) error { - if err := source.ConnectionOpenConfirm(counterparty, sourceConnection, counterpartyConnection); err != nil { + if err := path.EndpointA.UpdateClient(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - counterpartyConnection.ClientID, exported.Tendermint, - ) -} - -// ChanOpenInit initializes a channel on the source chain with the state INIT -// using the OpenInit handshake call. -// -// NOTE: The counterparty testing channel will be created even if it is not created in the -// application state. -func (coord *Coordinator) ChanOpenInit( - source, counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, - sourcePortID, counterpartyPortID string, - order channeltypes.Order, -) (ibctesting.TestChannel, ibctesting.TestChannel, error) { - sourceChannel := source.AddTestChannel(connection, sourcePortID) - counterpartyChannel := counterparty.AddTestChannel(counterpartyConnection, counterpartyPortID) - - // NOTE: only creation of a capability for a transfer or mock port is supported - // Other applications must bind to the port in InitGenesis or modify this code. - source.CreatePortCapability(sourceChannel.PortID) - coord.IncrementTime() - - // initialize channel on source - if err := source.ChanOpenInit(sourceChannel, counterpartyChannel, order, connection.ID); err != nil { - return sourceChannel, counterpartyChannel, err - } - coord.IncrementTime() - - // update source client on counterparty connection - if err := coord.UpdateClient( - counterparty, source, - counterpartyConnection.ClientID, exported.Tendermint, - ); err != nil { - return sourceChannel, counterpartyChannel, err + if err := path.EndpointB.UpdateClient(); err != nil { + return err } - return sourceChannel, counterpartyChannel, nil + return nil } // ChanOpenInitOnBothChains initializes a channel on the source chain and counterparty chain // with the state INIT using the OpenInit handshake call. -func (coord *Coordinator) ChanOpenInitOnBothChains( - source, counterparty *TestChain, - connection, counterpartyConnection *ibctesting.TestConnection, - sourcePortID, counterpartyPortID string, - order channeltypes.Order, -) (ibctesting.TestChannel, ibctesting.TestChannel, error) { - sourceChannel := source.AddTestChannel(connection, sourcePortID) - counterpartyChannel := counterparty.AddTestChannel(counterpartyConnection, counterpartyPortID) - +func (coord *Coordinator) ChanOpenInitOnBothChains(path *Path) error { // NOTE: only creation of a capability for a transfer or mock port is supported // Other applications must bind to the port in InitGenesis or modify this code. - source.CreatePortCapability(sourceChannel.PortID) - counterparty.CreatePortCapability(counterpartyChannel.PortID) - coord.IncrementTime() - // initialize channel on source - if err := source.ChanOpenInit(sourceChannel, counterpartyChannel, order, connection.ID); err != nil { - return sourceChannel, counterpartyChannel, err - } - coord.IncrementTime() - - // initialize channel on counterparty - if err := counterparty.ChanOpenInit(counterpartyChannel, sourceChannel, order, counterpartyConnection.ID); err != nil { - return sourceChannel, counterpartyChannel, err - } - coord.IncrementTime() - - // update counterparty client on source connection - if err := coord.UpdateClient( - source, counterparty, - connection.ClientID, exported.Tendermint, - ); err != nil { - return sourceChannel, counterpartyChannel, err - } - - // update source client on counterparty connection - if err := coord.UpdateClient( - counterparty, source, - counterpartyConnection.ClientID, exported.Tendermint, - ); err != nil { - return sourceChannel, counterpartyChannel, err - } - - return sourceChannel, counterpartyChannel, nil -} - -// ChanOpenTry initializes a channel on the source chain with the state TRYOPEN -// using the OpenTry handshake call. -func (coord *Coordinator) ChanOpenTry( - source, counterparty *TestChain, - sourceChannel, counterpartyChannel ibctesting.TestChannel, - connection *ibctesting.TestConnection, - order channeltypes.Order, -) error { - - // initialize channel on source - if err := source.ChanOpenTry(counterparty, sourceChannel, counterpartyChannel, order, connection.ID); err != nil { + if err := path.EndpointA.ChanOpenInit(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - connection.CounterpartyClientID, exported.Tendermint, - ) -} - -// ChanOpenAck initializes a channel on the source chain with the state OPEN -// using the OpenAck handshake call. -func (coord *Coordinator) ChanOpenAck( - source, counterparty *TestChain, - sourceChannel, counterpartyChannel ibctesting.TestChannel, -) error { - - if err := source.ChanOpenAck(counterparty, sourceChannel, counterpartyChannel); err != nil { + if err := path.EndpointB.ChanOpenInit(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - sourceChannel.CounterpartyClientID, exported.Tendermint, - ) -} - -// ChanOpenConfirm initializes a channel on the source chain with the state OPEN -// using the OpenConfirm handshake call. -func (coord *Coordinator) ChanOpenConfirm( - source, counterparty *TestChain, - sourceChannel, counterpartyChannel ibctesting.TestChannel, -) error { - - if err := source.ChanOpenConfirm(counterparty, sourceChannel, counterpartyChannel); err != nil { + if err := path.EndpointA.UpdateClient(); err != nil { return err } - coord.IncrementTime() - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - sourceChannel.CounterpartyClientID, exported.Tendermint, - ) + if err := path.EndpointB.UpdateClient(); err != nil { + return err + } + + return nil } -func (coord *Coordinator) CloseChannel( - source, counterparty *TestChain, - channel, counterpartyChannel ibctesting.TestChannel, -) { - err := source.ChanCloseInit(counterparty, channel) +// from A to B +func (coord *Coordinator) RelayAndAckPendingPackets(path *Path) error { + // get all the packet to relay src->dest + src := path.EndpointA + dest := path.EndpointB + toSend := src.Chain.PendingSendPackets + coord.t.Logf("Relay %d Packets A->B\n", len(toSend)) + + // send this to the other side + coord.IncrementTime() + coord.CommitBlock(src.Chain) + err := dest.UpdateClient() + if err != nil { + return err + } + for _, packet := range toSend { + err = dest.RecvPacket(packet) + if err != nil { + return err + } + } + src.Chain.PendingSendPackets = nil + + // get all the acks to relay dest->src + toAck := dest.Chain.PendingAckPackets + // TODO: assert >= len(toSend)? + coord.t.Logf("Ack %d Packets B->A\n", len(toAck)) + + // send the ack back from dest -> src + coord.IncrementTime() + coord.CommitBlock(dest.Chain) + err = src.UpdateClient() + if err != nil { + return err + } + for _, ack := range toAck { + err = src.AcknowledgePacket(ack.Packet, ack.Ack) + if err != nil { + return err + } + } + dest.Chain.PendingAckPackets = nil + return nil +} + +// TimeoutPendingPackets returns the package to source chain to let the IBC app revert any operation. +// from A to A +func (coord *Coordinator) TimeoutPendingPackets(path *Path) error { + src := path.EndpointA + dest := path.EndpointB + + toSend := src.Chain.PendingSendPackets + coord.t.Logf("Timeout %d Packets A->A\n", len(toSend)) + + if err := src.UpdateClient(); err != nil { + return err + } + // Increment time and commit block so that 5 second delay period passes between send and receive + coord.IncrementTime() + coord.CommitBlock(src.Chain, dest.Chain) + for _, packet := range toSend { + // get proof of packet unreceived on dest + packetKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proofUnreceived, proofHeight := dest.QueryProof(packetKey) + timeoutMsg := channeltypes.NewMsgTimeout(packet, packet.Sequence, proofUnreceived, proofHeight, src.Chain.SenderAccount.GetAddress().String()) + err := src.Chain.sendMsgs(timeoutMsg) + if err != nil { + return err + } + } + src.Chain.PendingSendPackets = nil + dest.Chain.PendingAckPackets = nil + return nil +} + +// CloseChannel close channel on both sides +func (coord *Coordinator) CloseChannel(path *Path) { + err := path.EndpointA.ChanCloseInit() require.NoError(coord.t, err) - coord.IncrementTime() - err = coord.UpdateClient(counterparty, source, counterpartyChannel.ClientID, exported.Tendermint) + err = path.EndpointB.UpdateClient() require.NoError(coord.t, err) - err = coord.ChanCloseConfirm(source, counterparty, channel, counterpartyChannel) + err = path.EndpointB.ChanCloseConfirm() require.NoError(coord.t, err) } - -// ChanCloseInit closes a channel on the source chain resulting in the channels state -// being set to CLOSED. -// -// NOTE: does not work with ibc-transfer module -func (coord *Coordinator) ChanCloseInit( - source, counterparty *TestChain, - channel ibctesting.TestChannel, -) error { - - if err := source.ChanCloseInit(counterparty, channel); err != nil { - return err - } - coord.IncrementTime() - - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - channel.CounterpartyClientID, exported.Tendermint, - ) -} - -// ChanCloseConfirm closes a channel on the counterparty chain resulting in the channels state -// being set to CLOSED. -// -// NOTE: does not work with ibc-transfer module -func (coord *Coordinator) ChanCloseConfirm( - source, counterparty *TestChain, - channel, counterpartyChannel ibctesting.TestChannel, -) error { - channelKey := host.ChannelKey(channel.PortID, channel.ID) - proof, proofHeight := source.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelCloseConfirm( - counterpartyChannel.PortID, counterpartyChannel.ID, - proof, proofHeight, - counterparty.SenderAccount.GetAddress(), - ) - return coord.SendMsgs(counterparty, source, counterpartyChannel.CounterpartyClientID, []sdk.Msg{msg}) -} - -// SetChannelClosed sets a channel state to CLOSED. -func (coord *Coordinator) SetChannelClosed( - source, counterparty *TestChain, - testChannel ibctesting.TestChannel, -) error { - channel := source.GetChannel(testChannel) - - channel.State = channeltypes.CLOSED - source.TestSupport(). - IBCKeeper().ChannelKeeper.SetChannel(source.GetContext(), testChannel.PortID, testChannel.ID, channel) - - coord.CommitBlock(source) - - // update source client on counterparty connection - return coord.UpdateClient( - counterparty, source, - testChannel.CounterpartyClientID, exported.Tendermint, - ) -} diff --git a/x/wasm/ibctesting/endpoint.go b/x/wasm/ibctesting/endpoint.go new file mode 100644 index 00000000..e39ebdb9 --- /dev/null +++ b/x/wasm/ibctesting/endpoint.go @@ -0,0 +1,544 @@ +package ibctesting + +import ( + "fmt" + + ibctesting "github.com/cosmos/ibc-go/v2/testing" + + // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v2/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" + "github.com/cosmos/ibc-go/v2/modules/core/exported" + ibctmtypes "github.com/cosmos/ibc-go/v2/modules/light-clients/07-tendermint/types" +) + +// Endpoint is a which represents a channel endpoint and its associated +// client and connections. It contains client, connection, and channel +// configuration parameters. Endpoint functions will utilize the parameters +// set in the configuration structs when executing IBC messages. +type Endpoint struct { + Chain *TestChain + Counterparty *Endpoint + ClientID string + ConnectionID string + ChannelID string + + ClientConfig ibctesting.ClientConfig + ConnectionConfig *ibctesting.ConnectionConfig + ChannelConfig *ibctesting.ChannelConfig +} + +// NewEndpoint constructs a new endpoint without the counterparty. +// CONTRACT: the counterparty endpoint must be set by the caller. +func NewEndpoint( + chain *TestChain, clientConfig ibctesting.ClientConfig, + connectionConfig *ibctesting.ConnectionConfig, channelConfig *ibctesting.ChannelConfig, +) *Endpoint { + return &Endpoint{ + Chain: chain, + ClientConfig: clientConfig, + ConnectionConfig: connectionConfig, + ChannelConfig: channelConfig, + } +} + +// NewDefaultEndpoint constructs a new endpoint using default values. +// CONTRACT: the counterparty endpoitn must be set by the caller. +func NewDefaultEndpoint(chain *TestChain) *Endpoint { + return &Endpoint{ + Chain: chain, + ClientConfig: ibctesting.NewTendermintConfig(), + ConnectionConfig: ibctesting.NewConnectionConfig(), + ChannelConfig: ibctesting.NewChannelConfig(), + } +} + +// QueryProof queries proof associated with this endpoint using the lastest client state +// height on the counterparty chain. +func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) { + // obtain the counterparty client representing the chain associated with the endpoint + clientState := endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID) + + // query proof on the counterparty using the latest height of the IBC client + return endpoint.QueryProofAtHeight(key, clientState.GetLatestHeight().GetRevisionHeight()) +} + +// QueryProofAtHeight queries proof associated with this endpoint using the proof height +// providied +func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, clienttypes.Height) { + // query proof on the counterparty using the latest height of the IBC client + return endpoint.Chain.QueryProofAtHeight(key, int64(height)) +} + +// CreateClient creates an IBC client on the endpoint. It will update the +// clientID for the endpoint if the message is successfully executed. +// NOTE: a solo machine client will be created with an empty diversifier. +func (endpoint *Endpoint) CreateClient() (err error) { + // ensure counterparty has committed state + endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) + + var ( + clientState exported.ClientState + consensusState exported.ConsensusState + ) + + switch endpoint.ClientConfig.GetClientType() { + case exported.Tendermint: + tmConfig, ok := endpoint.ClientConfig.(*ibctesting.TendermintConfig) + require.True(endpoint.Chain.t, ok) + + height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height) + clientState = ibctmtypes.NewClientState( + endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift, + height, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, tmConfig.AllowUpdateAfterExpiry, tmConfig.AllowUpdateAfterMisbehaviour, + ) + consensusState = endpoint.Counterparty.Chain.LastHeader.ConsensusState() + case exported.Solomachine: + // TODO + // solo := NewSolomachine(chain.t, endpoint.Chain.Codec, clientID, "", 1) + // clientState = solo.ClientState() + // consensusState = solo.ConsensusState() + + default: + err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) + } + + if err != nil { + return err + } + + msg, err := clienttypes.NewMsgCreateClient( + clientState, consensusState, endpoint.Chain.SenderAccount.GetAddress().String(), + ) + require.NoError(endpoint.Chain.t, err) + + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + endpoint.ClientID, err = ibctesting.ParseClientIDFromEvents(res.GetEvents()) + require.NoError(endpoint.Chain.t, err) + + return nil +} + +// UpdateClient updates the IBC client associated with the endpoint. +func (endpoint *Endpoint) UpdateClient() (err error) { + // ensure counterparty has committed state + endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) + + var ( + header exported.Header + ) + + switch endpoint.ClientConfig.GetClientType() { + case exported.Tendermint: + header, err = endpoint.Chain.ConstructUpdateTMClientHeader(endpoint.Counterparty.Chain, endpoint.ClientID) + + default: + err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) + } + + if err != nil { + return err + } + + msg, err := clienttypes.NewMsgUpdateClient( + endpoint.ClientID, header, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + require.NoError(endpoint.Chain.t, err) + + return endpoint.Chain.sendMsgs(msg) + +} + +// ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint. +func (endpoint *Endpoint) ConnOpenInit() error { + msg := connectiontypes.NewMsgConnectionOpenInit( + endpoint.ClientID, + endpoint.Counterparty.ClientID, + endpoint.Counterparty.Chain.GetPrefix(), ibctesting.DefaultOpenInitVersion, endpoint.ConnectionConfig.DelayPeriod, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents()) + require.NoError(endpoint.Chain.t, err) + + return nil +} + +// ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint. +func (endpoint *Endpoint) ConnOpenTry() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + counterpartyClient, proofClient, proofConsensus, consensusHeight, proofInit, proofHeight := endpoint.QueryConnectionHandshakeProof() + + msg := connectiontypes.NewMsgConnectionOpenTry( + "", endpoint.ClientID, // does not support handshake continuation + endpoint.Counterparty.ConnectionID, endpoint.Counterparty.ClientID, + counterpartyClient, endpoint.Counterparty.Chain.GetPrefix(), []*connectiontypes.Version{ibctesting.ConnectionVersion}, endpoint.ConnectionConfig.DelayPeriod, + proofInit, proofClient, proofConsensus, + proofHeight, consensusHeight, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + if endpoint.ConnectionID == "" { + endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents()) + require.NoError(endpoint.Chain.t, err) + } + + return nil +} + +// ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint. +func (endpoint *Endpoint) ConnOpenAck() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + counterpartyClient, proofClient, proofConsensus, consensusHeight, proofTry, proofHeight := endpoint.QueryConnectionHandshakeProof() + + msg := connectiontypes.NewMsgConnectionOpenAck( + endpoint.ConnectionID, endpoint.Counterparty.ConnectionID, counterpartyClient, // testing doesn't use flexible selection + proofTry, proofClient, proofConsensus, + proofHeight, consensusHeight, + ibctesting.ConnectionVersion, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint. +func (endpoint *Endpoint) ConnOpenConfirm() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID) + proof, height := endpoint.Counterparty.Chain.QueryProof(connectionKey) + + msg := connectiontypes.NewMsgConnectionOpenConfirm( + endpoint.ConnectionID, + proof, height, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// QueryConnectionHandshakeProof returns all the proofs necessary to execute OpenTry or Open Ack of +// the connection handshakes. It returns the counterparty client state, proof of the counterparty +// client state, proof of the counterparty consensus state, the consensus state height, proof of +// the counterparty connection, and the proof height for all the proofs returned. +func (endpoint *Endpoint) QueryConnectionHandshakeProof() ( + clientState exported.ClientState, proofClient, + proofConsensus []byte, consensusHeight clienttypes.Height, + proofConnection []byte, proofHeight clienttypes.Height, +) { + // obtain the client state on the counterparty chain + clientState = endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID) + + // query proof for the client state on the counterparty + clientKey := host.FullClientStateKey(endpoint.Counterparty.ClientID) + proofClient, proofHeight = endpoint.Counterparty.QueryProof(clientKey) + + consensusHeight = clientState.GetLatestHeight().(clienttypes.Height) + + // query proof for the consensus state on the counterparty + consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight) + proofConsensus, _ = endpoint.Counterparty.QueryProofAtHeight(consensusKey, proofHeight.GetRevisionHeight()) + + // query proof for the connection on the counterparty + connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID) + proofConnection, _ = endpoint.Counterparty.QueryProofAtHeight(connectionKey, proofHeight.GetRevisionHeight()) + + return +} + +// ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint. +func (endpoint *Endpoint) ChanOpenInit() error { + msg := channeltypes.NewMsgChannelOpenInit( + endpoint.ChannelConfig.PortID, + endpoint.ChannelConfig.Version, endpoint.ChannelConfig.Order, []string{endpoint.ConnectionID}, + endpoint.Counterparty.ChannelConfig.PortID, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents()) + require.NoError(endpoint.Chain.t, err) + + return nil +} + +// ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint. +func (endpoint *Endpoint) ChanOpenTry() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) + proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) + + msg := channeltypes.NewMsgChannelOpenTry( + endpoint.ChannelConfig.PortID, "", // does not support handshake continuation + endpoint.ChannelConfig.Version, endpoint.ChannelConfig.Order, []string{endpoint.ConnectionID}, + endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID, endpoint.Counterparty.ChannelConfig.Version, + proof, height, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + res, err := endpoint.Chain.SendMsgs(msg) + if err != nil { + return err + } + + if endpoint.ChannelID == "" { + endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents()) + require.NoError(endpoint.Chain.t, err) + } + + return nil +} + +// ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint. +func (endpoint *Endpoint) ChanOpenAck() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) + proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) + + msg := channeltypes.NewMsgChannelOpenAck( + endpoint.ChannelConfig.PortID, endpoint.ChannelID, + endpoint.Counterparty.ChannelID, endpoint.Counterparty.ChannelConfig.Version, // testing doesn't use flexible selection + proof, height, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint. +func (endpoint *Endpoint) ChanOpenConfirm() error { + if err := endpoint.UpdateClient(); err != nil { + return err + } + + channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) + proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) + + msg := channeltypes.NewMsgChannelOpenConfirm( + endpoint.ChannelConfig.PortID, endpoint.ChannelID, + proof, height, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// ChanCloseInit will construct and execute a MsgChannelCloseInit on the associated endpoint. +// +// NOTE: does not work with ibc-transfer module +func (endpoint *Endpoint) ChanCloseInit() error { + msg := channeltypes.NewMsgChannelCloseInit( + endpoint.ChannelConfig.PortID, endpoint.ChannelID, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// ChanCloseConfirm will construct and execute a NewMsgChannelCloseConfirm on the associated endpoint. +func (endpoint *Endpoint) ChanCloseConfirm() error { + channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) + proof, proofHeight := endpoint.Counterparty.QueryProof(channelKey) + + msg := channeltypes.NewMsgChannelCloseConfirm( + endpoint.ChannelConfig.PortID, endpoint.ChannelID, + proof, proofHeight, + endpoint.Chain.SenderAccount.GetAddress().String(), + ) + return endpoint.Chain.sendMsgs(msg) +} + +// SendPacket sends a packet through the channel keeper using the associated endpoint +// The counterparty client is updated so proofs can be sent to the counterparty chain. +func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error { + channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel()) + + // no need to send message, acting as a module + err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet) + if err != nil { + return err + } + + // commit changes since no message was sent + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) + + return endpoint.Counterparty.UpdateClient() +} + +// RecvPacket receives a packet on the associated endpoint. +// The counterparty client is updated. +func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error { + // get proof of packet commitment on source + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + proof, proofHeight := endpoint.Counterparty.Chain.QueryProof(packetKey) + + recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) + + // receive on counterparty and update source client + if err := endpoint.Chain.sendMsgs(recvMsg); err != nil { + return err + } + + return endpoint.Counterparty.UpdateClient() +} + +// WriteAcknowledgement writes an acknowledgement on the channel associated with the endpoint. +// The counterparty client is updated. +func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, packet exported.PacketI) error { + channelCap := endpoint.Chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel()) + + // no need to send message, acting as a handler + err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack.Acknowledgement()) + if err != nil { + return err + } + + // commit changes since no message was sent + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) + + return endpoint.Counterparty.UpdateClient() +} + +// AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint. +func (endpoint *Endpoint) AcknowledgePacket(packet channeltypes.Packet, ack []byte) error { + // get proof of acknowledgement on counterparty + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) + + ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) + + return endpoint.Chain.sendMsgs(ackMsg) +} + +// TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint. +func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { + // get proof for timeout based on channel order + var packetKey []byte + + switch endpoint.ChannelConfig.Order { + case channeltypes.ORDERED: + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) + case channeltypes.UNORDERED: + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + default: + return fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) + } + + proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) + nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) + require.True(endpoint.Chain.t, found) + + timeoutMsg := channeltypes.NewMsgTimeout( + packet, nextSeqRecv, + proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(), + ) + + return endpoint.Chain.sendMsgs(timeoutMsg) +} + +// SetChannelClosed sets a channel state to CLOSED. +func (endpoint *Endpoint) SetChannelClosed() error { + channel := endpoint.GetChannel() + + channel.State = channeltypes.CLOSED + endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) + + endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) + + return endpoint.Counterparty.UpdateClient() +} + +// GetClientState retrieves the Client State for this endpoint. The +// client state is expected to exist otherwise testing will fail. +func (endpoint *Endpoint) GetClientState() exported.ClientState { + return endpoint.Chain.GetClientState(endpoint.ClientID) +} + +// SetClientState sets the client state for this endpoint. +func (endpoint *Endpoint) SetClientState(clientState exported.ClientState) { + endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState) +} + +// GetConsensusState retrieves the Consensus State for this endpoint at the provided height. +// The consensus state is expected to exist otherwise testing will fail. +func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.ConsensusState { + consensusState, found := endpoint.Chain.GetConsensusState(endpoint.ClientID, height) + require.True(endpoint.Chain.t, found) + + return consensusState +} + +// SetConsensusState sets the consensus state for this endpoint. +func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height) { + endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(endpoint.Chain.GetContext(), endpoint.ClientID, height, consensusState) +} + +// GetConnection retrieves an IBC Connection for the endpoint. The +// connection is expected to exist otherwise testing will fail. +func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd { + connection, found := endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID) + require.True(endpoint.Chain.t, found) + + return connection +} + +// SetConnection sets the connection for this endpoint. +func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd) { + endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.SetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID, connection) +} + +// GetChannel retrieves an IBC Channel for the endpoint. The channel +// is expected to exist otherwise testing will fail. +func (endpoint *Endpoint) GetChannel() channeltypes.Channel { + channel, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) + require.True(endpoint.Chain.t, found) + + return channel +} + +// SetChannel sets the channel for this endpoint. +func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) { + endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) +} + +// QueryClientStateProof performs and abci query for a client stat associated +// with this endpoint and returns the ClientState along with the proof. +func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) { + // retrieve client state to provide proof for + clientState := endpoint.GetClientState() + + clientKey := host.FullClientStateKey(endpoint.ClientID) + proofClient, _ := endpoint.QueryProof(clientKey) + + return clientState, proofClient +} diff --git a/x/wasm/ibctesting/event_utils.go b/x/wasm/ibctesting/event_utils.go new file mode 100644 index 00000000..5188d8a8 --- /dev/null +++ b/x/wasm/ibctesting/event_utils.go @@ -0,0 +1,91 @@ +package ibctesting + +import ( + "strconv" + "strings" + + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +func getSendPackets(evts []abci.Event) []channeltypes.Packet { + var res []channeltypes.Packet + for _, evt := range evts { + if evt.Type == "send_packet" { + packet := parsePacketFromEvent(evt) + res = append(res, packet) + } + } + return res +} + +func getAckPackets(evts []abci.Event) []PacketAck { + var res []PacketAck + for _, evt := range evts { + if evt.Type == "write_acknowledgement" { + packet := parsePacketFromEvent(evt) + ack := PacketAck{ + Packet: packet, + Ack: []byte(getField(evt, "packet_ack")), + } + res = append(res, ack) + } + } + return res +} + +// Used for various debug statements above when needed... do not remove +// func showEvent(evt abci.Event) { +// fmt.Printf("evt.Type: %s\n", evt.Type) +// for _, attr := range evt.Attributes { +// fmt.Printf(" %s = %s\n", string(attr.Key), string(attr.Value)) +// } +//} + +func parsePacketFromEvent(evt abci.Event) channeltypes.Packet { + return channeltypes.Packet{ + Sequence: getUintField(evt, "packet_sequence"), + SourcePort: getField(evt, "packet_src_port"), + SourceChannel: getField(evt, "packet_src_channel"), + DestinationPort: getField(evt, "packet_dst_port"), + DestinationChannel: getField(evt, "packet_dst_channel"), + Data: []byte(getField(evt, "packet_data")), + TimeoutHeight: parseTimeoutHeight(getField(evt, "packet_timeout_height")), + TimeoutTimestamp: getUintField(evt, "packet_timeout_timestamp"), + } +} + +// return the value for the attribute with the given name +func getField(evt abci.Event, key string) string { + for _, attr := range evt.Attributes { + if string(attr.Key) == key { + return string(attr.Value) + } + } + return "" +} + +func getUintField(evt abci.Event, key string) uint64 { + raw := getField(evt, key) + return toUint64(raw) +} + +func toUint64(raw string) uint64 { + if raw == "" { + return 0 + } + i, err := strconv.ParseUint(raw, 10, 64) + if err != nil { + panic(err) + } + return i +} + +func parseTimeoutHeight(raw string) clienttypes.Height { + chunks := strings.Split(raw, "-") + return clienttypes.Height{ + RevisionNumber: toUint64(chunks[0]), + RevisionHeight: toUint64(chunks[1]), + } +} diff --git a/x/wasm/ibctesting/path.go b/x/wasm/ibctesting/path.go new file mode 100644 index 00000000..29ac881e --- /dev/null +++ b/x/wasm/ibctesting/path.go @@ -0,0 +1,99 @@ +package ibctesting + +import ( + "bytes" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" +) + +// Path contains two endpoints representing two chains connected over IBC +type Path struct { + EndpointA *Endpoint + EndpointB *Endpoint +} + +// NewPath constructs an endpoint for each chain using the default values +// for the endpoints. Each endpoint is updated to have a pointer to the +// counterparty endpoint. +func NewPath(chainA, chainB *TestChain) *Path { + endpointA := NewDefaultEndpoint(chainA) + endpointB := NewDefaultEndpoint(chainB) + + endpointA.Counterparty = endpointB + endpointB.Counterparty = endpointA + + return &Path{ + EndpointA: endpointA, + EndpointB: endpointB, + } +} + +// SetChannelOrdered sets the channel order for both endpoints to ORDERED. +func (path *Path) SetChannelOrdered() { + path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED + path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED +} + +// RelayPacket attempts to relay the packet first on EndpointA and then on EndpointB +// if EndpointA does not contain a packet commitment for that packet. An error is returned +// if a relay step fails or the packet commitment does not exist on either endpoint. +func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error { + pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) { + + // packet found, relay from A to B + if err := path.EndpointB.UpdateClient(); err != nil { + return err + } + + if err := path.EndpointB.RecvPacket(packet); err != nil { + return err + } + + if err := path.EndpointA.AcknowledgePacket(packet, ack); err != nil { + return err + } + return nil + + } + + pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointB.Chain.App.AppCodec(), packet)) { + + // packet found, relay B to A + if err := path.EndpointA.UpdateClient(); err != nil { + return err + } + + if err := path.EndpointA.RecvPacket(packet); err != nil { + return err + } + if err := path.EndpointB.AcknowledgePacket(packet, ack); err != nil { + return err + } + return nil + } + + return fmt.Errorf("packet commitment does not exist on either endpoint for provided packet") +} + +// SendMsg delivers the provided messages to the chain. The counterparty +// client is updated with the new source consensus state. +func (path *Path) SendMsg(msgs ...sdk.Msg) error { + if err := path.EndpointA.Chain.sendMsgs(msgs...); err != nil { + return err + } + if err := path.EndpointA.UpdateClient(); err != nil { + return err + } + return path.EndpointB.UpdateClient() +} + +func (path *Path) Invert() *Path { + return &Path{ + EndpointA: path.EndpointB, + EndpointB: path.EndpointA, + } +} diff --git a/x/wasm/ibctesting/wasm.go b/x/wasm/ibctesting/wasm.go index b752b246..4b661be1 100644 --- a/x/wasm/ibctesting/wasm.go +++ b/x/wasm/ibctesting/wasm.go @@ -8,13 +8,16 @@ import ( "io/ioutil" "strings" + wasmd "github.com/CosmWasm/wasmd/app" + + ibctesting "github.com/cosmos/ibc-go/v2/testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/protobuf/proto" //nolint "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/rand" - wasmd "github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -71,7 +74,7 @@ func (chain *TestChain) InstantiateContract(codeID uint64, initMsg []byte) sdk.A CodeID: codeID, Label: "ibc-test", Msg: initMsg, - Funds: sdk.Coins{TestCoin}, + Funds: sdk.Coins{ibctesting.TestCoin}, } r, err := chain.SendMsgs(instantiateMsg) @@ -132,10 +135,8 @@ func (chain *TestChain) parseSDKResultData(r *sdk.Result) sdk.TxMsgData { // ContractInfo is a helper function to returns the ContractInfo for the given contract address func (chain *TestChain) ContractInfo(contractAddr sdk.AccAddress) *types.ContractInfo { - return chain.TestSupport().WasmKeeper().GetContractInfo(chain.GetContext(), contractAddr) -} - -// TestSupport provides access to package private keepers. -func (chain *TestChain) TestSupport() *wasmd.TestSupport { - return wasmd.NewTestSupport(chain.t, chain.App) + type testSupporter interface { + TestSupport() *wasmd.TestSupport + } + return chain.App.(testSupporter).TestSupport().WasmKeeper().GetContractInfo(chain.GetContext(), contractAddr) } diff --git a/x/wasm/keeper/api.go b/x/wasm/keeper/api.go index 4d47cce7..3b39b34d 100644 --- a/x/wasm/keeper/api.go +++ b/x/wasm/keeper/api.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,8 +26,8 @@ var ( ) func humanAddress(canon []byte) (string, uint64, error) { - if len(canon) != sdk.AddrLen { - return "", costHumanize, fmt.Errorf("expected %d byte address", sdk.AddrLen) + if err := sdk.VerifyAddressFormat(canon); err != nil { + return "", costHumanize, err } return sdk.AccAddress(canon).String(), costHumanize, nil } diff --git a/x/wasm/keeper/genesis_test.go b/x/wasm/keeper/genesis_test.go index 70184fc7..d51dbb29 100644 --- a/x/wasm/keeper/genesis_test.go +++ b/x/wasm/keeper/genesis_test.go @@ -474,7 +474,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { ], "contracts": [ { - "contract_address": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", + "contract_address": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "contract_info": { "code_id": "1", "creator": "cosmos13x849jzd03vne42ynpj25hn8npjecxqrjghd8x", @@ -484,8 +484,8 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { } ], "sequences": [ - {"id_key": %q, "value": "2"}, - {"id_key": %q, "value": "2"} + {"id_key": "BGxhc3RDb2RlSWQ=", "value": "2"}, + {"id_key": "BGxhc3RDb250cmFjdElk", "value": "3"} ] }` keeper, ctx, _ := setupKeeper(t) @@ -496,9 +496,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { wasmCodeHash := sha256.Sum256(wasmCode) enc64 := base64.StdEncoding.EncodeToString - genesisStr := fmt.Sprintf(genesisTemplate, enc64(wasmCodeHash[:]), enc64(wasmCode), - enc64(append([]byte{0x04}, []byte("lastCodeId")...)), - enc64(append([]byte{0x04}, []byte("lastContractId")...))) + genesisStr := fmt.Sprintf(genesisTemplate, enc64(wasmCodeHash[:]), enc64(wasmCode)) var importState wasmTypes.GenesisState err = keeper.cdc.UnmarshalJSON([]byte(genesisStr), &importState) @@ -531,7 +529,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { assert.Equal(t, expCodeInfo, *gotCodeInfo) // verify contract - contractAddr, _ := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6") + contractAddr, _ := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr") gotContractInfo := keeper.GetContractInfo(ctx, contractAddr) require.NotNil(t, gotContractInfo) contractCreatorAddr := "cosmos13x849jzd03vne42ynpj25hn8npjecxqrjghd8x" @@ -553,15 +551,17 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { }, } assert.Equal(t, expHistory, keeper.GetContractHistory(ctx, contractAddr)) + assert.Equal(t, uint64(2), keeper.PeekAutoIncrementID(ctx, types.KeyLastCodeID)) + assert.Equal(t, uint64(3), keeper.PeekAutoIncrementID(ctx, types.KeyLastInstanceID)) } func TestSupportedGenMsgTypes(t *testing.T) { wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) var ( - myAddress sdk.AccAddress = bytes.Repeat([]byte{1}, sdk.AddrLen) - verifierAddress sdk.AccAddress = bytes.Repeat([]byte{2}, sdk.AddrLen) - beneficiaryAddress sdk.AccAddress = bytes.Repeat([]byte{3}, sdk.AddrLen) + myAddress sdk.AccAddress = bytes.Repeat([]byte{1}, types.ContractAddrLen) + verifierAddress sdk.AccAddress = bytes.Repeat([]byte{2}, types.ContractAddrLen) + beneficiaryAddress sdk.AccAddress = bytes.Repeat([]byte{3}, types.ContractAddrLen) ) const denom = "stake" importState := types.GenesisState{ @@ -604,7 +604,8 @@ func TestSupportedGenMsgTypes(t *testing.T) { ctx, keepers := CreateDefaultTestInput(t) keeper := keepers.WasmKeeper ctx = ctx.WithBlockHeight(0).WithGasMeter(sdk.NewInfiniteGasMeter()) - fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, myAddress, sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(100)))) + keepers.Faucet.Fund(ctx, myAddress, sdk.NewCoin(denom, sdk.NewInt(100))) + // when _, err = InitGenesis(ctx, keeper, importState, &StakingKeeperMock{}, TestHandler(keepers.ContractKeeper)) require.NoError(t, err) @@ -660,7 +661,7 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { wasmConfig := wasmTypes.DefaultWasmConfig() pk := paramskeeper.NewKeeper(encodingConfig.Marshaler, encodingConfig.Amino, keyParams, tkeyParams) - srcKeeper := NewKeeper(encodingConfig.Marshaler, keyWasm, pk.Subspace(wasmTypes.DefaultParamspace), authkeeper.AccountKeeper{}, nil, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, tempDir, wasmConfig, SupportedFeatures) + srcKeeper := NewKeeper(encodingConfig.Marshaler, keyWasm, pk.Subspace(wasmTypes.ModuleName), authkeeper.AccountKeeper{}, nil, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, tempDir, wasmConfig, SupportedFeatures) return &srcKeeper, ctx, []sdk.StoreKey{keyWasm, keyParams} } diff --git a/x/wasm/keeper/handler_plugin.go b/x/wasm/keeper/handler_plugin.go index 6798d3cb..c506400a 100644 --- a/x/wasm/keeper/handler_plugin.go +++ b/x/wasm/keeper/handler_plugin.go @@ -5,11 +5,12 @@ import ( "fmt" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + "github.com/cosmos/cosmos-sdk/baseapp" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -20,14 +21,19 @@ type msgEncoder interface { Encode(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) } +// MessageRouter ADR 031 request type routing +type MessageRouter interface { + Handler(msg sdk.Msg) baseapp.MsgServiceHandler +} + // SDKMessageHandler can handles messages that can be encoded into sdk.Message types and routed. type SDKMessageHandler struct { - router sdk.Router + router MessageRouter encoders msgEncoder } func NewDefaultMessageHandler( - router sdk.Router, + router MessageRouter, channelKeeper types.ChannelKeeper, capabilityKeeper types.CapabilityKeeper, bankKeeper types.Burner, @@ -46,7 +52,7 @@ func NewDefaultMessageHandler( ) } -func NewSDKMessageHandler(router sdk.Router, encoders msgEncoder) SDKMessageHandler { +func NewSDKMessageHandler(router MessageRouter, encoders msgEncoder) SDKMessageHandler { return SDKMessageHandler{ router: router, encoders: encoders, @@ -87,15 +93,17 @@ func (h SDKMessageHandler) handleSdkMessage(ctx sdk.Context, contractAddr sdk.Ad } // find the handler and execute it - handler := h.router.Route(ctx, msg.Route()) - if handler == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, msg.Route()) + if handler := h.router.Handler(msg); handler != nil { + // ADR 031 request type routing + msgResult, err := handler(ctx, msg) + return msgResult, err } - res, err := handler(ctx, msg) - if err != nil { - return nil, err - } - return res, nil + // legacy sdk.Msg routing + // Assuming that the app developer has migrated all their Msgs to + // proto messages and has registered all `Msg services`, then this + // path should never be called, because all those Msgs should be + // registered within the `msgServiceRouter` already. + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg) } // MessageHandlerChain defines a chain of handlers that are called one by one until it can be handled. diff --git a/x/wasm/keeper/handler_plugin_encoders.go b/x/wasm/keeper/handler_plugin_encoders.go index 69bb5959..24d98ee9 100644 --- a/x/wasm/keeper/handler_plugin_encoders.go +++ b/x/wasm/keeper/handler_plugin_encoders.go @@ -11,10 +11,10 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - ibcclienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + ibcclienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/keeper/handler_plugin_encoders_test.go b/x/wasm/keeper/handler_plugin_encoders_test.go index 518a7a9c..0060a886 100644 --- a/x/wasm/keeper/handler_plugin_encoders_test.go +++ b/x/wasm/keeper/handler_plugin_encoders_test.go @@ -5,9 +5,9 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/golang/protobuf/proto" "github.com/stretchr/testify/assert" @@ -29,9 +29,9 @@ func TestEncoding(t *testing.T) { addr3 = RandomAccountAddress(t) invalidAddr = "xrnd1d02kd90n38qvr3qb9qof83fn2d2" ) - valAddr := make(sdk.ValAddress, sdk.AddrLen) + valAddr := make(sdk.ValAddress, types.SDKAddrLen) valAddr[0] = 12 - valAddr2 := make(sdk.ValAddress, sdk.AddrLen) + valAddr2 := make(sdk.ValAddress, types.SDKAddrLen) valAddr2[1] = 123 jsonMsg := types.RawContractMessage(`{"foo": 123}`) diff --git a/x/wasm/keeper/handler_plugin_test.go b/x/wasm/keeper/handler_plugin_test.go index e54517f6..2b9e59f0 100644 --- a/x/wasm/keeper/handler_plugin_test.go +++ b/x/wasm/keeper/handler_plugin_test.go @@ -11,9 +11,9 @@ import ( 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" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -100,22 +100,26 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { } var gotMsg []sdk.Msg - capturingRouteFn := func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - gotMsg = append(gotMsg, msg) - return &myRouterResult, nil - } - + capturingMessageRouter := wasmtesting.MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler { + return func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) { + gotMsg = append(gotMsg, msg) + return &myRouterResult, nil + } + }) + noRouteMessageRouter := wasmtesting.MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler { + return nil + }) myContractAddr := RandomAccountAddress(t) myContractMessage := wasmvmtypes.CosmosMsg{Custom: []byte("{}")} specs := map[string]struct { - srcRoute sdk.Route + srcRoute MessageRouter srcEncoder CustomEncoder expErr *sdkerrors.Error expMsgDispatched int }{ "all good": { - srcRoute: sdk.NewRoute(types.RouterKey, capturingRouteFn), + srcRoute: capturingMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { myMsg := types.MsgExecuteContract{ Sender: myContractAddr.String(), @@ -127,7 +131,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { expMsgDispatched: 1, }, "multiple output msgs": { - srcRoute: sdk.NewRoute(types.RouterKey, capturingRouteFn), + srcRoute: capturingMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { first := &types.MsgExecuteContract{ Sender: myContractAddr.String(), @@ -144,7 +148,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { expMsgDispatched: 2, }, "invalid sdk message rejected": { - srcRoute: sdk.NewRoute(types.RouterKey, capturingRouteFn), + srcRoute: capturingMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { invalidMsg := types.MsgExecuteContract{ Sender: myContractAddr.String(), @@ -156,7 +160,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { expErr: types.ErrInvalid, }, "invalid sender rejected": { - srcRoute: sdk.NewRoute(types.RouterKey, capturingRouteFn), + srcRoute: capturingMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { invalidMsg := types.MsgExecuteContract{ Sender: RandomBech32AccountAddress(t), @@ -168,7 +172,7 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { expErr: sdkerrors.ErrUnauthorized, }, "unroutable message rejected": { - srcRoute: sdk.NewRoute("nothing", capturingRouteFn), + srcRoute: noRouteMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { myMsg := types.MsgExecuteContract{ Sender: myContractAddr.String(), @@ -180,9 +184,9 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { expErr: sdkerrors.ErrUnknownRequest, }, "encoding error passed": { - srcRoute: sdk.NewRoute("nothing", capturingRouteFn), + srcRoute: capturingMessageRouter, srcEncoder: func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { - myErr := types.ErrUnpinContractFailed + myErr := types.ErrUnpinContractFailed // any error that is not used return nil, myErr }, expErr: types.ErrUnpinContractFailed, @@ -191,12 +195,10 @@ func TestSDKMessageHandlerDispatch(t *testing.T) { for name, spec := range specs { t.Run(name, func(t *testing.T) { gotMsg = make([]sdk.Msg, 0) - router := baseapp.NewRouter() - router.AddRoute(spec.srcRoute) // when ctx := sdk.Context{} - h := NewSDKMessageHandler(router, MessageEncoders{Custom: spec.srcEncoder}) + h := NewSDKMessageHandler(spec.srcRoute, MessageEncoders{Custom: spec.srcEncoder}) gotEvents, gotData, gotErr := h.DispatchMsg(ctx, myContractAddr, "myPort", myContractMessage) // then @@ -316,11 +318,14 @@ func TestBurnCoinMessageHandlerIntegration(t *testing.T) { // module permissions are set correct and no other handler // picks the message in the default handler chain ctx, keepers := CreateDefaultTestInput(t) + // set some supply + keepers.Faucet.NewFundedAccount(ctx, sdk.NewCoin("denom", sdk.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{}) require.NoError(t, err) - example := InstantiateHackatomExampleContract(t, ctx, keepers) // with deposit of 100 stake specs := map[string]struct { msg wasmvmtypes.BurnMsg diff --git a/x/wasm/keeper/ibc.go b/x/wasm/keeper/ibc.go index d99bafa6..5d52d72a 100644 --- a/x/wasm/keeper/ibc.go +++ b/x/wasm/keeper/ibc.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + host "github.com/cosmos/ibc-go/v2/modules/core/24-host" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 702b0227..eca80ef9 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -2,7 +2,6 @@ package keeper import ( "bytes" - "crypto/sha256" "encoding/binary" "fmt" "math" @@ -11,6 +10,8 @@ import ( "strings" "time" + "github.com/cosmos/cosmos-sdk/types/address" + wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cosmos/cosmos-sdk/codec" @@ -59,7 +60,7 @@ type WasmVMResponseHandler interface { // Keeper will have a reference to Wasmer with it's own data directory. type Keeper struct { storeKey sdk.StoreKey - cdc codec.Marshaler + cdc codec.Codec accountKeeper types.AccountKeeper bank CoinTransferrer portKeeper types.PortKeeper @@ -77,7 +78,7 @@ type Keeper struct { // NewKeeper creates a new contract Keeper instance // If customEncoders is non-nil, we can use this to override some of the message handler, especially custom func NewKeeper( - cdc codec.Marshaler, + cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, accountKeeper types.AccountKeeper, @@ -88,7 +89,7 @@ func NewKeeper( portKeeper types.PortKeeper, capabilityKeeper types.CapabilityKeeper, portSource types.ICS20TransferPortSource, - router sdk.Router, + router MessageRouter, queryRouter GRPCQueryRouter, homeDir string, wasmConfig types.WasmConfig, @@ -201,7 +202,7 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, func (k Keeper) storeCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo) { store := ctx.KVStore(k.storeKey) // 0x01 | codeID (uint64) -> ContractInfo - store.Set(types.GetCodeKey(codeID), k.cdc.MustMarshalBinaryBare(&codeInfo)) + store.Set(types.GetCodeKey(codeID), k.cdc.MustMarshal(&codeInfo)) } func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo, wasmCode []byte) error { @@ -223,7 +224,7 @@ func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeIn return sdkerrors.Wrapf(types.ErrDuplicate, "duplicate code: %d", codeID) } // 0x01 | codeID (uint64) -> ContractInfo - store.Set(key, k.cdc.MustMarshalBinaryBare(&codeInfo)) + store.Set(key, k.cdc.MustMarshal(&codeInfo)) return nil } @@ -260,7 +261,7 @@ func (k Keeper) instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.A return nil, nil, sdkerrors.Wrap(types.ErrNotFound, "code") } var codeInfo types.CodeInfo - k.cdc.MustUnmarshalBinaryBare(bz, &codeInfo) + k.cdc.MustUnmarshal(bz, &codeInfo) if !authZ.CanInstantiateContract(codeInfo.InstantiateConfig, creator) { return nil, nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not instantiate") @@ -556,7 +557,7 @@ 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.MustMarshalBinaryBare(&e)) //nolint:gosec + store.Set(key, k.cdc.MustMarshal(&e)) //nolint:gosec } } @@ -566,7 +567,7 @@ func (k Keeper) GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) iter := prefixStore.Iterator(nil, nil) for ; iter.Valid(); iter.Next() { var e types.ContractCodeHistoryEntry - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &e) + k.cdc.MustUnmarshal(iter.Value(), &e) r = append(r, e) } return r @@ -581,7 +582,7 @@ func (k Keeper) getLastContractHistoryEntry(ctx sdk.Context, contractAddr sdk.Ac // all contracts have a history panic(fmt.Sprintf("no history for %s", contractAddr.String())) } - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &r) + k.cdc.MustUnmarshal(iter.Value(), &r) return r } @@ -627,14 +628,14 @@ func (k Keeper) contractInstance(ctx sdk.Context, contractAddress sdk.AccAddress return types.ContractInfo{}, types.CodeInfo{}, prefix.Store{}, sdkerrors.Wrap(types.ErrNotFound, "contract") } var contractInfo types.ContractInfo - k.cdc.MustUnmarshalBinaryBare(contractBz, &contractInfo) + k.cdc.MustUnmarshal(contractBz, &contractInfo) codeInfoBz := store.Get(types.GetCodeKey(contractInfo.CodeID)) if codeInfoBz == nil { return contractInfo, types.CodeInfo{}, prefix.Store{}, sdkerrors.Wrap(types.ErrNotFound, "code info") } var codeInfo types.CodeInfo - k.cdc.MustUnmarshalBinaryBare(codeInfoBz, &codeInfo) + k.cdc.MustUnmarshal(codeInfoBz, &codeInfo) prefixStoreKey := types.GetContractStorePrefix(contractAddress) prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) return contractInfo, codeInfo, prefixStore, nil @@ -647,7 +648,7 @@ func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) if contractBz == nil { return nil } - k.cdc.MustUnmarshalBinaryBare(contractBz, &contract) + k.cdc.MustUnmarshal(contractBz, &contract) return &contract } @@ -659,7 +660,7 @@ func (k Keeper) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) // 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.MustMarshalBinaryBare(contract)) + store.Set(types.GetContractAddressKey(contractAddress), k.cdc.MustMarshal(contract)) } func (k Keeper) IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) { @@ -667,7 +668,7 @@ func (k Keeper) IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, typ iter := prefixStore.Iterator(nil, nil) for ; iter.Valid(); iter.Next() { var contract types.ContractInfo - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &contract) + k.cdc.MustUnmarshal(iter.Value(), &contract) // cb returns true to stop early if cb(iter.Key(), contract) { break @@ -703,7 +704,7 @@ func (k Keeper) GetCodeInfo(ctx sdk.Context, codeID uint64) *types.CodeInfo { if codeInfoBz == nil { return nil } - k.cdc.MustUnmarshalBinaryBare(codeInfoBz, &codeInfo) + k.cdc.MustUnmarshal(codeInfoBz, &codeInfo) return &codeInfo } @@ -717,7 +718,7 @@ func (k Keeper) IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo iter := prefixStore.Iterator(nil, nil) for ; iter.Valid(); iter.Next() { var c types.CodeInfo - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &c) + k.cdc.MustUnmarshal(iter.Value(), &c) // cb returns true to stop early if cb(binary.BigEndian.Uint64(iter.Key()), c) { return @@ -732,7 +733,7 @@ func (k Keeper) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error) { if codeInfoBz == nil { return nil, nil } - k.cdc.MustUnmarshalBinaryBare(codeInfoBz, &codeInfo) + k.cdc.MustUnmarshal(codeInfoBz, &codeInfo) return k.wasmVM.GetCode(codeInfo.CodeHash) } @@ -873,42 +874,7 @@ func BuildContractAddress(codeID, instanceID uint64) sdk.AccAddress { contractID := make([]byte, 16) binary.BigEndian.PutUint64(contractID[:8], codeID) binary.BigEndian.PutUint64(contractID[8:], instanceID) - // 20 bytes to work with Cosmos SDK 0.42 (0.43 pushes for 32 bytes) - // TODO: remove truncate if we update to 0.43 before wasmd 1.0 - return Module(types.ModuleName, contractID)[:20] -} - -// Hash and Module is taken from https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-rc2/types/address/hash.go -// (PR #9088 included in Cosmos SDK 0.43 - can be swapped out for the sdk version when we upgrade) - -// Hash creates a new address from address type and key -func Hash(typ string, key []byte) []byte { - hasher := sha256.New() - _, err := hasher.Write([]byte(typ)) - // the error always nil, it's here only to satisfy the io.Writer interface - assertNil(err) - th := hasher.Sum(nil) - - hasher.Reset() - _, err = hasher.Write(th) - assertNil(err) - _, err = hasher.Write(key) - assertNil(err) - return hasher.Sum(nil) -} - -// Module is a specialized version of a composed address for modules. Each module account -// is constructed from a module name and module account key. -func Module(moduleName string, key []byte) []byte { - mKey := append([]byte(moduleName), 0) - return Hash("module", append(mKey, key...)) -} - -// Also from the 0.43 Cosmos SDK... sigh (sdkerrors.AssertNil) -func assertNil(err error) { - if err != nil { - panic(fmt.Errorf("logic error - this should never happen. %w", err)) - } + return address.Module(types.ModuleName, contractID)[:types.ContractAddrLen] } func (k Keeper) autoIncrementID(ctx sdk.Context, lastIDKey []byte) uint64 { @@ -1016,16 +982,17 @@ func NewBankCoinTransferrer(keeper types.BankKeeper) BankCoinTransferrer { // TransferCoins transfers coins from source to destination account when coin send was enabled for them and the recipient // is not in the blocked address list. -func (c BankCoinTransferrer) TransferCoins(parentCtx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (c BankCoinTransferrer) TransferCoins(parentCtx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amount sdk.Coins) error { em := sdk.NewEventManager() ctx := parentCtx.WithEventManager(em) - if err := c.keeper.SendEnabledCoins(ctx, amt...); err != nil { + if err := c.keeper.IsSendEnabledCoins(ctx, amount...); err != nil { return err } - if c.keeper.BlockedAddr(fromAddr) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "blocked address can not be used") + if c.keeper.BlockedAddr(toAddr) { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", toAddr.String()) } - sdkerr := c.keeper.SendCoins(ctx, fromAddr, toAddr, amt) + + sdkerr := c.keeper.SendCoins(ctx, fromAddr, toAddr, amount) if sdkerr != nil { return sdkerr } diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 18f1c000..d7443f66 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" @@ -47,10 +49,10 @@ func TestNewKeeper(t *testing.T) { func TestCreateSuccess(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) em := sdk.NewEventManager() contractID, err := keeper.Create(ctx.WithEventManager(em), creator, hackatomWasm, nil) @@ -75,7 +77,7 @@ func TestCreateNilCreatorAddress(t *testing.T) { func TestCreateNilWasmCode(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, err := keepers.ContractKeeper.Create(ctx, creator, nil, nil) require.Error(t, err, "nil WASM code is not allowed") @@ -84,7 +86,7 @@ func TestCreateNilWasmCode(t *testing.T) { func TestCreateInvalidWasmCode(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, err := keepers.ContractKeeper.Create(ctx, creator, []byte("potatoes"), nil) require.Error(t, err, "potatoes are not valid WASM code") @@ -93,7 +95,7 @@ func TestCreateInvalidWasmCode(t *testing.T) { func TestCreateStoresInstantiatePermission(t *testing.T) { var ( deposit = sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - myAddr sdk.AccAddress = bytes.Repeat([]byte{1}, sdk.AddrLen) + myAddr sdk.AccAddress = bytes.Repeat([]byte{1}, types.SDKAddrLen) ) specs := map[string]struct { @@ -140,11 +142,11 @@ func TestCreateStoresInstantiatePermission(t *testing.T) { func TestCreateWithParamPermissions(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, bankKeeper, keeper := keepers.AccountKeeper, keepers.BankKeeper, keepers.ContractKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) - otherAddr := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) + otherAddr := keepers.Faucet.NewFundedAccount(ctx, deposit...) specs := map[string]struct { srcPermission types.AccessConfig @@ -184,10 +186,10 @@ func TestCreateWithParamPermissions(t *testing.T) { func TestCreateDuplicate(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // create one copy contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) @@ -210,23 +212,24 @@ func TestCreateDuplicate(t *testing.T) { func TestCreateWithSimulation(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper ctx = ctx.WithBlockHeader(tmproto.Header{Height: 1}). WithGasMeter(stypes.NewInfiniteGasMeter()) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // create this once in simulation mode - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, err := keepers.ContractKeeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) require.Equal(t, uint64(1), contractID) // then try to create it in non-simulation mode (should not fail) ctx, keepers = CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper = keepers.AccountKeeper, keepers.ContractKeeper - contractID, err = keeper.Create(ctx, creator, hackatomWasm, nil) + ctx = ctx.WithGasMeter(sdk.NewGasMeter(10_000_000)) + creator = keepers.Faucet.NewFundedAccount(ctx, deposit...) + contractID, err = keepers.ContractKeeper.Create(ctx, creator, hackatomWasm, nil) + require.NoError(t, err) require.Equal(t, uint64(1), contractID) @@ -263,10 +266,10 @@ func TestIsSimulationMode(t *testing.T) { func TestCreateWithGzippedPayload(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm.gzip") require.NoError(t, err, "reading gzipped WASM code") @@ -282,10 +285,10 @@ func TestCreateWithGzippedPayload(t *testing.T) { func TestInstantiate(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) codeID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -306,11 +309,11 @@ func TestInstantiate(t *testing.T) { // create with no balance is also legal gotContractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), codeID, creator, nil, initMsgBz, "demo contract 1", nil) require.NoError(t, err) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", gotContractAddr.String()) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", gotContractAddr.String()) gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x16e8a), gasAfter-gasBefore) + require.Equal(t, uint64(0x18dab), gasAfter-gasBefore) } // ensure it is stored properly @@ -340,8 +343,8 @@ func TestInstantiate(t *testing.T) { func TestInstantiateWithDeposit(t *testing.T) { var ( - bob = bytes.Repeat([]byte{1}, sdk.AddrLen) - fred = bytes.Repeat([]byte{2}, sdk.AddrLen) + bob = bytes.Repeat([]byte{1}, types.SDKAddrLen) + fred = bytes.Repeat([]byte{2}, types.SDKAddrLen) deposit = sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) initMsg = HackatomExampleInitMsg{Verifier: fred, Beneficiary: bob} @@ -366,7 +369,7 @@ func TestInstantiateWithDeposit(t *testing.T) { "blocked address": { srcActor: authtypes.NewModuleAddress(authtypes.FeeCollectorName), fundAddr: true, - expError: true, + expError: false, }, } for msg, spec := range specs { @@ -397,9 +400,9 @@ func TestInstantiateWithDeposit(t *testing.T) { func TestInstantiateWithPermissions(t *testing.T) { var ( deposit = sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - myAddr = bytes.Repeat([]byte{1}, sdk.AddrLen) - otherAddr = bytes.Repeat([]byte{2}, sdk.AddrLen) - anyAddr = bytes.Repeat([]byte{3}, sdk.AddrLen) + myAddr = bytes.Repeat([]byte{1}, types.SDKAddrLen) + otherAddr = bytes.Repeat([]byte{2}, types.SDKAddrLen) + anyAddr = bytes.Repeat([]byte{3}, types.SDKAddrLen) ) initMsg := HackatomExampleInitMsg{ @@ -453,10 +456,9 @@ func TestInstantiateWithPermissions(t *testing.T) { func TestInstantiateWithNonExistingCodeID(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, bankKeeper := keepers.AccountKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) initMsg := HackatomExampleInitMsg{} initMsgBz, err := json.Marshal(initMsg) @@ -491,8 +493,8 @@ func TestExecute(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -507,7 +509,7 @@ func TestExecute(t *testing.T) { addr, _, err := keepers.ContractKeeper.Instantiate(ctx, contractID, creator, nil, initMsgBz, "demo contract 3", deposit) require.NoError(t, err) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", addr.String()) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", addr.String()) // ensure bob doesn't exist bobAcct := accKeeper.GetAccount(ctx, bob) @@ -544,7 +546,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(0x17621), gasAfter-gasBefore) + require.Equal(t, uint64(0x17cd2), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) @@ -555,22 +557,22 @@ func TestExecute(t *testing.T) { // ensure contract has updated balance contractAcct = accKeeper.GetAccount(ctx, addr) require.NotNil(t, contractAcct) - assert.Equal(t, sdk.Coins(nil), bankKeeper.GetAllBalances(ctx, contractAcct.GetAddress())) + assert.Equal(t, sdk.Coins{}, bankKeeper.GetAllBalances(ctx, contractAcct.GetAddress())) // and events emitted - require.Len(t, em.Events(), 5) + require.Len(t, em.Events(), 9) expEvt := sdk.NewEvent("execute", sdk.NewAttribute("_contract_address", addr.String())) - assert.Equal(t, expEvt, em.Events()[1]) + assert.Equal(t, expEvt, em.Events()[3], prettyEvents(t, em.Events())) t.Logf("Duration: %v (%d gas)\n", diff, gasAfter-gasBefore) } func TestExecuteWithDeposit(t *testing.T) { var ( - bob = bytes.Repeat([]byte{1}, sdk.AddrLen) - fred = bytes.Repeat([]byte{2}, sdk.AddrLen) - blockedAddr = authtypes.NewModuleAddress(authtypes.FeeCollectorName) + bob = bytes.Repeat([]byte{1}, types.SDKAddrLen) + fred = bytes.Repeat([]byte{2}, types.SDKAddrLen) + blockedAddr = authtypes.NewModuleAddress(distributiontypes.ModuleName) deposit = sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) ) @@ -595,7 +597,7 @@ func TestExecuteWithDeposit(t *testing.T) { srcActor: blockedAddr, fundAddr: true, beneficiary: fred, - expError: true, + expError: false, }, "coin transfer with all transfers disabled": { srcActor: bob, @@ -658,10 +660,10 @@ func TestExecuteWithDeposit(t *testing.T) { func TestExecuteWithNonExistingAddress(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) // unauthorized - trialCtx so we don't change state nonExistingAddress := RandomAccountAddress(t) @@ -671,12 +673,12 @@ func TestExecuteWithNonExistingAddress(t *testing.T) { func TestExecuteWithPanic(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -702,12 +704,12 @@ func TestExecuteWithPanic(t *testing.T) { func TestExecuteWithCpuLoop(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -744,12 +746,12 @@ func TestExecuteWithCpuLoop(t *testing.T) { func TestExecuteWithStorageLoop(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -785,12 +787,12 @@ func TestExecuteWithStorageLoop(t *testing.T) { func TestMigrate(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) originalCodeID := StoreHackatomExampleContract(t, ctx, keepers).CodeID newCodeID := StoreHackatomExampleContract(t, ctx, keepers).CodeID @@ -1000,11 +1002,11 @@ func TestMigrateReplacesTheSecondIndex(t *testing.T) { func TestMigrateWithDispatchedMessage(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, sdk.NewCoins(sdk.NewInt64Coin("denom", 5000))) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, sdk.NewInt64Coin("denom", 5000)) burnerCode, err := ioutil.ReadFile("./testdata/burner.wasm") require.NoError(t, err) @@ -1048,6 +1050,20 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { {"payout": myPayoutAddr}, }, }, + { + "Type": "coin_spent", + "Attr": []dict{ + {"spender": contractAddr}, + {"amount": "100000denom"}, + }, + }, + { + "Type": "coin_received", + "Attr": []dict{ + {"receiver": myPayoutAddr}, + {"amount": "100000denom"}, + }, + }, { "Type": "transfer", "Attr": []dict{ @@ -1065,7 +1081,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { require.Len(t, m, 0) // and all deposit tokens sent to myPayoutAddr - balance := bankKeeper.GetAllBalances(ctx, myPayoutAddr) + balance := keepers.BankKeeper.GetAllBalances(ctx, myPayoutAddr) assert.Equal(t, deposit, balance) } @@ -1159,7 +1175,7 @@ func TestSudo(t *testing.T) { accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -1174,7 +1190,7 @@ func TestSudo(t *testing.T) { require.NoError(t, err) addr, _, err := keepers.ContractKeeper.Instantiate(ctx, contractID, creator, nil, initMsgBz, "demo contract 3", deposit) require.NoError(t, err) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", addr.String()) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", addr.String()) // the community is broke _, _, community := keyPubAddr() @@ -1206,7 +1222,7 @@ func TestSudo(t *testing.T) { balance := bankKeeper.GetBalance(ctx, comAcct.GetAddress(), "denom") assert.Equal(t, sdk.NewInt64Coin("denom", 76543), balance) // and events emitted - require.Len(t, em.Events(), 2) + require.Len(t, em.Events(), 4, prettyEvents(t, em.Events())) expEvt := sdk.NewEvent("sudo", sdk.NewAttribute("_contract_address", addr.String())) assert.Equal(t, expEvt, em.Events()[0]) @@ -1240,12 +1256,12 @@ func mustMarshal(t *testing.T, r interface{}) []byte { func TestUpdateContractAdmin(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -1308,12 +1324,12 @@ func TestUpdateContractAdmin(t *testing.T) { func TestClearContractAdmin(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) @@ -1461,17 +1477,18 @@ func TestInitializePinnedCodes(t *testing.T) { } func TestPinnedContractLoops(t *testing.T) { - // a pinned contract that calls itself via submessages should terminate with an - // error at some point - ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - k := keepers.WasmKeeper - var capturedChecksums []wasmvm.Checksum mock := wasmtesting.MockWasmer{PinFn: func(checksum wasmvm.Checksum) error { capturedChecksums = append(capturedChecksums, checksum) return nil }} wasmtesting.MakeInstantiable(&mock) + + // a pinned contract that calls itself via submessages should terminate with an + // error at some point + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, WithWasmEngine(&mock)) + k := keepers.WasmKeeper + example := SeedNewContractInstance(t, ctx, keepers, &mock) require.NoError(t, k.pinCode(ctx, example.CodeID)) var loops int @@ -1482,7 +1499,7 @@ func TestPinnedContractLoops(t *testing.T) { Messages: []wasmvmtypes.SubMsg{ { ID: 1, - ReplyOn: wasmvmtypes.ReplyError, + ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{ Wasm: &wasmvmtypes.WasmMsg{ Execute: &wasmvmtypes.ExecuteMsg{ @@ -1497,7 +1514,8 @@ func TestPinnedContractLoops(t *testing.T) { } ctx = ctx.WithGasMeter(sdk.NewGasMeter(20000)) require.PanicsWithValue(t, sdk.ErrorOutOfGas{Descriptor: "ReadFlat"}, func() { - k.execute(ctx, example.Contract, RandomAccountAddress(t), anyMsg, nil) + _, err := k.execute(ctx, example.Contract, RandomAccountAddress(t), anyMsg, nil) + require.NoError(t, err) }) assert.True(t, ctx.GasMeter().IsOutOfGas()) assert.Greater(t, loops, 2) @@ -1612,7 +1630,7 @@ func TestReply(t *testing.T) { Bank: &wasmvmtypes.BankQuery{ Balance: &wasmvmtypes.BalanceQuery{Address: env.Contract.Address, Denom: "stake"}, }, - }, 1000*DefaultGasMultiplier) + }, 10_000*DefaultGasMultiplier) require.NoError(t, err) var gotBankRsp wasmvmtypes.BalanceResponse require.NoError(t, json.Unmarshal(bzRsp, &gotBankRsp)) @@ -1695,12 +1713,12 @@ func TestBuildContractAddress(t *testing.T) { "initial contract": { srcCodeID: 1, srcInstanceID: 1, - expectedAddr: "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", + expectedAddr: "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", }, "demo value": { srcCodeID: 1, srcInstanceID: 100, - expectedAddr: "cosmos1mujpjkwhut9yjw4xueyugc02evfv46y04aervg", + expectedAddr: "cosmos1mujpjkwhut9yjw4xueyugc02evfv46y0dtmnz4lh8xxkkdapym9stu5qm8", }, "both below max": { srcCodeID: math.MaxUint32 - 1, @@ -1713,12 +1731,12 @@ func TestBuildContractAddress(t *testing.T) { "codeID > max u32": { srcCodeID: math.MaxUint32 + 1, srcInstanceID: 17, - expectedAddr: "cosmos1673hrexz4h6s0ft04l96ygq667djzh2nvy7fsu", + expectedAddr: "cosmos1673hrexz4h6s0ft04l96ygq667djzh2nsr335kstjp49x5dk6rpsf5t0le", }, "instanceID > max u32": { srcCodeID: 22, srcInstanceID: math.MaxUint32 + 1, - expectedAddr: "cosmos10q3pgfvmeyy0veekgtqhxujxkhz0vm9z65ckqh", + expectedAddr: "cosmos10q3pgfvmeyy0veekgtqhxujxkhz0vm9zmalqgc7evrhj68q3l62qrdfg4m", }, } for name, spec := range specs { diff --git a/x/wasm/keeper/legacy_querier_test.go b/x/wasm/keeper/legacy_querier_test.go index 3fd0b4ec..e8b15fa8 100644 --- a/x/wasm/keeper/legacy_querier_test.go +++ b/x/wasm/keeper/legacy_querier_test.go @@ -18,12 +18,11 @@ import ( func TestLegacyQueryContractState(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) - anyAddr := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + anyAddr := keepers.Faucet.NewFundedAccount(ctx, sdk.NewInt64Coin("denom", 5000)) wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) @@ -156,12 +155,12 @@ func TestLegacyQueryContractState(t *testing.T) { func TestLegacyQueryContractListByCodeOrdering(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 500)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) - anyAddr := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + anyAddr := keepers.Faucet.NewFundedAccount(ctx, topUp...) wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) @@ -223,7 +222,7 @@ func TestLegacyQueryContractHistory(t *testing.T) { keeper := keepers.WasmKeeper var ( - otherAddr sdk.AccAddress = bytes.Repeat([]byte{0x2}, sdk.AddrLen) + otherAddr sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) ) specs := map[string]struct { diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index d4d513ec..1839f00d 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -76,8 +76,8 @@ func TestInstantiateProposal(t *testing.T) { ) var ( - oneAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, sdk.AddrLen) - otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, sdk.AddrLen) + oneAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, types.ContractAddrLen) + otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) ) src := types.InstantiateContractProposalFixture(func(p *types.InstantiateContractProposal) { p.CodeID = firstCodeID @@ -97,7 +97,7 @@ func TestInstantiateProposal(t *testing.T) { require.NoError(t, err) // then - contractAddr, err := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6") + contractAddr, err := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr") require.NoError(t, err) cInfo := wasmKeeper.GetContractInfo(ctx, contractAddr) @@ -139,8 +139,8 @@ func TestMigrateProposal(t *testing.T) { require.NoError(t, wasmKeeper.importCode(ctx, 2, codeInfoFixture, wasmCode)) var ( - anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, sdk.AddrLen) - otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, sdk.AddrLen) + anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, types.ContractAddrLen) + otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) contractAddr = BuildContractAddress(1, 1) ) @@ -207,7 +207,7 @@ func TestMigrateProposal(t *testing.T) { func TestAdminProposals(t *testing.T) { var ( - otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, sdk.AddrLen) + otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) contractAddr = BuildContractAddress(1, 1) ) wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") @@ -298,7 +298,7 @@ func TestUpdateParamsProposal(t *testing.T) { var ( cdc = keepers.WasmKeeper.cdc - myAddress sdk.AccAddress = make([]byte, sdk.AddrLen) + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) oneAddressAccessConfig = types.AccessTypeOnlyAddress.With(myAddress) ) @@ -311,7 +311,7 @@ func TestUpdateParamsProposal(t *testing.T) { }{ "update upload permission param": { src: proposal.ParamChange{ - Subspace: types.DefaultParamspace, + Subspace: types.ModuleName, Key: string(types.ParamStoreKeyUploadAccess), Value: string(cdc.MustMarshalJSON(&types.AllowNobody)), }, @@ -320,7 +320,7 @@ func TestUpdateParamsProposal(t *testing.T) { }, "update upload permission param with address": { src: proposal.ParamChange{ - Subspace: types.DefaultParamspace, + Subspace: types.ModuleName, Key: string(types.ParamStoreKeyUploadAccess), Value: string(cdc.MustMarshalJSON(&oneAddressAccessConfig)), }, @@ -329,7 +329,7 @@ func TestUpdateParamsProposal(t *testing.T) { }, "update instantiate param": { src: proposal.ParamChange{ - Subspace: types.DefaultParamspace, + Subspace: types.ModuleName, Key: string(types.ParamStoreKeyInstantiateAccess), Value: string(nobodyJson), }, diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index 111bf29c..ae041aec 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -20,14 +20,14 @@ import ( var _ types.QueryServer = &grpcQuerier{} type grpcQuerier struct { - cdc codec.Marshaler + cdc codec.Codec storeKey sdk.StoreKey keeper types.ViewKeeper queryGasLimit sdk.Gas } // NewGrpcQuerier constructor -func NewGrpcQuerier(cdc codec.Marshaler, storeKey sdk.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *grpcQuerier { //nolint:revive +func NewGrpcQuerier(cdc codec.Codec, storeKey sdk.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *grpcQuerier { //nolint:revive return &grpcQuerier{cdc: cdc, storeKey: storeKey, keeper: keeper, queryGasLimit: queryGasLimit} } @@ -65,7 +65,7 @@ func (q grpcQuerier) ContractHistory(c context.Context, req *types.QueryContract pageRes, err := query.FilteredPaginate(prefixStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { if accumulate { var e types.ContractCodeHistoryEntry - if err := q.cdc.UnmarshalBinaryBare(value, &e); err != nil { + if err := q.cdc.Unmarshal(value, &e); err != nil { return false, err } e.Updated = nil // redact @@ -235,7 +235,7 @@ func (q grpcQuerier) Codes(c context.Context, req *types.QueryCodesRequest) (*ty pageRes, err := query.FilteredPaginate(prefixStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { if accumulate { var c types.CodeInfo - if err := q.cdc.UnmarshalBinaryBare(value, &c); err != nil { + if err := q.cdc.Unmarshal(value, &c); err != nil { return false, err } r = append(r, types.CodeInfoResponse{ diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index 35ba039a..12208e2c 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -258,12 +258,12 @@ func TestQueryRawContractState(t *testing.T) { func TestQueryContractListByCodeOrdering(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 500)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) - anyAddr := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) + anyAddr := keepers.Faucet.NewFundedAccount(ctx, topUp...) wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index 4a4e5001..99d8c9af 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -4,7 +4,9 @@ import ( "encoding/json" "fmt" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + "github.com/cosmos/cosmos-sdk/baseapp" + + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/CosmWasm/wasmd/x/wasm/types" @@ -32,14 +34,8 @@ func NewQueryHandler(ctx sdk.Context, vmQueryHandler WasmVMQueryHandler, caller } } -// -- interfaces from baseapp - so we can use the GPRQueryRouter -- - -// GRPCQueryHandler defines a function type which handles ABCI Query requests -// using gRPC -type GRPCQueryHandler = func(ctx sdk.Context, req abci.RequestQuery) (abci.ResponseQuery, error) - type GRPCQueryRouter interface { - Route(path string) GRPCQueryHandler + Route(path string) baseapp.GRPCQueryHandler } // -- end baseapp interfaces -- diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index f4bad933..a760cb22 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -7,7 +7,7 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index b2e6a68e..2d605207 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -53,12 +53,12 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc func TestGasCostOnQuery(t *testing.T) { const ( - GasNoWork uint64 = 63_787 + GasNoWork uint64 = 63_958 // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork50 uint64 = 64_268 // this is a little shy of 50k gas - to keep an eye on the limit + GasWork50 uint64 = 64_401 // this is a little shy of 50k gas - to keep an eye on the limit - GasReturnUnhashed uint64 = 28 - GasReturnHashed uint64 = 24 + GasReturnUnhashed uint64 = 33 + GasReturnHashed uint64 = 25 ) cases := map[string]struct { @@ -103,7 +103,7 @@ func TestGasCostOnQuery(t *testing.T) { }, } - contractAddr, creator, ctx, keeper := initRecurseContract(t) + contractAddr, _, ctx, keeper := initRecurseContract(t) for name, tc := range cases { t.Run(name, func(t *testing.T) { @@ -130,9 +130,9 @@ func TestGasCostOnQuery(t *testing.T) { err = json.Unmarshal(data, &resp) require.NoError(t, err) if recurse.Work == 0 { - assert.Equal(t, len(resp.Hashed), len(creator.String())) + assert.Equal(t, len(contractAddr.String()), len(resp.Hashed)) } else { - assert.Equal(t, len(resp.Hashed), 32) + assert.Equal(t, 32, len(resp.Hashed)) } }) } @@ -216,9 +216,9 @@ func TestLimitRecursiveQueryGas(t *testing.T) { const ( // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork2k uint64 = 84103 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance + GasWork2k uint64 = 84_236 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance // This is overhead for calling into a sub-contract - GasReturnHashed uint64 = 24 + GasReturnHashed uint64 = 26 ) cases := map[string]struct { @@ -244,8 +244,8 @@ func TestLimitRecursiveQueryGas(t *testing.T) { Work: 2000, }, expectQueriesFromContract: 5, - // FIXME: why +1 ... confused a bit by calculations, seems like rounding issues - expectedGas: GasWork2k + 5*(GasWork2k+GasReturnHashed) + 1, + // FIXME: why -1 ... confused a bit by calculations, seems like rounding issues + expectedGas: GasWork2k + 5*(GasWork2k+GasReturnHashed) - 1, }, // this is where we expect an error... // it has enough gas to run 4 times and die on the 5th (4th time dispatching to sub-contract) diff --git a/x/wasm/keeper/reflect_test.go b/x/wasm/keeper/reflect_test.go index 1e23e9c8..9a25703d 100644 --- a/x/wasm/keeper/reflect_test.go +++ b/x/wasm/keeper/reflect_test.go @@ -90,7 +90,7 @@ func TestReflectContractSend(t *testing.T) { accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, _, bob := keyPubAddr() // upload reflect code @@ -172,8 +172,8 @@ func TestReflectCustomMsg(t *testing.T) { accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) - bob := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) + bob := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, _, fred := keyPubAddr() // upload code @@ -262,10 +262,10 @@ func TestReflectCustomMsg(t *testing.T) { func TestMaskReflectCustomQuery(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload code reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -312,12 +312,12 @@ func TestMaskReflectCustomQuery(t *testing.T) { func TestReflectStargateQuery(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper funds := sdk.NewCoins(sdk.NewInt64Coin("denom", 320000)) contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) expectedBalance := funds.Sub(contractStart) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, funds) + creator := keepers.Faucet.NewFundedAccount(ctx, funds...) // upload code reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -389,10 +389,10 @@ type reflectState struct { func TestMaskReflectWasmQueries(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) - accKeeper, keeper := keepers.AccountKeeper, keepers.WasmKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, keepers.BankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload reflect code reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -461,10 +461,10 @@ func TestMaskReflectWasmQueries(t *testing.T) { func TestWasmRawQueryWithNil(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) - accKeeper, keeper := keepers.AccountKeeper, keepers.WasmKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, keepers.BankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload reflect code reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -528,7 +528,7 @@ type reflectCustomMsg struct { // toReflectRawMsg encodes an sdk msg using any type with json encoding. // Then wraps it as an opaque message -func toReflectRawMsg(cdc codec.Marshaler, msg sdk.Msg) (wasmvmtypes.CosmosMsg, error) { +func toReflectRawMsg(cdc codec.Codec, msg sdk.Msg) (wasmvmtypes.CosmosMsg, error) { any, err := codectypes.NewAnyWithValue(msg) if err != nil { return wasmvmtypes.CosmosMsg{}, err @@ -547,7 +547,7 @@ func toReflectRawMsg(cdc codec.Marshaler, msg sdk.Msg) (wasmvmtypes.CosmosMsg, e } // reflectEncoders needs to be registered in test setup to handle custom message callbacks -func reflectEncoders(cdc codec.Marshaler) *MessageEncoders { +func reflectEncoders(cdc codec.Codec) *MessageEncoders { return &MessageEncoders{ Custom: fromReflectRawMsg(cdc), } @@ -555,7 +555,7 @@ func reflectEncoders(cdc codec.Marshaler) *MessageEncoders { // fromReflectRawMsg decodes msg.Data to an sdk.Msg using proto Any and json encoding. // this needs to be registered on the Encoders -func fromReflectRawMsg(cdc codec.Marshaler) CustomEncoder { +func fromReflectRawMsg(cdc codec.Codec) CustomEncoder { return func(_sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { var custom reflectCustomMsg err := json.Unmarshal(msg, &custom) diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index d89a7115..11bf2734 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -80,7 +80,7 @@ func TestOnOpenChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expGas, ctx.GasMeter().GasConsumed()-before-storageCosts) }) } @@ -185,7 +185,7 @@ func TestOnConnectChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -295,7 +295,7 @@ func TestOnCloseChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -314,6 +314,7 @@ func TestOnRecvPacket(t *testing.T) { parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 + const storageCosts = sdk.Gas(2903) specs := map[string]struct { contractAddr sdk.AccAddress @@ -400,7 +401,7 @@ func TestOnRecvPacket(t *testing.T) { }, "submessage reply can overwrite ack data": { contractAddr: example.Contract, - expContractGas: myContractGas + 10 + 2707, + expContractGas: myContractGas + storageCosts, contractResp: &wasmvmtypes.IBCReceiveResponse{ Acknowledgement: []byte("myAck"), Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyAlways, Msg: wasmvmtypes.CosmosMsg{Bank: &wasmvmtypes.BankMsg{}}}}, @@ -456,7 +457,7 @@ func TestOnRecvPacket(t *testing.T) { require.Equal(t, spec.expAck, gotAck) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -562,7 +563,7 @@ func TestOnAckPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -682,7 +683,7 @@ func TestOnTimeoutPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0xa9d) + const storageCosts = sdk.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/staking_test.go b/x/wasm/keeper/staking_test.go index e8740104..5265be59 100644 --- a/x/wasm/keeper/staking_test.go +++ b/x/wasm/keeper/staking_test.go @@ -95,14 +95,14 @@ func TestInitializeStaking(t *testing.T) { ctx, k := CreateTestInput(t, false, SupportedFeatures) accKeeper, stakingKeeper, keeper, bankKeeper := k.AccountKeeper, k.StakingKeeper, k.ContractKeeper, k.BankKeeper - valAddr := addValidator(t, ctx, stakingKeeper, accKeeper, bankKeeper, sdk.NewInt64Coin("stake", 1234567)) + 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)) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000), sdk.NewInt64Coin("stake", 500000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := k.Faucet.NewFundedAccount(ctx, deposit...) // upload staking derivates code stakingCode, err := ioutil.ReadFile("./testdata/staking.wasm") @@ -163,13 +163,14 @@ type initInfo struct { wasmKeeper Keeper contractKeeper wasmtypes.ContractOpsKeeper bankKeeper bankkeeper.Keeper + faucet *TestFaucet } func initializeStaking(t *testing.T) initInfo { ctx, k := CreateTestInput(t, false, SupportedFeatures) accKeeper, stakingKeeper, keeper, bankKeeper := k.AccountKeeper, k.StakingKeeper, k.WasmKeeper, k.BankKeeper - valAddr := addValidator(t, ctx, stakingKeeper, accKeeper, bankKeeper, sdk.NewInt64Coin("stake", 1000000)) + valAddr := addValidator(t, ctx, stakingKeeper, k.Faucet, sdk.NewInt64Coin("stake", 1000000)) ctx = nextBlock(ctx, stakingKeeper) // set some baseline - this seems to be needed @@ -184,7 +185,7 @@ func initializeStaking(t *testing.T) initInfo { assert.Equal(t, v.Status, stakingtypes.Bonded) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000), sdk.NewInt64Coin("stake", 500000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := k.Faucet.NewFundedAccount(ctx, deposit...) // upload staking derivates code stakingCode, err := ioutil.ReadFile("./testdata/staking.wasm") @@ -220,6 +221,7 @@ func initializeStaking(t *testing.T) initInfo { distKeeper: k.DistKeeper, bankKeeper: bankKeeper, contractKeeper: k.ContractKeeper, + faucet: k.Faucet, } } @@ -236,7 +238,7 @@ func TestBonding(t *testing.T) { // bob has 160k, putting 80k into the contract full := sdk.NewCoins(sdk.NewInt64Coin("stake", 160000)) funds := sdk.NewCoins(sdk.NewInt64Coin("stake", 80000)) - bob := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, full) + bob := initInfo.faucet.NewFundedAccount(ctx, full...) // check contract state before assertBalance(t, ctx, keeper, contractAddr, bob, "0") @@ -284,7 +286,7 @@ func TestUnbonding(t *testing.T) { // bob has 160k, putting 80k into the contract full := sdk.NewCoins(sdk.NewInt64Coin("stake", 160000)) funds := sdk.NewCoins(sdk.NewInt64Coin("stake", 80000)) - bob := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, full) + bob := initInfo.faucet.NewFundedAccount(ctx, full...) bond := StakingHandleMsg{ Bond: &struct{}{}, @@ -351,7 +353,7 @@ func TestReinvest(t *testing.T) { // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) funds := sdk.NewCoins(sdk.NewInt64Coin("stake", 200000)) - bob := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, full) + bob := initInfo.faucet.NewFundedAccount(ctx, full...) // we will stake 200k to a validator with 1M self-bond // this means we should get 1/6 of the rewards @@ -408,7 +410,7 @@ func TestQueryStakingInfo(t *testing.T) { // STEP 1: take a lot of setup from TestReinvest so we have non-zero info initInfo := initializeStaking(t) ctx, valAddr, contractAddr := initInfo.ctx, initInfo.valAddr, initInfo.contractAddr - keeper, stakingKeeper, accKeeper := initInfo.wasmKeeper, initInfo.stakingKeeper, initInfo.accKeeper + keeper, stakingKeeper := initInfo.wasmKeeper, initInfo.stakingKeeper distKeeper := initInfo.distKeeper // initial checks of bonding state @@ -419,7 +421,7 @@ func TestQueryStakingInfo(t *testing.T) { // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) funds := sdk.NewCoins(sdk.NewInt64Coin("stake", 200000)) - bob := createFakeFundedAccount(t, ctx, accKeeper, initInfo.bankKeeper, full) + bob := initInfo.faucet.NewFundedAccount(ctx, full...) // we will stake 200k to a validator with 1M self-bond // this means we should get 1/6 of the rewards @@ -441,7 +443,7 @@ func TestQueryStakingInfo(t *testing.T) { // STEP 2: Prepare the mask contract deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, initInfo.bankKeeper, deposit) + creator := initInfo.faucet.NewFundedAccount(ctx, deposit...) // upload mask code maskCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -587,7 +589,7 @@ func TestQueryStakingPlugin(t *testing.T) { // STEP 1: take a lot of setup from TestReinvest so we have non-zero info initInfo := initializeStaking(t) ctx, valAddr, contractAddr := initInfo.ctx, initInfo.valAddr, initInfo.contractAddr - stakingKeeper, accKeeper := initInfo.stakingKeeper, initInfo.accKeeper + stakingKeeper := initInfo.stakingKeeper distKeeper := initInfo.distKeeper // initial checks of bonding state @@ -598,7 +600,7 @@ func TestQueryStakingPlugin(t *testing.T) { // full is 2x funds, 1x goes to the contract, other stays on his wallet full := sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)) funds := sdk.NewCoins(sdk.NewInt64Coin("stake", 200000)) - bob := createFakeFundedAccount(t, ctx, accKeeper, initInfo.bankKeeper, full) + bob := initInfo.faucet.NewFundedAccount(ctx, full...) // we will stake 200k to a validator with 1M self-bond // this means we should get 1/6 of the rewards @@ -650,8 +652,8 @@ func TestQueryStakingPlugin(t *testing.T) { } // adds a few validators and returns a list of validators that are registered -func addValidator(t *testing.T, ctx sdk.Context, stakingKeeper stakingkeeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, value sdk.Coin) sdk.ValAddress { - owner := createFakeFundedAccount(t, ctx, accountKeeper, bankKeeper, sdk.Coins{value}) +func addValidator(t *testing.T, ctx sdk.Context, stakingKeeper stakingkeeper.Keeper, faucet *TestFaucet, value sdk.Coin) sdk.ValAddress { + owner := faucet.NewFundedAccount(ctx, value) privKey := secp256k1.GenPrivKey() pubKey := privKey.PubKey() diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index d304048e..2fdb17eb 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -7,6 +7,8 @@ import ( "strconv" "testing" + "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/stretchr/testify/assert" wasmvmtypes "github.com/CosmWasm/wasmvm/types" @@ -24,7 +26,7 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) creatorBalance := deposit.Sub(contractStart) _, _, fred := keyPubAddr() @@ -94,9 +96,10 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { require.NotNil(t, res.Result.Ok) sub := res.Result.Ok assert.Empty(t, sub.Data) - require.Len(t, sub.Events, 1) - - transfer := sub.Events[0] + require.Len(t, sub.Events, 3) + assert.Equal(t, "coin_spent", sub.Events[0].Type) + assert.Equal(t, "coin_received", sub.Events[1].Type) + transfer := sub.Events[2] assert.Equal(t, "transfer", transfer.Type) assert.Equal(t, wasmvmtypes.EventAttribute{ Key: "recipient", @@ -114,9 +117,9 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { ctx, keepers := CreateTestInput(t, false, ReflectFeatures) ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper contractStart := sdk.NewCoins(sdk.NewInt64Coin(fundedDenom, int64(fundedAmount))) - uploader := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, contractStart.Add(contractStart...)) + uploader := keepers.Faucet.NewFundedAccount(ctx, contractStart.Add(contractStart...)...) // upload code reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") @@ -221,11 +224,9 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { eventAddr := event.Attributes[0].Value assert.NotEqual(t, contract, eventAddr) - // data field is the raw canonical address - // QUESTION: why not types.MsgInstantiateContractResponse? difference between calling Router and Service? - require.Len(t, response.Ok.Data, 20) - resAddr := sdk.AccAddress(response.Ok.Data) - assert.Equal(t, eventAddr, resAddr.String()) + var res types.MsgInstantiateContractResponse + keepers.EncodingConfig.Marshaler.MustUnmarshal(response.Ok.Data, &res) + assert.Equal(t, eventAddr, res.Address) } cases := map[string]struct { @@ -246,7 +247,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { "send tokens": { submsgID: 5, msg: validBankSend, - resultAssertions: []assertion{assertReturnedEvents(1), assertGasUsed(96000, 101000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(112000, 112900)}, }, "not enough tokens": { submsgID: 6, @@ -266,7 +267,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(1), assertGasUsed(96000, 101000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(112000, 113000)}, }, "not enough tokens with limit": { submsgID: 16, @@ -274,7 +275,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { subMsgError: true, gasLimit: &subGasLimit, // uses same gas as call without limit (note we do not charge the 40k on reply) - resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("insufficient funds")}, + resultAssertions: []assertion{assertGasUsed(79000, 79040), assertErrorString("insufficient funds")}, }, "out of gas caught with gas limit": { submsgID: 17, @@ -282,7 +283,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { subMsgError: true, gasLimit: &subGasLimit, // uses all the subGasLimit, plus the 52k or so for the main contract - resultAssertions: []assertion{assertGasUsed(subGasLimit+71000, subGasLimit+74000), assertErrorString("out of gas")}, + resultAssertions: []assertion{assertGasUsed(subGasLimit+73000, subGasLimit+80000), assertErrorString("out of gas")}, }, "instantiate contract gets address in data and events": { submsgID: 21, @@ -290,10 +291,9 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { resultAssertions: []assertion{assertReturnedEvents(1), assertGotContractAddr}, }, } - for name, tc := range cases { t.Run(name, func(t *testing.T) { - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, contractStart) + creator := keepers.Faucet.NewFundedAccount(ctx, contractStart...) _, _, empty := keyPubAddr() contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, reflectID, creator, nil, []byte("{}"), fmt.Sprintf("contract %s", name), contractStart) @@ -372,12 +372,12 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { } ctx, keepers := CreateTestInput(t, false, ReflectFeatures, WithMessageHandler(NewSDKMessageHandler(nil, customEncoders))) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, _, fred := keyPubAddr() // upload code @@ -440,12 +440,12 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { // Try a simple send, no gas limit to for a sanity check before trying table tests func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { ctx, keepers := CreateTestInput(t, false, ReflectFeatures) - accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) - creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) + creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) _, _, fred := keyPubAddr() // upload code diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index 244651d1..f2df9c40 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -5,22 +5,20 @@ import ( "encoding/json" "fmt" "io/ioutil" + "testing" "time" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - params2 "github.com/cosmos/cosmos-sdk/simapp/params" "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" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" "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" @@ -34,14 +32,11 @@ import ( 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" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - ibc "github.com/cosmos/cosmos-sdk/x/ibc/core" - ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" - ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper" "github.com/cosmos/cosmos-sdk/x/mint" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" @@ -56,6 +51,13 @@ import ( 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/cosmos/ibc-go/v2/modules/apps/transfer" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v2/modules/core" + ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" @@ -64,17 +66,12 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + wasmappparams "github.com/CosmWasm/wasmd/app/params" + "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" "github.com/CosmWasm/wasmd/x/wasm/types" ) -type TestingT interface { - Errorf(format string, args ...interface{}) - FailNow() - TempDir() string - Helper() -} - var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, @@ -94,30 +91,25 @@ var ModuleBasics = module.NewBasicManager( transfer.AppModuleBasic{}, ) -func MakeTestCodec(t TestingT) codec.Marshaler { +func MakeTestCodec(t testing.TB) codec.Codec { return MakeEncodingConfig(t).Marshaler } -func MakeEncodingConfig(_ TestingT) params2.EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry := codectypes.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) +func MakeEncodingConfig(_ testing.TB) wasmappparams.EncodingConfig { + encodingConfig := wasmappparams.MakeEncodingConfig() + amino := encodingConfig.Amino + interfaceRegistry := encodingConfig.InterfaceRegistry std.RegisterInterfaces(interfaceRegistry) std.RegisterLegacyAminoCodec(amino) ModuleBasics.RegisterLegacyAminoCodec(amino) ModuleBasics.RegisterInterfaces(interfaceRegistry) + // add wasmd types types.RegisterInterfaces(interfaceRegistry) types.RegisterLegacyAminoCodec(amino) - return params2.EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, - } + return encodingConfig } var TestingStakeParams = stakingtypes.Params{ @@ -128,6 +120,51 @@ var TestingStakeParams = stakingtypes.Params{ BondDenom: "stake", } +type TestFaucet struct { + t testing.TB + bankKeeper bankkeeper.Keeper + sender sdk.AccAddress + balance sdk.Coins +} + +func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, initialAmount ...sdk.Coin) *TestFaucet { + require.NotEmpty(t, initialAmount) + r := &TestFaucet{t: t, bankKeeper: bankKeeper} + _, _, addr := keyPubAddr() + r.sender = addr + r.Mint(ctx, addr, initialAmount...) + r.balance = initialAmount + return r +} + +func (f *TestFaucet) Mint(parentCtx sdk.Context, addr sdk.AccAddress, amounts ...sdk.Coin) { + require.NotEmpty(f.t, amounts) + ctx := parentCtx.WithEventManager(sdk.NewEventManager()) // discard all faucet related events + err := f.bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts) + require.NoError(f.t, err) + err = f.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) + require.NoError(f.t, err) + f.balance = f.balance.Add(amounts...) +} + +func (f *TestFaucet) Fund(parentCtx sdk.Context, receiver sdk.AccAddress, amounts ...sdk.Coin) { + require.NotEmpty(f.t, amounts) + // ensure faucet is always filled + if !f.balance.IsAllGTE(amounts) { + f.Mint(parentCtx, f.sender, amounts...) + } + ctx := parentCtx.WithEventManager(sdk.NewEventManager()) // discard all faucet related events + err := f.bankKeeper.SendCoins(ctx, f.sender, receiver, amounts) + require.NoError(f.t, err) + f.balance = f.balance.Sub(amounts) +} + +func (f *TestFaucet) NewFundedAccount(ctx sdk.Context, amounts ...sdk.Coin) sdk.AccAddress { + _, _, addr := keyPubAddr() + f.Fund(ctx, addr, amounts...) + return addr +} + type TestKeepers struct { AccountKeeper authkeeper.AccountKeeper StakingKeeper stakingkeeper.Keeper @@ -138,23 +175,24 @@ type TestKeepers struct { WasmKeeper *Keeper IBCKeeper *ibckeeper.Keeper Router *baseapp.Router - EncodingConfig params2.EncodingConfig + EncodingConfig wasmappparams.EncodingConfig + Faucet *TestFaucet } // CreateDefaultTestInput common settings for CreateTestInput -func CreateDefaultTestInput(t TestingT) (sdk.Context, TestKeepers) { +func CreateDefaultTestInput(t testing.TB) (sdk.Context, TestKeepers) { return CreateTestInput(t, false, "staking") } -// encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) -func CreateTestInput(t TestingT, isCheckTx bool, supportedFeatures string, opts ...Option) (sdk.Context, TestKeepers) { +// CreateTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) +func CreateTestInput(t testing.TB, isCheckTx bool, supportedFeatures string, opts ...Option) (sdk.Context, TestKeepers) { // Load default wasm config return createTestInput(t, isCheckTx, supportedFeatures, 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( - t TestingT, + t testing.TB, isCheckTx bool, supportedFeatures string, wasmConfig types.WasmConfig, @@ -163,30 +201,28 @@ func createTestInput( ) (sdk.Context, TestKeepers) { tempDir := t.TempDir() - keyWasm := sdk.NewKVStoreKey(types.StoreKey) - keyAcc := sdk.NewKVStoreKey(authtypes.StoreKey) - keyBank := sdk.NewKVStoreKey(banktypes.StoreKey) - keyStaking := sdk.NewKVStoreKey(stakingtypes.StoreKey) - keyDistro := sdk.NewKVStoreKey(distributiontypes.StoreKey) - keyParams := sdk.NewKVStoreKey(paramstypes.StoreKey) - tkeyParams := sdk.NewTransientStoreKey(paramstypes.TStoreKey) - keyGov := sdk.NewKVStoreKey(govtypes.StoreKey) - keyIBC := sdk.NewKVStoreKey(ibchost.StoreKey) - keyCapability := sdk.NewKVStoreKey(capabilitytypes.StoreKey) - keyCapabilityTransient := storetypes.NewMemoryStoreKey(capabilitytypes.MemStoreKey) - + keys := sdk.NewKVStoreKeys( + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distributiontypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, + evidencetypes.StoreKey, ibctransfertypes.StoreKey, + capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, + types.StoreKey, + ) ms := store.NewCommitMultiStore(db) - ms.MountStoreWithDB(keyWasm, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyBank, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyDistro, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) - ms.MountStoreWithDB(keyGov, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyIBC, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyCapability, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(keyCapabilityTransient, sdk.StoreTypeMemory, db) + for _, v := range keys { + ms.MountStoreWithDB(v, sdk.StoreTypeIAVL, db) + } + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + for _, v := range tkeys { + ms.MountStoreWithDB(v, sdk.StoreTypeTransient, db) + } + + memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + for _, v := range memKeys { + ms.MountStoreWithDB(v, sdk.StoreTypeMemory, db) + } + require.NoError(t, ms.LoadLatestVersion()) ctx := sdk.NewContext(ms, tmproto.Header{ @@ -198,18 +234,31 @@ func createTestInput( encodingConfig := MakeEncodingConfig(t) appCodec, legacyAmino := encodingConfig.Marshaler, encodingConfig.Amino - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, keyParams, tkeyParams) - paramsKeeper.Subspace(authtypes.ModuleName) - paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distributiontypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(capabilitytypes.ModuleName) - paramsKeeper.Subspace(ibchost.ModuleName) - + paramsKeeper := paramskeeper.NewKeeper( + appCodec, + legacyAmino, + keys[paramstypes.StoreKey], + tkeys[paramstypes.TStoreKey], + ) + for _, m := range []string{authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + minttypes.ModuleName, + distributiontypes.ModuleName, + slashingtypes.ModuleName, + crisistypes.ModuleName, + ibctransfertypes.ModuleName, + capabilitytypes.ModuleName, + ibchost.ModuleName, + govtypes.ModuleName, + types.ModuleName} { + paramsKeeper.Subspace(m) + } + subspace := func(m string) paramstypes.Subspace { + r, ok := paramsKeeper.GetSubspace(m) + require.True(t, ok) + return r + } maccPerms := map[string][]string{ // module account permissions authtypes.FeeCollectorName: nil, distributiontypes.ModuleName: nil, @@ -220,61 +269,83 @@ func createTestInput( ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, types.ModuleName: {authtypes.Burner}, } - authSubsp, _ := paramsKeeper.GetSubspace(authtypes.ModuleName) - authKeeper := authkeeper.NewAccountKeeper( + accountKeeper := authkeeper.NewAccountKeeper( appCodec, - keyAcc, // target store - authSubsp, + keys[authtypes.StoreKey], // target store + subspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, // prototype maccPerms, ) blockedAddrs := make(map[string]bool) for acc := range maccPerms { - allowReceivingFunds := acc != distributiontypes.ModuleName - blockedAddrs[authtypes.NewModuleAddress(acc).String()] = allowReceivingFunds + blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true } - bankSubsp, _ := paramsKeeper.GetSubspace(banktypes.ModuleName) bankKeeper := bankkeeper.NewBaseKeeper( appCodec, - keyBank, - authKeeper, - bankSubsp, + keys[banktypes.StoreKey], + accountKeeper, + subspace(banktypes.ModuleName), blockedAddrs, ) - bankParams := banktypes.DefaultParams() - bankKeeper.SetParams(ctx, bankParams) - bankKeeper.SetSupply(ctx, banktypes.NewSupply(sdk.NewCoins( - sdk.NewCoin("denom", sdk.NewInt(10000)), - ))) - stakingSubsp, _ := paramsKeeper.GetSubspace(stakingtypes.ModuleName) - stakingKeeper := stakingkeeper.NewKeeper(appCodec, keyStaking, authKeeper, bankKeeper, stakingSubsp) + bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, + keys[stakingtypes.StoreKey], + accountKeeper, + bankKeeper, + subspace(stakingtypes.ModuleName), + ) stakingKeeper.SetParams(ctx, TestingStakeParams) - distSubsp, _ := paramsKeeper.GetSubspace(distributiontypes.ModuleName) - distKeeper := distributionkeeper.NewKeeper(appCodec, keyDistro, distSubsp, authKeeper, bankKeeper, stakingKeeper, authtypes.FeeCollectorName, nil) + distKeeper := distributionkeeper.NewKeeper( + appCodec, + keys[distributiontypes.StoreKey], + subspace(distributiontypes.ModuleName), + accountKeeper, + bankKeeper, + stakingKeeper, + authtypes.FeeCollectorName, + nil, + ) distKeeper.SetParams(ctx, distributiontypes.DefaultParams()) stakingKeeper.SetHooks(distKeeper.Hooks()) // set genesis items required for distribution distKeeper.SetFeePool(ctx, distributiontypes.InitialFeePool()) + upgradeKeeper := upgradekeeper.NewKeeper( + map[int64]bool{}, + keys[upgradetypes.StoreKey], + appCodec, + tempDir, + nil, + ) + + faucet := NewTestFaucet(t, ctx, bankKeeper, sdk.NewCoin("stake", sdk.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) - err := bankKeeper.SetBalances(ctx, distrAcc.GetAddress(), sdk.NewCoins( - sdk.NewCoin("stake", sdk.NewInt(2000000)), - )) - require.NoError(t, err) - authKeeper.SetModuleAccount(ctx, distrAcc) - capabilityKeeper := capabilitykeeper.NewKeeper(appCodec, keyCapability, keyCapabilityTransient) + faucet.Fund(ctx, distrAcc.GetAddress(), sdk.NewCoin("stake", sdk.NewInt(2000000))) + accountKeeper.SetModuleAccount(ctx, distrAcc) + + capabilityKeeper := capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + memKeys[capabilitytypes.MemStoreKey], + ) scopedIBCKeeper := capabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedWasmKeeper := capabilityKeeper.ScopeToModule(types.ModuleName) - ibcSubsp, _ := paramsKeeper.GetSubspace(ibchost.ModuleName) - ibcKeeper := ibckeeper.NewKeeper( - appCodec, keyIBC, ibcSubsp, stakingKeeper, scopedIBCKeeper, + appCodec, + keys[ibchost.StoreKey], + subspace(ibchost.ModuleName), + stakingKeeper, + upgradeKeeper, + scopedIBCKeeper, ) router := baseapp.NewRouter() @@ -286,15 +357,18 @@ func createTestInput( router.AddRoute(sdk.NewRoute(distributiontypes.RouterKey, dh)) querier := baseapp.NewGRPCQueryRouter() - banktypes.RegisterQueryServer(querier, bankKeeper) - stakingtypes.RegisterQueryServer(querier, stakingkeeper.Querier{Keeper: stakingKeeper}) - distributiontypes.RegisterQueryServer(querier, distKeeper) + querier.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) + msgRouter := baseapp.NewMsgServiceRouter() + msgRouter.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) + + cfg := sdk.GetConfig() + cfg.SetAddressVerifier(types.VerifyAddressLen()) keeper := NewKeeper( appCodec, - keyWasm, - paramsKeeper.Subspace(types.DefaultParamspace), - authKeeper, + keys[types.StoreKey], + subspace(types.ModuleName), + accountKeeper, bankKeeper, stakingKeeper, distKeeper, @@ -302,7 +376,7 @@ func createTestInput( &ibcKeeper.PortKeeper, scopedWasmKeeper, wasmtesting.MockIBCTransferKeeper{}, - router, + msgRouter, querier, tempDir, wasmConfig, @@ -314,6 +388,15 @@ func createTestInput( contractKeeper := NewDefaultPermissionKeeper(&keeper) router.AddRoute(sdk.NewRoute(types.RouterKey, TestHandler(contractKeeper))) + am := module.NewManager( // minimal module set that we use for message/ query tests + bank.NewAppModule(appCodec, bankKeeper, accountKeeper), + staking.NewAppModule(appCodec, stakingKeeper, accountKeeper, bankKeeper), + distribution.NewAppModule(appCodec, distKeeper, accountKeeper, bankKeeper, stakingKeeper), + ) + am.RegisterServices(module.NewConfigurator(appCodec, msgRouter, querier)) + types.RegisterMsgServer(msgRouter, NewMsgServerImpl(NewDefaultPermissionKeeper(keeper))) + types.RegisterQueryServer(querier, NewGrpcQuerier(appCodec, keys[types.ModuleName], keeper, keeper.queryGasLimit)) + govRouter := govtypes.NewRouter(). AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(paramsKeeper)). @@ -321,7 +404,13 @@ func createTestInput( AddRoute(types.RouterKey, NewWasmProposalHandler(&keeper, types.EnableAllProposals)) govKeeper := govkeeper.NewKeeper( - appCodec, keyGov, paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()), authKeeper, bankKeeper, stakingKeeper, govRouter, + appCodec, + keys[govtypes.StoreKey], + subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()), + accountKeeper, + bankKeeper, + stakingKeeper, + govRouter, ) govKeeper.SetProposalID(ctx, govtypes.DefaultStartingProposalID) @@ -330,7 +419,7 @@ func createTestInput( govKeeper.SetTallyParams(ctx, govtypes.DefaultTallyParams()) keepers := TestKeepers{ - AccountKeeper: authKeeper, + AccountKeeper: accountKeeper, StakingKeeper: stakingKeeper, DistKeeper: distKeeper, ContractKeeper: contractKeeper, @@ -340,6 +429,7 @@ func createTestInput( IBCKeeper: ibcKeeper, Router: router, EncodingConfig: encodingConfig, + Faucet: faucet, } return ctx, keepers } @@ -421,12 +511,12 @@ func handleExecute(ctx sdk.Context, k types.ContractOpsKeeper, msg *types.MsgExe }, nil } -func RandomAccountAddress(_ TestingT) sdk.AccAddress { +func RandomAccountAddress(_ testing.TB) sdk.AccAddress { _, _, addr := keyPubAddr() return addr } -func RandomBech32AccountAddress(t TestingT) string { +func RandomBech32AccountAddress(t testing.TB) string { return RandomAccountAddress(t).String() } @@ -437,19 +527,19 @@ type ExampleContract struct { CodeID uint64 } -func StoreHackatomExampleContract(t TestingT, ctx sdk.Context, keepers TestKeepers) ExampleContract { +func StoreHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { return StoreExampleContract(t, ctx, keepers, "./testdata/hackatom.wasm") } -func StoreBurnerExampleContract(t TestingT, ctx sdk.Context, keepers TestKeepers) ExampleContract { +func StoreBurnerExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { return StoreExampleContract(t, ctx, keepers, "./testdata/burner.wasm") } -func StoreIBCReflectContract(t TestingT, ctx sdk.Context, keepers TestKeepers) ExampleContract { +func StoreIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { return StoreExampleContract(t, ctx, keepers, "./testdata/ibc_reflect.wasm") } -func StoreReflectContract(t TestingT, ctx sdk.Context, keepers TestKeepers) uint64 { +func StoreReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) uint64 { wasmCode, err := ioutil.ReadFile("./testdata/reflect.wasm") require.NoError(t, err) @@ -459,7 +549,7 @@ func StoreReflectContract(t TestingT, ctx sdk.Context, keepers TestKeepers) uint return codeID } -func StoreExampleContract(t TestingT, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract { +func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract { anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) creator, _, creatorAddr := keyPubAddr() fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) @@ -480,7 +570,7 @@ type ExampleContractInstance struct { } // SeedNewContractInstance sets the mock wasmerEngine in keeper and calls store + instantiate to init the contract's metadata -func SeedNewContractInstance(t TestingT, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContractInstance { +func SeedNewContractInstance(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContractInstance { t.Helper() exampleContract := StoreRandomContract(t, ctx, keepers, mock) contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, exampleContract.CodeID, exampleContract.CreatorAddr, exampleContract.CreatorAddr, []byte(`{}`), "", nil) @@ -492,7 +582,7 @@ func SeedNewContractInstance(t TestingT, ctx sdk.Context, keepers TestKeepers, m } // StoreRandomContract sets the mock wasmerEngine in keeper and calls store -func StoreRandomContract(t TestingT, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContract { +func StoreRandomContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContract { t.Helper() anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) creator, _, creatorAddr := keyPubAddr() @@ -515,7 +605,7 @@ type HackatomExampleInstance struct { } // InstantiateHackatomExampleContract load and instantiate the "./testdata/hackatom.wasm" contract -func InstantiateHackatomExampleContract(t TestingT, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance { +func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance { contract := StoreHackatomExampleContract(t, ctx, keepers) verifier, _, verifierAddr := keyPubAddr() @@ -546,7 +636,7 @@ type HackatomExampleInitMsg struct { Beneficiary sdk.AccAddress `json:"beneficiary"` } -func (m HackatomExampleInitMsg) GetBytes(t TestingT) []byte { +func (m HackatomExampleInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) require.NoError(t, err) return initMsgBz @@ -560,7 +650,7 @@ type IBCReflectExampleInstance struct { } // InstantiateIBCReflectContract load and instantiate the "./testdata/ibc_reflect.wasm" contract -func InstantiateIBCReflectContract(t TestingT, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance { +func InstantiateIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance { reflectID := StoreReflectContract(t, ctx, keepers) ibcReflectID := StoreIBCReflectContract(t, ctx, keepers).CodeID @@ -583,7 +673,7 @@ type IBCReflectInitMsg struct { ReflectCodeID uint64 `json:"reflect_code_id"` } -func (m IBCReflectInitMsg) GetBytes(t TestingT) []byte { +func (m IBCReflectInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) require.NoError(t, err) return initMsgBz @@ -593,22 +683,16 @@ type BurnerExampleInitMsg struct { Payout sdk.AccAddress `json:"payout"` } -func (m BurnerExampleInitMsg) GetBytes(t TestingT) []byte { +func (m BurnerExampleInitMsg) GetBytes(t testing.TB) []byte { initMsgBz, err := json.Marshal(m) require.NoError(t, err) return initMsgBz } -func createFakeFundedAccount(t TestingT, ctx sdk.Context, am authkeeper.AccountKeeper, bank bankkeeper.Keeper, coins sdk.Coins) sdk.AccAddress { //nolint:deadcode,unused - _, _, addr := keyPubAddr() - fundAccounts(t, ctx, am, bank, addr, coins) - return addr -} - -func fundAccounts(t TestingT, ctx sdk.Context, am authkeeper.AccountKeeper, bank bankkeeper.Keeper, addr sdk.AccAddress, coins sdk.Coins) { +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) - require.NoError(t, bank.SetBalances(ctx, addr, coins)) + NewTestFaucet(t, ctx, bank, coins...).Fund(ctx, addr, coins...) } var keyCounter uint64 diff --git a/x/wasm/keeper/wasmtesting/message_router.go b/x/wasm/keeper/wasmtesting/message_router.go new file mode 100644 index 00000000..712e012d --- /dev/null +++ b/x/wasm/keeper/wasmtesting/message_router.go @@ -0,0 +1,27 @@ +package wasmtesting + +import ( + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// MockMessageRouter mock for testing +type MockMessageRouter struct { + HandlerFn func(msg sdk.Msg) baseapp.MsgServiceHandler +} + +// Handler is the entry point +func (m MockMessageRouter) Handler(msg sdk.Msg) baseapp.MsgServiceHandler { + if m.HandlerFn == nil { + panic("not expected to be called") + } + return m.HandlerFn(msg) +} + +// MessageRouterFunc convenient type to match the keeper.MessageRouter interface +type MessageRouterFunc func(msg sdk.Msg) baseapp.MsgServiceHandler + +// Handler is the entry point +func (m MessageRouterFunc) Handler(msg sdk.Msg) baseapp.MsgServiceHandler { + return m(msg) +} diff --git a/x/wasm/keeper/wasmtesting/mock_keepers.go b/x/wasm/keeper/wasmtesting/mock_keepers.go index e8570aed..2d2c99f2 100644 --- a/x/wasm/keeper/wasmtesting/mock_keepers.go +++ b/x/wasm/keeper/wasmtesting/mock_keepers.go @@ -3,8 +3,8 @@ package wasmtesting import ( sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" "github.com/CosmWasm/wasmd/x/wasm/types" ) diff --git a/x/wasm/module.go b/x/wasm/module.go index 59f63b34..9453cf09 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -59,14 +59,14 @@ func (AppModuleBasic) Name() string { // DefaultGenesis returns default genesis state as raw bytes for the wasm // module. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(&GenesisState{ Params: DefaultParams(), }) } // ValidateGenesis performs genesis state validation for the wasm module. -func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONMarshaler, config client.TxEncodingConfig, message json.RawMessage) error { +func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { var data GenesisState err := marshaler.UnmarshalJSON(message, &data) if err != nil { @@ -100,13 +100,19 @@ func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) // AppModule implements an application module for the wasm module. type AppModule struct { AppModuleBasic - cdc codec.Marshaler + cdc codec.Codec keeper *Keeper validatorSetSource keeper.ValidatorSetSource } +// ConsensusVersion is a sequence number for state-breaking change of the +// module. It should be incremented on each consensus-breaking change +// introduced by the module. To avoid wrong/empty versions, the initial version +// should be set to 1. +func (AppModule) ConsensusVersion() uint64 { return 1 } + // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Marshaler, keeper *Keeper, validatorSetSource keeper.ValidatorSetSource) AppModule { +func NewAppModule(cdc codec.Codec, keeper *Keeper, validatorSetSource keeper.ValidatorSetSource) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, cdc: cdc, @@ -139,7 +145,7 @@ func (AppModule) QuerierRoute() string { // InitGenesis performs genesis initialization for the wasm module. It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState GenesisState cdc.MustUnmarshalJSON(data, &genesisState) validators, err := InitGenesis(ctx, am.keeper, genesisState, am.validatorSetSource, am.Route().Handler()) @@ -151,7 +157,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data j // ExportGenesis returns the exported genesis state as raw bytes for the wasm // module. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs := ExportGenesis(ctx, am.keeper) return cdc.MustMarshalJSON(gs) } diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index 6433d9f1..360743a1 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -29,6 +29,7 @@ type testData struct { keeper Keeper bankKeeper bankkeeper.Keeper stakingKeeper stakingkeeper.Keeper + faucet *keeper.TestFaucet } func setupTest(t *testing.T) testData { @@ -41,6 +42,7 @@ func setupTest(t *testing.T) testData { keeper: *keepers.WasmKeeper, bankKeeper: keepers.BankKeeper, stakingKeeper: keepers.StakingKeeper, + faucet: keepers.Faucet, } return data } @@ -141,9 +143,7 @@ type state struct { func TestHandleInstantiate(t *testing.T) { data := setupTest(t) - - deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, deposit) + creator := data.faucet.NewFundedAccount(data.ctx, sdk.NewInt64Coin("denom", 100000)) h := data.module.Route().Handler() q := data.module.LegacyQuerierHandler(nil) @@ -177,7 +177,7 @@ func TestHandleInstantiate(t *testing.T) { require.NoError(t, err) contractBech32Addr := parseInitResponse(t, res.Data) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", contractBech32Addr) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", contractBech32Addr) // this should be standard x/wasm init event, nothing from contract require.Equal(t, 3, len(res.Events), prettyEvents(res.Events)) require.Equal(t, "message", res.Events[0].Type) @@ -203,8 +203,9 @@ func TestHandleExecute(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, topUp) + + creator := data.faucet.NewFundedAccount(data.ctx, deposit.Add(deposit...)...) + fred := data.faucet.NewFundedAccount(data.ctx, topUp...) h := data.module.Route().Handler() q := data.module.LegacyQuerierHandler(nil) @@ -235,15 +236,17 @@ func TestHandleExecute(t *testing.T) { require.NoError(t, err) contractBech32Addr := parseInitResponse(t, res.Data) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", contractBech32Addr) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", contractBech32Addr) // this should be standard x/wasm message event, init event, plus a bank send event (2), with no custom contract events - require.Equal(t, 4, len(res.Events), prettyEvents(res.Events)) + require.Equal(t, 6, len(res.Events), prettyEvents(res.Events)) require.Equal(t, "message", res.Events[0].Type) assertAttribute(t, "module", "wasm", res.Events[0].Attributes[0]) - require.Equal(t, "transfer", res.Events[1].Type) - require.Equal(t, "instantiate", res.Events[2].Type) - require.Equal(t, "wasm", res.Events[3].Type) - assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[3].Attributes[0]) + require.Equal(t, "coin_spent", res.Events[1].Type) + require.Equal(t, "coin_received", res.Events[2].Type) + require.Equal(t, "transfer", res.Events[3].Type) + require.Equal(t, "instantiate", res.Events[4].Type) + require.Equal(t, "wasm", res.Events[5].Type) + assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[5].Attributes[0]) // ensure bob doesn't exist bobAcct := data.acctKeeper.GetAccount(data.ctx, bob) @@ -273,32 +276,37 @@ func TestHandleExecute(t *testing.T) { assertExecuteResponse(t, res.Data, []byte{0xf0, 0x0b, 0xaa}) // this should be standard message event, plus x/wasm init event, plus 2 bank send event, plus a special event from the contract - require.Equal(t, 6, len(res.Events), prettyEvents(res.Events)) + require.Equal(t, 10, len(res.Events), prettyEvents(res.Events)) assert.Equal(t, "message", res.Events[0].Type) assertAttribute(t, "module", "wasm", res.Events[0].Attributes[0]) + assert.Equal(t, "coin_spent", res.Events[1].Type) + assert.Equal(t, "coin_received", res.Events[2].Type) - require.Equal(t, "transfer", res.Events[1].Type) - require.Len(t, res.Events[1].Attributes, 3) - assertAttribute(t, "recipient", contractBech32Addr, res.Events[1].Attributes[0]) - assertAttribute(t, "sender", fred.String(), res.Events[1].Attributes[1]) - assertAttribute(t, "amount", "5000denom", res.Events[1].Attributes[2]) + require.Equal(t, "transfer", res.Events[3].Type) + require.Len(t, res.Events[3].Attributes, 3) + assertAttribute(t, "recipient", contractBech32Addr, res.Events[3].Attributes[0]) + assertAttribute(t, "sender", fred.String(), res.Events[3].Attributes[1]) + assertAttribute(t, "amount", "5000denom", res.Events[3].Attributes[2]) - assert.Equal(t, "execute", res.Events[2].Type) + assert.Equal(t, "execute", res.Events[4].Type) // custom contract event attribute - assert.Equal(t, "wasm", res.Events[3].Type) - assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[3].Attributes[0]) - assertAttribute(t, "action", "release", res.Events[3].Attributes[1]) + assert.Equal(t, "wasm", res.Events[5].Type) + assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[5].Attributes[0]) + assertAttribute(t, "action", "release", res.Events[5].Attributes[1]) // custom contract event - assert.Equal(t, "wasm-hackatom", res.Events[4].Type) - assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[4].Attributes[0]) - assertAttribute(t, "action", "release", res.Events[4].Attributes[1]) + assert.Equal(t, "wasm-hackatom", res.Events[6].Type) + assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[6].Attributes[0]) + assertAttribute(t, "action", "release", res.Events[6].Attributes[1]) // second transfer (this without conflicting message) - assert.Equal(t, "transfer", res.Events[5].Type) - assertAttribute(t, "recipient", bob.String(), res.Events[5].Attributes[0]) - assertAttribute(t, "sender", contractBech32Addr, res.Events[5].Attributes[1]) - assertAttribute(t, "amount", "105000denom", res.Events[5].Attributes[2]) + assert.Equal(t, "coin_spent", res.Events[7].Type) + assert.Equal(t, "coin_received", res.Events[8].Type) + + assert.Equal(t, "transfer", res.Events[9].Type) + assertAttribute(t, "recipient", bob.String(), res.Events[9].Attributes[0]) + assertAttribute(t, "sender", contractBech32Addr, res.Events[9].Attributes[1]) + assertAttribute(t, "amount", "105000denom", res.Events[9].Attributes[2]) // finally, standard x/wasm tag // ensure bob now exists and got both payments released @@ -311,7 +319,7 @@ func TestHandleExecute(t *testing.T) { contractAcct = data.acctKeeper.GetAccount(data.ctx, contractAddr) require.NotNil(t, contractAcct) - assert.Equal(t, sdk.Coins(nil), data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress())) + assert.Equal(t, sdk.Coins{}, data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress())) // ensure all contract state is as after init assertCodeList(t, q, data.ctx, 1) @@ -331,8 +339,8 @@ func TestHandleExecuteEscrow(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, deposit.Add(deposit...)) - fred := createFakeFundedAccount(t, data.ctx, data.acctKeeper, data.bankKeeper, topUp) + creator := data.faucet.NewFundedAccount(data.ctx, deposit.Add(deposit...)...) + fred := data.faucet.NewFundedAccount(data.ctx, topUp...) h := data.module.Route().Handler() @@ -360,7 +368,7 @@ func TestHandleExecuteEscrow(t *testing.T) { res, err = h(data.ctx, &initCmd) require.NoError(t, err) contractBech32Addr := parseInitResponse(t, res.Data) - require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6", contractBech32Addr) + require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", contractBech32Addr) handleMsg := map[string]interface{}{ "release": map[string]interface{}{}, @@ -389,7 +397,7 @@ func TestHandleExecuteEscrow(t *testing.T) { contractAddr, _ := sdk.AccAddressFromBech32(contractBech32Addr) contractAcct := data.acctKeeper.GetAccount(data.ctx, contractAddr) require.NotNil(t, contractAcct) - assert.Equal(t, sdk.Coins(nil), data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress())) + assert.Equal(t, sdk.Coins{}, data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress())) } func TestReadWasmConfig(t *testing.T) { @@ -570,12 +578,3 @@ func assertContractInfo(t *testing.T, q sdk.Querier, ctx sdk.Context, contractBe assert.Equal(t, codeID, res.CodeID) assert.Equal(t, creator.String(), res.Creator) } - -func createFakeFundedAccount(t *testing.T, ctx sdk.Context, am authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, coins sdk.Coins) sdk.AccAddress { - t.Helper() - _, _, addr := keyPubAddr() - acc := am.NewAccountWithAddress(ctx, addr) - am.SetAccount(ctx, acc) - require.NoError(t, bankKeeper.SetBalances(ctx, addr, coins)) - return addr -} diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index 4e58663a..c7e83212 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -5,17 +5,18 @@ import ( "fmt" "testing" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + ibctesting "github.com/cosmos/ibc-go/v2/testing" + wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - wasmd "github.com/CosmWasm/wasmd/app" wasmibctesting "github.com/CosmWasm/wasmd/x/wasm/ibctesting" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" @@ -30,6 +31,12 @@ const ( var doNotTimeout = clienttypes.NewHeight(1, 1111111) func TestPinPong(t *testing.T) { + // custom IBC protocol example + // scenario: given two chains, + // with a contract on chain A and chain B + // when a ibc packet comes in, the contract responds with a new packet containing + // either ping or pong + pingContract := &player{t: t, actor: ping} pongContract := &player{t: t, actor: pong} @@ -44,14 +51,13 @@ func TestPinPong(t *testing.T) { chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) - coordinator.CommitBlock(chainA, chainB) - _ = chainB.SeedNewContractInstance() // skip 1 instance so that addresses are not the same var ( pingContractAddr = chainA.SeedNewContractInstance() pongContractAddr = chainB.SeedNewContractInstance() ) require.NotEqual(t, pingContractAddr, pongContractAddr) + coordinator.CommitBlock(chainA, chainB) pingContract.chain = chainA pingContract.contractAddr = pingContractAddr @@ -63,16 +69,26 @@ func TestPinPong(t *testing.T) { sourcePortID = wasmkeeper.PortIDForContract(pingContractAddr) counterpartyPortID = wasmkeeper.PortIDForContract(pongContractAddr) ) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - connA.NextChannelVersion = ping - connB.NextChannelVersion = pong - channelA, _ := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartyPortID, channeltypes.UNORDERED) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: sourcePortID, + Version: ibctransfertypes.Version, + Order: channeltypes.ORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: counterpartyPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.ORDERED, + } + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) + // trigger start game via execute const startValue uint64 = 100 const rounds = 3 s := startGame{ - ChannelID: channelA.ID, + ChannelID: path.EndpointA.ChannelID, Value: startValue, } startMsg := &wasmtypes.MsgExecuteContract{ @@ -80,21 +96,25 @@ func TestPinPong(t *testing.T) { Contract: pingContractAddr.String(), Msg: s.GetBytes(), } - // send message to chainA - err := coordinator.SendMsg(chainA, chainB, clientB, startMsg) + // on chain A + _, err := path.EndpointA.Chain.SendMsgs(startMsg) require.NoError(t, err) - t.Log("Duplicate messages are due to check/deliver tx calls") - + // when some rounds are played for i := 1; i <= rounds; i++ { t.Logf("++ round: %d\n", i) - err := coordinator.RelayAndAckPendingPackets(chainA, chainB, clientA, clientB) + + require.Len(t, chainA.PendingSendPackets, 1) + err := coordinator.RelayAndAckPendingPackets(path) require.NoError(t, err) // switch side - err = coordinator.RelayAndAckPendingPackets(chainB, chainA, clientB, clientA) + require.Len(t, chainB.PendingSendPackets, 1) + err = coordinator.RelayAndAckPendingPackets(path.Invert()) require.NoError(t, err) } + + // then receive/response state is as expected assert.Equal(t, startValue+rounds, pingContract.QueryState(lastBallSentKey)) assert.Equal(t, uint64(rounds), pingContract.QueryState(lastBallReceivedKey)) assert.Equal(t, uint64(rounds+1), pingContract.QueryState(sentBallsCountKey)) @@ -106,7 +126,6 @@ func TestPinPong(t *testing.T) { assert.Equal(t, uint64(rounds), pongContract.QueryState(sentBallsCountKey)) assert.Equal(t, uint64(rounds), pongContract.QueryState(receivedBallsCountKey)) assert.Equal(t, uint64(rounds), pongContract.QueryState(confirmedBallsCountKey)) - } var _ wasmtesting.IBCContractCallbacks = &player{} @@ -124,9 +143,6 @@ type player struct { // Contracts finds all connected channels and broadcasts a ping message func (p *player) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { p.execCalls++ - if p.execCalls%2 == 1 { // skip checkTx step because of no rollback with `chain.GetContext()` - return &wasmvmtypes.Response{}, 0, nil - } // start game var start startGame if err := json.Unmarshal(executeMsg, &start); err != nil { @@ -306,7 +322,7 @@ func (p player) incrementCounter(key []byte, store wasmvm.KVStore) uint64 { } func (p player) QueryState(key []byte) uint64 { - raw := wasmd.NewTestSupport(p.t, p.chain.App).WasmKeeper().QueryRaw(p.chain.GetContext(), p.contractAddr, key) + raw := p.chain.GetTestSupport().WasmKeeper().QueryRaw(p.chain.GetContext(), p.contractAddr, key) return sdk.BigEndianToUint64(raw) } diff --git a/x/wasm/relay_test.go b/x/wasm/relay_test.go index 51379719..67862721 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -2,6 +2,7 @@ package wasm_test import ( "encoding/json" + "errors" "testing" "time" @@ -9,102 +10,160 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v2/testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - wasmd "github.com/CosmWasm/wasmd/app" - "github.com/CosmWasm/wasmd/x/wasm/ibctesting" + wasmibctesting "github.com/CosmWasm/wasmd/x/wasm/ibctesting" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtesting "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" "github.com/CosmWasm/wasmd/x/wasm/types" ) func TestFromIBCTransferToContract(t *testing.T) { - // scenario: a contract can handle the receiving side of an ics20 transfer - myContract := receiverContract{t: t} - var ( - chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(&myContract), - )} - coordinator = ibctesting.NewCoordinator(t, 2, nil, chainAOpts) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) - ) - coordinator.CommitBlock(chainA, chainB) - myContractAddr := chainB.SeedNewContractInstance() - contractAPortID := chainB.ContractInfo(myContractAddr).IBCPortID + // scenario: given two chains, + // with a contract on chain B + // then the contract can handle the receiving side of an ics20 transfer + // that was started on chain A via ibc transfer module - myContract.contractAddr = myContractAddr - myContract.chain = chainB + transferAmount := sdk.NewInt(1) + specs := map[string]struct { + contract wasmtesting.IBCContractCallbacks + setupContract func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) + expChainABalanceDiff sdk.Int + expChainBBalanceDiff sdk.Int + }{ + "ack": { + contract: &ackReceiverContract{}, + setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { + c := contract.(*ackReceiverContract) + c.t = t + c.chain = chain + }, + expChainABalanceDiff: transferAmount.Neg(), + expChainBBalanceDiff: transferAmount, + }, + "nack": { + contract: &nackReceiverContract{}, + setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { + c := contract.(*nackReceiverContract) + c.t = t + }, + expChainABalanceDiff: sdk.ZeroInt(), + expChainBBalanceDiff: sdk.ZeroInt(), + }, + "error": { + contract: &errorReceiverContract{}, + setupContract: func(t *testing.T, contract wasmtesting.IBCContractCallbacks, chain *wasmibctesting.TestChain) { + c := contract.(*errorReceiverContract) + c.t = t + }, + expChainABalanceDiff: sdk.ZeroInt(), + expChainBBalanceDiff: sdk.ZeroInt(), + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + var ( + chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( + wasmtesting.NewIBCContractMockWasmer(spec.contract), + )} + coordinator = wasmibctesting.NewCoordinator(t, 2, []wasmkeeper.Option{}, chainAOpts) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) + ) + coordinator.CommitBlock(chainA, chainB) + myContractAddr := chainB.SeedNewContractInstance() + contractBPortID := chainB.ContractInfo(myContractAddr).IBCPortID - var ( - sourcePortID = "transfer" - counterpartPortID = contractAPortID - ) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.UNORDERED) + spec.setupContract(t, spec.contract, chainB) - originalBalance := wasmd.NewTestSupport(t, chainA.App).BankKeeper().GetBalance(chainA.GetContext(), chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: "transfer", + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: contractBPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } - // with the channels established, let's do a transfer via sdk transfer - coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) - timeoutHeight := clienttypes.NewHeight(1, 110) - msg := ibctransfertypes.NewMsgTransfer(channelA.PortID, channelA.ID, coinToSendToB, chainA.SenderAccount.GetAddress(), chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) - err := coordinator.SendMsg(chainA, chainB, clientB, msg) - require.NoError(t, err) + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) - // when relay to chain B and handle Ack on chain A - fungibleTokenPacket := ibctransfertypes.NewFungibleTokenPacketData(coinToSendToB.Denom, coinToSendToB.Amount.Uint64(), chainA.SenderAccount.GetAddress().String(), chainB.SenderAccount.GetAddress().String()) - packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).GetBytes() - err = coordinator.RelayPacket(chainA, chainB, clientA, clientB, packet, ack) - require.NoError(t, err) + originalChainABalance := chainA.Balance(chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + // when transfer via sdk transfer from A (module) -> B (contract) + coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + timeoutHeight := clienttypes.NewHeight(1, 110) + msg := ibctransfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, coinToSendToB, chainA.SenderAccount.GetAddress().String(), chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0) + _, err := chainA.SendMsgs(msg) + require.NoError(t, err) + require.NoError(t, path.EndpointB.UpdateClient()) - // then - newBalance := wasmd.NewTestSupport(t, chainA.App).BankKeeper().GetBalance(chainA.GetContext(), chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) - assert.Equal(t, originalBalance.Sub(coinToSendToB), newBalance) + // then + require.Equal(t, 1, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) - voucherDenom := ibctransfertypes.ParseDenomTrace(ibctransfertypes.GetPrefixedDenom(channelB.PortID, channelB.ID, coinToSendToB.Denom)).IBCDenom() - bankKeeperB := wasmd.NewTestSupport(t, chainB.App).BankKeeper() - chainBBalance := bankKeeperB.GetBalance(chainB.GetContext(), chainB.SenderAccount.GetAddress(), voucherDenom) - // note: the contract is called during check and deliverTX but the context used in the contract does not rollback - // so that we got twice the amount - assert.Equal(t, sdk.Coin{Denom: voucherDenom, Amount: coinToSendToB.Amount.Mul(sdk.NewInt(2))}.String(), chainBBalance.String(), bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) + // and when relay to chain B and handle Ack on chain A + err = coordinator.RelayAndAckPendingPackets(path) + require.NoError(t, err) + + // then + require.Equal(t, 0, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) + + // and source chain balance was decreased + newChainABalance := chainA.Balance(chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + assert.Equal(t, originalChainABalance.Amount.Add(spec.expChainABalanceDiff), newChainABalance.Amount) + + // and dest chain balance contains voucher + expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, spec.expChainBBalanceDiff) + gotBalance := chainB.Balance(chainB.SenderAccount.GetAddress(), expBalance.Denom) + assert.Equal(t, expBalance, gotBalance, "got total balance: %s", chainB.AllBalances(chainB.SenderAccount.GetAddress())) + }) + } } -func TestContractCanUseIBCTransferMsg(t *testing.T) { - // scenario: a contract can start an ibc transfer via ibctransfertypes.NewMsgTransfer - // on an existing connection - myContract := &sendViaIBCTransferContract{t: t} +func TestContractCanInitiateIBCTransferMsg(t *testing.T) { + // scenario: given two chains, + // with a contract on chain A + // then the contract can start an ibc transfer via ibctransfertypes.NewMsgTransfer + // that is handled on chain A by the ibc transfer module and + // received on chain B via ibc transfer module as well + myContract := &sendViaIBCTransferContract{t: t} var ( chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( wasmtesting.NewIBCContractMockWasmer(myContract)), } - coordinator = ibctesting.NewCoordinator(t, 2, chainAOpts, nil) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) + coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) - coordinator.CommitBlock(chainA, chainB) myContractAddr := chainA.SeedNewContractInstance() coordinator.CommitBlock(chainA, chainB) - var ( - sourcePortID = ibctransfertypes.ModuleName - counterpartPortID = ibctransfertypes.ModuleName - ) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: ibctransfertypes.PortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: ibctransfertypes.PortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.UNORDERED) - - // send message to chainA + // when contract is triggered to send IBCTransferMsg receiverAddress := chainB.SenderAccount.GetAddress() - - timeoutHeight := clienttypes.NewHeight(0, 110) coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) // start transfer from chainA to chainB @@ -112,57 +171,70 @@ func TestContractCanUseIBCTransferMsg(t *testing.T) { Sender: chainA.SenderAccount.GetAddress().String(), Contract: myContractAddr.String(), Msg: startTransfer{ - ChannelID: channelA.ID, + ChannelID: path.EndpointA.ChannelID, CoinsToSend: coinToSendToB, ReceiverAddr: receiverAddress.String(), }.GetBytes(), } - err := coordinator.SendMsg(chainA, chainB, clientB, startMsg) + _, err := chainA.SendMsgs(startMsg) require.NoError(t, err) - // relay send - fungibleTokenPacket := ibctransfertypes.NewFungibleTokenPacketData(coinToSendToB.Denom, coinToSendToB.Amount.Uint64(), myContractAddr.String(), receiverAddress.String()) - packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - err = coordinator.RelayPacket(chainA, chainB, clientA, clientB, packet, ack.GetBytes()) - require.NoError(t, err) // relay committed + // then + require.Equal(t, 1, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) - bankKeeperB := wasmd.NewTestSupport(t, chainB.App).BankKeeper() - voucherDenom := ibctransfertypes.ParseDenomTrace(ibctransfertypes.GetPrefixedDenom(channelB.PortID, channelB.ID, coinToSendToB.Denom)).IBCDenom() - newBalance := bankKeeperB.GetBalance(chainB.GetContext(), receiverAddress, voucherDenom) - assert.Equal(t, sdk.NewCoin(voucherDenom, coinToSendToB.Amount).String(), newBalance.String(), bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) + // and when relay to chain B and handle Ack on chain A + err = coordinator.RelayAndAckPendingPackets(path) + require.NoError(t, err) + + // then + require.Equal(t, 0, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) + + // and dest chain balance contains voucher + bankKeeperB := chainB.GetTestSupport().BankKeeper() + expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, coinToSendToB.Amount) + gotBalance := chainB.Balance(chainB.SenderAccount.GetAddress(), expBalance.Denom) + assert.Equal(t, expBalance, gotBalance, "got total balance: %s", bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) } func TestContractCanEmulateIBCTransferMessage(t *testing.T) { - // scenario: a contract can be the sending side of an ics20 transfer - // on an existing connection + // scenario: given two chains, + // with a contract on chain A + // then the contract can emulate the ibc transfer module in the contract to send an ibc packet + // which is received on chain B via ibc transfer module + myContract := &sendEmulatedIBCTransferContract{t: t} var ( chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( wasmtesting.NewIBCContractMockWasmer(myContract)), } - coordinator = ibctesting.NewCoordinator(t, 2, chainAOpts, nil) + coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) - coordinator.CommitBlock(chainA, chainB) myContractAddr := chainA.SeedNewContractInstance() myContract.contractAddr = myContractAddr.String() - var ( - sourcePortID = chainA.ContractInfo(myContractAddr).IBCPortID - counterpartPortID = ibctransfertypes.ModuleName - ) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.UNORDERED) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: chainA.ContractInfo(myContractAddr).IBCPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: ibctransfertypes.PortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) - // send message to chainA - receiverAddress := chainB.SenderAccount.GetAddress() - - var timeoutHeight clienttypes.Height + // 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)) // start transfer from chainA to chainB @@ -170,89 +242,115 @@ func TestContractCanEmulateIBCTransferMessage(t *testing.T) { Sender: chainA.SenderAccount.GetAddress().String(), Contract: myContractAddr.String(), Msg: startTransfer{ - ChannelID: channelA.ID, + ChannelID: path.EndpointA.ChannelID, CoinsToSend: coinToSendToB, ReceiverAddr: receiverAddress.String(), ContractIBCPort: chainA.ContractInfo(myContractAddr).IBCPortID, Timeout: timeout, }.GetBytes(), + Funds: sdk.NewCoins(coinToSendToB), } - err := coordinator.SendMsg(chainA, chainB, clientB, startMsg) + _, err := chainA.SendMsgs(startMsg) require.NoError(t, err) - // relay send - fungibleTokenPacket := ibctransfertypes.NewFungibleTokenPacketData(coinToSendToB.Denom, coinToSendToB.Amount.Uint64(), myContractAddr.String(), receiverAddress.String()) - packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, timeout) - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - err = coordinator.RelayPacket(chainA, chainB, clientA, clientB, packet, ack.GetBytes()) - require.NoError(t, err) // relay committed + // then + require.Equal(t, 1, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) - bankKeeperB := wasmd.NewTestSupport(t, chainB.App).BankKeeper() - voucherDenom := ibctransfertypes.ParseDenomTrace(ibctransfertypes.GetPrefixedDenom(channelB.PortID, channelB.ID, coinToSendToB.Denom)).IBCDenom() - newBalance := bankKeeperB.GetBalance(chainB.GetContext(), receiverAddress, voucherDenom) - assert.Equal(t, sdk.NewCoin(voucherDenom, coinToSendToB.Amount).String(), newBalance.String(), bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) + // and when relay to chain B and handle Ack on chain A + err = coordinator.RelayAndAckPendingPackets(path) + require.NoError(t, err) + + // then + require.Equal(t, 0, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) + + // and dest chain balance contains voucher + bankKeeperB := chainB.GetTestSupport().BankKeeper() + expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, coinToSendToB.Amount) + gotBalance := chainB.Balance(chainB.SenderAccount.GetAddress(), expBalance.Denom) + assert.Equal(t, expBalance, gotBalance, "got total balance: %s", bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) } func TestContractCanEmulateIBCTransferMessageWithTimeout(t *testing.T) { - // scenario: a contract is the sending side of an ics20 transfer but the packet was not received - // on the destination chain within the timeout boundaries + // scenario: given two chains, + // with a contract on chain A + // then the contract can emulate the ibc transfer module in the contract to send an ibc packet + // which is not received on chain B and times out + myContract := &sendEmulatedIBCTransferContract{t: t} var ( chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( wasmtesting.NewIBCContractMockWasmer(myContract)), } - coordinator = ibctesting.NewCoordinator(t, 2, chainAOpts, nil) + coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) coordinator.CommitBlock(chainA, chainB) myContractAddr := chainA.SeedNewContractInstance() myContract.contractAddr = myContractAddr.String() - var ( - sourcePortID = chainA.ContractInfo(myContractAddr).IBCPortID - counterpartPortID = ibctransfertypes.ModuleName - ) - clientA, clientB, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.UNORDERED) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: chainA.ContractInfo(myContractAddr).IBCPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: ibctransfertypes.PortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) + coordinator.UpdateTime() - // start process by sending message to the contract on chainA + // 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)) - timeout := uint64(chainB.LastHeader.Header.Time.Add(time.Nanosecond).UnixNano()) // not enough time + initialContractBalance := chainA.Balance(myContractAddr, sdk.DefaultBondDenom) + initialSenderBalance := chainA.Balance(chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) // custom payload data to be transferred into a proper ICS20 ibc packet startMsg := &types.MsgExecuteContract{ Sender: chainA.SenderAccount.GetAddress().String(), Contract: myContractAddr.String(), Msg: startTransfer{ - ChannelID: channelA.ID, + ChannelID: path.EndpointA.ChannelID, CoinsToSend: coinToSendToB, ReceiverAddr: receiverAddress.String(), ContractIBCPort: chainA.ContractInfo(myContractAddr).IBCPortID, Timeout: timeout, }.GetBytes(), + Funds: sdk.NewCoins(coinToSendToB), } - err := coordinator.SendMsg(chainA, chainB, clientB, startMsg) + _, err := chainA.SendMsgs(startMsg) require.NoError(t, err) - err = coordinator.UpdateClient(chainA, chainB, clientA, ibcexported.Tendermint) + coordinator.CommitBlock(chainA, chainB) + // then + require.Equal(t, 1, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) + newContractBalance := chainA.Balance(myContractAddr, sdk.DefaultBondDenom) + assert.Equal(t, initialContractBalance.Add(coinToSendToB), newContractBalance) // hold in escrow + + // when timeout packet send (by the relayer) + err = coordinator.TimeoutPendingPackets(path) require.NoError(t, err) + coordinator.CommitBlock(chainA) - // timeout packet send (by the relayer) - fungibleTokenPacketData := ibctransfertypes.NewFungibleTokenPacketData(coinToSendToB.Denom, coinToSendToB.Amount.Uint64(), myContractAddr.String(), receiverAddress.String()) - var timeoutHeight clienttypes.Height - packet := channeltypes.NewPacket(fungibleTokenPacketData.GetBytes(), 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, timeout) + // then + require.Equal(t, 0, len(chainA.PendingSendPackets)) + require.Equal(t, 0, len(chainB.PendingSendPackets)) - err = coordinator.TimeoutPacket(chainA, chainB, clientB, packet) - require.NoError(t, err) - - // then verify account has no vouchers - bankKeeperB := wasmd.NewTestSupport(t, chainB.App).BankKeeper() - voucherDenom := ibctransfertypes.ParseDenomTrace(ibctransfertypes.GetPrefixedDenom(channelB.PortID, channelB.ID, coinToSendToB.Denom)).IBCDenom() - newBalance := bankKeeperB.GetBalance(chainB.GetContext(), receiverAddress, voucherDenom) - assert.Equal(t, sdk.NewInt64Coin(voucherDenom, 0).String(), newBalance.String(), bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress())) + // and then verify account balances restored + newContractBalance = chainA.Balance(myContractAddr, sdk.DefaultBondDenom) + assert.Equal(t, initialContractBalance.String(), newContractBalance.String()) + newSenderBalance := chainA.Balance(chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) + assert.Equal(t, initialSenderBalance.String(), newSenderBalance.String()) } func TestContractHandlesChannelClose(t *testing.T) { @@ -268,31 +366,31 @@ func TestContractHandlesChannelClose(t *testing.T) { chainBOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( wasmtesting.NewIBCContractMockWasmer(myContractB)), } - coordinator = ibctesting.NewCoordinator(t, 2, chainAOpts, chainBOpts) + coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts, chainBOpts) - chainA = coordinator.GetChain(ibctesting.GetChainID(0)) - chainB = coordinator.GetChain(ibctesting.GetChainID(1)) + chainA = coordinator.GetChain(wasmibctesting.GetChainID(0)) + chainB = coordinator.GetChain(wasmibctesting.GetChainID(1)) ) + coordinator.CommitBlock(chainA, chainB) myContractAddrA := chainA.SeedNewContractInstance() _ = chainB.SeedNewContractInstance() // skip one instance myContractAddrB := chainB.SeedNewContractInstance() - var ( - sourcePortID = chainA.ContractInfo(myContractAddrA).IBCPortID - counterpartPortID = chainB.ContractInfo(myContractAddrB).IBCPortID - ) - _, _, connA, connB := coordinator.SetupClientConnections(chainA, chainB, ibcexported.Tendermint) - channelA, channelB := coordinator.CreateChannel(chainA, chainB, connA, connB, sourcePortID, counterpartPortID, channeltypes.UNORDERED) - - err := coordinator.ChanCloseInit(chainA, chainB, channelA) - require.NoError(t, err) - assert.True(t, myContractA.closeCalled) - - err = coordinator.UpdateClient(chainB, chainA, channelB.ClientID, ibcexported.Tendermint) - require.NoError(t, err) - err = coordinator.ChanCloseConfirm(chainA, chainB, channelA, channelB) - require.NoError(t, err) + path := wasmibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: chainA.ContractInfo(myContractAddrA).IBCPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{ + PortID: chainB.ContractInfo(myContractAddrB).IBCPortID, + Version: ibctransfertypes.Version, + Order: channeltypes.UNORDERED, + } + coordinator.SetupConnections(path) + coordinator.CreateChannels(path) + coordinator.CloseChannel(path) assert.True(t, myContractB.closeCalled) } @@ -335,7 +433,6 @@ func (s *sendViaIBCTransferContract) Execute(code wasmvm.Checksum, env wasmvmtyp } return &wasmvmtypes.Response{Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{IBC: ibcMsg}}}}, 0, nil - return &wasmvmtypes.Response{Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{IBC: ibcMsg}}}}, 0, nil } var _ wasmtesting.IBCContractCallbacks = &sendEmulatedIBCTransferContract{} @@ -353,9 +450,11 @@ func (s *sendEmulatedIBCTransferContract) Execute(code wasmvm.Checksum, env wasm if err := json.Unmarshal(executeMsg, &in); err != nil { return nil, 0, err } - + require.Len(s.t, info.Funds, 1) + require.Equal(s.t, in.CoinsToSend.Amount.String(), info.Funds[0].Amount) + require.Equal(s.t, in.CoinsToSend.Denom, info.Funds[0].Denom) dataPacket := ibctransfertypes.NewFungibleTokenPacketData( - in.CoinsToSend.Denom, in.CoinsToSend.Amount.Uint64(), s.contractAddr, in.ReceiverAddr, + in.CoinsToSend.Denom, in.CoinsToSend.Amount.String(), info.Sender, in.ReceiverAddr, ) if err := dataPacket.ValidateBasic(); err != nil { return nil, 0, err @@ -378,11 +477,16 @@ func (c *sendEmulatedIBCTransferContract) IBCPacketTimeout(codeID wasmvm.Checksu if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(packet.Data, &data); err != nil { return nil, 0, err } + if err := data.ValidateBasic(); err != nil { + return nil, 0, err + + } + amount, _ := sdk.NewIntFromString(data.Amount) returnTokens := &wasmvmtypes.BankMsg{ Send: &wasmvmtypes.SendMsg{ ToAddress: data.Sender, - Amount: wasmvmtypes.Coins{wasmvmtypes.NewCoin(data.Amount, data.Denom)}, + Amount: wasmvmtypes.Coins{wasmvmtypes.NewCoin(amount.Uint64(), data.Denom)}, }} return &wasmvmtypes.IBCBasicResponse{Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{Bank: returnTokens}}}}, 0, nil @@ -405,38 +509,38 @@ func (g startTransfer) GetBytes() types.RawContractMessage { return b } -var _ wasmtesting.IBCContractCallbacks = &receiverContract{} +var _ wasmtesting.IBCContractCallbacks = &ackReceiverContract{} // contract that acts as the receiving side for an ics-20 transfer. -type receiverContract struct { +type ackReceiverContract struct { contractStub - t *testing.T - contractAddr sdk.AccAddress - chain *ibctesting.TestChain + t *testing.T + chain *wasmibctesting.TestChain } -func (c *receiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (c *ackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { packet := msg.Packet var src ibctransfertypes.FungibleTokenPacketData if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(packet.Data, &src); err != nil { return nil, 0, err } + require.NoError(c.t, src.ValidateBasic()) + // call original ibctransfer keeper to not copy all code into this ibcPacket := toIBCPacket(packet) ctx := c.chain.GetContext() // HACK: please note that this is not reverted after checkTX - err := c.chain.TestSupport().TransferKeeper().OnRecvPacket(ctx, ibcPacket, src) + err := c.chain.GetTestSupport().TransferKeeper().OnRecvPacket(ctx, ibcPacket, src) if err != nil { return nil, 0, sdkerrors.Wrap(err, "within our smart contract") } var log []wasmvmtypes.EventAttribute // note: all events are under `wasm` event type - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).GetBytes() + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() return &wasmvmtypes.IBCReceiveResult{Ok: &wasmvmtypes.IBCReceiveResponse{Acknowledgement: ack, Attributes: log}}, 0, nil } -func (c *receiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { - +func (c *ackReceiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { var data ibctransfertypes.FungibleTokenPacketData if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(msg.OriginalPacket.Data, &data); err != nil { return nil, 0, err @@ -451,7 +555,7 @@ func (c *receiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes. // call original ibctransfer keeper to not copy all code into this ctx := c.chain.GetContext() // HACK: please note that this is not reverted after checkTX ibcPacket := toIBCPacket(msg.OriginalPacket) - err := c.chain.TestSupport().TransferKeeper().OnAcknowledgementPacket(ctx, ibcPacket, data, ack) + err := c.chain.GetTestSupport().TransferKeeper().OnAcknowledgementPacket(ctx, ibcPacket, data, ack) if err != nil { return nil, 0, sdkerrors.Wrap(err, "within our smart contract") } @@ -459,6 +563,40 @@ func (c *receiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes. return &wasmvmtypes.IBCBasicResponse{}, 0, nil } +// contract that acts as the receiving side for an ics-20 transfer and always returns a nack. +type nackReceiverContract struct { + contractStub + t *testing.T +} + +func (c *nackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { + packet := msg.Packet + + var src ibctransfertypes.FungibleTokenPacketData + if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(packet.Data, &src); err != nil { + return nil, 0, err + } + require.NoError(c.t, src.ValidateBasic()) + return &wasmvmtypes.IBCReceiveResult{Err: "nack-testing"}, 0, nil +} + +// contract that acts as the receiving side for an ics-20 transfer and always returns an error. +type errorReceiverContract struct { + contractStub + t *testing.T +} + +func (c *errorReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { + packet := msg.Packet + + var src ibctransfertypes.FungibleTokenPacketData + if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(packet.Data, &src); err != nil { + return nil, 0, err + } + require.NoError(c.t, src.ValidateBasic()) + return nil, 0, errors.New("error-testing") +} + // simple helper struct that implements connection setup methods. type contractStub struct{} diff --git a/x/wasm/simulation/genesis.go b/x/wasm/simulation/genesis.go index 4ac69fb1..c9bd60e7 100644 --- a/x/wasm/simulation/genesis.go +++ b/x/wasm/simulation/genesis.go @@ -13,8 +13,11 @@ func RandomizedGenState(simstate *module.SimulationState) { Params: params, Codes: nil, Contracts: nil, - Sequences: nil, - GenMsgs: nil, + Sequences: []types.Sequence{ + {IDKey: types.KeyLastCodeID, Value: simstate.Rand.Uint64()}, + {IDKey: types.KeyLastInstanceID, Value: simstate.Rand.Uint64()}, + }, + GenMsgs: nil, } _, err := simstate.Cdc.MarshalJSON(&wasmGenesis) diff --git a/x/wasm/simulation/params.go b/x/wasm/simulation/params.go index bb2e4fc9..1f953cca 100644 --- a/x/wasm/simulation/params.go +++ b/x/wasm/simulation/params.go @@ -11,7 +11,7 @@ import ( "github.com/CosmWasm/wasmd/x/wasm/types" ) -func ParamChanges(r *rand.Rand, cdc codec.Marshaler) []simtypes.ParamChange { +func ParamChanges(r *rand.Rand, cdc codec.Codec) []simtypes.ParamChange { params := RandomParams(r) return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, string(types.ParamStoreKeyUploadAccess), diff --git a/x/wasm/types/expected_keepers.go b/x/wasm/types/expected_keepers.go index bf3efc64..873e906e 100644 --- a/x/wasm/types/expected_keepers.go +++ b/x/wasm/types/expected_keepers.go @@ -7,10 +7,10 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" - connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types" - channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported" ) // BankViewKeeper defines a subset of methods implemented by the cosmos-sdk bank keeper @@ -29,7 +29,7 @@ type Burner interface { type BankKeeper interface { BankViewKeeper Burner - SendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error + IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error BlockedAddr(addr sdk.AccAddress) bool SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error } diff --git a/x/wasm/types/keys.go b/x/wasm/types/keys.go index fe802f28..982bf1a0 100644 --- a/x/wasm/types/keys.go +++ b/x/wasm/types/keys.go @@ -57,7 +57,7 @@ func GetContractStorePrefix(addr sdk.AccAddress) []byte { func GetContractByCreatedSecondaryIndexKey(contractAddr sdk.AccAddress, c ContractCodeHistoryEntry) []byte { prefix := GetContractByCodeIDSecondaryIndexPrefix(c.CodeID) prefixLen := len(prefix) - r := make([]byte, prefixLen+AbsoluteTxPositionLen+sdk.AddrLen) + r := make([]byte, prefixLen+AbsoluteTxPositionLen+ContractAddrLen) copy(r[0:], prefix) copy(r[prefixLen:], c.Updated.Bytes()) copy(r[prefixLen+AbsoluteTxPositionLen:], contractAddr) @@ -87,7 +87,7 @@ func GetContractCodeHistoryElementKey(contractAddr sdk.AccAddress, pos uint64) [ // GetContractCodeHistoryElementPrefix returns the key prefix for a contract code history entry: `` func GetContractCodeHistoryElementPrefix(contractAddr sdk.AccAddress) []byte { prefixLen := len(ContractCodeHistoryElementPrefix) - r := make([]byte, prefixLen+sdk.AddrLen) + r := make([]byte, prefixLen+ContractAddrLen) copy(r[0:], ContractCodeHistoryElementPrefix) copy(r[prefixLen:], contractAddr) return r diff --git a/x/wasm/types/keys_test.go b/x/wasm/types/keys_test.go index 95ef74ff..614a73fd 100644 --- a/x/wasm/types/keys_test.go +++ b/x/wasm/types/keys_test.go @@ -4,7 +4,6 @@ import ( "bytes" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" ) @@ -33,13 +32,16 @@ func TestGetContractByCreatedSecondaryIndexKey(t *testing.T) { CodeID: 1, Updated: &AbsoluteTxPosition{2 + 1<<(8*7), 3 + 1<<(8*7)}, } - addr := bytes.Repeat([]byte{4}, sdk.AddrLen) + addr := bytes.Repeat([]byte{4}, ContractAddrLen) got := GetContractByCreatedSecondaryIndexKey(addr, e) exp := []byte{6, // prefix 0, 0, 0, 0, 0, 0, 0, 1, // codeID 1, 0, 0, 0, 0, 0, 0, 2, // height 1, 0, 0, 0, 0, 0, 0, 3, // index - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // address + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // address 32 bytes + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, } assert.Equal(t, exp, got) } diff --git a/x/wasm/types/params.go b/x/wasm/types/params.go index 1a3eede8..c3b21d2e 100644 --- a/x/wasm/types/params.go +++ b/x/wasm/types/params.go @@ -13,8 +13,6 @@ import ( ) const ( - // DefaultParamspace for params keeper - DefaultParamspace = ModuleName // DefaultMaxWasmCodeSize limit max bytes read to prevent gzip bombs DefaultMaxWasmCodeSize = 600 * 1024 * 2 ) diff --git a/x/wasm/types/params_test.go b/x/wasm/types/params_test.go index 21b2443c..4cf9bab8 100644 --- a/x/wasm/types/params_test.go +++ b/x/wasm/types/params_test.go @@ -13,7 +13,7 @@ import ( func TestValidateParams(t *testing.T) { var ( - anyAddress sdk.AccAddress = make([]byte, sdk.AddrLen) + anyAddress sdk.AccAddress = make([]byte, ContractAddrLen) invalidAddress = "invalid address" ) diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go index 8e2aed8f..aac9c73d 100644 --- a/x/wasm/types/proposal_test.go +++ b/x/wasm/types/proposal_test.go @@ -95,7 +95,7 @@ func TestValidateProposalCommons(t *testing.T) { func TestValidateStoreCodeProposal(t *testing.T) { var ( - anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x0}, sdk.AddrLen) + anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x0}, ContractAddrLen) invalidAddress = "invalid address" ) @@ -439,7 +439,7 @@ func TestProposalStrings(t *testing.T) { exp: `Store Code Proposal: Title: Foo Description: Bar - Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du + Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 WasmCode: 0102030405060708090A `, }, @@ -450,11 +450,11 @@ func TestProposalStrings(t *testing.T) { exp: `Instantiate Code Proposal: Title: Foo Description: Bar - Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du - Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du + Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 + Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 Code id: 1 Label: testing - Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\"}" + Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\"}" Funds: 1foo,2bar `, }, @@ -463,11 +463,11 @@ func TestProposalStrings(t *testing.T) { exp: `Instantiate Code Proposal: Title: Foo Description: Bar - Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du - Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du + Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 + Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 Code id: 1 Label: testing - Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\"}" + Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\"}" Funds: `, }, @@ -476,11 +476,11 @@ func TestProposalStrings(t *testing.T) { exp: `Instantiate Code Proposal: Title: Foo Description: Bar - Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du + Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 Admin: Code id: 1 Label: testing - Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\"}" + Msg: "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\",\"beneficiary\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\"}" Funds: `, }, @@ -489,10 +489,10 @@ func TestProposalStrings(t *testing.T) { exp: `Migrate Contract Proposal: Title: Foo Description: Bar - Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 + Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr Code id: 1 - Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du - Msg "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du\"}" + Run as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 + Msg "{\"verifier\":\"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4\"}" `, }, "update admin": { @@ -500,8 +500,8 @@ func TestProposalStrings(t *testing.T) { exp: `Update Contract Admin Proposal: Title: Foo Description: Bar - Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 - New Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du + Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr + New Admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 `, }, "clear admin": { @@ -509,7 +509,7 @@ func TestProposalStrings(t *testing.T) { exp: `Clear Contract Admin Proposal: Title: Foo Description: Bar - Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 + Contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr `, }, "pin codes": { @@ -555,7 +555,7 @@ func TestProposalYaml(t *testing.T) { }), exp: `title: Foo description: Bar -run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du +run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 wasm_byte_code: AQIDBAUGBwgJCg== instantiate_permission: null `, @@ -566,11 +566,11 @@ instantiate_permission: null }), exp: `title: Foo description: Bar -run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du -admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du +run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 +admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 code_id: 1 label: testing -msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"}' +msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4"}' funds: - denom: foo amount: "1" @@ -582,11 +582,11 @@ funds: src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { p.Funds = nil }), exp: `title: Foo description: Bar -run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du -admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du +run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 +admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 code_id: 1 label: testing -msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"}' +msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4"}' funds: [] `, }, @@ -594,11 +594,11 @@ funds: [] src: InstantiateContractProposalFixture(func(p *InstantiateContractProposal) { p.Admin = "" }), exp: `title: Foo description: Bar -run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du +run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 admin: "" code_id: 1 label: testing -msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"}' +msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4","beneficiary":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4"}' funds: [] `, }, @@ -606,25 +606,25 @@ funds: [] src: MigrateContractProposalFixture(), exp: `title: Foo description: Bar -contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 +contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr code_id: 1 -msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"}' -run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du +msg: '{"verifier":"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4"}' +run_as: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 `, }, "update admin": { src: UpdateAdminProposalFixture(), exp: `title: Foo description: Bar -new_admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du -contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 +new_admin: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4 +contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr `, }, "clear admin": { src: ClearAdminProposalFixture(), exp: `title: Foo description: Bar -contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6 +contract: cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr `, }, "pin codes": { diff --git a/x/wasm/types/test_fixtures.go b/x/wasm/types/test_fixtures.go index fc721c7d..1c74771f 100644 --- a/x/wasm/types/test_fixtures.go +++ b/x/wasm/types/test_fixtures.go @@ -70,7 +70,7 @@ func CodeFixture(mutators ...func(*Code)) Code { func CodeInfoFixture(mutators ...func(*CodeInfo)) CodeInfo { wasmCode := bytes.Repeat([]byte{0x1}, 10) codeHash := sha256.Sum256(wasmCode) - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" fixture := CodeInfo{ CodeHash: codeHash[:], Creator: anyAddress, @@ -83,7 +83,7 @@ func CodeInfoFixture(mutators ...func(*CodeInfo)) CodeInfo { } func ContractFixture(mutators ...func(*Contract)) Contract { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" fixture := Contract{ ContractAddress: anyAddress, @@ -102,7 +102,7 @@ func OnlyGenesisFields(info *ContractInfo) { } func ContractInfoFixture(mutators ...func(*ContractInfo)) ContractInfo { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" fixture := ContractInfo{ CodeID: 1, @@ -126,7 +126,7 @@ func WithSHA256CodeHash(wasmCode []byte) func(info *CodeInfo) { func MsgStoreCodeFixture(mutators ...func(*MsgStoreCode)) *MsgStoreCode { var wasmIdent = []byte("\x00\x61\x73\x6D") - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" r := &MsgStoreCode{ Sender: anyAddress, WASMByteCode: wasmIdent, @@ -139,7 +139,7 @@ func MsgStoreCodeFixture(mutators ...func(*MsgStoreCode)) *MsgStoreCode { } func MsgInstantiateContractFixture(mutators ...func(*MsgInstantiateContract)) *MsgInstantiateContract { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" r := &MsgInstantiateContract{ Sender: anyAddress, Admin: anyAddress, @@ -159,8 +159,8 @@ func MsgInstantiateContractFixture(mutators ...func(*MsgInstantiateContract)) *M func MsgExecuteContractFixture(mutators ...func(*MsgExecuteContract)) *MsgExecuteContract { const ( - anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" - firstContractAddress = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" + firstContractAddress = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" ) r := &MsgExecuteContract{ Sender: anyAddress, @@ -178,7 +178,7 @@ func MsgExecuteContractFixture(mutators ...func(*MsgExecuteContract)) *MsgExecut } func StoreCodeProposalFixture(mutators ...func(*StoreCodeProposal)) *StoreCodeProposal { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" p := &StoreCodeProposal{ Title: "Foo", Description: "Bar", @@ -193,7 +193,7 @@ func StoreCodeProposalFixture(mutators ...func(*StoreCodeProposal)) *StoreCodePr func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractProposal)) *InstantiateContractProposal { var ( - anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, sdk.AddrLen) + anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) initMsg = struct { Verifier sdk.AccAddress `json:"verifier"` @@ -203,7 +203,7 @@ func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractP Beneficiary: anyValidAddress, } ) - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" initMsgBz, err := json.Marshal(initMsg) if err != nil { @@ -228,7 +228,7 @@ func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractP func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal)) *MigrateContractProposal { var ( - anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, sdk.AddrLen) + anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) migMsg = struct { Verifier sdk.AccAddress `json:"verifier"` @@ -240,8 +240,8 @@ func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal) panic(err) } const ( - contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" - anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" + anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" ) p := &MigrateContractProposal{ Title: "Foo", @@ -260,8 +260,8 @@ func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal) func UpdateAdminProposalFixture(mutators ...func(p *UpdateAdminProposal)) *UpdateAdminProposal { const ( - contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" - anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" + contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" + anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4" ) p := &UpdateAdminProposal{ @@ -277,7 +277,7 @@ func UpdateAdminProposalFixture(mutators ...func(p *UpdateAdminProposal)) *Updat } func ClearAdminProposalFixture(mutators ...func(p *ClearAdminProposal)) *ClearAdminProposal { - const contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhuc53mp6" + const contractAddr = "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr" p := &ClearAdminProposal{ Title: "Foo", Description: "Bar", diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index 01b878a5..b0ea43e9 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -5,6 +5,8 @@ import ( "strings" "testing" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -17,8 +19,8 @@ func TestStoreCodeValidation(t *testing.T) { require.NoError(t, err) badAddress := bad.String() // proper address size - goodAddress := sdk.AccAddress(make([]byte, 20)).String() - + goodAddress := sdk.AccAddress(make([]byte, ContractAddrLen)).String() + sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) cases := map[string]struct { msg MsgStoreCode valid bool @@ -505,7 +507,7 @@ func TestMsgMigrateContract(t *testing.T) { func TestMsgJsonSignBytes(t *testing.T) { const myInnerMsg = `{"foo":"bar"}` specs := map[string]struct { - src sdk.Msg + src legacytx.LegacyMsg exp string }{ "MsgInstantiateContract": { diff --git a/x/wasm/types/types.go b/x/wasm/types/types.go index 32ce7326..e9187992 100644 --- a/x/wasm/types/types.go +++ b/x/wasm/types/types.go @@ -15,6 +15,11 @@ const ( defaultMemoryCacheSize uint32 = 100 // in MiB defaultSmartQueryGasLimit uint64 = 3_000_000 defaultContractDebugMode = false + + // ContractAddrLen defines a valid address length for contracts + ContractAddrLen = 32 + // SDKAddrLen defines a valid address length that was used in sdk address generation + SDKAddrLen = 20 ) func (m Model) ValidateBasic() error { @@ -315,3 +320,13 @@ func DefaultWasmConfig() WasmConfig { ContractDebugMode: defaultContractDebugMode, } } + +// VerifyAddressLen ensures that the address matches the expected length +func VerifyAddressLen() func(addr []byte) error { + return func(addr []byte) error { + if len(addr) != ContractAddrLen && len(addr) != SDKAddrLen { + return sdkerrors.ErrInvalidAddress + } + return nil + } +} diff --git a/x/wasm/types/types_test.go b/x/wasm/types/types_test.go index 8d5d3196..4401bad4 100644 --- a/x/wasm/types/types_test.go +++ b/x/wasm/types/types_test.go @@ -1,6 +1,7 @@ package types import ( + "bytes" "context" "strings" "testing" @@ -171,8 +172,8 @@ func TestContractInfoSetExtension(t *testing.T) { } func TestContractInfoMarshalUnmarshal(t *testing.T) { - var myAddr sdk.AccAddress = rand.Bytes(sdk.AddrLen) - var myOtherAddr sdk.AccAddress = rand.Bytes(sdk.AddrLen) + var myAddr sdk.AccAddress = rand.Bytes(ContractAddrLen) + var myOtherAddr sdk.AccAddress = rand.Bytes(ContractAddrLen) var anyPos = AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2} anyTime := time.Now().UTC() @@ -197,11 +198,11 @@ func TestContractInfoMarshalUnmarshal(t *testing.T) { govtypes.RegisterInterfaces(interfaceRegistry) // when encode - bz, err := marshaler.MarshalBinaryBare(&src) + bz, err := marshaler.Marshal(&src) require.NoError(t, err) // and decode var dest ContractInfo - err = marshaler.UnmarshalBinaryBare(bz, &dest) + err = marshaler.Unmarshal(bz, &dest) // then require.NoError(t, err) assert.Equal(t, src, dest) @@ -292,7 +293,7 @@ func TestContractInfoReadExtension(t *testing.T) { func TestNewEnv(t *testing.T) { myTime := time.Unix(0, 1619700924259075000) t.Logf("++ unix: %d", myTime.UnixNano()) - var myContractAddr sdk.AccAddress = randBytes(sdk.AddrLen) + var myContractAddr sdk.AccAddress = randBytes(ContractAddrLen) specs := map[string]struct { srcCtx sdk.Context exp wasmvmtypes.Env @@ -330,5 +331,44 @@ func TestNewEnv(t *testing.T) { assert.Equal(t, spec.exp, NewEnv(spec.srcCtx, myContractAddr)) }) } - +} + +func TestVerifyAddressLen(t *testing.T) { + specs := map[string]struct { + src []byte + expErr bool + }{ + "valid contract address": { + src: bytes.Repeat([]byte{1}, 32), + }, + "valid legacy address": { + src: bytes.Repeat([]byte{1}, 20), + }, + "address too short for legacy": { + src: bytes.Repeat([]byte{1}, 19), + expErr: true, + }, + "address too short for contract": { + src: bytes.Repeat([]byte{1}, 31), + expErr: true, + }, + "address too long for legacy": { + src: bytes.Repeat([]byte{1}, 21), + expErr: true, + }, + "address too long for contract": { + src: bytes.Repeat([]byte{1}, 33), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + gotErr := VerifyAddressLen()(spec.src) + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + }) + } }