diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 088cbc66e1..fa0d204637 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,10 @@ version: 2 -updates: +updates: +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 - package-ecosystem: gomod directory: "/" schedule: diff --git a/.github/workflows/codeql-analizer.yml b/.github/workflows/codeql-analizer.yml index c1ee968796..67b8a1a44c 100644 --- a/.github/workflows/codeql-analizer.yml +++ b/.github/workflows/codeql-analizer.yml @@ -5,7 +5,7 @@ on: paths: - "**.go" push: - branches: [ master ] + branches: [ main ] paths: - "**.go" @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2.3.5 + uses: actions/checkout@v3.1.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/proto-buf-publisher.yml b/.github/workflows/proto-buf-publisher.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/INTEGRATION.md b/INTEGRATION.md index 2d7f508919..b01d1e4229 100644 --- a/INTEGRATION.md +++ b/INTEGRATION.md @@ -3,7 +3,10 @@ # Integration If you want to use Wasm in your own app, here is how you can get this working -quickly and easily. First, check to make sure you fit the pre-requisites, +quickly and easily. +First start with This [article](https://medium.com/cosmwasm/cosmwasm-for-ctos-iv-native-integrations-713140bf75fc) +in the "CosmWasm for CTOs" series that gives you a high level view. +Then check to make sure you fit the pre-requisites, then integrate the `x/wasm` module as described below, and finally, you can add custom messages and queries to your custom Go/SDK modules, exposing them to any chain-specific contract. @@ -14,26 +17,18 @@ The pre-requisites of integrating `x/wasm` into your custom app is to be using a compatible version of the Cosmos SDK, and to accept some limits to the hardware it runs on. -| wasmd | Cosmos SDK | -|:------:|:-----------:| -| v0.24 | v0.45.0 | -| v0.23 | v0.45.0 | -| v0.22 | v0.45.0 | -| v0.21 | v0.42.x | -| v0.20 | v0.42.x | -| v0.19 | v0.42.x | -| v0.18 | v0.42.x | -| v0.17 | v0.42.x | -| v0.16 | v0.42.x | -| v0.15 | v0.41.x | -| v0.14 | v0.40.x | -| v0.13 | v0.40.0-rc3 | -| v0.12 | v0.40.0-rc3 | -| v0.11 | v0.39.1 | -| v0.10 | v0.39.1 | -| v0.9 | v0.38.3 | -| v0.8 | v0.38.3 | -| v0.7 | v0.38.3 | +| wasmd | Cosmos SDK | +|:-----:|:----------:| +| v0.29 | v0.45.8 | +| v0.28 | v0.45.5 | +| v0.27 | v0.45.4 | +| v0.26 | v0.45.1 | +| v0.25 | v0.45.1 | +| v0.24 | v0.45.0 | +| v0.23 | v0.45.0 | +| v0.22 | v0.45.0 | +| v0.21 | v0.42.x | + We currently only support Intel/AMD64 CPUs and OSX or Linux. For Linux, the standard build commands work for `glibc` systems (Ubuntu, Debian, CentOS, etc). If you wish to compile @@ -72,9 +67,12 @@ from the Cosmos SDK, and enabled them in `app.go`. If so, you can just look at [`wasmd/app/app.go`](https://github.com/CosmWasm/wasmd/blob/master/app/app.go#) for how to do so (just search there for lines with `wasm`). -`wasmd` also comes with a custom `ante handler` that adds the TX position in the block into the context -and passes it to the contracts. In order to support this feature you would need to add our custom -ante handler into the `ante handler chain` as in: [`app/ante.go`](https://github.com/CosmWasm/wasmd/blob/master/app/ante.go) +`wasmd` also comes with 2 custom `ante handlers`: +* `CountTXDecorator` adds the TX position in the block into the context and passes it to the contracts +* `LimitSimulationGasDecorator` prevents an "infinite gas" query + +In order to support these features you would need to add our custom +ante handlers into the `ante handler chain` as in: [`app/ante.go`](https://github.com/CosmWasm/wasmd/blob/master/app/ante.go) ### Copied into your app @@ -202,5 +200,5 @@ the SDK is implemented properly. Once you have tested this and are happy with the results, you can wire it up in `app.go`. Just edit [the default `NewKeeper` constructor](https://github.com/CosmWasm/wasmd/blob/v0.8.0-rc1/app/app.go#L257-L258) -to have the proper `supportedFeatures` and pass in the `CustomEncoder` and `CustomQuerier` as the last two arguments to `NewKeeper`. +to have the proper `availableCapabilities` and pass in the `CustomEncoder` and `CustomQuerier` as the last two arguments to `NewKeeper`. Now you can compile your chain and upload your custom contracts on it. \ No newline at end of file diff --git a/Makefile b/Makefile index e72fe11a57..c27800f72c 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ go.sum: go.mod draw-deps: @# requires brew install graphviz or apt-get install graphviz - go get github.com/RobotsAndPencils/goviz + go install github.com/RobotsAndPencils/goviz@latest @goviz -i ./cmd/wasmd -d 2 | dot -Tpng -o dependency-graph.png clean: @@ -166,7 +166,7 @@ format: format-tools ### Protobuf ### ############################################################################### PROTO_VERSION=v0.2 -PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen@sha256:372dce7be2f465123e26459973ca798fc489ff2c75aeecd814c0ca8ced24faca +PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen:$(PROTO_VERSION) PROTO_FORMATTER_IMAGE=tendermintdev/docker-build-proto@sha256:aabcfe2fc19c31c0f198d4cd26393f5e5ca9502d7ea3feafbfe972448fee7cae PROTO_GEN_SWAGGER_IMAGE=cosmos-sdk-proto-gen-swagger-$(PROTO_VERSION) diff --git a/README.md b/README.md index d04eecf291..321e978319 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ compatibility list: | line/wasmd | cosmwasm/wasmd | line/wasmvm | cosmwasm/wasmvm | cosmwasm-vm | cosmwasm-std | |------------|----------------|:--------------|-----------------|-------------|--------------| +| | 0.29 | | v1.1.0 | | 1.0-1.1 | +| | 0.28 | | v1.0.0 | | 1.0-1.1 | | 0.1 | 0.27 | v1.0.0-0.10.0 | v1.0.0 | | 1.0 | | | 0.26 | | 1.0.0-beta10 | | 1.0 | | | 0.25 | | 1.0.0-beta10 | | 1.0 | @@ -52,7 +54,7 @@ It will also run contracts compiled with 1.x assuming they don't opt into any ne The 1.x cosmwasm_vm will support all contracts with 1.0 <= version <= 1.x. Note that `cosmwasm-std` version defines which contracts are compatible with this system. The wasm code uploaded must -have been compiled with one of the supported `cosmwasm-std` versions, or will be rejeted upon upload (with some error +have been compiled with one of the supported `cosmwasm-std` versions, or will be rejected upon upload (with some error message about "contract too old?" or "contract too new?"). `cosmwasm-vm` version defines the runtime used. It is a breaking change to switch runtimes (you will need to organize a chain upgrade). As of `cosmwasm-vm 0.13` we are using [wasmer](https://github.com/wasmerio/wasmer/) 1.0, which is significantly more performant than the older versions. @@ -95,9 +97,9 @@ The used cosmos-sdk version is in transition migrating from amino encoding to pr We use standard cosmos-sdk encoding (amino) for all sdk Messages. However, the message body sent to all contracts, as well as the internal state is encoded using JSON. Cosmwasm allows arbitrary bytes with the contract itself -responsible for decodng. For better UX, we often use `json.RawMessage` to contain these bytes, which enforces that it is +responsible for decoding. For better UX, we often use `json.RawMessage` to contain these bytes, which enforces that it is valid json, but also give a much more readable interface. If you want to use another encoding in the contracts, that is -a relatively minor change to wasmd but would currently require a fork. Please open in issue if this is important for +a relatively minor change to wasmd but would currently require a fork. Please open an issue if this is important for your use case. ## Quick Start @@ -109,6 +111,12 @@ make test if you are using a linux without X or headless linux, look at [this article](https://ahelpme.com/linux/dbusexception-could-not-get-owner-of-name-org-freedesktop-secrets-no-such-name) or [#31](https://github.com/CosmWasm/wasmd/issues/31#issuecomment-577058321). ## Protobuf +The protobuf files for this project are published automatically to the [buf repository](https://buf.build/) to make integration easier: + +| wasmd version | buf tag | +|---------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| 0.26.x | [51931206dbe09529c1819a8a2863d291035a2549](https://buf.build/cosmwasm/wasmd/tree/51931206dbe09529c1819a8a2863d291035a2549:cosmwasm/wasm/v1) | + Generate protobuf ```shell script make proto-gen diff --git a/app/app.go b/app/app.go index 2409eac995..93a6903bc7 100644 --- a/app/app.go +++ b/app/app.go @@ -64,7 +64,6 @@ import ( govkeeper "github.com/line/lbm-sdk/x/gov/keeper" govtypes "github.com/line/lbm-sdk/x/gov/types" ica "github.com/line/lbm-sdk/x/ibc/applications/27-interchain-accounts" - icacontroller "github.com/line/lbm-sdk/x/ibc/applications/27-interchain-accounts/controller" icacontrollerkeeper "github.com/line/lbm-sdk/x/ibc/applications/27-interchain-accounts/controller/keeper" icacontrollertypes "github.com/line/lbm-sdk/x/ibc/applications/27-interchain-accounts/controller/types" icahost "github.com/line/lbm-sdk/x/ibc/applications/27-interchain-accounts/host" @@ -248,33 +247,33 @@ type WasmApp struct { memKeys map[string]*sdk.MemoryStoreKey // keepers - accountKeeper authkeeper.AccountKeeper - bankKeeper bankkeeper.Keeper - capabilityKeeper *capabilitykeeper.Keeper - stakingKeeper stakingkeeper.Keeper - slashingKeeper slashingkeeper.Keeper - mintKeeper mintkeeper.Keeper - distrKeeper distrkeeper.Keeper - govKeeper govkeeper.Keeper - crisisKeeper crisiskeeper.Keeper - upgradeKeeper upgradekeeper.Keeper - paramsKeeper paramskeeper.Keeper - evidenceKeeper evidencekeeper.Keeper - ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - icaControllerKeeper icacontrollerkeeper.Keeper - icaHostKeeper icahostkeeper.Keeper - // interTxKeeper intertxkeeper.Keeper // TODO support later - transferKeeper ibctransferkeeper.Keeper - feeGrantKeeper feegrantkeeper.Keeper - authzKeeper authzkeeper.Keeper - wasmKeeper wasm.Keeper - - scopedIBCKeeper capabilitykeeper.ScopedKeeper - scopedICAHostKeeper capabilitykeeper.ScopedKeeper - scopedICAControllerKeeper capabilitykeeper.ScopedKeeper - scopedInterTxKeeper capabilitykeeper.ScopedKeeper - scopedTransferKeeper capabilitykeeper.ScopedKeeper - scopedWasmKeeper capabilitykeeper.ScopedKeeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAControllerKeeper icacontrollerkeeper.Keeper + ICAHostKeeper icahostkeeper.Keeper + // InterTxKeeper intertxkeeper.Keeper // TODO support later + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper + WasmKeeper wasm.Keeper + + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper + ScopedInterTxKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper // make IBC modules public for test purposes // these modules are never directly routed to by the IBC Router @@ -333,7 +332,7 @@ func NewWasmApp( memKeys: memKeys, } - app.paramsKeeper = initParamsKeeper( + app.ParamsKeeper = initParamsKeeper( appCodec, legacyAmino, keys[paramstypes.StoreKey], @@ -341,90 +340,86 @@ func NewWasmApp( ) // set the BaseApp's parameter store - bApp.SetParamStore(app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) + bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) // add capability keeper and ScopeToModule for ibc module - app.capabilityKeeper = capabilitykeeper.NewKeeper( + app.CapabilityKeeper = capabilitykeeper.NewKeeper( appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey], ) - scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName) - scopedICAHostKeeper := app.capabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - scopedICAControllerKeeper := app.capabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) - scopedInterTxKeeper := app.capabilityKeeper.ScopeToModule(intertxtypes.ModuleName) - scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedWasmKeeper := app.capabilityKeeper.ScopeToModule(wasm.ModuleName) - // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do - // note replicate if you do not need to test core IBC or light clients. - scopedIBCMockKeeper := app.capabilityKeeper.ScopeToModule(ibcmock.ModuleName) - scopedICAMockKeeper := app.capabilityKeeper.ScopeToModule(ibcmock.ModuleName + icacontrollertypes.SubModuleName) - app.capabilityKeeper.Seal() + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(intertxtypes.ModuleName) + scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) + app.CapabilityKeeper.Seal() // add keepers - app.accountKeeper = authkeeper.NewAccountKeeper( + app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, keys[authtypes.StoreKey], app.getSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, ) - app.bankKeeper = bankpluskeeper.NewBaseKeeper( + app.BankKeeper = bankpluskeeper.NewBaseKeeper( appCodec, keys[banktypes.StoreKey], - app.accountKeeper, + app.AccountKeeper, app.getSubspace(banktypes.ModuleName), app.BlockedAddrs(), ) - app.authzKeeper = authzkeeper.NewKeeper( + app.AuthzKeeper = authzkeeper.NewKeeper( keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter(), ) - app.feeGrantKeeper = feegrantkeeper.NewKeeper( + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( appCodec, keys[feegrant.StoreKey], - app.accountKeeper, + app.AccountKeeper, ) stakingKeeper := stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], - app.accountKeeper, - app.bankKeeper, + app.AccountKeeper, + app.BankKeeper, app.getSubspace(stakingtypes.ModuleName), ) - app.mintKeeper = mintkeeper.NewKeeper( + app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], app.getSubspace(minttypes.ModuleName), &stakingKeeper, - app.accountKeeper, - app.bankKeeper, + app.AccountKeeper, + app.BankKeeper, authtypes.FeeCollectorName, ) - app.distrKeeper = distrkeeper.NewKeeper( + app.DistrKeeper = distrkeeper.NewKeeper( appCodec, keys[distrtypes.StoreKey], app.getSubspace(distrtypes.ModuleName), - app.accountKeeper, - app.bankKeeper, + app.AccountKeeper, + app.BankKeeper, &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), ) - app.slashingKeeper = slashingkeeper.NewKeeper( + app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.getSubspace(slashingtypes.ModuleName), ) - app.crisisKeeper = crisiskeeper.NewKeeper( + app.CrisisKeeper = crisiskeeper.NewKeeper( app.getSubspace(crisistypes.ModuleName), invCheckPeriod, - app.bankKeeper, + app.BankKeeper, authtypes.FeeCollectorName, ) - app.upgradeKeeper = upgradekeeper.NewKeeper( + app.UpgradeKeeper = upgradekeeper.NewKeeper( skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, @@ -434,16 +429,16 @@ func NewWasmApp( // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.stakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()), + app.StakingKeeper = *stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) - app.ibcKeeper = ibckeeper.NewKeeper( + app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibchost.StoreKey], app.getSubspace(ibchost.ModuleName), - app.stakingKeeper, - app.upgradeKeeper, + app.StakingKeeper, + app.UpgradeKeeper, scopedIBCKeeper, ) @@ -451,78 +446,66 @@ func NewWasmApp( govRouter := govtypes.NewRouter() 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(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) // Create Transfer Keepers - app.transferKeeper = ibctransferkeeper.NewKeeper( + app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.getSubspace(ibctransfertypes.ModuleName), - app.ibcKeeper.ChannelKeeper, - app.ibcKeeper.ChannelKeeper, - &app.ibcKeeper.PortKeeper, - app.accountKeeper, - app.bankKeeper, + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, scopedTransferKeeper, ) - transferModule := transfer.NewAppModule(app.transferKeeper) - transferIBCModule := transfer.NewIBCModule(app.transferKeeper) + transferModule := transfer.NewAppModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - _ = app.getSubspace(icahosttypes.SubModuleName) - app.icaHostKeeper = icahostkeeper.NewKeeper( + app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.getSubspace(icahosttypes.SubModuleName), - app.ibcKeeper.ChannelKeeper, - &app.ibcKeeper.PortKeeper, - app.accountKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), ) - app.icaControllerKeeper = icacontrollerkeeper.NewKeeper( + app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( appCodec, keys[icacontrollertypes.StoreKey], app.getSubspace(icacontrollertypes.SubModuleName), - app.ibcKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee - app.ibcKeeper.ChannelKeeper, - &app.ibcKeeper.PortKeeper, + app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, scopedICAControllerKeeper, app.MsgServiceRouter(), ) - icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper) - icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper) - - // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do - // note replicate if you do not need to test core IBC or light clients. - mockModule := ibcmock.NewAppModule(&app.ibcKeeper.PortKeeper) - mockIBCModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp(ibcmock.ModuleName, scopedIBCMockKeeper)) - // initialize ICA module with mock module as the authentication module on the controller side - icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper)) - app.ICAAuthModule = icaAuthModule - - // TODO support later - //// For wasmd we use the demo controller from https://github.com/cosmos/interchain-accounts but see notes below - // app.interTxKeeper = intertxkeeper.NewKeeper(appCodec, keys[intertxtypes.StoreKey], app.icaControllerKeeper, scopedInterTxKeeper) + icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper) + icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) + + // For wasmd we use the demo controller from https://github.com/cosmos/interchain-accounts but see notes below + // app.InterTxKeeper = intertxkeeper.NewKeeper(appCodec, keys[intertxtypes.StoreKey], app.ICAControllerKeeper, scopedInterTxKeeper) // Note: please do your research before using this in production app, this is a demo and not an officially // supported IBC team implementation. Do your own research before using it. - // interTxModule := intertx.NewAppModule(appCodec, app.interTxKeeper) - // interTxIBCModule := intertx.NewIBCModule(app.interTxKeeper) + // interTxModule := intertx.NewAppModule(appCodec, app.InterTxKeeper) + // interTxIBCModule := intertx.NewIBCModule(app.InterTxKeeper) // You will likely want to swap out the second argument with your own reviewed and maintained ica auth module - // icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, interTxIBCModule) - - icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, icaAuthModule) + // icaControllerIBCModule := icacontroller.NewIBCModule(app.ICAControllerKeeper, interTxIBCModule) // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, keys[evidencetypes.StoreKey], - &app.stakingKeeper, - app.slashingKeeper, + &app.StakingKeeper, + app.SlashingKeeper, ) - app.evidenceKeeper = *evidenceKeeper + app.EvidenceKeeper = *evidenceKeeper wasmDir := filepath.Join(homePath, "wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) @@ -532,24 +515,24 @@ func NewWasmApp( // The last arguments can contain custom message handlers, and custom query handlers, // if we want to allow any custom callbacks - supportedFeatures := "iterator,staking,stargate" - app.wasmKeeper = wasm.NewKeeper( + availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1" + app.WasmKeeper = wasm.NewKeeper( appCodec, keys[wasm.StoreKey], app.getSubspace(wasm.ModuleName), - app.accountKeeper, - app.bankKeeper, - app.stakingKeeper, - app.distrKeeper, - app.ibcKeeper.ChannelKeeper, - &app.ibcKeeper.PortKeeper, + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.DistrKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, scopedWasmKeeper, - app.transferKeeper, + app.TransferKeeper, app.MsgServiceRouter(), app.GRPCQueryRouter(), wasmDir, wasmConfig, - supportedFeatures, + availableCapabilities, nil, nil, wasmOpts..., @@ -560,23 +543,22 @@ func NewWasmApp( // The gov proposal types can be individually enabled if len(enabledProposals) != 0 { - govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.wasmKeeper, enabledProposals)) + govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) } ibcRouter. - AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.ibcKeeper.ChannelKeeper)). + AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper)). AddRoute(ibctransfertypes.ModuleName, transferIBCModule). - AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). - AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - // AddRoute(intertxtypes.ModuleName, icaControllerIBCModule). - AddRoute(ibcmock.ModuleName, mockIBCModule) - app.ibcKeeper.SetRouter(ibcRouter) + // AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + // AddRoute(intertxtypes.ModuleName, icaControllerIBCModule) + app.IBCKeeper.SetRouter(ibcRouter) - app.govKeeper = govkeeper.NewKeeper( + app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.getSubspace(govtypes.ModuleName), - app.accountKeeper, - app.bankKeeper, + app.AccountKeeper, + app.BankKeeper, &stakingKeeper, govRouter, ) @@ -590,30 +572,31 @@ func NewWasmApp( // must be passed by reference here. app.mm = module.NewManager( genutil.NewAppModule( - app.accountKeeper, - app.stakingKeeper, + app.AccountKeeper, + app.StakingKeeper, app.BaseApp.DeliverTx, encodingConfig.TxConfig, ), - auth.NewAppModule(appCodec, app.accountKeeper, nil), - vesting.NewAppModule(app.accountKeeper, app.bankKeeper), - bankplus.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper), - capability.NewAppModule(appCodec, *app.capabilityKeeper), - 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), - distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper), - staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper), - upgrade.NewAppModule(app.upgradeKeeper), - wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper), - 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), + auth.NewAppModule(appCodec, app.AccountKeeper, nil), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bankplus.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + 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), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + 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, icaModule, - crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them + // interTxModule, + 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 @@ -706,7 +689,7 @@ func NewWasmApp( // Uncomment if you want to set a custom migration order here. // app.mm.SetOrderMigrations(custom order) - app.mm.RegisterInvariants(&app.crisisKeeper) + app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) @@ -717,38 +700,39 @@ func NewWasmApp( // NOTE: this is not required apps that don't use the simulator for fuzz testing // transactions app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts), - bankplus.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), - evidence.NewAppModule(app.evidenceKeeper), - wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper), - ibc.NewAppModule(app.ibcKeeper), + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), + bankplus.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), + evidence.NewAppModule(app.EvidenceKeeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + ibc.NewAppModule(app.IBCKeeper), transferModule, ) app.sm.RegisterStoreDecoders() // initialize stores app.MountKVStores(keys) + // app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) anteHandler, err := NewAnteHandler( HandlerOptions{ HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.accountKeeper, - BankKeeper: app.bankKeeper, - FeegrantKeeper: app.feeGrantKeeper, + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - IBCKeeper: app.ibcKeeper, + IBCKeeper: app.IBCKeeper, WasmConfig: &wasmConfig, TXCounterStoreKey: keys[wasm.StoreKey], }, @@ -767,19 +751,19 @@ func NewWasmApp( // see cmd/wasmd/root.go: 206 - 214 approx if manager := app.SnapshotManager(); manager != nil { err := manager.RegisterExtensions( - wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.wasmKeeper), + wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper), ) if err != nil { panic(fmt.Errorf("failed to register snapshot extension: %s", err)) } } - app.scopedIBCKeeper = scopedIBCKeeper - app.scopedTransferKeeper = scopedTransferKeeper - app.scopedWasmKeeper = scopedWasmKeeper - app.scopedICAHostKeeper = scopedICAHostKeeper - app.scopedICAControllerKeeper = scopedICAControllerKeeper - app.scopedInterTxKeeper = scopedInterTxKeeper + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedWasmKeeper = scopedWasmKeeper + app.ScopedICAHostKeeper = scopedICAHostKeeper + app.ScopedICAControllerKeeper = scopedICAControllerKeeper + app.ScopedInterTxKeeper = scopedInterTxKeeper if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -788,11 +772,11 @@ func NewWasmApp( ctx := app.BaseApp.NewUncachedContext(true, ocproto.Header{}) // Initialize pinned codes in wasmvm as they are not persisted there - if err := app.wasmKeeper.InitializePinnedCodes(ctx); err != nil { + if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil { tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } // Initialize the keeper of bankkeeper - app.bankKeeper.(bankpluskeeper.Keeper).InitializeBankPlus(ctx) + app.BankKeeper.(bankpluskeeper.Keeper).InitializeBankPlus(ctx) } return app @@ -801,7 +785,17 @@ func NewWasmApp( // Name returns the name of the App func (app *WasmApp) Name() string { return app.BaseApp.Name() } -// application updates every begin block +// ModuleManager returns instance +func (app *WasmApp) ModuleManager() module.Manager { + return *app.mm +} + +// ModuleConfigurator returns instance +func (app *WasmApp) ModuleConfigurator() module.Configurator { + return app.configurator +} + +// BeginBlocker application updates every begin block func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { return app.mm.BeginBlock(ctx, req) } @@ -818,7 +812,7 @@ func (app *WasmApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci panic(err) } - app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } @@ -861,7 +855,7 @@ func (app *WasmApp) LegacyAmino() *codec.LegacyAmino { //nolint:staticcheck // // NOTE: This is solely to be used for testing purposes. func (app *WasmApp) getSubspace(moduleName string) paramstypes.Subspace { - subspace, _ := app.paramsKeeper.GetSubspace(moduleName) + subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) return subspace } diff --git a/app/app_test.go b/app/app_test.go index ad08c3ef09..8e5acf8e24 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -49,9 +49,9 @@ func TestBlockedAddrs(t *testing.T) { for acc := range maccPerms { //for acc := range gapp.BlockedAddrs() { t.Run(acc, func(t *testing.T) { - addr := gapp.accountKeeper.GetModuleAddress(acc) + addr := gapp.AccountKeeper.GetModuleAddress(acc) if blockedAddrs[addr.String()] { - require.True(t, gapp.bankKeeper.BlockedAddr(addr), + require.True(t, gapp.BankKeeper.BlockedAddr(addr), "ensure that blocked addresses are properly set in bank keeper", ) } diff --git a/app/export.go b/app/export.go index cc9735b711..a302255b58 100644 --- a/app/export.go +++ b/app/export.go @@ -34,7 +34,7 @@ func (app *WasmApp) ExportAppStateAndValidators( return servertypes.ExportedApp{}, err } - validators, err := staking.WriteValidators(ctx, app.stakingKeeper) + validators, err := staking.WriteValidators(ctx, app.StakingKeeper) return servertypes.ExportedApp{ AppState: appState, Validators: validators, @@ -45,7 +45,8 @@ func (app *WasmApp) ExportAppStateAndValidators( // prepare for fresh start at zero height // NOTE zero height genesis is a temporary feature which will be deprecated -// in favour of export at a block height +// +// in favour of export at a block height func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false @@ -65,18 +66,18 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ } /* Just to be safe, assert the invariants on current state. */ - app.crisisKeeper.AssertInvariants(ctx) + app.CrisisKeeper.AssertInvariants(ctx) /* Handle fee distribution state. */ // withdraw all validator commission - app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, _ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) //nolint:errcheck + app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) //nolint:errcheck return false }) // withdraw all delegator rewards - dels := app.stakingKeeper.GetAllDelegations(ctx) + dels := app.StakingKeeper.GetAllDelegations(ctx) for _, delegation := range dels { valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) if err != nil { @@ -87,28 +88,28 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ if err != nil { panic(err) } - _, _ = app.distrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) //nolint:errcheck + _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) //nolint:errcheck } // clear validator slash events - app.distrKeeper.DeleteAllValidatorSlashEvents(ctx) + app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) // clear validator historical rewards - app.distrKeeper.DeleteAllValidatorHistoricalRewards(ctx) + app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) // set context height to zero height := ctx.BlockHeight() ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.distrKeeper.GetFeePool(ctx) + scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) + feePool := app.DistrKeeper.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.distrKeeper.SetFeePool(ctx, feePool) + app.DistrKeeper.SetFeePool(ctx, feePool) - app.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) return false }) @@ -122,8 +123,8 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ if err != nil { panic(err) } - app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - app.distrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) + app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) + app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) } // reset context height @@ -132,20 +133,20 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ /* Handle staking state. */ // iterate through redelegations, reset creation height - app.stakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } - app.stakingKeeper.SetRedelegation(ctx, red) + app.StakingKeeper.SetRedelegation(ctx, red) return false }) // iterate through unbonding delegations, reset creation height - app.stakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } - app.stakingKeeper.SetUnbondingDelegation(ctx, ubd) + app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) return false }) @@ -157,7 +158,7 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.stakingKeeper.GetValidator(ctx, addr) + validator, found := app.StakingKeeper.GetValidator(ctx, addr) if !found { panic("expected validator, not found") } @@ -167,13 +168,13 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ validator.Jailed = true } - app.stakingKeeper.SetValidator(ctx, validator) + app.StakingKeeper.SetValidator(ctx, validator) counter++ } iter.Close() - _, err := app.stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) + _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) if err != nil { log.Fatal(err) } @@ -181,11 +182,11 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ /* Handle slashing state. */ // reset start height on signing infos - app.slashingKeeper.IterateValidatorSigningInfos( + app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.slashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) return false }, ) diff --git a/app/params/weights.go b/app/params/weights.go index 797996603a..9cb2dd39a4 100644 --- a/app/params/weights.go +++ b/app/params/weights.go @@ -20,6 +20,7 @@ const ( DefaultWeightCommunitySpendProposal int = 5 DefaultWeightTextProposal int = 5 DefaultWeightParamChangeProposal int = 5 - DefaultWeightMsgStoreCode int = 100 + DefaultWeightMsgStoreCode int = 50 DefaultWeightMsgInstantiateContract int = 100 + DefaultWeightMsgExecuteContract int = 100 ) diff --git a/app/sim_test.go b/app/sim_test.go index e9c3f1283b..4d8e0c0d9b 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -6,14 +6,20 @@ import ( "os" "path/filepath" "testing" + "time" + + "github.com/line/lbm-sdk/store" + "github.com/line/lbm-sdk/store/prefix" "github.com/stretchr/testify/require" dbm "github.com/tendermint/tm-db" "github.com/line/lbm-sdk/baseapp" + "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/simapp" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/kv" + "github.com/line/lbm-sdk/types/module" simtypes "github.com/line/lbm-sdk/types/simulation" authtypes "github.com/line/lbm-sdk/x/auth/types" authzkeeper "github.com/line/lbm-sdk/x/authz/keeper" @@ -119,7 +125,7 @@ func TestAppImportExport(t *testing.T) { t, os.Stdout, app.BaseApp, - simapp.AppStateFn(app.AppCodec(), app.SimulationManager()), + AppStateFn(app.AppCodec(), app.SimulationManager()), simtypes.RandomAccounts, simapp.SimulationOperations(app, app.AppCodec(), config), app.ModuleAccountAddrs(), @@ -191,6 +197,37 @@ func TestAppImportExport(t *testing.T) { // delete persistent tx counter value ctxA.KVStore(app.keys[wasm.StoreKey]).Delete(wasmtypes.TXCounterPrefix) + // reset contract code index in source DB for comparison with dest DB + dropContractHistory := func(s store.KVStore, keys ...[]byte) { + for _, key := range keys { + prefixStore := prefix.NewStore(s, key) + iter := prefixStore.Iterator(nil, nil) + for ; iter.Valid(); iter.Next() { + prefixStore.Delete(iter.Key()) + } + iter.Close() + } + } + prefixes := [][]byte{wasmtypes.ContractCodeHistoryElementPrefix, wasmtypes.ContractByCodeIDAndCreatedSecondaryIndexPrefix} + dropContractHistory(ctxA.KVStore(app.keys[wasm.StoreKey]), prefixes...) + dropContractHistory(ctxB.KVStore(newApp.keys[wasm.StoreKey]), prefixes...) + + normalizeContractInfo := func(ctx sdk.Context, app *WasmApp) { + var index uint64 + app.WasmKeeper.IterateContractInfo(ctx, func(address sdk.AccAddress, info wasmtypes.ContractInfo) bool { + created := &wasmtypes.AbsoluteTxPosition{ + BlockHeight: uint64(0), + TxIndex: index, + } + info.Created = created + store := ctx.KVStore(app.keys[wasm.StoreKey]) + store.Set(wasmtypes.GetContractAddressKey(address), app.appCodec.MustMarshal(&info)) + index++ + return false + }) + } + normalizeContractInfo(ctxA, app) + normalizeContractInfo(ctxB, newApp) // diff both stores for _, skp := range storeKeysPrefixes { storeA := ctxA.KVStore(skp.A) @@ -216,7 +253,7 @@ func TestFullAppSimulation(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() encConf := MakeEncodingConfig() - app := NewWasmApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, + app := NewWasmApp(logger, db, nil, true, map[int64]bool{}, t.TempDir(), simapp.FlagPeriodValue, encConf, wasm.EnableAllProposals, simapp.EmptyAppOptions{}, nil, fauxMerkleModeOpt) require.Equal(t, "WasmApp", app.Name()) @@ -225,7 +262,7 @@ func TestFullAppSimulation(t *testing.T) { t, os.Stdout, app.BaseApp, - simapp.AppStateFn(app.appCodec, app.SimulationManager()), + AppStateFn(app.appCodec, app.SimulationManager()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 simapp.SimulationOperations(app, app.AppCodec(), config), app.ModuleAccountAddrs(), @@ -242,3 +279,15 @@ func TestFullAppSimulation(t *testing.T) { simapp.PrintStats(db) } } + +// AppStateFn returns the initial application state using a genesis or the simulation parameters. +// It panics if the user provides files for both of them. +// If a file is not given for the genesis or the sim params, it creates a randomized one. +func AppStateFn(codec codec.Codec, manager *module.SimulationManager) simtypes.AppStateFn { + // quick hack to setup app state genesis with our app modules + simapp.ModuleBasics = ModuleBasics + if simapp.FlagGenesisTimeValue == 0 { // always set to have a block time + simapp.FlagGenesisTimeValue = time.Now().Unix() + } + return simapp.AppStateFn(codec, manager) +} diff --git a/app/test_access.go b/app/test_access.go index e8d9ae80dd..59d1f95e49 100644 --- a/app/test_access.go +++ b/app/test_access.go @@ -16,6 +16,7 @@ import ( "github.com/line/wasmd/x/wasm" ) +// Deprecated: use public app attributes directly type TestSupport struct { t testing.TB app *WasmApp @@ -26,11 +27,11 @@ func NewTestSupport(t testing.TB, app *WasmApp) *TestSupport { } func (s TestSupport) IBCKeeper() *ibckeeper.Keeper { - return s.app.ibcKeeper + return s.app.IBCKeeper } func (s TestSupport) WasmKeeper() wasm.Keeper { - return s.app.wasmKeeper + return s.app.WasmKeeper } func (s TestSupport) AppCodec() codec.Codec { @@ -38,27 +39,27 @@ func (s TestSupport) AppCodec() codec.Codec { } func (s TestSupport) ScopedWasmIBCKeeper() capabilitykeeper.ScopedKeeper { - return s.app.scopedWasmKeeper + return s.app.ScopedWasmKeeper } func (s TestSupport) ScopeIBCKeeper() capabilitykeeper.ScopedKeeper { - return s.app.scopedIBCKeeper + return s.app.ScopedIBCKeeper } func (s TestSupport) ScopedTransferKeeper() capabilitykeeper.ScopedKeeper { - return s.app.scopedTransferKeeper + return s.app.ScopedTransferKeeper } func (s TestSupport) StakingKeeper() stakingkeeper.Keeper { - return s.app.stakingKeeper + return s.app.StakingKeeper } func (s TestSupport) BankKeeper() bankkeeper.Keeper { - return s.app.bankKeeper + return s.app.BankKeeper } func (s TestSupport) TransferKeeper() ibctransferkeeper.Keeper { - return s.app.transferKeeper + return s.app.TransferKeeper } func (s TestSupport) GetBaseApp() *baseapp.BaseApp { diff --git a/app/test_helpers.go b/app/test_helpers.go index f6af83d792..bf320b8ec0 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -71,6 +71,29 @@ func setup(t testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Opt return app, GenesisState{} } +// Setup initializes a new WasmApp with DefaultNodeHome for integration tests +func Setup(isCheckTx bool, opts ...wasm.Option) *WasmApp { + db := dbm.NewMemDB() + app := NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, opts) + + if !isCheckTx { + genesisState := NewDefaultGenesisState() + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + panic(err) + } + + app.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + } + return app +} + // SetupWithGenesisValSet initializes a new WasmApp with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the WasmApp from first genesis @@ -202,7 +225,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { // AddTestAddrsFromPubKeys adds the addresses into the WasmApp providing only the public keys. func AddTestAddrsFromPubKeys(app *WasmApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) { - initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt)) + initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt)) for _, pk := range pubKeys { initAccountWithCoins(app, ctx, sdk.AccAddress(pk.Address()), initCoins) @@ -224,7 +247,7 @@ func AddTestAddrsIncremental(app *WasmApp, ctx sdk.Context, accNum int, accAmt s func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { testAddrs := strategy(accNum) - initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt)) + initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt)) // fill all the addresses with some coins, set the loose pool tokens simultaneously for _, addr := range testAddrs { @@ -235,12 +258,12 @@ func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int, str } func initAccountWithCoins(app *WasmApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { - err := app.bankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) + err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) if err != nil { panic(err) } - err = app.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) if err != nil { panic(err) } @@ -281,7 +304,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) { // CheckBalance checks the balance of an account. func CheckBalance(t *testing.T, app *WasmApp, addr sdk.AccAddress, balances sdk.Coins) { ctxCheck := app.BaseApp.NewContext(true, ocproto.Header{}) - require.True(t, balances.IsEqual(app.bankKeeper.GetAllBalances(ctxCheck, addr))) + require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr))) } const DefaultGas = 1200000 @@ -298,7 +321,7 @@ func SignCheckDeliver( txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, - 2*DefaultGas, + helpers.DefaultGenTxGas, chainID, accNums, accSeqs, diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index da19df9252..d8d827b1d6 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -2,7 +2,7 @@ package benchmarks import ( "encoding/json" - "io/ioutil" + "os" "testing" "time" @@ -118,7 +118,7 @@ func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo { wasmApp.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: height, Time: time.Now()}}) // upload the code - cw20Code, err := ioutil.ReadFile("./testdata/cw20_base.wasm") + cw20Code, err := os.ReadFile("./testdata/cw20_base.wasm") require.NoError(b, err) storeMsg := wasmtypes.MsgStoreCode{ Sender: addr.String(), diff --git a/buf.work.yaml b/buf.work.yaml index 98094695ff..1b4a0d95c2 100644 --- a/buf.work.yaml +++ b/buf.work.yaml @@ -6,4 +6,3 @@ version: v1 directories: - proto - - third_party/proto diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index ac05cc6779..611f0c4d87 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -61,7 +61,7 @@ tools-stamp: statik runsim golangci-lint statik: $(STATIK) $(STATIK): @echo "Installing statik..." - @(cd /tmp && go get github.com/rakyll/statik@v0.1.6) + @(cd /tmp && go install github.com/rakyll/statik@v0.1.6) # Install the runsim binary with a temporary workaround of entering an outside # directory as the "go get" command ignores the -mod option and will polute the @@ -71,12 +71,12 @@ $(STATIK): runsim: $(RUNSIM) $(RUNSIM): @echo "Installing runsim..." - @(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0) + @(cd /tmp && go install github.com/cosmos/tools/cmd/runsim@v1.0.0) golangci-lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT): @echo "Installing golangci-lint..." - @(cd /tmp && go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.28.0) + @(cd /tmp && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0) tools-clean: rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) diff --git a/contrib/local/02-contracts.sh b/contrib/local/02-contracts.sh index ecbadf31eb..c445d948b6 100755 --- a/contrib/local/02-contracts.sh +++ b/contrib/local/02-contracts.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -o errexit -o nounset -o pipefail +set -o errexit -o nounset -o pipefail -x DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" @@ -9,7 +9,10 @@ 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 -o json) CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value') +CODE_HASH=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-2].value') echo "* Code id: $CODE_ID" +echo "* Code checksum: $CODE_HASH" + echo "* Download code" TMPDIR=$(mktemp -t wasmdXXXXXX) wasmd q wasm code "$CODE_ID" "$TMPDIR" @@ -27,6 +30,17 @@ wasmd tx wasm instantiate "$CODE_ID" "$INIT" --admin="$(wasmd keys show validato CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]') echo "* Contract address: $CONTRACT" + +echo "## Create new contract instance with predictable address" +wasmd tx wasm instantiate2 "$CODE_ID" "$INIT" $(echo -n "testing" | xxd -ps) \ + --admin="$(wasmd keys show validator -a)" \ + --from validator --amount="100ustake" --label "local0.1.0" \ + --fix-msg \ + --gas 1000000 -y --chain-id=testing -b block -o json | jq + +predictedAdress=$(wasmd q wasm build-address "$CODE_HASH" $(wasmd keys show validator -a) $(echo -n "testing" | xxd -ps) "$INIT") +wasmd q wasm contract "$predictedAdress" -o json | jq + echo "### Query all" RESP=$(wasmd query wasm contract-state all "$CONTRACT" -o json) echo "$RESP" | jq diff --git a/docker/setup_and_run.sh b/docker/setup_and_run.sh new file mode 100644 index 0000000000..f5bacbf67c --- /dev/null +++ b/docker/setup_and_run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +./setup_wasmd.sh "$@" +./run_wasmd.sh \ No newline at end of file diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index b01be26d6b..1635f6ca19 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -23,6 +23,8 @@ - [MsgExecuteContract](#cosmwasm.wasm.v1.MsgExecuteContract) - [MsgExecuteContractResponse](#cosmwasm.wasm.v1.MsgExecuteContractResponse) - [MsgInstantiateContract](#cosmwasm.wasm.v1.MsgInstantiateContract) + - [MsgInstantiateContract2](#cosmwasm.wasm.v1.MsgInstantiateContract2) + - [MsgInstantiateContract2Response](#cosmwasm.wasm.v1.MsgInstantiateContract2Response) - [MsgInstantiateContractResponse](#cosmwasm.wasm.v1.MsgInstantiateContractResponse) - [MsgMigrateContract](#cosmwasm.wasm.v1.MsgMigrateContract) - [MsgMigrateContractResponse](#cosmwasm.wasm.v1.MsgMigrateContractResponse) @@ -71,6 +73,8 @@ - [QueryContractInfoResponse](#cosmwasm.wasm.v1.QueryContractInfoResponse) - [QueryContractsByCodeRequest](#cosmwasm.wasm.v1.QueryContractsByCodeRequest) - [QueryContractsByCodeResponse](#cosmwasm.wasm.v1.QueryContractsByCodeResponse) + - [QueryParamsRequest](#cosmwasm.wasm.v1.QueryParamsRequest) + - [QueryParamsResponse](#cosmwasm.wasm.v1.QueryParamsResponse) - [QueryPinnedCodesRequest](#cosmwasm.wasm.v1.QueryPinnedCodesRequest) - [QueryPinnedCodesResponse](#cosmwasm.wasm.v1.QueryPinnedCodesResponse) - [QueryRawContractStateRequest](#cosmwasm.wasm.v1.QueryRawContractStateRequest) @@ -139,7 +143,8 @@ AccessConfig access control type. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `permission` | [AccessType](#cosmwasm.wasm.v1.AccessType) | | | -| `address` | [string](#string) | | | +| `address` | [string](#string) | | Address Deprecated: replaced by addresses | +| `addresses` | [string](#string) | repeated | | @@ -263,8 +268,9 @@ AccessType permission types | ---- | ------ | ----------- | | ACCESS_TYPE_UNSPECIFIED | 0 | AccessTypeUnspecified placeholder for empty value | | ACCESS_TYPE_NOBODY | 1 | AccessTypeNobody forbidden | -| ACCESS_TYPE_ONLY_ADDRESS | 2 | AccessTypeOnlyAddress restricted to an address | +| ACCESS_TYPE_ONLY_ADDRESS | 2 | AccessTypeOnlyAddress restricted to a single address Deprecated: use AccessTypeAnyOfAddresses instead | | ACCESS_TYPE_EVERYBODY | 3 | AccessTypeEverybody unrestricted | +| ACCESS_TYPE_ANY_OF_ADDRESSES | 4 | AccessTypeAnyOfAddresses allow any of the addresses | @@ -348,7 +354,7 @@ MsgExecuteContractResponse returns execution result data. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `data` | [bytes](#bytes) | | Data contains base64-encoded bytes to returned from the contract | +| `data` | [bytes](#bytes) | | Data contains bytes to returned from the contract | @@ -376,6 +382,45 @@ code id. + + +### MsgInstantiateContract2 +MsgInstantiateContract2 create a new smart contract instance for the given +code id with a predicable address. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | Sender is the that actor that signed the messages | +| `admin` | [string](#string) | | Admin is an optional address that can execute migrations | +| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | +| `label` | [string](#string) | | Label is optional metadata to be stored with a contract instance. | +| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract on instantiation | +| `funds` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Funds coins that are transferred to the contract on instantiation | +| `salt` | [bytes](#bytes) | | Salt is an arbitrary value provided by the sender. Size can be 1 to 64. | +| `fix_msg` | [bool](#bool) | | FixMsg include the msg value into the hash for the predictable address. Default is false | + + + + + + + + +### MsgInstantiateContract2Response +MsgInstantiateContract2Response return instantiation result data + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | Address is the bech32 address of the new contract instance. | +| `data` | [bytes](#bytes) | | Data contains bytes to returned from the contract | + + + + + + ### MsgInstantiateContractResponse @@ -385,7 +430,7 @@ MsgInstantiateContractResponse return instantiation result data | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | Address is the bech32 address of the new contract instance. | -| `data` | [bytes](#bytes) | | Data contains base64-encoded bytes to returned from the contract | +| `data` | [bytes](#bytes) | | Data contains bytes to returned from the contract | @@ -451,6 +496,7 @@ MsgStoreCodeResponse returns store result data. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | +| `checksum` | [bytes](#bytes) | | Checksum is the sha256 hash of the stored code | @@ -498,7 +544,8 @@ Msg defines the wasm Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `StoreCode` | [MsgStoreCode](#cosmwasm.wasm.v1.MsgStoreCode) | [MsgStoreCodeResponse](#cosmwasm.wasm.v1.MsgStoreCodeResponse) | StoreCode to submit Wasm code to the system | | -| `InstantiateContract` | [MsgInstantiateContract](#cosmwasm.wasm.v1.MsgInstantiateContract) | [MsgInstantiateContractResponse](#cosmwasm.wasm.v1.MsgInstantiateContractResponse) | Instantiate creates a new smart contract instance for the given code id. | | +| `InstantiateContract` | [MsgInstantiateContract](#cosmwasm.wasm.v1.MsgInstantiateContract) | [MsgInstantiateContractResponse](#cosmwasm.wasm.v1.MsgInstantiateContractResponse) | InstantiateContract creates a new smart contract instance for the given code id. | | +| `InstantiateContract2` | [MsgInstantiateContract2](#cosmwasm.wasm.v1.MsgInstantiateContract2) | [MsgInstantiateContract2Response](#cosmwasm.wasm.v1.MsgInstantiateContract2Response) | InstantiateContract2 creates a new smart contract instance for the given code id with a predictable address | | | `ExecuteContract` | [MsgExecuteContract](#cosmwasm.wasm.v1.MsgExecuteContract) | [MsgExecuteContractResponse](#cosmwasm.wasm.v1.MsgExecuteContractResponse) | Execute submits the given message data to a smart contract | | | `MigrateContract` | [MsgMigrateContract](#cosmwasm.wasm.v1.MsgMigrateContract) | [MsgMigrateContractResponse](#cosmwasm.wasm.v1.MsgMigrateContractResponse) | Migrate runs a code upgrade/ downgrade for a smart contract | | | `UpdateAdmin` | [MsgUpdateAdmin](#cosmwasm.wasm.v1.MsgUpdateAdmin) | [MsgUpdateAdminResponse](#cosmwasm.wasm.v1.MsgUpdateAdminResponse) | UpdateAdmin sets a new admin for a smart contract | | @@ -581,7 +628,7 @@ order. The intention is to have more human readable data that is auditable. | ----- | ---- | ----- | ----------- | | `store_code` | [MsgStoreCode](#cosmwasm.wasm.v1.MsgStoreCode) | | | | `instantiate_contract` | [MsgInstantiateContract](#cosmwasm.wasm.v1.MsgInstantiateContract) | | | -| `execute_contract` | [MsgExecuteContract](#cosmwasm.wasm.v1.MsgExecuteContract) | | | +| `execute_contract` | [MsgExecuteContract](#cosmwasm.wasm.v1.MsgExecuteContract) | | MsgInstantiateContract2 intentionally not supported see https://github.com/CosmWasm/wasmd/issues/987 | @@ -800,6 +847,7 @@ StoreCodeProposal gov proposal content type to submit WASM code to the system | `run_as` | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender | | `wasm_byte_code` | [bytes](#bytes) | | WASMByteCode can be raw or gzip compressed | | `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply on contract creation, optional | +| `unpin_code` | [bool](#bool) | | UnpinCode code on upload, optional | @@ -1109,6 +1157,31 @@ Query/ContractsByCode RPC method + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#cosmwasm.wasm.v1.Params) | | params defines the parameters of the module. | + + + + + + ### QueryPinnedCodesRequest @@ -1230,6 +1303,7 @@ Query provides defines the gRPC querier service | `Code` | [QueryCodeRequest](#cosmwasm.wasm.v1.QueryCodeRequest) | [QueryCodeResponse](#cosmwasm.wasm.v1.QueryCodeResponse) | Code gets the binary code and metadata for a singe wasm code | GET|/cosmwasm/wasm/v1/code/{code_id}| | `Codes` | [QueryCodesRequest](#cosmwasm.wasm.v1.QueryCodesRequest) | [QueryCodesResponse](#cosmwasm.wasm.v1.QueryCodesResponse) | Codes gets the metadata for all stored wasm codes | GET|/cosmwasm/wasm/v1/code| | `PinnedCodes` | [QueryPinnedCodesRequest](#cosmwasm.wasm.v1.QueryPinnedCodesRequest) | [QueryPinnedCodesResponse](#cosmwasm.wasm.v1.QueryPinnedCodesResponse) | PinnedCodes gets the pinned code ids | GET|/cosmwasm/wasm/v1/codes/pinned| +| `Params` | [QueryParamsRequest](#cosmwasm.wasm.v1.QueryParamsRequest) | [QueryParamsResponse](#cosmwasm.wasm.v1.QueryParamsResponse) | Params gets the module params | GET|/cosmwasm/wasm/v1/codes/params| diff --git a/docs/proto/proto.md b/docs/proto/proto.md deleted file mode 100644 index 6637b9a28f..0000000000 --- a/docs/proto/proto.md +++ /dev/null @@ -1,1121 +0,0 @@ -# Protocol Documentation - - -## Table of Contents - -- [x/wasm/types/genesis.proto](#x/wasm/types/genesis.proto) - - [Code](#cosmwasm.wasm.v1beta1.Code) - - [Contract](#cosmwasm.wasm.v1beta1.Contract) - - [GenesisState](#cosmwasm.wasm.v1beta1.GenesisState) - - [GenesisState.GenMsgs](#cosmwasm.wasm.v1beta1.GenesisState.GenMsgs) - - [Sequence](#cosmwasm.wasm.v1beta1.Sequence) - -- [x/wasm/types/ibc.proto](#x/wasm/types/ibc.proto) - - [MsgIBCCloseChannel](#cosmwasm.wasm.v1beta1.MsgIBCCloseChannel) - - [MsgIBCSend](#cosmwasm.wasm.v1beta1.MsgIBCSend) - -- [x/wasm/types/proposal.proto](#x/wasm/types/proposal.proto) - - [ClearAdminProposal](#cosmwasm.wasm.v1beta1.ClearAdminProposal) - - [InstantiateContractProposal](#cosmwasm.wasm.v1beta1.InstantiateContractProposal) - - [MigrateContractProposal](#cosmwasm.wasm.v1beta1.MigrateContractProposal) - - [PinCodesProposal](#cosmwasm.wasm.v1beta1.PinCodesProposal) - - [StoreCodeProposal](#cosmwasm.wasm.v1beta1.StoreCodeProposal) - - [UnpinCodesProposal](#cosmwasm.wasm.v1beta1.UnpinCodesProposal) - - [UpdateAdminProposal](#cosmwasm.wasm.v1beta1.UpdateAdminProposal) - -- [x/wasm/types/query.proto](#x/wasm/types/query.proto) - - [CodeInfoResponse](#cosmwasm.wasm.v1beta1.CodeInfoResponse) - - [ContractInfoWithAddress](#cosmwasm.wasm.v1beta1.ContractInfoWithAddress) - - [QueryAllContractStateRequest](#cosmwasm.wasm.v1beta1.QueryAllContractStateRequest) - - [QueryAllContractStateResponse](#cosmwasm.wasm.v1beta1.QueryAllContractStateResponse) - - [QueryCodeRequest](#cosmwasm.wasm.v1beta1.QueryCodeRequest) - - [QueryCodeResponse](#cosmwasm.wasm.v1beta1.QueryCodeResponse) - - [QueryCodesRequest](#cosmwasm.wasm.v1beta1.QueryCodesRequest) - - [QueryCodesResponse](#cosmwasm.wasm.v1beta1.QueryCodesResponse) - - [QueryContractHistoryRequest](#cosmwasm.wasm.v1beta1.QueryContractHistoryRequest) - - [QueryContractHistoryResponse](#cosmwasm.wasm.v1beta1.QueryContractHistoryResponse) - - [QueryContractInfoRequest](#cosmwasm.wasm.v1beta1.QueryContractInfoRequest) - - [QueryContractInfoResponse](#cosmwasm.wasm.v1beta1.QueryContractInfoResponse) - - [QueryContractsByCodeRequest](#cosmwasm.wasm.v1beta1.QueryContractsByCodeRequest) - - [QueryContractsByCodeResponse](#cosmwasm.wasm.v1beta1.QueryContractsByCodeResponse) - - [QueryRawContractStateRequest](#cosmwasm.wasm.v1beta1.QueryRawContractStateRequest) - - [QueryRawContractStateResponse](#cosmwasm.wasm.v1beta1.QueryRawContractStateResponse) - - [QuerySmartContractStateRequest](#cosmwasm.wasm.v1beta1.QuerySmartContractStateRequest) - - [QuerySmartContractStateResponse](#cosmwasm.wasm.v1beta1.QuerySmartContractStateResponse) - - - [Query](#cosmwasm.wasm.v1beta1.Query) - -- [x/wasm/types/tx.proto](#x/wasm/types/tx.proto) - - [MsgClearAdmin](#cosmwasm.wasm.v1beta1.MsgClearAdmin) - - [MsgClearAdminResponse](#cosmwasm.wasm.v1beta1.MsgClearAdminResponse) - - [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) - - [MsgExecuteContractResponse](#cosmwasm.wasm.v1beta1.MsgExecuteContractResponse) - - [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) - - [MsgInstantiateContractResponse](#cosmwasm.wasm.v1beta1.MsgInstantiateContractResponse) - - [MsgMigrateContract](#cosmwasm.wasm.v1beta1.MsgMigrateContract) - - [MsgMigrateContractResponse](#cosmwasm.wasm.v1beta1.MsgMigrateContractResponse) - - [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) - - [MsgStoreCodeResponse](#cosmwasm.wasm.v1beta1.MsgStoreCodeResponse) - - [MsgUpdateAdmin](#cosmwasm.wasm.v1beta1.MsgUpdateAdmin) - - [MsgUpdateAdminResponse](#cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse) - - - [Msg](#cosmwasm.wasm.v1beta1.Msg) - -- [x/wasm/types/types.proto](#x/wasm/types/types.proto) - - [AbsoluteTxPosition](#cosmwasm.wasm.v1beta1.AbsoluteTxPosition) - - [AccessConfig](#cosmwasm.wasm.v1beta1.AccessConfig) - - [AccessTypeParam](#cosmwasm.wasm.v1beta1.AccessTypeParam) - - [CodeInfo](#cosmwasm.wasm.v1beta1.CodeInfo) - - [ContractCodeHistoryEntry](#cosmwasm.wasm.v1beta1.ContractCodeHistoryEntry) - - [ContractInfo](#cosmwasm.wasm.v1beta1.ContractInfo) - - [Model](#cosmwasm.wasm.v1beta1.Model) - - [Params](#cosmwasm.wasm.v1beta1.Params) - - - [AccessType](#cosmwasm.wasm.v1beta1.AccessType) - - [ContractCodeHistoryOperationType](#cosmwasm.wasm.v1beta1.ContractCodeHistoryOperationType) - -- [Scalar Value Types](#scalar-value-types) - - - - -

Top

- -## x/wasm/types/genesis.proto - - - - - -### Code -Code struct encompasses CodeInfo and CodeBytes - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | | -| code_info | [CodeInfo](#cosmwasm.wasm.v1beta1.CodeInfo) | | | -| code_bytes | [bytes](#bytes) | | | -| pinned | [bool](#bool) | | Pinned to wasmvm cache | - - - - - - - - -### Contract -Contract struct encompasses ContractAddress, ContractInfo, and ContractState - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| contract_address | [string](#string) | | | -| contract_info | [ContractInfo](#cosmwasm.wasm.v1beta1.ContractInfo) | | | -| contract_state | [Model](#cosmwasm.wasm.v1beta1.Model) | repeated | | - - - - - - - - -### GenesisState -GenesisState - genesis state of x/wasm - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| params | [Params](#cosmwasm.wasm.v1beta1.Params) | | | -| codes | [Code](#cosmwasm.wasm.v1beta1.Code) | repeated | | -| contracts | [Contract](#cosmwasm.wasm.v1beta1.Contract) | repeated | | -| sequences | [Sequence](#cosmwasm.wasm.v1beta1.Sequence) | repeated | | -| gen_msgs | [GenesisState.GenMsgs](#cosmwasm.wasm.v1beta1.GenesisState.GenMsgs) | repeated | | - - - - - - - - -### GenesisState.GenMsgs -GenMsgs define the messages that can be executed during genesis phase in order. -The intention is to have more human readable data that is auditable. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| store_code | [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) | | | -| instantiate_contract | [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) | | | -| execute_contract | [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) | | | - - - - - - - - -### Sequence -Sequence key and value of an id generation counter - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| id_key | [bytes](#bytes) | | | -| value | [uint64](#uint64) | | | - - - - - - - - - - - - - - - - -

Top

- -## x/wasm/types/ibc.proto - - - - - -### MsgIBCCloseChannel -MsgIBCCloseChannel port and channel need to be owned by the contract - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| channel | [string](#string) | | | - - - - - - - - -### MsgIBCSend -MsgIBCSend - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| channel | [string](#string) | | the channel by which the packet will be sent | -| timeout_height | [uint64](#uint64) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | -| timeout_timestamp | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | -| data | [bytes](#bytes) | | data is the payload to transfer | - - - - - - - - - - - - - - - - -

Top

- -## x/wasm/types/proposal.proto - - - - - -### ClearAdminProposal -ClearAdminProposal gov proposal content type to clear the admin of a contract. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| contract | [string](#string) | | Contract is the address of the smart contract | - - - - - - - - -### InstantiateContractProposal -InstantiateContractProposal gov proposal content type to instantiate a contract. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| run_as | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender | -| admin | [string](#string) | | Admin is an optional address that can execute migrations | -| code_id | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | -| label | [string](#string) | | Label is optional metadata to be stored with a constract instance. | -| init_msg | [bytes](#bytes) | | InitMsg json encoded message to be passed to the contract on instantiation | -| funds | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Funds coins that are transferred to the contract on instantiation | - - - - - - - - -### MigrateContractProposal -MigrateContractProposal gov proposal content type to migrate a contract. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| run_as | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender | -| contract | [string](#string) | | Contract is the address of the smart contract | -| code_id | [uint64](#uint64) | | CodeID references the new WASM code | -| migrate_msg | [bytes](#bytes) | | MigrateMsg json encoded message to be passed to the contract on migration | - - - - - - - - -### PinCodesProposal -PinCodesProposal gov proposal content type to pin a set of code ids in the wasmvm cache. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| code_ids | [uint64](#uint64) | repeated | CodeIDs references the new WASM codes | - - - - - - - - -### StoreCodeProposal -StoreCodeProposal gov proposal content type to submit WASM code to the system - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| run_as | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender | -| wasm_byte_code | [bytes](#bytes) | | WASMByteCode can be raw or gzip compressed | -| source | [string](#string) | | Source is a valid absolute HTTPS URI to the contract's source code, optional | -| builder | [string](#string) | | Builder is a valid docker image name with tag, optional | -| instantiate_permission | [AccessConfig](#cosmwasm.wasm.v1beta1.AccessConfig) | | InstantiatePermission to apply on contract creation, optional | - - - - - - - - -### UnpinCodesProposal -UnpinCodesProposal gov proposal content type to unpin a set of code ids in the wasmvm cache. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| code_ids | [uint64](#uint64) | repeated | CodeIDs references the WASM codes | - - - - - - - - -### UpdateAdminProposal -UpdateAdminProposal gov proposal content type to set an admin for a contract. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| title | [string](#string) | | Title is a short summary | -| description | [string](#string) | | Description is a human readable text | -| new_admin | [string](#string) | | NewAdmin address to be set | -| contract | [string](#string) | | Contract is the address of the smart contract | - - - - - - - - - - - - - - - - -

Top

- -## x/wasm/types/query.proto - - - - - -### CodeInfoResponse -CodeInfoResponse contains code meta data from CodeInfo - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | id for legacy support | -| creator | [string](#string) | | | -| data_hash | [bytes](#bytes) | | | -| source | [string](#string) | | | -| builder | [string](#string) | | | - - - - - - - - -### ContractInfoWithAddress -ContractInfoWithAddress adds the address (key) to the ContractInfo representation - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | | -| contract_info | [ContractInfo](#cosmwasm.wasm.v1beta1.ContractInfo) | | | - - - - - - - - -### QueryAllContractStateRequest -QueryAllContractStateRequest is the request type for the Query/AllContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract | -| pagination | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - - - - - - - - -### QueryAllContractStateResponse -QueryAllContractStateResponse is the response type for the Query/AllContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| models | [Model](#cosmwasm.wasm.v1beta1.Model) | repeated | | -| pagination | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - - - - - - - - -### QueryCodeRequest -QueryCodeRequest is the request type for the Query/Code RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | grpc-gateway_out does not support Go style CodID | - - - - - - - - -### QueryCodeResponse -QueryCodeResponse is the response type for the Query/Code RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_info | [CodeInfoResponse](#cosmwasm.wasm.v1beta1.CodeInfoResponse) | | | -| data | [bytes](#bytes) | | | - - - - - - - - -### QueryCodesRequest -QueryCodesRequest is the request type for the Query/Codes RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| pagination | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - - - - - - - - -### QueryCodesResponse -QueryCodesResponse is the response type for the Query/Codes RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_infos | [CodeInfoResponse](#cosmwasm.wasm.v1beta1.CodeInfoResponse) | repeated | | -| pagination | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - - - - - - - - -### QueryContractHistoryRequest -QueryContractHistoryRequest is the request type for the Query/ContractHistory RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract to query | -| pagination | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - - - - - - - - -### QueryContractHistoryResponse -QueryContractHistoryResponse is the response type for the Query/ContractHistory RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| entries | [ContractCodeHistoryEntry](#cosmwasm.wasm.v1beta1.ContractCodeHistoryEntry) | repeated | | -| pagination | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - - - - - - - - -### QueryContractInfoRequest -QueryContractInfoRequest is the request type for the Query/ContractInfo RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract to query | - - - - - - - - -### QueryContractInfoResponse -QueryContractInfoResponse is the response type for the Query/ContractInfo RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract | -| contract_info | [ContractInfo](#cosmwasm.wasm.v1beta1.ContractInfo) | | | - - - - - - - - -### QueryContractsByCodeRequest -QueryContractsByCodeRequest is the request type for the Query/ContractsByCode RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | grpc-gateway_out does not support Go style CodID | -| pagination | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - - - - - - - - -### QueryContractsByCodeResponse -QueryContractsByCodeResponse is the response type for the Query/ContractsByCode RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| contract_infos | [ContractInfoWithAddress](#cosmwasm.wasm.v1beta1.ContractInfoWithAddress) | repeated | | -| pagination | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | - - - - - - - - -### QueryRawContractStateRequest -QueryRawContractStateRequest is the request type for the Query/RawContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract | -| query_data | [bytes](#bytes) | | | - - - - - - - - -### QueryRawContractStateResponse -QueryRawContractStateResponse is the response type for the Query/RawContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| data | [bytes](#bytes) | | Data contains the raw store data | - - - - - - - - -### QuerySmartContractStateRequest -QuerySmartContractStateRequest is the request type for the Query/SmartContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | address is the address of the contract | -| query_data | [bytes](#bytes) | | QueryData contains the query data passed to the contract | - - - - - - - - -### QuerySmartContractStateResponse -QuerySmartContractStateResponse is the response type for the Query/SmartContractState RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| data | [bytes](#bytes) | | Data contains the json data returned from the smart contract | - - - - - - - - - - - - - - -### Query -Query provides defines the gRPC querier service - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| ContractInfo | [QueryContractInfoRequest](#cosmwasm.wasm.v1beta1.QueryContractInfoRequest) | [QueryContractInfoResponse](#cosmwasm.wasm.v1beta1.QueryContractInfoResponse) | ContractInfo gets the contract meta data | -| ContractHistory | [QueryContractHistoryRequest](#cosmwasm.wasm.v1beta1.QueryContractHistoryRequest) | [QueryContractHistoryResponse](#cosmwasm.wasm.v1beta1.QueryContractHistoryResponse) | ContractHistory gets the contract code history | -| ContractsByCode | [QueryContractsByCodeRequest](#cosmwasm.wasm.v1beta1.QueryContractsByCodeRequest) | [QueryContractsByCodeResponse](#cosmwasm.wasm.v1beta1.QueryContractsByCodeResponse) | ContractsByCode lists all smart contracts for a code id | -| AllContractState | [QueryAllContractStateRequest](#cosmwasm.wasm.v1beta1.QueryAllContractStateRequest) | [QueryAllContractStateResponse](#cosmwasm.wasm.v1beta1.QueryAllContractStateResponse) | AllContractState gets all raw store data for a single contract | -| RawContractState | [QueryRawContractStateRequest](#cosmwasm.wasm.v1beta1.QueryRawContractStateRequest) | [QueryRawContractStateResponse](#cosmwasm.wasm.v1beta1.QueryRawContractStateResponse) | RawContractState gets single key from the raw store data of a contract | -| SmartContractState | [QuerySmartContractStateRequest](#cosmwasm.wasm.v1beta1.QuerySmartContractStateRequest) | [QuerySmartContractStateResponse](#cosmwasm.wasm.v1beta1.QuerySmartContractStateResponse) | SmartContractState get smart query result from the contract | -| Code | [QueryCodeRequest](#cosmwasm.wasm.v1beta1.QueryCodeRequest) | [QueryCodeResponse](#cosmwasm.wasm.v1beta1.QueryCodeResponse) | Code gets the binary code and metadata for a singe wasm code | -| Codes | [QueryCodesRequest](#cosmwasm.wasm.v1beta1.QueryCodesRequest) | [QueryCodesResponse](#cosmwasm.wasm.v1beta1.QueryCodesResponse) | Codes gets the metadata for all stored wasm codes | - - - - - - -

Top

- -## x/wasm/types/tx.proto - - - - - -### MsgClearAdmin -MsgClearAdmin removes any admin stored for a smart contract - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| contract | [string](#string) | | Contract is the address of the smart contract | - - - - - - - - -### MsgClearAdminResponse -MsgClearAdminResponse returns empty data - - - - - - - - -### MsgExecuteContract -MsgExecuteContract submits the given message data to a smart contract - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| contract | [string](#string) | | Contract is the address of the smart contract | -| msg | [bytes](#bytes) | | Msg json encoded message to be passed to the contract | -| funds | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Funds coins that are transferred to the contract on execution | - - - - - - - - -### MsgExecuteContractResponse -MsgExecuteContractResponse returns execution result data. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| data | [bytes](#bytes) | | Data contains base64-encoded bytes to returned from the contract | - - - - - - - - -### MsgInstantiateContract -MsgInstantiateContract create a new smart contract instance for the given code id. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| admin | [string](#string) | | Admin is an optional address that can execute migrations | -| code_id | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | -| label | [string](#string) | | Label is optional metadata to be stored with a contract instance. | -| init_msg | [bytes](#bytes) | | InitMsg json encoded message to be passed to the contract on instantiation | -| funds | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Funds coins that are transferred to the contract on instantiation | - - - - - - - - -### MsgInstantiateContractResponse -MsgInstantiateContractResponse return instantiation result data - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| address | [string](#string) | | Address is the bech32 address of the new contract instance. | -| data | [bytes](#bytes) | | Data contains base64-encoded bytes to returned from the contract | - - - - - - - - -### MsgMigrateContract -MsgMigrateContract runs a code upgrade/ downgrade for a smart contract - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| contract | [string](#string) | | Contract is the address of the smart contract | -| code_id | [uint64](#uint64) | | CodeID references the new WASM code | -| migrate_msg | [bytes](#bytes) | | MigrateMsg json encoded message to be passed to the contract on migration | - - - - - - - - -### MsgMigrateContractResponse -MsgMigrateContractResponse returns contract migration result data. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| data | [bytes](#bytes) | | Data contains same raw bytes returned as data from the wasm contract. (May be empty) | - - - - - - - - -### MsgStoreCode -MsgStoreCode submit Wasm code to the system - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| wasm_byte_code | [bytes](#bytes) | | WASMByteCode can be raw or gzip compressed | -| source | [string](#string) | | Source is a valid absolute HTTPS URI to the contract's source code, optional | -| builder | [string](#string) | | Builder is a valid docker image name with tag, optional | -| instantiate_permission | [AccessConfig](#cosmwasm.wasm.v1beta1.AccessConfig) | | InstantiatePermission access control to apply on contract creation, optional | - - - - - - - - -### MsgStoreCodeResponse -MsgStoreCodeResponse returns store result data. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | - - - - - - - - -### MsgUpdateAdmin -MsgUpdateAdmin sets a new admin for a smart contract - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| sender | [string](#string) | | Sender is the that actor that signed the messages | -| new_admin | [string](#string) | | NewAdmin address to be set | -| contract | [string](#string) | | Contract is the address of the smart contract | - - - - - - - - -### MsgUpdateAdminResponse -MsgUpdateAdminResponse returns empty data - - - - - - - - - - - - - - -### Msg -Msg defines the wasm Msg service. - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| StoreCode | [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) | [MsgStoreCodeResponse](#cosmwasm.wasm.v1beta1.MsgStoreCodeResponse) | StoreCode to submit Wasm code to the system | -| InstantiateContract | [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) | [MsgInstantiateContractResponse](#cosmwasm.wasm.v1beta1.MsgInstantiateContractResponse) | Instantiate creates a new smart contract instance for the given code id. | -| ExecuteContract | [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) | [MsgExecuteContractResponse](#cosmwasm.wasm.v1beta1.MsgExecuteContractResponse) | Execute submits the given message data to a smart contract | -| MigrateContract | [MsgMigrateContract](#cosmwasm.wasm.v1beta1.MsgMigrateContract) | [MsgMigrateContractResponse](#cosmwasm.wasm.v1beta1.MsgMigrateContractResponse) | Migrate runs a code upgrade/ downgrade for a smart contract | -| UpdateAdmin | [MsgUpdateAdmin](#cosmwasm.wasm.v1beta1.MsgUpdateAdmin) | [MsgUpdateAdminResponse](#cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse) | UpdateAdmin sets a new admin for a smart contract | -| ClearAdmin | [MsgClearAdmin](#cosmwasm.wasm.v1beta1.MsgClearAdmin) | [MsgClearAdminResponse](#cosmwasm.wasm.v1beta1.MsgClearAdminResponse) | ClearAdmin removes any admin stored for a smart contract | - - - - - - -

Top

- -## x/wasm/types/types.proto - - - - - -### AbsoluteTxPosition -AbsoluteTxPosition is a unique transaction position that allows for global ordering of transactions. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| block_height | [uint64](#uint64) | | BlockHeight is the block the contract was created at | -| tx_index | [uint64](#uint64) | | TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) | - - - - - - - - -### AccessConfig -AccessConfig access control type. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| permission | [AccessType](#cosmwasm.wasm.v1beta1.AccessType) | | | -| address | [string](#string) | | | - - - - - - - - -### AccessTypeParam -AccessTypeParam - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| value | [AccessType](#cosmwasm.wasm.v1beta1.AccessType) | | | - - - - - - - - -### CodeInfo -CodeInfo is data for the uploaded contract WASM code - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_hash | [bytes](#bytes) | | CodeHash is the unique identifier created by wasmvm | -| creator | [string](#string) | | Creator address who initially stored the code | -| source | [string](#string) | | Source is a valid absolute HTTPS URI to the contract's source code, optional | -| builder | [string](#string) | | Builder is a valid docker image name with tag, optional | -| instantiate_config | [AccessConfig](#cosmwasm.wasm.v1beta1.AccessConfig) | | InstantiateConfig access control to apply on contract creation, optional | - - - - - - - - -### ContractCodeHistoryEntry -ContractCodeHistoryEntry metadata to a contract. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| operation | [ContractCodeHistoryOperationType](#cosmwasm.wasm.v1beta1.ContractCodeHistoryOperationType) | | | -| code_id | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | -| updated | [AbsoluteTxPosition](#cosmwasm.wasm.v1beta1.AbsoluteTxPosition) | | Updated Tx position when the operation was executed. | -| msg | [bytes](#bytes) | | | - - - - - - - - -### ContractInfo -ContractInfo stores a WASM contract instance - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_id | [uint64](#uint64) | | CodeID is the reference to the stored Wasm code | -| creator | [string](#string) | | Creator address who initially instantiated the contract | -| admin | [string](#string) | | Admin is an optional address that can execute migrations | -| label | [string](#string) | | Label is optional metadata to be stored with a contract instance. | -| created | [AbsoluteTxPosition](#cosmwasm.wasm.v1beta1.AbsoluteTxPosition) | | Created Tx position when the contract was instantiated. This data should kept internal and not be exposed via query results. Just use for sorting | -| ibc_port_id | [string](#string) | | | - - - - - - - - -### Model -Model is a struct that holds a KV pair - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| key | [bytes](#bytes) | | hex-encode key to read it better (this is often ascii) | -| value | [bytes](#bytes) | | base64-encode raw value | - - - - - - - - -### Params -Params defines the set of wasm parameters. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| code_upload_access | [AccessConfig](#cosmwasm.wasm.v1beta1.AccessConfig) | | | -| instantiate_default_permission | [AccessType](#cosmwasm.wasm.v1beta1.AccessType) | | | -| max_wasm_code_size | [uint64](#uint64) | | | - - - - - - - - - - -### AccessType -AccessType permission types - -| Name | Number | Description | -| ---- | ------ | ----------- | -| ACCESS_TYPE_UNSPECIFIED | 0 | AccessTypeUnspecified placeholder for empty value | -| ACCESS_TYPE_NOBODY | 1 | AccessTypeNobody forbidden | -| ACCESS_TYPE_ONLY_ADDRESS | 2 | AccessTypeOnlyAddress restricted to an address | -| ACCESS_TYPE_EVERYBODY | 3 | AccessTypeEverybody unrestricted | - - - - - -### ContractCodeHistoryOperationType -ContractCodeHistoryOperationType actions that caused a code change - -| Name | Number | Description | -| ---- | ------ | ----------- | -| CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED | 0 | ContractCodeHistoryOperationTypeUnspecified placeholder for empty value | -| CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT | 1 | ContractCodeHistoryOperationTypeInit on chain contract instantiation | -| CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE | 2 | ContractCodeHistoryOperationTypeMigrate code migration | -| CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS | 3 | ContractCodeHistoryOperationTypeGenesis based on genesis data | - - - - - - - - - - -## Scalar Value Types - -| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | -| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | -| double | | double | double | float | float64 | double | float | Float | -| float | | float | float | float | float32 | float | float | Float | -| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | -| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | -| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | -| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | -| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | -| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | -| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | - diff --git a/go.mod b/go.mod index 47b07b5048..e5a032b783 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/cosmos/iavl v0.19.4 github.com/cosmos/interchain-accounts v0.1.0 - github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b + github.com/dvsekhvalnov/jose2go v1.5.0 github.com/go-kit/kit v0.12.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 @@ -14,7 +14,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/line/lbm-sdk v0.46.1-0.20230106043757-1ece23d83a0b github.com/line/ostracon v1.0.7 - github.com/line/wasmvm v1.0.0-0.10.0 + github.com/line/wasmvm v1.1.1-0.11.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.14.0 github.com/rakyll/statik v0.1.7 @@ -26,6 +26,7 @@ require ( github.com/spf13/viper v1.14.0 github.com/stretchr/testify v1.8.1 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 + github.com/tendermint/tendermint v0.34.20 github.com/tendermint/tm-db v0.6.7 google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e google.golang.org/grpc v1.50.1 @@ -54,7 +55,7 @@ require ( github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect - github.com/danieljoos/wincred v1.0.2 // indirect + github.com/danieljoos/wincred v1.1.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.4 // indirect @@ -67,9 +68,9 @@ require ( 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/glog v0.0.0-20160126235308-23def4e6c14b // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.0.0 // indirect + github.com/google/btree v1.1.2 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -90,7 +91,6 @@ require ( github.com/klauspost/compress v1.15.1 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -98,6 +98,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect github.com/minio/highwayhash v1.0.2 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect @@ -119,7 +120,6 @@ require ( github.com/tendermint/btcd v0.1.1 // indirect github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tendermint/tendermint v0.34.20 // indirect github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.4.0 // indirect @@ -135,8 +135,7 @@ require ( ) replace ( - // Use the cosmos-flavored keyring library - github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 + github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 // 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 diff --git a/go.sum b/go.sum index 9199e30e8b..05730064b5 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= +github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= github.com/Antonboom/errname v0.1.6/go.mod h1:7lz79JAnuoMNDAWE9MeeIr1/c/VpSUWatBv2FH9NYpI= github.com/Antonboom/nilnil v0.1.1/go.mod h1:L1jBqoWM7AOeTD+tSquifKSesRHs4ZdaxvZR+xdJEaI= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= @@ -252,9 +254,6 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= github.com/coinbase/rosetta-sdk-go v0.8.2 h1:+sNgMUPpntOsYLy5aRsHqBY6I0MTxZkS4JXV1Un3DKc= github.com/coinbase/rosetta-sdk-go v0.8.2/go.mod h1:tXPR6AIW9ogsH4tYIaFOKOgfJNanCvcyl7JKLd4DToc= -github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= -github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= -github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 h1:MFLTqgfJclmtaQ1SRUrWwmDX/1UBok3XWUethkJ2swQ= github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71/go.mod h1:TrHYHH4Wze7v7Hkwu1MH1W+mCPQKM+gs+PicdEV14o8= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= @@ -279,6 +278,8 @@ 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.45.1 h1:PY79YxPea5qlRLExRnzg8/rT1Scc8GGgRs22p7DX99Q= github.com/cosmos/cosmos-sdk v0.45.1/go.mod h1:XXS/asyCqWNWkx2rW6pSuen+EVcpAFxq6khrhnZgHaQ= +github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= +github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -289,8 +290,6 @@ github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok= github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/interchain-accounts v0.1.0 h1:QmuwNsf1Hxl3P5GSGt7Z+JeuHPiZw4Z34R/038P5T6s= github.com/cosmos/interchain-accounts v0.1.0/go.mod h1:Fv6LXDs+0ng4mIDVWwEJMXbAIMxY4kiq+A7Bw1Fb9AY= -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= @@ -306,8 +305,9 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= -github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= +github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= +github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -346,8 +346,9 @@ github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbT 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/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= +github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= 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= @@ -364,12 +365,10 @@ github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8 github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/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/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/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= @@ -469,8 +468,9 @@ github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= 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= @@ -523,8 +523,9 @@ github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPP github.com/golangci/revgrep v0.0.0-20210930125155-c22e5001d4f2/go.mod h1:LK+zW4MpyytAWQRz0M4xnzEk50lSvqDQKfx304apFkY= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -824,15 +825,12 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55/go.mod h1:DHRJroSL7NaRkpvocRx3OtRsleXVsYSxBI9SfHFlTQ0= github.com/line/lbm-sdk v0.46.1-0.20230106043757-1ece23d83a0b h1:1+GG69CVRO1tXeywJrY6jGeW4+SPXrmGRwB9ARmYP5w= github.com/line/lbm-sdk v0.46.1-0.20230106043757-1ece23d83a0b/go.mod h1:rSDmksVcmPZfREb7+fPjxsMYF3WN1PQgSU/ZLbN8szE= github.com/line/ostracon v1.0.7 h1:8vh/gsM6Sf6z2s38og8YufIhrWN2TwXpm4I3DqKEVyI= github.com/line/ostracon v1.0.7/go.mod h1:gmEKYdaMaDAl5xJ8sJJo0s6OvzBSZwM01nWRCGA5oDY= -github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486 h1:uvXQdcWaUyNsgkXBz375FpQ285WEJaLXhQ5HtoNK/GU= -github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486/go.mod h1:wmkyPabXjtVZ1dvRofmurjaceghywtCSYGqFuFS+TbI= -github.com/line/wasmvm v1.0.0-0.10.0 h1:lxKdyNrRug/Sk7h2pb0aBsbTMNTesQU+TM/edSS9cg0= -github.com/line/wasmvm v1.0.0-0.10.0/go.mod h1:86gNsXbobrNQccER5XbU5j6qN0P/C1JML0iSKIgLYho= +github.com/line/wasmvm v1.1.1-0.11.0 h1:vWyJh1AdUmKa7FDBpsJKrToxXVFrDswG/xD6ZfPMszk= +github.com/line/wasmvm v1.1.1-0.11.0/go.mod h1:Lq3FVvi/rb+OOlTxqtcqcao2GGESQ4hUpuXMcjdJbco= github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= @@ -899,6 +897,7 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= 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-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -1711,6 +1710,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc 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-20210819135213-f52c844e1c1c/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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/proto/buf.gen.doc.yml b/proto/buf.gen.doc.yml new file mode 100644 index 0000000000..43c1f10f2a --- /dev/null +++ b/proto/buf.gen.doc.yml @@ -0,0 +1,5 @@ +version: v1 +plugins: + - name: doc + out: ../docs/proto + opt: ../docs/proto/protodoc-markdown.tmpl,proto-docs.md \ No newline at end of file diff --git a/proto/buf.gen.gogo.yml b/proto/buf.gen.gogo.yml new file mode 100644 index 0000000000..855ea251ad --- /dev/null +++ b/proto/buf.gen.gogo.yml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - name: gocosmos + out: .. + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types + - name: grpc-gateway + out: .. + opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file diff --git a/proto/buf.lock b/proto/buf.lock new file mode 100644 index 0000000000..3d4ba2f161 --- /dev/null +++ b/proto/buf.lock @@ -0,0 +1,19 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + commit: 1935555c206d4afb9e94615dfd0fad31 + - remote: buf.build + owner: cosmos + repository: cosmos-sdk + commit: 8cb30a2c4de74dc9bd8d260b1e75e176 + - remote: buf.build + owner: cosmos + repository: gogo-proto + commit: 6652e3443c3b4504bb3bf82e73a7e409 + - remote: buf.build + owner: googleapis + repository: googleapis + commit: 8d7204855ec14631a499bd7393ce1970 diff --git a/proto/buf.yaml b/proto/buf.yaml index cf215e6829..9c12bd28b7 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -5,6 +5,10 @@ # the previous configuration. version: v1 name: buf.build/cosmwasm/wasmd +deps: + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/cosmos-sdk:8cb30a2c4de74dc9bd8d260b1e75e176 #v0.46.x + - buf.build/cosmos/gogo-proto breaking: use: - FILE diff --git a/proto/cosmwasm/wasm/v1/genesis.proto b/proto/cosmwasm/wasm/v1/genesis.proto index cd709d0700..c3c6deaccf 100644 --- a/proto/cosmwasm/wasm/v1/genesis.proto +++ b/proto/cosmwasm/wasm/v1/genesis.proto @@ -36,6 +36,8 @@ message GenesisState { MsgStoreCode store_code = 1; MsgInstantiateContract instantiate_contract = 2; MsgExecuteContract execute_contract = 3; + // MsgInstantiateContract2 intentionally not supported + // see https://github.com/CosmWasm/wasmd/issues/987 } } } diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index 94a4420d9f..71fa05dff1 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -24,6 +24,8 @@ message StoreCodeProposal { reserved 5, 6; // InstantiatePermission to apply on contract creation, optional AccessConfig instantiate_permission = 7; + // UnpinCode code on upload, optional + bool unpin_code = 8; } // InstantiateContractProposal gov proposal content type to instantiate a diff --git a/proto/cosmwasm/wasm/v1/query.proto b/proto/cosmwasm/wasm/v1/query.proto index 0382d9a599..687386866c 100644 --- a/proto/cosmwasm/wasm/v1/query.proto +++ b/proto/cosmwasm/wasm/v1/query.proto @@ -58,6 +58,11 @@ service Query { rpc PinnedCodes(QueryPinnedCodesRequest) returns (QueryPinnedCodesResponse) { option (google.api.http).get = "/cosmwasm/wasm/v1/codes/pinned"; } + + // Params gets the module params + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmwasm/wasm/v1/codes/params"; + } } // QueryContractInfoRequest is the request type for the Query/ContractInfo RPC @@ -222,3 +227,12 @@ message QueryPinnedCodesResponse { // 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 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/cosmwasm/wasm/v1/tx.proto b/proto/cosmwasm/wasm/v1/tx.proto index c97086325c..40274408c5 100644 --- a/proto/cosmwasm/wasm/v1/tx.proto +++ b/proto/cosmwasm/wasm/v1/tx.proto @@ -12,9 +12,14 @@ option (gogoproto.goproto_getters_all) = false; service Msg { // StoreCode to submit Wasm code to the system rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse); - // Instantiate creates a new smart contract instance for the given code id. + // InstantiateContract creates a new smart contract instance for the given + // code id. rpc InstantiateContract(MsgInstantiateContract) returns (MsgInstantiateContractResponse); + // InstantiateContract2 creates a new smart contract instance for the given + // code id with a predictable address + rpc InstantiateContract2(MsgInstantiateContract2) + returns (MsgInstantiateContract2Response); // Execute submits the given message data to a smart contract rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse); // Migrate runs a code upgrade/ downgrade for a smart contract @@ -41,6 +46,8 @@ message MsgStoreCode { message MsgStoreCodeResponse { // CodeID is the reference to the stored WASM code uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; + // Checksum is the sha256 hash of the stored code + bytes checksum = 2; } // MsgInstantiateContract create a new smart contract instance for the given @@ -62,11 +69,45 @@ message MsgInstantiateContract { (gogoproto.castrepeated) = "github.com/line/lbm-sdk/types.Coins" ]; } + +// MsgInstantiateContract2 create a new smart contract instance for the given +// code id with a predicable address. +message MsgInstantiateContract2 { + // Sender is the that actor that signed the messages + string sender = 1; + // Admin is an optional address that can execute migrations + string admin = 2; + // CodeID is the reference to the stored WASM code + uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; + // Label is optional metadata to be stored with a contract instance. + string label = 4; + // Msg json encoded message to be passed to the contract on instantiation + bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ]; + // Funds coins that are transferred to the contract on instantiation + repeated cosmos.base.v1beta1.Coin funds = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // Salt is an arbitrary value provided by the sender. Size can be 1 to 64. + bytes salt = 7; + // FixMsg include the msg value into the hash for the predictable address. + // Default is false + bool fix_msg = 8; +} + // MsgInstantiateContractResponse return instantiation result data message MsgInstantiateContractResponse { // Address is the bech32 address of the new contract instance. string address = 1; - // Data contains base64-encoded bytes to returned from the contract + // Data contains bytes to returned from the contract + bytes data = 2; +} + +// MsgInstantiateContract2Response return instantiation result data +message MsgInstantiateContract2Response { + // Address is the bech32 address of the new contract instance. + string address = 1; + // Data contains bytes to returned from the contract bytes data = 2; } @@ -87,7 +128,7 @@ message MsgExecuteContract { // MsgExecuteContractResponse returns execution result data. message MsgExecuteContractResponse { - // Data contains base64-encoded bytes to returned from the contract + // Data contains bytes to returned from the contract bytes data = 1; } diff --git a/proto/cosmwasm/wasm/v1/types.proto b/proto/cosmwasm/wasm/v1/types.proto index 6b4388d8f5..70c5f95433 100644 --- a/proto/cosmwasm/wasm/v1/types.proto +++ b/proto/cosmwasm/wasm/v1/types.proto @@ -19,12 +19,16 @@ enum AccessType { // AccessTypeNobody forbidden ACCESS_TYPE_NOBODY = 1 [ (gogoproto.enumvalue_customname) = "AccessTypeNobody" ]; - // AccessTypeOnlyAddress restricted to an address + // AccessTypeOnlyAddress restricted to a single address + // Deprecated: use AccessTypeAnyOfAddresses instead ACCESS_TYPE_ONLY_ADDRESS = 2 [ (gogoproto.enumvalue_customname) = "AccessTypeOnlyAddress" ]; // AccessTypeEverybody unrestricted ACCESS_TYPE_EVERYBODY = 3 [ (gogoproto.enumvalue_customname) = "AccessTypeEverybody" ]; + // AccessTypeAnyOfAddresses allow any of the addresses + ACCESS_TYPE_ANY_OF_ADDRESSES = 4 + [ (gogoproto.enumvalue_customname) = "AccessTypeAnyOfAddresses" ]; } // AccessTypeParam @@ -37,7 +41,11 @@ message AccessTypeParam { message AccessConfig { option (gogoproto.goproto_stringer) = true; AccessType permission = 1 [ (gogoproto.moretags) = "yaml:\"permission\"" ]; + + // Address + // Deprecated: replaced by addresses string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + repeated string addresses = 3 [ (gogoproto.moretags) = "yaml:\"addresses\"" ]; } // Params defines the set of wasm parameters. diff --git a/third_party/proto/buf.yaml b/third_party/proto/buf.yaml deleted file mode 100644 index d0638a2426..0000000000 --- a/third_party/proto/buf.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by "buf config migrate-v1beta1". Edit as necessary, and -# remove this comment when you're finished. -# -# This module represents the "third_party/proto" root found in -# the previous configuration. -version: v1 -build: - excludes: - - google/protobuf -breaking: - use: - - FILE - ignore: - - confio - - cosmos - - cosmos_proto - - gogoproto - - google - - ibc - - tendermint -lint: - use: - - DEFAULT - - COMMENTS - - FILE_LOWER_SNAKE_CASE - except: - - UNARY_RPC - - COMMENT_FIELD - - SERVICE_SUFFIX - - PACKAGE_VERSION_SUFFIX - - RPC_REQUEST_STANDARD_NAME - - PACKAGE_DIRECTORY_MATCH - ignore: - - confio - - cosmos - - cosmos_proto - - gogoproto - - google - - ibc - - tendermint diff --git a/third_party/proto/confio/proofs.proto b/third_party/proto/confio/proofs.proto deleted file mode 100644 index da43503ecb..0000000000 --- a/third_party/proto/confio/proofs.proto +++ /dev/null @@ -1,234 +0,0 @@ -syntax = "proto3"; - -package ics23; -option go_package = "github.com/confio/ics23/go"; - -enum HashOp { - // NO_HASH is the default if no data passed. Note this is an illegal argument some places. - NO_HASH = 0; - SHA256 = 1; - SHA512 = 2; - KECCAK = 3; - RIPEMD160 = 4; - BITCOIN = 5; // ripemd160(sha256(x)) -} - -/** -LengthOp defines how to process the key and value of the LeafOp -to include length information. After encoding the length with the given -algorithm, the length will be prepended to the key and value bytes. -(Each one with it's own encoded length) -*/ -enum LengthOp { - // NO_PREFIX don't include any length info - NO_PREFIX = 0; - // VAR_PROTO uses protobuf (and go-amino) varint encoding of the length - VAR_PROTO = 1; - // VAR_RLP uses rlp int encoding of the length - VAR_RLP = 2; - // FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer - FIXED32_BIG = 3; - // FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer - FIXED32_LITTLE = 4; - // FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer - FIXED64_BIG = 5; - // FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer - FIXED64_LITTLE = 6; - // REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) - REQUIRE_32_BYTES = 7; - // REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) - REQUIRE_64_BYTES = 8; -} - -/** -ExistenceProof takes a key and a value and a set of steps to perform on it. -The result of peforming all these steps will provide a "root hash", which can -be compared to the value in a header. - -Since it is computationally infeasible to produce a hash collission for any of the used -cryptographic hash functions, if someone can provide a series of operations to transform -a given key and value into a root hash that matches some trusted root, these key and values -must be in the referenced merkle tree. - -The only possible issue is maliablity in LeafOp, such as providing extra prefix data, -which should be controlled by a spec. Eg. with lengthOp as NONE, - prefix = FOO, key = BAR, value = CHOICE -and - prefix = F, key = OOBAR, value = CHOICE -would produce the same value. - -With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field -in the ProofSpec is valuable to prevent this mutability. And why all trees should -length-prefix the data before hashing it. -*/ -message ExistenceProof { - bytes key = 1; - bytes value = 2; - LeafOp leaf = 3; - repeated InnerOp path = 4; -} - -/* -NonExistenceProof takes a proof of two neighbors, one left of the desired key, -one right of the desired key. If both proofs are valid AND they are neighbors, -then there is no valid proof for the given key. -*/ -message NonExistenceProof { - bytes key = 1; // TODO: remove this as unnecessary??? we prove a range - ExistenceProof left = 2; - ExistenceProof right = 3; -} - -/* -CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages -*/ -message CommitmentProof { - oneof proof { - ExistenceProof exist = 1; - NonExistenceProof nonexist = 2; - BatchProof batch = 3; - CompressedBatchProof compressed = 4; - } -} - -/** -LeafOp represents the raw key-value data we wish to prove, and -must be flexible to represent the internal transformation from -the original key-value pairs into the basis hash, for many existing -merkle trees. - -key and value are passed in. So that the signature of this operation is: - leafOp(key, value) -> output - -To process this, first prehash the keys and values if needed (ANY means no hash in this case): - hkey = prehashKey(key) - hvalue = prehashValue(value) - -Then combine the bytes, and hash it - output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) -*/ -message LeafOp { - HashOp hash = 1; - HashOp prehash_key = 2; - HashOp prehash_value = 3; - LengthOp length = 4; - // prefix is a fixed bytes that may optionally be included at the beginning to differentiate - // a leaf node from an inner node. - bytes prefix = 5; -} - -/** -InnerOp represents a merkle-proof step that is not a leaf. -It represents concatenating two children and hashing them to provide the next result. - -The result of the previous step is passed in, so the signature of this op is: - innerOp(child) -> output - -The result of applying InnerOp should be: - output = op.hash(op.prefix || child || op.suffix) - - where the || operator is concatenation of binary data, -and child is the result of hashing all the tree below this step. - -Any special data, like prepending child with the length, or prepending the entire operation with -some value to differentiate from leaf nodes, should be included in prefix and suffix. -If either of prefix or suffix is empty, we just treat it as an empty string -*/ -message InnerOp { - HashOp hash = 1; - bytes prefix = 2; - bytes suffix = 3; -} - - -/** -ProofSpec defines what the expected parameters are for a given proof type. -This can be stored in the client and used to validate any incoming proofs. - - verify(ProofSpec, Proof) -> Proof | Error - -As demonstrated in tests, if we don't fix the algorithm used to calculate the -LeafHash for a given tree, there are many possible key-value pairs that can -generate a given hash (by interpretting the preimage differently). -We need this for proper security, requires client knows a priori what -tree format server uses. But not in code, rather a configuration object. -*/ -message ProofSpec { - // any field in the ExistenceProof must be the same as in this spec. - // except Prefix, which is just the first bytes of prefix (spec can be longer) - LeafOp leaf_spec = 1; - InnerSpec inner_spec = 2; - // max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) - int32 max_depth = 3; - // min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) - int32 min_depth = 4; -} - -/* -InnerSpec contains all store-specific structure info to determine if two proofs from a -given store are neighbors. - -This enables: - - isLeftMost(spec: InnerSpec, op: InnerOp) - isRightMost(spec: InnerSpec, op: InnerOp) - isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) -*/ -message InnerSpec { - // Child order is the ordering of the children node, must count from 0 - // iavl tree is [0, 1] (left then right) - // merk is [0, 2, 1] (left, right, here) - repeated int32 child_order = 1; - int32 child_size = 2; - int32 min_prefix_length = 3; - int32 max_prefix_length = 4; - // empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) - bytes empty_child = 5; - // hash is the algorithm that must be used for each InnerOp - HashOp hash = 6; -} - -/* -BatchProof is a group of multiple proof types than can be compressed -*/ -message BatchProof { - repeated BatchEntry entries = 1; -} - -// Use BatchEntry not CommitmentProof, to avoid recursion -message BatchEntry { - oneof proof { - ExistenceProof exist = 1; - NonExistenceProof nonexist = 2; - } -} - - -/****** all items here are compressed forms *******/ - -message CompressedBatchProof { - repeated CompressedBatchEntry entries = 1; - repeated InnerOp lookup_inners = 2; -} - -// Use BatchEntry not CommitmentProof, to avoid recursion -message CompressedBatchEntry { - oneof proof { - CompressedExistenceProof exist = 1; - CompressedNonExistenceProof nonexist = 2; - } -} - -message CompressedExistenceProof { - bytes key = 1; - bytes value = 2; - LeafOp leaf = 3; - // these are indexes into the lookup_inners table in CompressedBatchProof - repeated int32 path = 4; -} - -message CompressedNonExistenceProof { - bytes key = 1; // TODO: remove this as unnecessary??? we prove a range - CompressedExistenceProof left = 2; - CompressedExistenceProof right = 3; -} diff --git a/third_party/proto/cosmos/auth/v1beta1/auth.proto b/third_party/proto/cosmos/auth/v1beta1/auth.proto deleted file mode 100644 index 72e1d9ec28..0000000000 --- a/third_party/proto/cosmos/auth/v1beta1/auth.proto +++ /dev/null @@ -1,50 +0,0 @@ -syntax = "proto3"; -package cosmos.auth.v1beta1; - -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; - -// BaseAccount defines a base account type. It contains all the necessary fields -// for basic account functionality. Any custom account type should extend this -// type for additional functionality (e.g. vesting). -message BaseAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.equal) = false; - - option (cosmos_proto.implements_interface) = "AccountI"; - - string address = 1; - google.protobuf.Any pub_key = 2 - [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; - uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; - uint64 sequence = 4; -} - -// ModuleAccount defines an account for modules that holds coins on a pool. -message ModuleAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - option (cosmos_proto.implements_interface) = "ModuleAccountI"; - - BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; - string name = 2; - repeated string permissions = 3; -} - -// Params defines the parameters for the auth module. -message Params { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""]; - uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""]; - uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""]; - uint64 sig_verify_cost_ed25519 = 4 - [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; - uint64 sig_verify_cost_secp256k1 = 5 - [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; -} diff --git a/third_party/proto/cosmos/auth/v1beta1/genesis.proto b/third_party/proto/cosmos/auth/v1beta1/genesis.proto deleted file mode 100644 index c88b94ee4e..0000000000 --- a/third_party/proto/cosmos/auth/v1beta1/genesis.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package cosmos.auth.v1beta1; - -import "google/protobuf/any.proto"; -import "gogoproto/gogo.proto"; -import "cosmos/auth/v1beta1/auth.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; - -// GenesisState defines the auth module's genesis state. -message GenesisState { - // params defines all the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false]; - - // accounts are the accounts present at genesis. - repeated google.protobuf.Any accounts = 2; -} diff --git a/third_party/proto/cosmos/auth/v1beta1/query.proto b/third_party/proto/cosmos/auth/v1beta1/query.proto deleted file mode 100644 index 4d9759cada..0000000000 --- a/third_party/proto/cosmos/auth/v1beta1/query.proto +++ /dev/null @@ -1,74 +0,0 @@ -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"; -import "cosmos/auth/v1beta1/auth.proto"; -import "cosmos_proto/cosmos.proto"; - -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}"; - } - - // Params queries all parameters. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/auth/v1beta1/params"; - } -} - -// 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; - option (gogoproto.goproto_getters) = false; - - // address defines the address to query for. - string address = 1; -} - -// QueryAccountResponse is the response type for the Query/Account RPC method. -message QueryAccountResponse { - // account defines the account of the corresponding address. - google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; -} - -// 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 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/authz/v1beta1/authz.proto b/third_party/proto/cosmos/authz/v1beta1/authz.proto deleted file mode 100644 index 2c376905eb..0000000000 --- a/third_party/proto/cosmos/authz/v1beta1/authz.proto +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index 7a3cf7c8cf..0000000000 --- a/third_party/proto/cosmos/authz/v1beta1/event.proto +++ /dev/null @@ -1,25 +0,0 @@ -// 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 deleted file mode 100644 index ea89869445..0000000000 --- a/third_party/proto/cosmos/authz/v1beta1/genesis.proto +++ /dev/null @@ -1,24 +0,0 @@ -// 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 deleted file mode 100644 index 428210de01..0000000000 --- a/third_party/proto/cosmos/authz/v1beta1/query.proto +++ /dev/null @@ -1,35 +0,0 @@ -// 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 deleted file mode 100644 index 457f0d662a..0000000000 --- a/third_party/proto/cosmos/authz/v1beta1/tx.proto +++ /dev/null @@ -1,70 +0,0 @@ -// 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 deleted file mode 100644 index 4f58b15e49..0000000000 --- a/third_party/proto/cosmos/bank/v1beta1/authz.proto +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index df91008df6..0000000000 --- a/third_party/proto/cosmos/bank/v1beta1/bank.proto +++ /dev/null @@ -1,96 +0,0 @@ -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"; - -// Params defines the parameters for the bank module. -message Params { - option (gogoproto.goproto_stringer) = false; - repeated SendEnabled send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled,omitempty\""]; - bool default_send_enabled = 2 [(gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\""]; -} - -// SendEnabled maps coin denom to a send_enabled status (whether a denom is -// sendable). -message SendEnabled { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - string denom = 1; - bool enabled = 2; -} - -// Input models transaction input. -message Input { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string address = 1; - repeated cosmos.base.v1beta1.Coin coins = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// Output models transaction outputs. -message Output { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string address = 1; - repeated cosmos.base.v1beta1.Coin coins = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// 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 deprecated = true; - - 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"]; -} - -// DenomUnit represents a struct that describes a given -// denomination unit of the basic token. -message DenomUnit { - // denom represents the string name of the given denom unit (e.g uatom). - string denom = 1; - // exponent represents power of 10 exponent that one must - // raise the base_denom to in order to equal the given DenomUnit's denom - // 1 denom = 1^exponent base_denom - // (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with - // exponent = 6, thus: 1 atom = 10^6 uatom). - uint32 exponent = 2; - // aliases is a list of string aliases for the given denom - repeated string aliases = 3; -} - -// Metadata represents a struct that describes -// a basic token. -message Metadata { - string description = 1; - // denom_units represents the list of DenomUnit's for a given coin - repeated DenomUnit denom_units = 2; - // base represents the base denom (should be the DenomUnit with exponent = 0). - string base = 3; - // 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 deleted file mode 100644 index 8fd7329a0a..0000000000 --- a/third_party/proto/cosmos/bank/v1beta1/genesis.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; -package cosmos.bank.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/bank/v1beta1/bank.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; - -// GenesisState defines the bank module's genesis state. -message GenesisState { - // params defines all the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false]; - - // balances is an array containing the balances of all the accounts. - repeated Balance balances = 2 [(gogoproto.nullable) = false]; - - // 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]; - - // denom_metadata defines the metadata of the differents coins. - repeated Metadata denom_metadata = 4 [(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false]; -} - -// Balance defines an account address and balance pair used in the bank module's -// genesis state. -message Balance { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // address is the address of the balance holder. - string address = 1; - - // coins defines the different coins this balance holds. - repeated cosmos.base.v1beta1.Coin coins = 2 - [(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 deleted file mode 100644 index 520ba06964..0000000000 --- a/third_party/proto/cosmos/bank/v1beta1/query.proto +++ /dev/null @@ -1,163 +0,0 @@ -syntax = "proto3"; -package cosmos.bank.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/bank/v1beta1/bank.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; - -// Query defines the gRPC querier service. -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}/by_denom"; - } - - // AllBalances queries the balance of all coins for a single account. - rpc AllBalances(QueryAllBalancesRequest) returns (QueryAllBalancesResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}"; - } - - // TotalSupply queries the total supply of all coins. - rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/supply"; - } - - // SupplyOf queries the supply of a single coin. - rpc SupplyOf(QuerySupplyOfRequest) returns (QuerySupplyOfResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/supply/{denom}"; - } - - // Params queries the parameters of x/bank module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/params"; - } - - // DenomsMetadata queries the client metadata of a given coin denomination. - rpc DenomMetadata(QueryDenomMetadataRequest) returns (QueryDenomMetadataResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}"; - } - - // DenomsMetadata queries the client metadata for all registered coin denominations. - rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) { - option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata"; - } -} - -// QueryBalanceRequest is the request type for the Query/Balance RPC method. -message QueryBalanceRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // address is the address to query balances for. - string address = 1; - - // denom is the coin denom to query balances for. - string denom = 2; -} - -// QueryBalanceResponse is the response type for the Query/Balance RPC method. -message QueryBalanceResponse { - // balance is the balance of the coin. - cosmos.base.v1beta1.Coin balance = 1; -} - -// QueryBalanceRequest is the request type for the Query/AllBalances RPC method. -message QueryAllBalancesRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // address is the address to query balances for. - string address = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryAllBalancesResponse is the response type for the Query/AllBalances RPC -// method. -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"]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC -// method. -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"]; - - // 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. -message QuerySupplyOfRequest { - // denom is the coin denom to query balances for. - string denom = 1; -} - -// QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. -message QuerySupplyOfResponse { - // amount is the supply of the coin. - cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false]; -} - -// QueryParamsRequest defines the request type for querying x/bank parameters. -message QueryParamsRequest {} - -// QueryParamsResponse defines the response type for querying x/bank parameters. -message QueryParamsResponse { - Params params = 1 [(gogoproto.nullable) = false]; -} - -// QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. -message QueryDenomsMetadataRequest { - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC -// method. -message QueryDenomsMetadataResponse { - // metadata provides the client information for all the registered tokens. - repeated Metadata metadatas = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. -message QueryDenomMetadataRequest { - // denom is the coin denom to query the metadata for. - string denom = 1; -} - -// QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC -// method. -message QueryDenomMetadataResponse { - // metadata describes and provides all the client information for the requested token. - Metadata metadata = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/bank/v1beta1/tx.proto b/third_party/proto/cosmos/bank/v1beta1/tx.proto deleted file mode 100644 index 26b2ab41f4..0000000000 --- a/third_party/proto/cosmos/bank/v1beta1/tx.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; -package cosmos.bank.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/bank/v1beta1/bank.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; - -// Msg defines the bank Msg service. -service Msg { - // Send defines a method for sending coins from one account to another account. - rpc Send(MsgSend) returns (MsgSendResponse); - - // MultiSend defines a method for sending coins from some accounts to other accounts. - rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse); -} - -// MsgSend represents a message to send coins from one account to another. -message MsgSend { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; - string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// MsgSendResponse defines the Msg/Send response type. -message MsgSendResponse {} - -// MsgMultiSend represents an arbitrary multi-in, multi-out send message. -message MsgMultiSend { - option (gogoproto.equal) = false; - - repeated Input inputs = 1 [(gogoproto.nullable) = false]; - repeated Output outputs = 2 [(gogoproto.nullable) = false]; -} - -// MsgMultiSendResponse defines the Msg/MultiSend response type. -message MsgMultiSendResponse {} diff --git a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto deleted file mode 100644 index e24ae7bd5e..0000000000 --- a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto +++ /dev/null @@ -1,144 +0,0 @@ -syntax = "proto3"; -package cosmos.base.abci.v1beta1; - -import "gogoproto/gogo.proto"; -import "tendermint/abci/types.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/types"; -option (gogoproto.goproto_stringer_all) = false; - -// TxResponse defines a structure containing relevant tx data and metadata. The -// tags are stringified and the log is JSON decoded. -message TxResponse { - option (gogoproto.goproto_getters) = false; - // The block height - int64 height = 1; - // The transaction hash. - string txhash = 2 [(gogoproto.customname) = "TxHash"]; - // Namespace for the Code - string codespace = 3; - // Response code. - uint32 code = 4; - // Result bytes, if any. - string data = 5; - // The output of the application's logger (raw string). May be - // non-deterministic. - string raw_log = 6; - // The output of the application's logger (typed). May be non-deterministic. - repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false]; - // Additional information. May be non-deterministic. - string info = 8; - // Amount of gas requested for transaction. - int64 gas_wanted = 9; - // Amount of gas consumed by transaction. - int64 gas_used = 10; - // The request transaction bytes. - google.protobuf.Any tx = 11; - // Time of the previous block. For heights > 1, it's the weighted median of - // 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. -message ABCIMessageLog { - option (gogoproto.stringer) = true; - - uint32 msg_index = 1; - string log = 2; - - // Events contains a slice of Event objects that were emitted during some - // execution. - repeated StringEvent events = 3 [(gogoproto.castrepeated) = "StringEvents", (gogoproto.nullable) = false]; -} - -// StringEvent defines en Event object wrapper where all the attributes -// contain key/value pairs that are strings instead of raw bytes. -message StringEvent { - option (gogoproto.stringer) = true; - - string type = 1; - repeated Attribute attributes = 2 [(gogoproto.nullable) = false]; -} - -// Attribute defines an attribute wrapper where the key and value are -// strings instead of raw bytes. -message Attribute { - string key = 1; - string value = 2; -} - -// GasInfo defines tx execution gas context. -message GasInfo { - // GasWanted is the maximum units of work we allow this tx to perform. - uint64 gas_wanted = 1 [(gogoproto.moretags) = "yaml:\"gas_wanted\""]; - - // GasUsed is the amount of gas actually consumed. - uint64 gas_used = 2 [(gogoproto.moretags) = "yaml:\"gas_used\""]; -} - -// Result is the union of ResponseFormat and ResponseCheckTx. -message Result { - option (gogoproto.goproto_getters) = false; - - // Data is any data returned from message or handler execution. It MUST be - // length prefixed in order to separate data from multiple message executions. - bytes data = 1; - - // Log contains the log information from message or handler execution. - string log = 2; - - // Events contains a slice of Event objects that were emitted during message - // or handler execution. - repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false]; -} - -// SimulationResponse defines the response generated when a transaction is -// successfully simulated. -message SimulationResponse { - GasInfo gas_info = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - Result result = 2; -} - -// MsgData defines the data returned in a Result object during message -// execution. -message MsgData { - option (gogoproto.stringer) = true; - - string msg_type = 1; - bytes data = 2; -} - -// TxMsgData defines a list of MsgData. A transaction will have a MsgData object -// for each message. -message TxMsgData { - option (gogoproto.stringer) = true; - - repeated MsgData data = 1; -} - -// SearchTxsResult defines a structure for querying txs pageable -message SearchTxsResult { - option (gogoproto.stringer) = true; - - // Count of all txs - uint64 total_count = 1 [(gogoproto.moretags) = "yaml:\"total_count\"", (gogoproto.jsontag) = "total_count"]; - // Count of txs in current page - uint64 count = 2; - // Index of current page, start from 1 - uint64 page_number = 3 [(gogoproto.moretags) = "yaml:\"page_number\"", (gogoproto.jsontag) = "page_number"]; - // Count of total pages - uint64 page_total = 4 [(gogoproto.moretags) = "yaml:\"page_total\"", (gogoproto.jsontag) = "page_total"]; - // Max count txs per page - uint64 limit = 5; - // List of txs in current page - repeated TxResponse txs = 6; -} diff --git a/third_party/proto/cosmos/base/kv/v1beta1/kv.proto b/third_party/proto/cosmos/base/kv/v1beta1/kv.proto deleted file mode 100644 index 4e9b8d2850..0000000000 --- a/third_party/proto/cosmos/base/kv/v1beta1/kv.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package cosmos.base.kv.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/types/kv"; - -// Pairs defines a repeated slice of Pair objects. -message Pairs { - repeated Pair pairs = 1 [(gogoproto.nullable) = false]; -} - -// Pair defines a key/value bytes tuple. -message Pair { - bytes key = 1; - bytes value = 2; -} diff --git a/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto b/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto deleted file mode 100644 index 22670e72b8..0000000000 --- a/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; -package cosmos.base.reflection.v1beta1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/reflection"; - -// ReflectionService defines a service for interface reflection. -service ReflectionService { - // ListAllInterfaces lists all the interfaces registered in the interface - // registry. - rpc ListAllInterfaces(ListAllInterfacesRequest) returns (ListAllInterfacesResponse) { - option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces"; - }; - - // ListImplementations list all the concrete types that implement a given - // interface. - rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) { - option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/" - "{interface_name}/implementations"; - }; -} - -// ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. -message ListAllInterfacesRequest {} - -// ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. -message ListAllInterfacesResponse { - // interface_names is an array of all the registered interfaces. - repeated string interface_names = 1; -} - -// ListImplementationsRequest is the request type of the ListImplementations -// RPC. -message ListImplementationsRequest { - // interface_name defines the interface to query the implementations for. - string interface_name = 1; -} - -// ListImplementationsResponse is the response type of the ListImplementations -// RPC. -message ListImplementationsResponse { - repeated string implementation_message_names = 1; -} diff --git a/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto b/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto deleted file mode 100644 index d5b048558f..0000000000 --- a/third_party/proto/cosmos/base/reflection/v2alpha1/reflection.proto +++ /dev/null @@ -1,218 +0,0 @@ -// 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/snapshots/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto deleted file mode 100644 index 9ac5a7c31b..0000000000 --- a/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; -package cosmos.base.snapshots.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/snapshots/types"; - -// Snapshot contains Tendermint state sync snapshot info. -message Snapshot { - uint64 height = 1; - uint32 format = 2; - uint32 chunks = 3; - bytes hash = 4; - Metadata metadata = 5 [(gogoproto.nullable) = false]; -} - -// Metadata contains SDK-specific snapshot metadata. -message Metadata { - repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes -} \ No newline at end of file diff --git a/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto b/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto deleted file mode 100644 index 98a33d30e7..0000000000 --- a/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package cosmos.base.store.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/store/types"; - -// CommitInfo defines commit information used by the multi-store when committing -// a version/height. -message CommitInfo { - int64 version = 1; - repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; -} - -// StoreInfo defines store-specific commit information. It contains a reference -// between a store name and the commit ID. -message StoreInfo { - string name = 1; - CommitID commit_id = 2 [(gogoproto.nullable) = false]; -} - -// CommitID defines the committment information when a specific store is -// committed. -message CommitID { - option (gogoproto.goproto_stringer) = false; - - int64 version = 1; - bytes hash = 2; -} diff --git a/third_party/proto/cosmos/base/store/v1beta1/listening.proto b/third_party/proto/cosmos/base/store/v1beta1/listening.proto deleted file mode 100644 index 359997109c..0000000000 --- a/third_party/proto/cosmos/base/store/v1beta1/listening.proto +++ /dev/null @@ -1,16 +0,0 @@ -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/store/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto deleted file mode 100644 index 834855093b..0000000000 --- a/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; -package cosmos.base.store.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/store/types"; - -// SnapshotItem is an item contained in a rootmulti.Store snapshot. -message SnapshotItem { - // item is the specific type of snapshot item. - oneof item { - SnapshotStoreItem store = 1; - SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; - } -} - -// SnapshotStoreItem contains metadata about a snapshotted store. -message SnapshotStoreItem { - string name = 1; -} - -// SnapshotIAVLItem is an exported IAVL node. -message SnapshotIAVLItem { - bytes key = 1; - bytes value = 2; - int64 version = 3; - int32 height = 4; -} \ No newline at end of file diff --git a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto deleted file mode 100644 index 3c31877aa0..0000000000 --- a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto +++ /dev/null @@ -1,138 +0,0 @@ -syntax = "proto3"; -package cosmos.base.tendermint.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "google/api/annotations.proto"; -import "tendermint/p2p/types.proto"; -import "tendermint/types/block.proto"; -import "tendermint/types/types.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"; - -// Service defines the gRPC querier service for tendermint queries. -service Service { - // GetNodeInfo queries the current node info. - rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/node_info"; - } - // GetSyncing queries node syncing. - rpc GetSyncing(GetSyncingRequest) returns (GetSyncingResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/syncing"; - } - // GetLatestBlock returns the latest block. - rpc GetLatestBlock(GetLatestBlockRequest) returns (GetLatestBlockResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/latest"; - } - // GetBlockByHeight queries block for given height. - rpc GetBlockByHeight(GetBlockByHeightRequest) returns (GetBlockByHeightResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/{height}"; - } - - // GetLatestValidatorSet queries latest validator-set. - rpc GetLatestValidatorSet(GetLatestValidatorSetRequest) returns (GetLatestValidatorSetResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/latest"; - } - // GetValidatorSetByHeight queries validator-set at a given height. - rpc GetValidatorSetByHeight(GetValidatorSetByHeightRequest) returns (GetValidatorSetByHeightResponse) { - option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/{height}"; - } -} - -// GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. -message GetValidatorSetByHeightRequest { - int64 height = 1; - // pagination defines an pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. -message GetValidatorSetByHeightResponse { - int64 block_height = 1; - repeated Validator validators = 2; - // pagination defines an pagination for the response. - cosmos.base.query.v1beta1.PageResponse pagination = 3; -} - -// GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. -message GetLatestValidatorSetRequest { - // pagination defines an pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. -message GetLatestValidatorSetResponse { - int64 block_height = 1; - repeated Validator validators = 2; - // pagination defines an pagination for the response. - cosmos.base.query.v1beta1.PageResponse pagination = 3; -} - -// Validator is the type for the validator-set. -message Validator { - string address = 1; - google.protobuf.Any pub_key = 2; - int64 voting_power = 3; - int64 proposer_priority = 4; -} - -// GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. -message GetBlockByHeightRequest { - int64 height = 1; -} - -// GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. -message GetBlockByHeightResponse { - .tendermint.types.BlockID block_id = 1; - .tendermint.types.Block block = 2; -} - -// GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. -message GetLatestBlockRequest {} - -// GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. -message GetLatestBlockResponse { - .tendermint.types.BlockID block_id = 1; - .tendermint.types.Block block = 2; -} - -// GetSyncingRequest is the request type for the Query/GetSyncing RPC method. -message GetSyncingRequest {} - -// GetSyncingResponse is the response type for the Query/GetSyncing RPC method. -message GetSyncingResponse { - bool syncing = 1; -} - -// GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. -message GetNodeInfoRequest {} - -// GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. -message GetNodeInfoResponse { - .tendermint.p2p.DefaultNodeInfo default_node_info = 1; - VersionInfo application_version = 2; -} - -// 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; - // Since: cosmos-sdk 0.43 - string cosmos_sdk_version = 8; -} - -// Module is the type for VersionInfo -message Module { - // module path - string path = 1; - // module version - string version = 2; - // checksum - string sum = 3; -} diff --git a/third_party/proto/cosmos/capability/v1beta1/capability.proto b/third_party/proto/cosmos/capability/v1beta1/capability.proto deleted file mode 100644 index 1c8332f341..0000000000 --- a/third_party/proto/cosmos/capability/v1beta1/capability.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package cosmos.capability.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; - -import "gogoproto/gogo.proto"; - -// Capability defines an implementation of an object capability. The index -// provided to a Capability must be globally unique. -message Capability { - option (gogoproto.goproto_stringer) = false; - - uint64 index = 1 [(gogoproto.moretags) = "yaml:\"index\""]; -} - -// Owner defines a single capability owner. An owner is defined by the name of -// capability and the module name. -message Owner { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.goproto_getters) = false; - - string module = 1 [(gogoproto.moretags) = "yaml:\"module\""]; - string name = 2 [(gogoproto.moretags) = "yaml:\"name\""]; -} - -// CapabilityOwners defines a set of owners of a single Capability. The set of -// owners must be unique. -message CapabilityOwners { - repeated Owner owners = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/capability/v1beta1/genesis.proto b/third_party/proto/cosmos/capability/v1beta1/genesis.proto deleted file mode 100644 index 05bb0afc4a..0000000000 --- a/third_party/proto/cosmos/capability/v1beta1/genesis.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package cosmos.capability.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/capability/v1beta1/capability.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; - -// GenesisOwners defines the capability owners with their corresponding index. -message GenesisOwners { - // index is the index of the capability owner. - uint64 index = 1; - - // index_owners are the owners at the given index. - CapabilityOwners index_owners = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"index_owners\""]; -} - -// GenesisState defines the capability module's genesis state. -message GenesisState { - // index is the capability global index. - uint64 index = 1; - - // owners represents a map from index to owners of the capability index - // index key is string to allow amino marshalling. - repeated GenesisOwners owners = 2 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/crisis/v1beta1/genesis.proto b/third_party/proto/cosmos/crisis/v1beta1/genesis.proto deleted file mode 100644 index 5b0ff7ec72..0000000000 --- a/third_party/proto/cosmos/crisis/v1beta1/genesis.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package cosmos.crisis.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -// GenesisState defines the crisis module's genesis state. -message GenesisState { - // constant_fee is the fee used to verify the invariant in the crisis - // module. - cosmos.base.v1beta1.Coin constant_fee = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constant_fee\""]; -} diff --git a/third_party/proto/cosmos/crisis/v1beta1/tx.proto b/third_party/proto/cosmos/crisis/v1beta1/tx.proto deleted file mode 100644 index 26457ad6d5..0000000000 --- a/third_party/proto/cosmos/crisis/v1beta1/tx.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; -package cosmos.crisis.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; - -import "gogoproto/gogo.proto"; - -// Msg defines the bank Msg service. -service Msg { - // VerifyInvariant defines a method to verify a particular invariance. - rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse); -} - -// MsgVerifyInvariant represents a message to verify a particular invariance. -message MsgVerifyInvariant { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string sender = 1; - string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""]; - string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""]; -} - -// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. -message MsgVerifyInvariantResponse {} diff --git a/third_party/proto/cosmos/crypto/ed25519/keys.proto b/third_party/proto/cosmos/crypto/ed25519/keys.proto deleted file mode 100644 index 6ffec34483..0000000000 --- a/third_party/proto/cosmos/crypto/ed25519/keys.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; -package cosmos.crypto.ed25519; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"; - -// 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"]; -} - -// 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/multisig/keys.proto b/third_party/proto/cosmos/crypto/multisig/keys.proto deleted file mode 100644 index f8398e8052..0000000000 --- a/third_party/proto/cosmos/crypto/multisig/keys.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; -package cosmos.crypto.multisig; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"; - -// LegacyAminoPubKey specifies a public key type -// which nests multiple public keys and a threshold, -// it uses legacy amino address rules. -message LegacyAminoPubKey { - option (gogoproto.goproto_getters) = false; - - uint32 threshold = 1 [(gogoproto.moretags) = "yaml:\"threshold\""]; - repeated google.protobuf.Any public_keys = 2 - [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""]; -} diff --git a/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto b/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto deleted file mode 100644 index bf671f1711..0000000000 --- a/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; -package cosmos.crypto.multisig.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/crypto/types"; - -// MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. -// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers -// signed and with which modes. -message MultiSignature { - option (gogoproto.goproto_unrecognized) = true; - repeated bytes signatures = 1; -} - -// CompactBitArray is an implementation of a space efficient bit array. -// This is used to ensure that the encoded data takes up a minimal amount of -// space after proto encoding. -// This is not thread safe, and is not intended for concurrent usage. -message CompactBitArray { - option (gogoproto.goproto_stringer) = false; - - uint32 extra_bits_stored = 1; - bytes elems = 2; -} diff --git a/third_party/proto/cosmos/crypto/secp256k1/keys.proto b/third_party/proto/cosmos/crypto/secp256k1/keys.proto deleted file mode 100644 index a22725713a..0000000000 --- a/third_party/proto/cosmos/crypto/secp256k1/keys.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; -package cosmos.crypto.secp256k1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"; - -// PubKey defines a secp256k1 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. -message PubKey { - option (gogoproto.goproto_stringer) = false; - - bytes key = 1; -} - -// PrivKey defines a secp256k1 private key. -message PrivKey { - bytes key = 1; -} diff --git a/third_party/proto/cosmos/crypto/secp256r1/keys.proto b/third_party/proto/cosmos/crypto/secp256r1/keys.proto deleted file mode 100644 index 2e96c6e3c6..0000000000 --- a/third_party/proto/cosmos/crypto/secp256r1/keys.proto +++ /dev/null @@ -1,23 +0,0 @@ -// 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/distribution/v1beta1/distribution.proto b/third_party/proto/cosmos/distribution/v1beta1/distribution.proto deleted file mode 100644 index ae98ec0b98..0000000000 --- a/third_party/proto/cosmos/distribution/v1beta1/distribution.proto +++ /dev/null @@ -1,157 +0,0 @@ -syntax = "proto3"; -package cosmos.distribution.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -// Params defines the set of params for the distribution module. -message Params { - option (gogoproto.goproto_stringer) = false; - string community_tax = 1 [ - (gogoproto.moretags) = "yaml:\"community_tax\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string base_proposer_reward = 2 [ - (gogoproto.moretags) = "yaml:\"base_proposer_reward\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string bonus_proposer_reward = 3 [ - (gogoproto.moretags) = "yaml:\"bonus_proposer_reward\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - bool withdraw_addr_enabled = 4 [(gogoproto.moretags) = "yaml:\"withdraw_addr_enabled\""]; -} - -// ValidatorHistoricalRewards represents historical rewards for a validator. -// Height is implicit within the store key. -// Cumulative reward ratio is the sum from the zeroeth period -// until this period of rewards / tokens, per the spec. -// The reference count indicates the number of objects -// which might need to reference this historical entry at any point. -// ReferenceCount = -// number of outstanding delegations which ended the associated period (and -// might need to read that record) -// + number of slashes which ended the associated period (and might need to -// read that record) -// + one per validator for the zeroeth period, set on initialization -message ValidatorHistoricalRewards { - repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1 [ - (gogoproto.moretags) = "yaml:\"cumulative_reward_ratio\"", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false - ]; - uint32 reference_count = 2 [(gogoproto.moretags) = "yaml:\"reference_count\""]; -} - -// ValidatorCurrentRewards represents current rewards and current -// period for a validator kept as a running counter and incremented -// each block as long as the validator's tokens remain constant. -message ValidatorCurrentRewards { - repeated cosmos.base.v1beta1.DecCoin rewards = 1 - [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; - uint64 period = 2; -} - -// ValidatorAccumulatedCommission represents accumulated commission -// for a validator kept as a running counter, can be withdrawn at any time. -message ValidatorAccumulatedCommission { - repeated cosmos.base.v1beta1.DecCoin commission = 1 - [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; -} - -// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards -// for a validator inexpensive to track, allows simple sanity checks. -message ValidatorOutstandingRewards { - repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ - (gogoproto.moretags) = "yaml:\"rewards\"", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false - ]; -} - -// ValidatorSlashEvent represents a validator slash event. -// Height is implicit within the store key. -// This is needed to calculate appropriate amount of staking tokens -// for delegations which are withdrawn after a slash has occurred. -message ValidatorSlashEvent { - uint64 validator_period = 1 [(gogoproto.moretags) = "yaml:\"validator_period\""]; - string fraction = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} - -// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. -message ValidatorSlashEvents { - option (gogoproto.goproto_stringer) = false; - repeated ValidatorSlashEvent validator_slash_events = 1 - [(gogoproto.moretags) = "yaml:\"validator_slash_events\"", (gogoproto.nullable) = false]; -} - -// FeePool is the global fee pool for distribution. -message FeePool { - repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.moretags) = "yaml:\"community_pool\"" - ]; -} - -// CommunityPoolSpendProposal details a proposal for use of community funds, -// together with how many coins are proposed to be spent, and to which -// recipient account. -message CommunityPoolSpendProposal { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - string title = 1; - string description = 2; - string recipient = 3; - repeated cosmos.base.v1beta1.Coin amount = 4 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// DelegatorStartingInfo represents the starting info for a delegator reward -// period. It tracks the previous validator period, the delegation's amount of -// staking token, and the creation height (to check later on if any slashes have -// occurred). NOTE: Even though validators are slashed to whole staking tokens, -// the delegators within the validator may be left with less than a full token, -// thus sdk.Dec is used. -message DelegatorStartingInfo { - uint64 previous_period = 1 [(gogoproto.moretags) = "yaml:\"previous_period\""]; - string stake = 2 [ - (gogoproto.moretags) = "yaml:\"stake\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - uint64 height = 3 [(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"]; -} - -// DelegationDelegatorReward represents the properties -// of a delegator's delegation reward. -message DelegationDelegatorReward { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = true; - - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - repeated cosmos.base.v1beta1.DecCoin reward = 2 - [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; -} - -// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal -// with a deposit -message CommunityPoolSpendProposalWithDeposit { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = true; - - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - string recipient = 3 [(gogoproto.moretags) = "yaml:\"recipient\""]; - string amount = 4 [(gogoproto.moretags) = "yaml:\"amount\""]; - string deposit = 5 [(gogoproto.moretags) = "yaml:\"deposit\""]; -} diff --git a/third_party/proto/cosmos/distribution/v1beta1/genesis.proto b/third_party/proto/cosmos/distribution/v1beta1/genesis.proto deleted file mode 100644 index c0b17cdf11..0000000000 --- a/third_party/proto/cosmos/distribution/v1beta1/genesis.proto +++ /dev/null @@ -1,155 +0,0 @@ -syntax = "proto3"; -package cosmos.distribution.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/distribution/v1beta1/distribution.proto"; - -// DelegatorWithdrawInfo is the address for where distributions rewards are -// withdrawn to by default this struct is only used at genesis to feed in -// default withdraw addresses. -message DelegatorWithdrawInfo { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_address is the address of the delegator. - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - - // withdraw_address is the address to withdraw the delegation rewards to. - string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; -} - -// ValidatorOutstandingRewardsRecord is used for import/export via genesis json. -message ValidatorOutstandingRewardsRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator_address is the address of the validator. - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - // outstanding_rewards represents the oustanding rewards of a validator. - repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"outstanding_rewards\"" - ]; -} - -// ValidatorAccumulatedCommissionRecord is used for import / export via genesis -// json. -message ValidatorAccumulatedCommissionRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator_address is the address of the validator. - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - // accumulated is the accumulated commission of a validator. - ValidatorAccumulatedCommission accumulated = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"accumulated\""]; -} - -// ValidatorHistoricalRewardsRecord is used for import / export via genesis -// json. -message ValidatorHistoricalRewardsRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator_address is the address of the validator. - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - // period defines the period the historical rewards apply to. - uint64 period = 2; - - // rewards defines the historical rewards of a validator. - ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; -} - -// ValidatorCurrentRewardsRecord is used for import / export via genesis json. -message ValidatorCurrentRewardsRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator_address is the address of the validator. - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - // rewards defines the current rewards of a validator. - ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; -} - -// DelegatorStartingInfoRecord used for import / export via genesis json. -message DelegatorStartingInfoRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_address is the address of the delegator. - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - - // validator_address is the address of the validator. - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - - // starting_info defines the starting info of a delegator. - DelegatorStartingInfo starting_info = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"starting_info\""]; -} - -// ValidatorSlashEventRecord is used for import / export via genesis json. -message ValidatorSlashEventRecord { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validator_address is the address of the validator. - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - // height defines the block height at which the slash event occured. - uint64 height = 2; - // period is the period of the slash event. - uint64 period = 3; - // validator_slash_event describes the slash event. - ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"event\""]; -} - -// GenesisState defines the distribution module's genesis state. -message GenesisState { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // params defines all the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"params\""]; - - // fee_pool defines the fee pool at genesis. - FeePool fee_pool = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"fee_pool\""]; - - // fee_pool defines the delegator withdraw infos at genesis. - repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_withdraw_infos\""]; - - // fee_pool defines the previous proposer at genesis. - string previous_proposer = 4 [(gogoproto.moretags) = "yaml:\"previous_proposer\""]; - - // fee_pool defines the outstanding rewards of all validators at genesis. - repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"outstanding_rewards\""]; - - // fee_pool defines the accumulated commisions of all validators at genesis. - repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_accumulated_commissions\""]; - - // fee_pool defines the historical rewards of all validators at genesis. - repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_historical_rewards\""]; - - // fee_pool defines the current rewards of all validators at genesis. - repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_current_rewards\""]; - - // fee_pool defines the delegator starting infos at genesis. - repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_starting_infos\""]; - - // fee_pool defines the validator slash events at genesis. - repeated ValidatorSlashEventRecord validator_slash_events = 10 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_slash_events\""]; -} diff --git a/third_party/proto/cosmos/distribution/v1beta1/query.proto b/third_party/proto/cosmos/distribution/v1beta1/query.proto deleted file mode 100644 index 2991218d80..0000000000 --- a/third_party/proto/cosmos/distribution/v1beta1/query.proto +++ /dev/null @@ -1,218 +0,0 @@ -syntax = "proto3"; -package cosmos.distribution.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/distribution/v1beta1/distribution.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; - -// Query defines the gRPC querier service for distribution module. -service Query { - // Params queries params of the distribution module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/params"; - } - - // ValidatorOutstandingRewards queries rewards of a validator address. - rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) - returns (QueryValidatorOutstandingRewardsResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" - "{validator_address}/outstanding_rewards"; - } - - // ValidatorCommission queries accumulated commission for a validator. - rpc ValidatorCommission(QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" - "{validator_address}/commission"; - } - - // ValidatorSlashes queries slash events of a validator. - rpc ValidatorSlashes(QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes"; - } - - // DelegationRewards queries the total rewards accrued by a delegation. - rpc DelegationRewards(QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/" - "{validator_address}"; - } - - // DelegationTotalRewards queries the total rewards accrued by a each - // validator. - rpc DelegationTotalRewards(QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards"; - } - - // DelegatorValidators queries the validators of a delegator. - rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" - "{delegator_address}/validators"; - } - - // DelegatorWithdrawAddress queries withdraw address of a delegator. - rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" - "{delegator_address}/withdraw_address"; - } - - // CommunityPool queries the community pool coins. - rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) { - option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool"; - } -} - -// 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 [(gogoproto.nullable) = false]; -} - -// QueryValidatorOutstandingRewardsRequest is the request type for the -// Query/ValidatorOutstandingRewards RPC method. -message QueryValidatorOutstandingRewardsRequest { - // validator_address defines the validator address to query for. - string validator_address = 1; -} - -// QueryValidatorOutstandingRewardsResponse is the response type for the -// Query/ValidatorOutstandingRewards RPC method. -message QueryValidatorOutstandingRewardsResponse { - ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false]; -} - -// QueryValidatorCommissionRequest is the request type for the -// Query/ValidatorCommission RPC method -message QueryValidatorCommissionRequest { - // validator_address defines the validator address to query for. - string validator_address = 1; -} - -// QueryValidatorCommissionResponse is the response type for the -// Query/ValidatorCommission RPC method -message QueryValidatorCommissionResponse { - // commission defines the commision the validator received. - ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false]; -} - -// QueryValidatorSlashesRequest is the request type for the -// Query/ValidatorSlashes RPC method -message QueryValidatorSlashesRequest { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = true; - - // validator_address defines the validator address to query for. - string validator_address = 1; - // starting_height defines the optional starting height to query the slashes. - uint64 starting_height = 2; - // starting_height defines the optional ending height to query the slashes. - uint64 ending_height = 3; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 4; -} - -// QueryValidatorSlashesResponse is the response type for the -// Query/ValidatorSlashes RPC method. -message QueryValidatorSlashesResponse { - // slashes defines the slashes the validator received. - repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDelegationRewardsRequest is the request type for the -// Query/DelegationRewards RPC method. -message QueryDelegationRewardsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_address defines the delegator address to query for. - string delegator_address = 1; - // validator_address defines the validator address to query for. - string validator_address = 2; -} - -// QueryDelegationRewardsResponse is the response type for the -// Query/DelegationRewards RPC method. -message QueryDelegationRewardsResponse { - // rewards defines the rewards accrued by a delegation. - repeated cosmos.base.v1beta1.DecCoin rewards = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; -} - -// QueryDelegationTotalRewardsRequest is the request type for the -// Query/DelegationTotalRewards RPC method. -message QueryDelegationTotalRewardsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - // delegator_address defines the delegator address to query for. - string delegator_address = 1; -} - -// QueryDelegationTotalRewardsResponse is the response type for the -// Query/DelegationTotalRewards RPC method. -message QueryDelegationTotalRewardsResponse { - // rewards defines all the rewards accrued by a delegator. - repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; - // total defines the sum of all the rewards. - repeated cosmos.base.v1beta1.DecCoin total = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; -} - -// QueryDelegatorValidatorsRequest is the request type for the -// Query/DelegatorValidators RPC method. -message QueryDelegatorValidatorsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_address defines the delegator address to query for. - string delegator_address = 1; -} - -// QueryDelegatorValidatorsResponse is the response type for the -// Query/DelegatorValidators RPC method. -message QueryDelegatorValidatorsResponse { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // validators defines the validators a delegator is delegating for. - repeated string validators = 1; -} - -// QueryDelegatorWithdrawAddressRequest is the request type for the -// Query/DelegatorWithdrawAddress RPC method. -message QueryDelegatorWithdrawAddressRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_address defines the delegator address to query for. - string delegator_address = 1; -} - -// QueryDelegatorWithdrawAddressResponse is the response type for the -// Query/DelegatorWithdrawAddress RPC method. -message QueryDelegatorWithdrawAddressResponse { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // withdraw_address defines the delegator address to query for. - string withdraw_address = 1; -} - -// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC -// method. -message QueryCommunityPoolRequest {} - -// QueryCommunityPoolResponse is the response type for the Query/CommunityPool -// RPC method. -message QueryCommunityPoolResponse { - // pool defines community pool's coins. - repeated cosmos.base.v1beta1.DecCoin pool = 1 - [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/distribution/v1beta1/tx.proto b/third_party/proto/cosmos/distribution/v1beta1/tx.proto deleted file mode 100644 index e6ce478bcd..0000000000 --- a/third_party/proto/cosmos/distribution/v1beta1/tx.proto +++ /dev/null @@ -1,79 +0,0 @@ -syntax = "proto3"; -package cosmos.distribution.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -// Msg defines the distribution Msg service. -service Msg { - // SetWithdrawAddress defines a method to change the withdraw address - // for a delegator (or validator self-delegation). - rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); - - // WithdrawDelegatorReward defines a method to withdraw rewards of delegator - // from a single validator. - rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse); - - // WithdrawValidatorCommission defines a method to withdraw the - // full commission to the validator address. - rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); - - // FundCommunityPool defines a method to allow an account to directly - // fund the community pool. - rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse); -} - -// MsgSetWithdrawAddress sets the withdraw address for -// a delegator (or validator self-delegation). -message MsgSetWithdrawAddress { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; -} - -// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. -message MsgSetWithdrawAddressResponse {} - -// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator -// from a single validator. -message MsgWithdrawDelegatorReward { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; -} - -// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. -message MsgWithdrawDelegatorRewardResponse {} - -// MsgWithdrawValidatorCommission withdraws the full commission to the validator -// address. -message MsgWithdrawValidatorCommission { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; -} - -// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. -message MsgWithdrawValidatorCommissionResponse {} - -// MsgFundCommunityPool allows an account to directly -// fund the community pool. -message MsgFundCommunityPool { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - repeated cosmos.base.v1beta1.Coin amount = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - string depositor = 2; -} - -// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. -message MsgFundCommunityPoolResponse {} diff --git a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto deleted file mode 100644 index 14612c314f..0000000000 --- a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; -package cosmos.evidence.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; - -// Equivocation implements the Evidence interface and defines evidence of double -// signing misbehavior. -message Equivocation { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.equal) = false; - - int64 height = 1; - google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - int64 power = 3; - string consensus_address = 4 [(gogoproto.moretags) = "yaml:\"consensus_address\""]; -} \ No newline at end of file diff --git a/third_party/proto/cosmos/evidence/v1beta1/genesis.proto b/third_party/proto/cosmos/evidence/v1beta1/genesis.proto deleted file mode 100644 index 199f446f7e..0000000000 --- a/third_party/proto/cosmos/evidence/v1beta1/genesis.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; -package cosmos.evidence.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; - -import "google/protobuf/any.proto"; - -// GenesisState defines the evidence module's genesis state. -message GenesisState { - // evidence defines all the evidence at genesis. - repeated google.protobuf.Any evidence = 1; -} diff --git a/third_party/proto/cosmos/evidence/v1beta1/query.proto b/third_party/proto/cosmos/evidence/v1beta1/query.proto deleted file mode 100644 index eda00544c7..0000000000 --- a/third_party/proto/cosmos/evidence/v1beta1/query.proto +++ /dev/null @@ -1,51 +0,0 @@ -syntax = "proto3"; -package cosmos.evidence.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "google/api/annotations.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; - -// Query defines the gRPC querier service. -service Query { - // Evidence queries evidence based on evidence hash. - rpc Evidence(QueryEvidenceRequest) returns (QueryEvidenceResponse) { - option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence/{evidence_hash}"; - } - - // AllEvidence queries all evidence. - rpc AllEvidence(QueryAllEvidenceRequest) returns (QueryAllEvidenceResponse) { - option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence"; - } -} - -// QueryEvidenceRequest is the request type for the Query/Evidence RPC method. -message QueryEvidenceRequest { - // evidence_hash defines the hash of the requested evidence. - bytes evidence_hash = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; -} - -// QueryEvidenceResponse is the response type for the Query/Evidence RPC method. -message QueryEvidenceResponse { - // evidence returns the requested evidence. - google.protobuf.Any evidence = 1; -} - -// QueryEvidenceRequest is the request type for the Query/AllEvidence RPC -// method. -message QueryAllEvidenceRequest { - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC -// method. -message QueryAllEvidenceResponse { - // evidence returns all evidences. - repeated google.protobuf.Any evidence = 1; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} diff --git a/third_party/proto/cosmos/evidence/v1beta1/tx.proto b/third_party/proto/cosmos/evidence/v1beta1/tx.proto deleted file mode 100644 index 38795f25d4..0000000000 --- a/third_party/proto/cosmos/evidence/v1beta1/tx.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package cosmos.evidence.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "cosmos_proto/cosmos.proto"; - -// Msg defines the evidence Msg service. -service Msg { - // SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or - // counterfactual signing. - rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); -} - -// MsgSubmitEvidence represents a message that supports submitting arbitrary -// Evidence of misbehavior such as equivocation or counterfactual signing. -message MsgSubmitEvidence { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string submitter = 1; - google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "Evidence"]; -} - -// MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. -message MsgSubmitEvidenceResponse { - // hash defines the hash of the evidence. - bytes hash = 4; -} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto b/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto deleted file mode 100644 index a86691f912..0000000000 --- a/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto +++ /dev/null @@ -1,78 +0,0 @@ -// 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 deleted file mode 100644 index 5b1ac4ca55..0000000000 --- a/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 9cf2a4987d..0000000000 --- a/third_party/proto/cosmos/feegrant/v1beta1/query.proto +++ /dev/null @@ -1,55 +0,0 @@ -// 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 deleted file mode 100644 index 2d875e9224..0000000000 --- a/third_party/proto/cosmos/feegrant/v1beta1/tx.proto +++ /dev/null @@ -1,49 +0,0 @@ -// 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/genutil/v1beta1/genesis.proto b/third_party/proto/cosmos/genutil/v1beta1/genesis.proto deleted file mode 100644 index a0207793d9..0000000000 --- a/third_party/proto/cosmos/genutil/v1beta1/genesis.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package cosmos.genutil.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/genutil/types"; - -// GenesisState defines the raw genesis transaction in JSON. -message GenesisState { - // gen_txs defines the genesis transactions. - repeated bytes gen_txs = 1 [ - (gogoproto.casttype) = "encoding/json.RawMessage", - (gogoproto.jsontag) = "gentxs", - (gogoproto.moretags) = "yaml:\"gentxs\"" - ]; -} diff --git a/third_party/proto/cosmos/gov/v1beta1/genesis.proto b/third_party/proto/cosmos/gov/v1beta1/genesis.proto deleted file mode 100644 index a999500449..0000000000 --- a/third_party/proto/cosmos/gov/v1beta1/genesis.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package cosmos.gov.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/gov/v1beta1/gov.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; - -// GenesisState defines the gov module's genesis state. -message GenesisState { - // starting_proposal_id is the ID of the starting proposal. - uint64 starting_proposal_id = 1 [(gogoproto.moretags) = "yaml:\"starting_proposal_id\""]; - // deposits defines all the deposits present at genesis. - repeated Deposit deposits = 2 [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false]; - // votes defines all the votes present at genesis. - repeated Vote votes = 3 [(gogoproto.castrepeated) = "Votes", (gogoproto.nullable) = false]; - // proposals defines all the proposals present at genesis. - repeated Proposal proposals = 4 [(gogoproto.castrepeated) = "Proposals", (gogoproto.nullable) = false]; - // params defines all the paramaters of related to deposit. - DepositParams deposit_params = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_params\""]; - // params defines all the paramaters of related to voting. - VotingParams voting_params = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_params\""]; - // params defines all the paramaters of related to tally. - TallyParams tally_params = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"tally_params\""]; -} diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto deleted file mode 100644 index 344b5ada19..0000000000 --- a/third_party/proto/cosmos/gov/v1beta1/gov.proto +++ /dev/null @@ -1,200 +0,0 @@ -syntax = "proto3"; -package cosmos.gov.v1beta1; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = false; -option (gogoproto.goproto_getters_all) = false; - -// VoteOption enumerates the valid vote options for a given governance proposal. -enum VoteOption { - option (gogoproto.goproto_enum_prefix) = false; - - // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. - VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"]; - // VOTE_OPTION_YES defines a yes vote option. - VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"]; - // VOTE_OPTION_ABSTAIN defines an abstain vote option. - VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"]; - // VOTE_OPTION_NO defines a no vote option. - VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"]; - // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. - 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 { - option (cosmos_proto.implements_interface) = "Content"; - - option (gogoproto.equal) = true; - - string title = 1; - string description = 2; -} - -// Deposit defines an amount deposited by an account address to an active -// proposal. -message Deposit { - option (gogoproto.goproto_getters) = false; - option (gogoproto.equal) = false; - - uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; - string depositor = 2; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// Proposal defines the core field members of a governance proposal. -message Proposal { - option (gogoproto.equal) = true; - - uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""]; - google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"]; - ProposalStatus status = 3 [(gogoproto.moretags) = "yaml:\"proposal_status\""]; - TallyResult final_tally_result = 4 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""]; - google.protobuf.Timestamp submit_time = 5 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; - google.protobuf.Timestamp deposit_end_time = 6 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""]; - repeated cosmos.base.v1beta1.Coin total_deposit = 7 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"total_deposit\"" - ]; - google.protobuf.Timestamp voting_start_time = 8 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""]; - google.protobuf.Timestamp voting_end_time = 9 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; -} - -// ProposalStatus enumerates the valid statuses of a proposal. -enum ProposalStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. - PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"]; - // PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit - // period. - PROPOSAL_STATUS_DEPOSIT_PERIOD = 1 [(gogoproto.enumvalue_customname) = "StatusDepositPeriod"]; - // PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting - // period. - PROPOSAL_STATUS_VOTING_PERIOD = 2 [(gogoproto.enumvalue_customname) = "StatusVotingPeriod"]; - // PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has - // passed. - PROPOSAL_STATUS_PASSED = 3 [(gogoproto.enumvalue_customname) = "StatusPassed"]; - // PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has - // been rejected. - PROPOSAL_STATUS_REJECTED = 4 [(gogoproto.enumvalue_customname) = "StatusRejected"]; - // PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has - // failed. - PROPOSAL_STATUS_FAILED = 5 [(gogoproto.enumvalue_customname) = "StatusFailed"]; -} - -// TallyResult defines a standard tally for a governance proposal. -message TallyResult { - option (gogoproto.equal) = true; - - string yes = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string abstain = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string no = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string no_with_veto = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"no_with_veto\"" - ]; -} - -// Vote defines a vote on a governance proposal. -// A Vote consists of a proposal ID, the voter, and the vote option. -message Vote { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.equal) = false; - - 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. -message DepositParams { - // Minimum deposit for a proposal to enter voting period. - repeated cosmos.base.v1beta1.Coin min_deposit = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"min_deposit\"", - (gogoproto.jsontag) = "min_deposit,omitempty" - ]; - - // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 - // months. - google.protobuf.Duration max_deposit_period = 2 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.jsontag) = "max_deposit_period,omitempty", - (gogoproto.moretags) = "yaml:\"max_deposit_period\"" - ]; -} - -// VotingParams defines the params for voting on governance proposals. -message VotingParams { - // Length of the voting period. - google.protobuf.Duration voting_period = 1 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.jsontag) = "voting_period,omitempty", - (gogoproto.moretags) = "yaml:\"voting_period\"" - ]; -} - -// TallyParams defines the params for tallying votes on governance proposals. -message TallyParams { - // Minimum percentage of total stake needed to vote for a result to be - // considered valid. - bytes quorum = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "quorum,omitempty" - ]; - - // Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. - bytes threshold = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "threshold,omitempty" - ]; - - // Minimum value of Veto votes to Total votes ratio for proposal to be - // vetoed. Default value: 1/3. - bytes veto_threshold = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "veto_threshold,omitempty", - (gogoproto.moretags) = "yaml:\"veto_threshold\"" - ]; -} diff --git a/third_party/proto/cosmos/gov/v1beta1/query.proto b/third_party/proto/cosmos/gov/v1beta1/query.proto deleted file mode 100644 index da62bdbad1..0000000000 --- a/third_party/proto/cosmos/gov/v1beta1/query.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; -package cosmos.gov.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/gov/v1beta1/gov.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; - -// Query defines the gRPC querier service for gov module -service Query { - // Proposal queries proposal details based on ProposalID. - rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}"; - } - - // Proposals queries all proposals based on given status. - rpc Proposals(QueryProposalsRequest) returns (QueryProposalsResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals"; - } - - // Vote queries voted information based on proposalID, voterAddr. - rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}"; - } - - // Votes queries votes of a given proposal. - rpc Votes(QueryVotesRequest) returns (QueryVotesResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes"; - } - - // Params queries all parameters of the gov module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}"; - } - - // Deposit queries single deposit information based proposalID, depositAddr. - rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}"; - } - - // Deposits queries all deposits of a single proposal. - rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits"; - } - - // TallyResult queries the tally of a proposal vote. - rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) { - option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally"; - } -} - -// QueryProposalRequest is the request type for the Query/Proposal RPC method. -message QueryProposalRequest { - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; -} - -// QueryProposalResponse is the response type for the Query/Proposal RPC method. -message QueryProposalResponse { - Proposal proposal = 1 [(gogoproto.nullable) = false]; -} - -// QueryProposalsRequest is the request type for the Query/Proposals RPC method. -message QueryProposalsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // proposal_status defines the status of the proposals. - ProposalStatus proposal_status = 1; - - // voter defines the voter address for the proposals. - string voter = 2; - - // depositor defines the deposit addresses from the proposals. - string depositor = 3; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 4; -} - -// QueryProposalsResponse is the response type for the Query/Proposals RPC -// method. -message QueryProposalsResponse { - repeated Proposal proposals = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryVoteRequest is the request type for the Query/Vote RPC method. -message QueryVoteRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; - - // voter defines the oter address for the proposals. - string voter = 2; -} - -// QueryVoteResponse is the response type for the Query/Vote RPC method. -message QueryVoteResponse { - // vote defined the queried vote. - Vote vote = 1 [(gogoproto.nullable) = false]; -} - -// QueryVotesRequest is the request type for the Query/Votes RPC method. -message QueryVotesRequest { - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryVotesResponse is the response type for the Query/Votes RPC method. -message QueryVotesResponse { - // votes defined the queried votes. - repeated Vote votes = 1 [(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 { - // params_type defines which parameters to query for, can be one of "voting", - // "tallying" or "deposit". - string params_type = 1; -} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - // voting_params defines the parameters related to voting. - VotingParams voting_params = 1 [(gogoproto.nullable) = false]; - // deposit_params defines the parameters related to deposit. - DepositParams deposit_params = 2 [(gogoproto.nullable) = false]; - // tally_params defines the parameters related to tally. - TallyParams tally_params = 3 [(gogoproto.nullable) = false]; -} - -// QueryDepositRequest is the request type for the Query/Deposit RPC method. -message QueryDepositRequest { - option (gogoproto.goproto_getters) = false; - option (gogoproto.equal) = false; - - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; - - // depositor defines the deposit addresses from the proposals. - string depositor = 2; -} - -// QueryDepositResponse is the response type for the Query/Deposit RPC method. -message QueryDepositResponse { - // deposit defines the requested deposit. - Deposit deposit = 1 [(gogoproto.nullable) = false]; -} - -// QueryDepositsRequest is the request type for the Query/Deposits RPC method. -message QueryDepositsRequest { - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryDepositsResponse is the response type for the Query/Deposits RPC method. -message QueryDepositsResponse { - repeated Deposit deposits = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryTallyResultRequest is the request type for the Query/Tally RPC method. -message QueryTallyResultRequest { - // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; -} - -// QueryTallyResultResponse is the response type for the Query/Tally RPC method. -message QueryTallyResultResponse { - // tally defines the requested tally. - TallyResult tally = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto deleted file mode 100644 index 36c0a95d27..0000000000 --- a/third_party/proto/cosmos/gov/v1beta1/tx.proto +++ /dev/null @@ -1,99 +0,0 @@ -syntax = "proto3"; -package cosmos.gov.v1beta1; - -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/gov/v1beta1/gov.proto"; -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; - -// Msg defines the bank Msg service. -service Msg { - // SubmitProposal defines a method to create new proposal given a content. - rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse); - - // 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); -} - -// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary -// proposal Content. -message MsgSubmitProposal { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"]; - repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"initial_deposit\"" - ]; - string proposer = 3; -} - -// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. -message MsgSubmitProposalResponse { - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; -} - -// MsgVote defines a message to cast a vote. -message MsgVote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; - string voter = 2; - VoteOption option = 3; -} - -// 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; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; - string depositor = 2; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// MsgDepositResponse defines the Msg/Deposit response type. -message MsgDepositResponse {} diff --git a/third_party/proto/cosmos/mint/v1beta1/genesis.proto b/third_party/proto/cosmos/mint/v1beta1/genesis.proto deleted file mode 100644 index 4e783fb544..0000000000 --- a/third_party/proto/cosmos/mint/v1beta1/genesis.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package cosmos.mint.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/mint/v1beta1/mint.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; - -// GenesisState defines the mint module's genesis state. -message GenesisState { - // minter is a space for holding current inflation information. - Minter minter = 1 [(gogoproto.nullable) = false]; - - // params defines all the paramaters of the module. - Params params = 2 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/mint/v1beta1/mint.proto b/third_party/proto/cosmos/mint/v1beta1/mint.proto deleted file mode 100644 index f94d4ae2e8..0000000000 --- a/third_party/proto/cosmos/mint/v1beta1/mint.proto +++ /dev/null @@ -1,53 +0,0 @@ -syntax = "proto3"; -package cosmos.mint.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; - -import "gogoproto/gogo.proto"; - -// Minter represents the minting state. -message Minter { - // current annual inflation rate - string inflation = 1 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - // current annual expected provisions - string annual_provisions = 2 [ - (gogoproto.moretags) = "yaml:\"annual_provisions\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -// Params holds parameters for the mint module. -message Params { - option (gogoproto.goproto_stringer) = false; - - // type of coin to mint - string mint_denom = 1; - // maximum annual change in inflation rate - string inflation_rate_change = 2 [ - (gogoproto.moretags) = "yaml:\"inflation_rate_change\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // maximum inflation rate - string inflation_max = 3 [ - (gogoproto.moretags) = "yaml:\"inflation_max\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // minimum inflation rate - string inflation_min = 4 [ - (gogoproto.moretags) = "yaml:\"inflation_min\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // goal of percent bonded atoms - string goal_bonded = 5 [ - (gogoproto.moretags) = "yaml:\"goal_bonded\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // expected blocks per year - uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; -} diff --git a/third_party/proto/cosmos/mint/v1beta1/query.proto b/third_party/proto/cosmos/mint/v1beta1/query.proto deleted file mode 100644 index acd341d777..0000000000 --- a/third_party/proto/cosmos/mint/v1beta1/query.proto +++ /dev/null @@ -1,57 +0,0 @@ -syntax = "proto3"; -package cosmos.mint.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/mint/v1beta1/mint.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; - -// Query provides defines the gRPC querier service. -service Query { - // Params returns the total set of minting parameters. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/params"; - } - - // Inflation returns the current minting inflation value. - rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; - } - - // AnnualProvisions current minting annual provisions value. - rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; - } -} - -// 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 [(gogoproto.nullable) = false]; -} - -// QueryInflationRequest is the request type for the Query/Inflation RPC method. -message QueryInflationRequest {} - -// QueryInflationResponse is the response type for the Query/Inflation RPC -// method. -message QueryInflationResponse { - // inflation is the current minting inflation value. - bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} - -// QueryAnnualProvisionsRequest is the request type for the -// Query/AnnualProvisions RPC method. -message QueryAnnualProvisionsRequest {} - -// QueryAnnualProvisionsResponse is the response type for the -// Query/AnnualProvisions RPC method. -message QueryAnnualProvisionsResponse { - // annual_provisions is the current minting annual provisions value. - bytes annual_provisions = 1 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/params/v1beta1/params.proto b/third_party/proto/cosmos/params/v1beta1/params.proto deleted file mode 100644 index 5382fd7999..0000000000 --- a/third_party/proto/cosmos/params/v1beta1/params.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; -package cosmos.params.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; - -// ParameterChangeProposal defines a proposal to change one or more parameters. -message ParameterChangeProposal { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - string title = 1; - string description = 2; - repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; -} - -// ParamChange defines an individual parameter change, for use in -// ParameterChangeProposal. -message ParamChange { - option (gogoproto.goproto_stringer) = false; - - string subspace = 1; - string key = 2; - string value = 3; -} diff --git a/third_party/proto/cosmos/params/v1beta1/query.proto b/third_party/proto/cosmos/params/v1beta1/query.proto deleted file mode 100644 index 1078e02ae3..0000000000 --- a/third_party/proto/cosmos/params/v1beta1/query.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package cosmos.params.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/params/v1beta1/params.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; - -// Query defines the gRPC querier service. -service Query { - // Params queries a specific parameter of a module, given its subspace and - // key. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/params/v1beta1/params"; - } -} - -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest { - // subspace defines the module to query the parameter for. - string subspace = 1; - - // key defines the key of the parameter in the subspace. - string key = 2; -} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // param defines the queried parameter. - ParamChange param = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto deleted file mode 100644 index a7aebcfbad..0000000000 --- a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto +++ /dev/null @@ -1,50 +0,0 @@ -syntax = "proto3"; -package cosmos.slashing.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; - -import "gogoproto/gogo.proto"; -import "cosmos/slashing/v1beta1/slashing.proto"; - -// GenesisState defines the slashing module's genesis state. -message GenesisState { - // params defines all the paramaters of related to deposit. - Params params = 1 [(gogoproto.nullable) = false]; - - // signing_infos represents a map between validator addresses and their - // signing infos. - repeated SigningInfo signing_infos = 2 - [(gogoproto.moretags) = "yaml:\"signing_infos\"", (gogoproto.nullable) = false]; - - // 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]; -} - -// SigningInfo stores validator signing info of corresponding address. -message SigningInfo { - // address is the validator address. - string address = 1; - // validator_signing_info represents the signing info of this validator. - ValidatorSigningInfo validator_signing_info = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_signing_info\""]; -} - -// ValidatorMissedBlocks contains array of missed blocks of corresponding -// address. -message ValidatorMissedBlocks { - // address is the validator address. - string address = 1; - // missed_blocks is an array of missed blocks by the validator. - repeated MissedBlock missed_blocks = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"missed_blocks\""]; -} - -// MissedBlock contains height and missed status as boolean. -message MissedBlock { - // index is the height at which the block was missed. - int64 index = 1; - // missed is the missed status. - bool missed = 2; -} diff --git a/third_party/proto/cosmos/slashing/v1beta1/query.proto b/third_party/proto/cosmos/slashing/v1beta1/query.proto deleted file mode 100644 index 869049a0ed..0000000000 --- a/third_party/proto/cosmos/slashing/v1beta1/query.proto +++ /dev/null @@ -1,63 +0,0 @@ -syntax = "proto3"; -package cosmos.slashing.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/slashing/v1beta1/slashing.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; - -// Query provides defines the gRPC querier service -service Query { - // Params queries the parameters of slashing module - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/slashing/v1beta1/params"; - } - - // SigningInfo queries the signing info of given cons address - rpc SigningInfo(QuerySigningInfoRequest) returns (QuerySigningInfoResponse) { - option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos/{cons_address}"; - } - - // SigningInfos queries signing info of all validators - rpc SigningInfos(QuerySigningInfosRequest) returns (QuerySigningInfosResponse) { - option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos"; - } -} - -// 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 params = 1 [(gogoproto.nullable) = false]; -} - -// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC -// method -message QuerySigningInfoRequest { - // cons_address is the address to query signing info of - string cons_address = 1; -} - -// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC -// method -message QuerySigningInfoResponse { - // val_signing_info is the signing info of requested val cons address - ValidatorSigningInfo val_signing_info = 1 [(gogoproto.nullable) = false]; -} - -// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC -// method -message QuerySigningInfosRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC -// method -message QuerySigningInfosResponse { - // info is the signing info of all validators - repeated cosmos.slashing.v1beta1.ValidatorSigningInfo info = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} diff --git a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto deleted file mode 100644 index 882a0fb60c..0000000000 --- a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; -package cosmos.slashing.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -// ValidatorSigningInfo defines a validator's signing info for monitoring their -// liveness activity. -message ValidatorSigningInfo { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - string address = 1; - // Height at which validator was first a candidate OR was unjailed - int64 start_height = 2 [(gogoproto.moretags) = "yaml:\"start_height\""]; - // 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 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). It is set - // once the validator commits an equivocation or for any other configured misbehiavor. - bool tombstoned = 5; - // 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\""]; -} - -// Params represents the parameters used for by the slashing module. -message Params { - int64 signed_blocks_window = 1 [(gogoproto.moretags) = "yaml:\"signed_blocks_window\""]; - bytes min_signed_per_window = 2 [ - (gogoproto.moretags) = "yaml:\"min_signed_per_window\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - google.protobuf.Duration downtime_jail_duration = 3 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.moretags) = "yaml:\"downtime_jail_duration\"" - ]; - bytes slash_fraction_double_sign = 4 [ - (gogoproto.moretags) = "yaml:\"slash_fraction_double_sign\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - bytes slash_fraction_downtime = 5 [ - (gogoproto.moretags) = "yaml:\"slash_fraction_downtime\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} diff --git a/third_party/proto/cosmos/slashing/v1beta1/tx.proto b/third_party/proto/cosmos/slashing/v1beta1/tx.proto deleted file mode 100644 index 4d63370ecc..0000000000 --- a/third_party/proto/cosmos/slashing/v1beta1/tx.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package cosmos.slashing.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; - -// Msg defines the slashing Msg service. -service Msg { - // Unjail defines a method for unjailing a jailed validator, thus returning - // them into the bonded validator set, so they can begin receiving provisions - // and rewards again. - rpc Unjail(MsgUnjail) returns (MsgUnjailResponse); -} - -// MsgUnjail defines the Msg/Unjail request type -message MsgUnjail { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = true; - - string validator_addr = 1 [(gogoproto.moretags) = "yaml:\"address\"", (gogoproto.jsontag) = "address"]; -} - -// MsgUnjailResponse defines the Msg/Unjail response type -message MsgUnjailResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/staking/v1beta1/authz.proto b/third_party/proto/cosmos/staking/v1beta1/authz.proto deleted file mode 100644 index d50c329c91..0000000000 --- a/third_party/proto/cosmos/staking/v1beta1/authz.proto +++ /dev/null @@ -1,47 +0,0 @@ -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/genesis.proto b/third_party/proto/cosmos/staking/v1beta1/genesis.proto deleted file mode 100644 index d1563dbc54..0000000000 --- a/third_party/proto/cosmos/staking/v1beta1/genesis.proto +++ /dev/null @@ -1,53 +0,0 @@ -syntax = "proto3"; -package cosmos.staking.v1beta1; - -option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; - -import "gogoproto/gogo.proto"; -import "cosmos/staking/v1beta1/staking.proto"; - -// GenesisState defines the staking module's genesis state. -message GenesisState { - // params defines all the paramaters of related to deposit. - Params params = 1 [(gogoproto.nullable) = false]; - - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - bytes last_total_power = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"last_total_power\"", - (gogoproto.nullable) = false - ]; - - // last_validator_powers is a special index that provides a historical list - // of the last-block's bonded validators. - repeated LastValidatorPower last_validator_powers = 3 - [(gogoproto.moretags) = "yaml:\"last_validator_powers\"", (gogoproto.nullable) = false]; - - // delegations defines the validator set at genesis. - repeated Validator validators = 4 [(gogoproto.nullable) = false]; - - // delegations defines the delegations active at genesis. - repeated Delegation delegations = 5 [(gogoproto.nullable) = false]; - - // unbonding_delegations defines the unbonding delegations active at genesis. - repeated UnbondingDelegation unbonding_delegations = 6 - [(gogoproto.moretags) = "yaml:\"unbonding_delegations\"", (gogoproto.nullable) = false]; - - // redelegations defines the redelegations active at genesis. - repeated Redelegation redelegations = 7 [(gogoproto.nullable) = false]; - - bool exported = 8; -} - -// LastValidatorPower required for validator set update logic. -message LastValidatorPower { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // address is the address of the validator. - string address = 1; - - // power defines the power of the validator. - int64 power = 2; -} diff --git a/third_party/proto/cosmos/staking/v1beta1/query.proto b/third_party/proto/cosmos/staking/v1beta1/query.proto deleted file mode 100644 index 4852c53535..0000000000 --- a/third_party/proto/cosmos/staking/v1beta1/query.proto +++ /dev/null @@ -1,348 +0,0 @@ -syntax = "proto3"; -package cosmos.staking.v1beta1; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/staking/v1beta1/staking.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; - -// Query defines the gRPC querier service. -service Query { - // Validators queries all validators that match the given status. - rpc Validators(QueryValidatorsRequest) returns (QueryValidatorsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators"; - } - - // Validator queries validator info for given validator address. - rpc Validator(QueryValidatorRequest) returns (QueryValidatorResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}"; - } - - // ValidatorDelegations queries delegate info for given validator. - rpc ValidatorDelegations(QueryValidatorDelegationsRequest) returns (QueryValidatorDelegationsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations"; - } - - // ValidatorUnbondingDelegations queries unbonding delegations of a validator. - rpc ValidatorUnbondingDelegations(QueryValidatorUnbondingDelegationsRequest) - returns (QueryValidatorUnbondingDelegationsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators/" - "{validator_addr}/unbonding_delegations"; - } - - // Delegation queries delegate info for given validator delegator pair. - rpc Delegation(QueryDelegationRequest) returns (QueryDelegationResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" - "{delegator_addr}"; - } - - // UnbondingDelegation queries unbonding info for given validator delegator - // pair. - rpc UnbondingDelegation(QueryUnbondingDelegationRequest) returns (QueryUnbondingDelegationResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" - "{delegator_addr}/unbonding_delegation"; - } - - // DelegatorDelegations queries all delegations of a given delegator address. - rpc DelegatorDelegations(QueryDelegatorDelegationsRequest) returns (QueryDelegatorDelegationsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/delegations/{delegator_addr}"; - } - - // DelegatorUnbondingDelegations queries all unbonding delegations of a given - // delegator address. - rpc DelegatorUnbondingDelegations(QueryDelegatorUnbondingDelegationsRequest) - returns (QueryDelegatorUnbondingDelegationsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/" - "{delegator_addr}/unbonding_delegations"; - } - - // Redelegations queries redelegations of given address. - rpc Redelegations(QueryRedelegationsRequest) returns (QueryRedelegationsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations"; - } - - // DelegatorValidators queries all validators info for given delegator - // address. - rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators"; - } - - // DelegatorValidator queries validator info for given delegator validator - // pair. - rpc DelegatorValidator(QueryDelegatorValidatorRequest) returns (QueryDelegatorValidatorResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators/" - "{validator_addr}"; - } - - // HistoricalInfo queries the historical info for given height. - rpc HistoricalInfo(QueryHistoricalInfoRequest) returns (QueryHistoricalInfoResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/historical_info/{height}"; - } - - // Pool queries the pool info. - rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/pool"; - } - - // Parameters queries the staking parameters. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/staking/v1beta1/params"; - } -} - -// QueryValidatorsRequest is request type for Query/Validators RPC method. -message QueryValidatorsRequest { - // status enables to query for validators matching a given status. - string status = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryValidatorsResponse is response type for the Query/Validators RPC method -message QueryValidatorsResponse { - // validators contains all the queried validators. - repeated Validator validators = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryValidatorRequest is response type for the Query/Validator RPC method -message QueryValidatorRequest { - // validator_addr defines the validator address to query for. - string validator_addr = 1; -} - -// QueryValidatorResponse is response type for the Query/Validator RPC method -message QueryValidatorResponse { - // validator defines the the validator info. - Validator validator = 1 [(gogoproto.nullable) = false]; -} - -// QueryValidatorDelegationsRequest is request type for the -// Query/ValidatorDelegations RPC method -message QueryValidatorDelegationsRequest { - // validator_addr defines the validator address to query for. - string validator_addr = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryValidatorDelegationsResponse is response type for the -// Query/ValidatorDelegations RPC method -message QueryValidatorDelegationsResponse { - repeated DelegationResponse delegation_responses = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "DelegationResponses"]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryValidatorUnbondingDelegationsRequest is required type for the -// Query/ValidatorUnbondingDelegations RPC method -message QueryValidatorUnbondingDelegationsRequest { - // validator_addr defines the validator address to query for. - string validator_addr = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryValidatorUnbondingDelegationsResponse is response type for the -// Query/ValidatorUnbondingDelegations RPC method. -message QueryValidatorUnbondingDelegationsResponse { - repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDelegationRequest is request type for the Query/Delegation RPC method. -message QueryDelegationRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // validator_addr defines the validator address to query for. - string validator_addr = 2; -} - -// QueryDelegationResponse is response type for the Query/Delegation RPC method. -message QueryDelegationResponse { - // delegation_responses defines the delegation info of a delegation. - DelegationResponse delegation_response = 1; -} - -// QueryUnbondingDelegationRequest is request type for the -// Query/UnbondingDelegation RPC method. -message QueryUnbondingDelegationRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // validator_addr defines the validator address to query for. - string validator_addr = 2; -} - -// QueryDelegationResponse is response type for the Query/UnbondingDelegation -// RPC method. -message QueryUnbondingDelegationResponse { - // unbond defines the unbonding information of a delegation. - UnbondingDelegation unbond = 1 [(gogoproto.nullable) = false]; -} - -// QueryDelegatorDelegationsRequest is request type for the -// Query/DelegatorDelegations RPC method. -message QueryDelegatorDelegationsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryDelegatorDelegationsResponse is response type for the -// Query/DelegatorDelegations RPC method. -message QueryDelegatorDelegationsResponse { - // delegation_responses defines all the delegations' info of a delegator. - repeated DelegationResponse delegation_responses = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDelegatorUnbondingDelegationsRequest is request type for the -// Query/DelegatorUnbondingDelegations RPC method. -message QueryDelegatorUnbondingDelegationsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryUnbondingDelegatorDelegationsResponse is response type for the -// Query/UnbondingDelegatorDelegations RPC method. -message QueryDelegatorUnbondingDelegationsResponse { - repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryRedelegationsRequest is request type for the Query/Redelegations RPC -// method. -message QueryRedelegationsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // src_validator_addr defines the validator address to redelegate from. - string src_validator_addr = 2; - - // dst_validator_addr defines the validator address to redelegate to. - string dst_validator_addr = 3; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 4; -} - -// QueryRedelegationsResponse is response type for the Query/Redelegations RPC -// method. -message QueryRedelegationsResponse { - repeated RedelegationResponse redelegation_responses = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDelegatorValidatorsRequest is request type for the -// Query/DelegatorValidators RPC method. -message QueryDelegatorValidatorsRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryDelegatorValidatorsResponse is response type for the -// Query/DelegatorValidators RPC method. -message QueryDelegatorValidatorsResponse { - // validators defines the the validators' info of a delegator. - repeated Validator validators = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryDelegatorValidatorRequest is request type for the -// Query/DelegatorValidator RPC method. -message QueryDelegatorValidatorRequest { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // delegator_addr defines the delegator address to query for. - string delegator_addr = 1; - - // validator_addr defines the validator address to query for. - string validator_addr = 2; -} - -// QueryDelegatorValidatorResponse response type for the -// Query/DelegatorValidator RPC method. -message QueryDelegatorValidatorResponse { - // validator defines the the validator info. - Validator validator = 1 [(gogoproto.nullable) = false]; -} - -// QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC -// method. -message QueryHistoricalInfoRequest { - // height defines at which height to query the historical info. - int64 height = 1; -} - -// QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC -// method. -message QueryHistoricalInfoResponse { - // hist defines the historical info at the given height. - HistoricalInfo hist = 1; -} - -// QueryPoolRequest is request type for the Query/Pool RPC method. -message QueryPoolRequest {} - -// QueryPoolResponse is response type for the Query/Pool RPC method. -message QueryPoolResponse { - // pool defines the pool info. - Pool pool = 1 [(gogoproto.nullable) = false]; -} - -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // params holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/cosmos/staking/v1beta1/staking.proto b/third_party/proto/cosmos/staking/v1beta1/staking.proto deleted file mode 100644 index 76e9599e2d..0000000000 --- a/third_party/proto/cosmos/staking/v1beta1/staking.proto +++ /dev/null @@ -1,334 +0,0 @@ -syntax = "proto3"; -package cosmos.staking.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "tendermint/types/types.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; - -// HistoricalInfo contains header and validator information for a given block. -// It is stored as part of staking module's state, which persists the `n` most -// recent HistoricalInfo -// (`n` is set by the staking module's `historical_entries` parameter). -message HistoricalInfo { - tendermint.types.Header header = 1 [(gogoproto.nullable) = false]; - repeated Validator valset = 2 [(gogoproto.nullable) = false]; -} - -// CommissionRates defines the initial commission rates to be used for creating -// a validator. -message CommissionRates { - option (gogoproto.equal) = true; - 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]; - // max_rate defines the maximum commission rate which validator can ever charge, as a fraction. - string max_rate = 2 [ - (gogoproto.moretags) = "yaml:\"max_rate\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // max_change_rate defines the maximum daily increase of the validator commission, as a fraction. - string max_change_rate = 3 [ - (gogoproto.moretags) = "yaml:\"max_change_rate\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -// Commission defines commission parameters for a given validator. -message Commission { - option (gogoproto.equal) = true; - 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]; - // update_time is the last time the commission rate was changed. - google.protobuf.Timestamp update_time = 2 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\""]; -} - -// Description defines a validator description. -message Description { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - // moniker defines a human-readable name for the validator. - string moniker = 1; - // identity defines an optional identity signature (ex. UPort or Keybase). - string identity = 2; - // website defines an optional website link. - 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; -} - -// Validator defines a validator, together with the total amount of the -// Validator's bond shares and their exchange rate to coins. Slashing results in -// a decrease in the exchange rate, allowing correct calculation of future -// undelegations without iterating over delegators. When coins are delegated to -// this validator, the validator is credited with a delegation whose number of -// bond shares is based on the amount of coins delegated divided by the current -// exchange rate. Voting power can be calculated as total bonded shares -// multiplied by exchange rate. -message Validator { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - 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\""]; - // 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; - // status is the validator status (bonded/unbonding/unbonded). - BondStatus status = 4; - // tokens define the delegated tokens (incl. self-delegation). - string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // delegator_shares defines total shares issued to a validator's delegators. - string delegator_shares = 6 [ - (gogoproto.moretags) = "yaml:\"delegator_shares\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // description defines the description terms for the validator. - 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\""]; - // unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. - 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]; - // min_self_delegation is the validator's self declared minimum self delegation. - string min_self_delegation = 11 [ - (gogoproto.moretags) = "yaml:\"min_self_delegation\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -// BondStatus is the status of a validator. -enum BondStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // UNSPECIFIED defines an invalid validator status. - BOND_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "Unspecified"]; - // UNBONDED defines a validator that is not bonded. - BOND_STATUS_UNBONDED = 1 [(gogoproto.enumvalue_customname) = "Unbonded"]; - // UNBONDING defines a validator that is unbonding. - BOND_STATUS_UNBONDING = 2 [(gogoproto.enumvalue_customname) = "Unbonding"]; - // BONDED defines a validator that is bonded. - BOND_STATUS_BONDED = 3 [(gogoproto.enumvalue_customname) = "Bonded"]; -} - -// ValAddresses defines a repeated set of validator addresses. -message ValAddresses { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = true; - - repeated string addresses = 1; -} - -// DVPair is struct that just has a delegator-validator pair with no other data. -// It is intended to be used as a marshalable pointer. For example, a DVPair can -// be used to construct the key to getting an UnbondingDelegation from state. -message DVPair { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; -} - -// DVPairs defines an array of DVPair objects. -message DVPairs { - repeated DVPair pairs = 1 [(gogoproto.nullable) = false]; -} - -// DVVTriplet is struct that just has a delegator-validator-validator triplet -// with no other data. It is intended to be used as a marshalable pointer. For -// example, a DVVTriplet can be used to construct the key to getting a -// Redelegation from state. -message DVVTriplet { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; - string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; -} - -// DVVTriplets defines an array of DVVTriplet objects. -message DVVTriplets { - repeated DVVTriplet triplets = 1 [(gogoproto.nullable) = false]; -} - -// Delegation represents the bond with tokens held by an account. It is -// owned by one delegator, and is associated with the voting power of one -// validator. -message Delegation { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - // delegator_address is the bech32-encoded address of the delegator. - 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\""]; - // shares define the delegation shares received. - string shares = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} - -// UnbondingDelegation stores all of a single delegator's unbonding bonds -// for a single validator in an time-ordered list. -message UnbondingDelegation { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - // delegator_address is the bech32-encoded address of the delegator. - 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\""]; - // entries are the unbonding delegation entries. - repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries -} - -// UnbondingDelegationEntry defines an unbonding object with relevant metadata. -message UnbondingDelegationEntry { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - // creation_height is the height which the unbonding took place. - 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\""]; - // initial_balance defines the tokens initially scheduled to receive at completion. - string initial_balance = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"initial_balance\"" - ]; - // balance defines the tokens to receive at completion. - string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; -} - -// RedelegationEntry defines a redelegation object with relevant metadata. -message RedelegationEntry { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - // creation_height defines the height which the redelegation took place. - 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\""]; - // initial_balance defines the initial balance when redelegation started. - string initial_balance = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"initial_balance\"" - ]; - // shares_dst is the amount of destination-validator shares created by redelegation. - string shares_dst = 4 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} - -// Redelegation contains the list of a particular delegator's redelegating bonds -// from a particular source validator to a particular destination validator. -message Redelegation { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - // delegator_address is the bech32-encoded address of the delegator. - 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\""]; - // validator_dst_address is the validator redelegation destination operator 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 -} - -// Params defines the parameters for the staking module. -message Params { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - // unbonding_time is the time duration of unbonding. - 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\""]; - // max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). - 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\""]; -} - -// DelegationResponse is equivalent to Delegation except that it contains a -// balance in addition to shares which is more suitable for client responses. -message DelegationResponse { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - - Delegation delegation = 1 [(gogoproto.nullable) = false]; - - cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; -} - -// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -message RedelegationEntryResponse { - option (gogoproto.equal) = true; - - RedelegationEntry redelegation_entry = 1 [(gogoproto.nullable) = false]; - string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; -} - -// RedelegationResponse is equivalent to a Redelegation except that its entries -// contain a balance in addition to shares which is more suitable for client -// responses. -message RedelegationResponse { - option (gogoproto.equal) = false; - - Redelegation redelegation = 1 [(gogoproto.nullable) = false]; - repeated RedelegationEntryResponse entries = 2 [(gogoproto.nullable) = false]; -} - -// Pool is used for tracking bonded and not-bonded token supply of the bond -// denomination. -message Pool { - option (gogoproto.description) = true; - option (gogoproto.equal) = true; - string not_bonded_tokens = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.jsontag) = "not_bonded_tokens", - (gogoproto.nullable) = false - ]; - string bonded_tokens = 2 [ - (gogoproto.jsontag) = "bonded_tokens", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"bonded_tokens\"" - ]; -} diff --git a/third_party/proto/cosmos/staking/v1beta1/tx.proto b/third_party/proto/cosmos/staking/v1beta1/tx.proto deleted file mode 100644 index 7b05d89eea..0000000000 --- a/third_party/proto/cosmos/staking/v1beta1/tx.proto +++ /dev/null @@ -1,126 +0,0 @@ -syntax = "proto3"; -package cosmos.staking.v1beta1; - -import "google/protobuf/any.proto"; -import "google/protobuf/timestamp.proto"; -import "gogoproto/gogo.proto"; - -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/staking/v1beta1/staking.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; - -// Msg defines the staking Msg service. -service Msg { - // CreateValidator defines a method for creating a new validator. - rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse); - - // EditValidator defines a method for editing an existing validator. - rpc EditValidator(MsgEditValidator) returns (MsgEditValidatorResponse); - - // Delegate defines a method for performing a delegation of coins - // from a delegator to a validator. - rpc Delegate(MsgDelegate) returns (MsgDelegateResponse); - - // BeginRedelegate defines a method for performing a redelegation - // of coins from a delegator and source validator to a destination validator. - rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse); - - // Undelegate defines a method for performing an undelegation from a - // delegate and a validator. - rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse); -} - -// MsgCreateValidator defines a SDK message for creating a new validator. -message MsgCreateValidator { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Description description = 1 [(gogoproto.nullable) = false]; - CommissionRates commission = 2 [(gogoproto.nullable) = false]; - string min_self_delegation = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"min_self_delegation\"", - (gogoproto.nullable) = false - ]; - string delegator_address = 4 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 5 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"]; - cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false]; -} - -// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. -message MsgCreateValidatorResponse {} - -// MsgEditValidator defines a SDK message for editing an existing validator. -message MsgEditValidator { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - Description description = 1 [(gogoproto.nullable) = false]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"address\""]; - - // We pass a reference to the new commission rate and min self delegation as - // it's not mandatory to update. If not updated, the deserialized rate will be - // zero with no way to distinguish if an update was intended. - // REF: #2373 - string commission_rate = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"commission_rate\"" - ]; - string min_self_delegation = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"min_self_delegation\"" - ]; -} - -// MsgEditValidatorResponse defines the Msg/EditValidator response type. -message MsgEditValidatorResponse {} - -// MsgDelegate defines a SDK message for performing a delegation of coins -// from a delegator to a validator. -message MsgDelegate { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; -} - -// MsgDelegateResponse defines the Msg/Delegate response type. -message MsgDelegateResponse {} - -// MsgBeginRedelegate defines a SDK message for performing a redelegation -// of coins from a delegator and source validator to a destination validator. -message MsgBeginRedelegate { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; - string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; - cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; -} - -// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. -message MsgBeginRedelegateResponse { - google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} - -// MsgUndelegate defines a SDK message for performing an undelegation from a -// delegate and a validator. -message MsgUndelegate { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; -} - -// MsgUndelegateResponse defines the Msg/Undelegate response type. -message MsgUndelegateResponse { - google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} diff --git a/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto b/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto deleted file mode 100644 index 4c1be40594..0000000000 --- a/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto +++ /dev/null @@ -1,79 +0,0 @@ -syntax = "proto3"; -package cosmos.tx.signing.v1beta1; - -import "cosmos/crypto/multisig/v1beta1/multisig.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/types/tx/signing"; - -// SignMode represents a signing mode with its own security guarantees. -enum SignMode { - // SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be - // rejected - SIGN_MODE_UNSPECIFIED = 0; - - // SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is - // verified with raw bytes from Tx - SIGN_MODE_DIRECT = 1; - - // SIGN_MODE_TEXTUAL is a future signing mode that will verify some - // human-readable textual representation on top of the binary representation - // from SIGN_MODE_DIRECT - SIGN_MODE_TEXTUAL = 2; - - // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses - // Amino JSON and will be removed in the future - SIGN_MODE_LEGACY_AMINO_JSON = 127; -} - -// SignatureDescriptors wraps multiple SignatureDescriptor's. -message SignatureDescriptors { - // signatures are the signature descriptors - repeated SignatureDescriptor signatures = 1; -} - -// SignatureDescriptor is a convenience type which represents the full data for -// a signature including the public key of the signer, signing modes and the -// signature itself. It is primarily used for coordinating signatures between -// clients. -message SignatureDescriptor { - // public_key is the public key of the signer - google.protobuf.Any public_key = 1; - - Data data = 2; - - // sequence is the sequence of the account, which describes the - // number of committed transactions signed by a given address. It is used to prevent - // replay attacks. - uint64 sequence = 3; - - // Data represents signature data - message Data { - // sum is the oneof that specifies whether this represents single or multi-signature data - oneof sum { - // single represents a single signer - Single single = 1; - - // multi represents a multisig signer - Multi multi = 2; - } - - // Single is the signature data for a single signer - message Single { - // mode is the signing mode of the single signer - SignMode mode = 1; - - // signature is the raw signature bytes - bytes signature = 2; - } - - // Multi is the signature data for a multisig public key - message Multi { - // bitarray specifies which keys within the multisig are signing - cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; - - // signatures is the signatures of the multi-signature - repeated Data signatures = 2; - } - } -} diff --git a/third_party/proto/cosmos/tx/v1beta1/service.proto b/third_party/proto/cosmos/tx/v1beta1/service.proto deleted file mode 100644 index acfbf15b36..0000000000 --- a/third_party/proto/cosmos/tx/v1beta1/service.proto +++ /dev/null @@ -1,134 +0,0 @@ -syntax = "proto3"; -package cosmos.tx.v1beta1; - -import "google/api/annotations.proto"; -import "cosmos/base/abci/v1beta1/abci.proto"; -import "cosmos/tx/v1beta1/tx.proto"; -import "gogoproto/gogo.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; - -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 { - // Simulate simulates executing a transaction for estimating gas usage. - rpc Simulate(SimulateRequest) returns (SimulateResponse) { - option (google.api.http) = { - post: "/cosmos/tx/v1beta1/simulate" - body: "*" - }; - } - // GetTx fetches a tx by hash. - rpc GetTx(GetTxRequest) returns (GetTxResponse) { - option (google.api.http).get = "/cosmos/tx/v1beta1/txs/{hash}"; - } - // BroadcastTx broadcast transaction. - rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) { - option (google.api.http) = { - post: "/cosmos/tx/v1beta1/txs" - body: "*" - }; - } - // GetTxsEvent fetches txs by event. - rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { - option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; - } -} - -// GetTxsEventRequest is the request type for the Service.TxsByEvents -// RPC method. -message GetTxsEventRequest { - // events is the list of transaction event type. - 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 -// RPC method. -message GetTxsEventResponse { - // txs is the list of queried transactions. - repeated cosmos.tx.v1beta1.Tx txs = 1; - // tx_responses is the list of queried TxResponses. - repeated cosmos.base.abci.v1beta1.TxResponse tx_responses = 2; - // pagination defines an pagination for the response. - cosmos.base.query.v1beta1.PageResponse pagination = 3; -} - -// BroadcastTxRequest is the request type for the Service.BroadcastTxRequest -// RPC method. -message BroadcastTxRequest { - // tx_bytes is the raw transaction. - bytes tx_bytes = 1; - BroadcastMode mode = 2; -} - -// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. -enum BroadcastMode { - // zero-value for mode ordering - BROADCAST_MODE_UNSPECIFIED = 0; - // BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for - // the tx to be committed in a block. - BROADCAST_MODE_BLOCK = 1; - // BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for - // a CheckTx execution response only. - BROADCAST_MODE_SYNC = 2; - // BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns - // immediately. - BROADCAST_MODE_ASYNC = 3; -} - -// BroadcastTxResponse is the response type for the -// Service.BroadcastTx method. -message BroadcastTxResponse { - // tx_response is the queried TxResponses. - cosmos.base.abci.v1beta1.TxResponse tx_response = 1; -} - -// SimulateRequest is the request type for the Service.Simulate -// RPC method. -message SimulateRequest { - // tx is the transaction to simulate. - // 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 -// Service.SimulateRPC method. -message SimulateResponse { - // gas_info is the information about gas used in the simulation. - cosmos.base.abci.v1beta1.GasInfo gas_info = 1; - // result is the result of the simulation. - cosmos.base.abci.v1beta1.Result result = 2; -} - -// GetTxRequest is the request type for the Service.GetTx -// RPC method. -message GetTxRequest { - // hash is the tx hash to query, encoded as a hex string. - string hash = 1; -} - -// GetTxResponse is the response type for the Service.GetTx method. -message GetTxResponse { - // tx is the queried transaction. - cosmos.tx.v1beta1.Tx tx = 1; - // tx_response is the queried TxResponses. - cosmos.base.abci.v1beta1.TxResponse tx_response = 2; -} \ No newline at end of file diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto deleted file mode 100644 index 6d5caf12c7..0000000000 --- a/third_party/proto/cosmos/tx/v1beta1/tx.proto +++ /dev/null @@ -1,183 +0,0 @@ -syntax = "proto3"; -package cosmos.tx.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/crypto/multisig/v1beta1/multisig.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/tx/signing/v1beta1/signing.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; - -// Tx is the standard type used for broadcasting transactions. -message Tx { - // body is the processable content of the transaction - TxBody body = 1; - - // auth_info is the authorization related content of the transaction, - // specifically signers, signer modes and fee - AuthInfo auth_info = 2; - - // signatures is a list of signatures that matches the length and order of - // AuthInfo's signer_infos to allow connecting signature meta information like - // public key and signing mode by position. - repeated bytes signatures = 3; -} - -// TxRaw is a variant of Tx that pins the signer's exact binary representation -// of body and auth_info. This is used for signing, broadcasting and -// verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and -// the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used -// as the transaction ID. -message TxRaw { - // body_bytes is a protobuf serialization of a TxBody that matches the - // representation in SignDoc. - bytes body_bytes = 1; - - // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the - // representation in SignDoc. - bytes auth_info_bytes = 2; - - // signatures is a list of signatures that matches the length and order of - // AuthInfo's signer_infos to allow connecting signature meta information like - // public key and signing mode by position. - repeated bytes signatures = 3; -} - -// SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. -message SignDoc { - // body_bytes is protobuf serialization of a TxBody that matches the - // representation in TxRaw. - bytes body_bytes = 1; - - // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the - // representation in TxRaw. - bytes auth_info_bytes = 2; - - // chain_id is the unique identifier of the chain this transaction targets. - // It prevents signed transactions from being used on another chain by an - // attacker - string chain_id = 3; - - // account_number is the account number of the account in state - uint64 account_number = 4; -} - -// TxBody is the body of a transaction that all signers sign over. -message TxBody { - // messages is a list of messages to be executed. The required signers of - // those messages define the number and order of elements in AuthInfo's - // signer_infos and Tx's signatures. Each required signer address is added to - // the list only the first time it occurs. - // By convention, the first required signer (usually from the first message) - // is referred to as the primary signer and pays the fee for the whole - // transaction. - repeated google.protobuf.Any messages = 1; - - // 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 - // be processed by the chain - uint64 timeout_height = 3; - - // extension_options are arbitrary options that can be added by chains - // when the default options are not sufficient. If any of these are present - // and can't be handled, the transaction will be rejected - repeated google.protobuf.Any extension_options = 1023; - - // extension_options are arbitrary options that can be added by chains - // when the default options are not sufficient. If any of these are present - // and can't be handled, they will be ignored - repeated google.protobuf.Any non_critical_extension_options = 2047; -} - -// AuthInfo describes the fee and signer modes that are used to sign a -// transaction. -message AuthInfo { - // signer_infos defines the signing modes for the required signers. The number - // and order of elements must match the required signers from TxBody's - // messages. The first element is the primary signer and the one which pays - // the fee. - repeated SignerInfo signer_infos = 1; - - // Fee is the fee and gas limit for the transaction. The first signer is the - // primary signer and the one which pays the fee. The fee can be calculated - // based on the cost of evaluating the body and doing signature verification - // of the signers. This can be estimated via simulation. - Fee fee = 2; -} - -// SignerInfo describes the public key and signing mode of a single top-level -// signer. -message SignerInfo { - // public_key is the public key of the signer. It is optional for accounts - // that already exist in state. If unset, the verifier can use the required \ - // signer address for this position and lookup the public key. - google.protobuf.Any public_key = 1; - - // mode_info describes the signing mode of the signer and is a nested - // structure to support nested multisig pubkey's - ModeInfo mode_info = 2; - - // sequence is the sequence of the account, which describes the - // number of committed transactions signed by a given address. It is used to - // prevent replay attacks. - uint64 sequence = 3; -} - -// ModeInfo describes the signing mode of a single or nested multisig signer. -message ModeInfo { - // sum is the oneof that specifies whether this represents a single or nested - // multisig signer - oneof sum { - // single represents a single signer - Single single = 1; - - // multi represents a nested multisig signer - Multi multi = 2; - } - - // Single is the mode info for a single signer. It is structured as a message - // to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the - // future - message Single { - // mode is the signing mode of the single signer - cosmos.tx.signing.v1beta1.SignMode mode = 1; - } - - // Multi is the mode info for a multisig public key - message Multi { - // bitarray specifies which keys within the multisig are signing - cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; - - // mode_infos is the corresponding modes of the signers of the multisig - // which could include nested multisig public keys - repeated ModeInfo mode_infos = 2; - } -} - -// Fee includes the amount of coins paid in fees and the maximum -// gas to be used by the transaction. The ratio yields an effective "gasprice", -// which must be above some miminum to be accepted into the mempool. -message Fee { - // amount is the amount of coins to be paid as a fee - repeated cosmos.base.v1beta1.Coin amount = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - - // gas_limit is the maximum gas that can be used in transaction processing - // before an out of gas error occurs - uint64 gas_limit = 2; - - // if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. - // the payer must be a tx signer (and thus have signed this field in AuthInfo). - // setting this field does *not* change the ordering of required signers for the transaction. - string payer = 3; - - // if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used - // to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does - // not support fee grants, this will fail - string granter = 4; -} diff --git a/third_party/proto/cosmos/upgrade/v1beta1/query.proto b/third_party/proto/cosmos/upgrade/v1beta1/query.proto deleted file mode 100644 index dd14ba6401..0000000000 --- a/third_party/proto/cosmos/upgrade/v1beta1/query.proto +++ /dev/null @@ -1,104 +0,0 @@ -syntax = "proto3"; -package cosmos.upgrade.v1beta1; - -import "google/protobuf/any.proto"; -import "google/api/annotations.proto"; -import "cosmos/upgrade/v1beta1/upgrade.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; - -// Query defines the gRPC upgrade querier service. -service Query { - // CurrentPlan queries the current upgrade plan. - rpc CurrentPlan(QueryCurrentPlanRequest) returns (QueryCurrentPlanResponse) { - option (google.api.http).get = "/cosmos/upgrade/v1beta1/current_plan"; - } - - // AppliedPlan queries a previously applied upgrade plan by its name. - rpc AppliedPlan(QueryAppliedPlanRequest) returns (QueryAppliedPlanResponse) { - option (google.api.http).get = "/cosmos/upgrade/v1beta1/applied_plan/{name}"; - } - - // UpgradedConsensusState queries the consensus state that will serve - // 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 -// method. -message QueryCurrentPlanRequest {} - -// QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC -// method. -message QueryCurrentPlanResponse { - // plan is the current upgrade plan. - Plan plan = 1; -} - -// QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC -// method. -message QueryAppliedPlanRequest { - // name is the name of the applied plan to query for. - string name = 1; -} - -// QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC -// method. -message QueryAppliedPlanResponse { - // height is the block height at which the plan was applied. - int64 height = 1; -} - -// 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; -} - -// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState -// RPC method. -message QueryUpgradedConsensusStateResponse { - 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 deleted file mode 100644 index e888b393d6..0000000000 --- a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ /dev/null @@ -1,78 +0,0 @@ -syntax = "proto3"; -package cosmos.upgrade.v1beta1; - -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_getters_all) = false; - -// Plan specifies information about a planned upgrade and when it should occur. -message Plan { - 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 - // the first BeginBlock method after the upgrade is applied. It is also used - // to detect whether a software version can handle a given upgrade. If no - // upgrade handler with this name has been set in the software, it will be - // assumed that the software is out-of-date when the upgrade Time or Height is - // reached and the software will exit. - string name = 1; - - // 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. - int64 height = 3; - - // Any application specific upgrade info to be included on-chain - // such as a git commit that validators could automatically upgrade to - string info = 4; - - // 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.goproto_stringer) = false; - - string title = 1; - string description = 2; - Plan plan = 3 [(gogoproto.nullable) = false]; -} - -// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software -// upgrade. -message CancelSoftwareUpgradeProposal { - 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/tx.proto b/third_party/proto/cosmos/vesting/v1beta1/tx.proto deleted file mode 100644 index c49be802a7..0000000000 --- a/third_party/proto/cosmos/vesting/v1beta1/tx.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; -package cosmos.vesting.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; - -// Msg defines the bank Msg service. -service Msg { - // CreateVestingAccount defines a method that enables creating a vesting - // account. - rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); -} - -// MsgCreateVestingAccount defines a message that enables creating a vesting -// account. -message MsgCreateVestingAccount { - option (gogoproto.equal) = true; - - string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; - string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - - int64 end_time = 4 [(gogoproto.moretags) = "yaml:\"end_time\""]; - bool delayed = 5; -} - -// MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. -message MsgCreateVestingAccountResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto deleted file mode 100644 index e9f661f93c..0000000000 --- a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto +++ /dev/null @@ -1,85 +0,0 @@ -syntax = "proto3"; -package cosmos.vesting.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/auth/v1beta1/auth.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; - -// BaseVestingAccount implements the VestingAccount interface. It contains all -// the necessary fields needed for any vesting account implementation. -message BaseVestingAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - cosmos.auth.v1beta1.BaseAccount base_account = 1 [(gogoproto.embed) = true]; - repeated cosmos.base.v1beta1.Coin original_vesting = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"original_vesting\"" - ]; - repeated cosmos.base.v1beta1.Coin delegated_free = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"delegated_free\"" - ]; - repeated cosmos.base.v1beta1.Coin delegated_vesting = 4 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"delegated_vesting\"" - ]; - int64 end_time = 5 [(gogoproto.moretags) = "yaml:\"end_time\""]; -} - -// ContinuousVestingAccount implements the VestingAccount interface. It -// continuously vests by unlocking coins linearly with respect to time. -message ContinuousVestingAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; - int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; -} - -// DelayedVestingAccount implements the VestingAccount interface. It vests all -// coins after a specific time, but non prior. In other words, it keeps them -// locked until a specified time. -message DelayedVestingAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; -} - -// Period defines a length of time and amount of coins that will vest. -message Period { - option (gogoproto.goproto_stringer) = false; - - int64 length = 1; - repeated cosmos.base.v1beta1.Coin amount = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; -} - -// PeriodicVestingAccount implements the VestingAccount interface. It -// periodically vests by unlocking coins during each specified period. -message PeriodicVestingAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - - BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; - 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/api/httpbody.proto b/third_party/proto/google/api/httpbody.proto deleted file mode 100644 index 4428515c12..0000000000 --- a/third_party/proto/google/api/httpbody.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; -option java_multiple_files = true; -option java_outer_classname = "HttpBodyProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Message that represents an arbitrary HTTP body. It should only be used for -// payload formats that can't be represented as JSON, such as raw binary or -// an HTML page. -// -// -// This message can be used both in streaming and non-streaming API methods in -// the request as well as the response. -// -// It can be used as a top-level request field, which is convenient if one -// wants to extract parameters from either the URL or HTTP template into the -// request fields and also want access to the raw HTTP body. -// -// Example: -// -// message GetResourceRequest { -// // A unique request id. -// string request_id = 1; -// -// // The raw HTTP body is bound to this field. -// google.api.HttpBody http_body = 2; -// } -// -// service ResourceService { -// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); -// rpc UpdateResource(google.api.HttpBody) returns -// (google.protobuf.Empty); -// } -// -// Example with streaming methods: -// -// service CaldavService { -// rpc GetCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// rpc UpdateCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// } -// -// Use of this type only changes how the request and response bodies are -// handled, all other features will continue to work unchanged. -message HttpBody { - // The HTTP Content-Type header value specifying the content type of the body. - string content_type = 1; - - // The HTTP request/response body as raw binary. - bytes data = 2; - - // Application specific response metadata. Must be set in the first response - // for streaming APIs. - repeated google.protobuf.Any extensions = 3; -} \ No newline at end of file diff --git a/third_party/proto/google/protobuf/any.proto b/third_party/proto/google/protobuf/any.proto deleted file mode 100644 index 58b511583a..0000000000 --- a/third_party/proto/google/protobuf/any.proto +++ /dev/null @@ -1,164 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -import "gogoproto/gogo.proto"; - -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "types"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "AnyProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; - -// `Any` contains an arbitrary serialized protocol buffer message along with a -// URL that describes the type of the serialized message. -// -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// Example 4: Pack and unpack a message in Go -// -// foo := &pb.Foo{...} -// any, err := ptypes.MarshalAny(foo) -// ... -// foo := &pb.Foo{} -// if err := ptypes.UnmarshalAny(any, foo); err != nil { -// ... -// } -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } -// -message Any { - // A URL/resource name that uniquely identifies the type of the serialized - // protocol buffer message. This string must contain at least - // one "/" character. The last segment of the URL's path must represent - // the fully qualified name of the type (as in - // `path/google.protobuf.Duration`). The name should be in a canonical form - // (e.g., leading "." is not accepted). - // - // In practice, teams usually precompile into the binary all types that they - // expect it to use in the context of Any. However, for URLs which use the - // scheme `http`, `https`, or no scheme, one can optionally set up a type - // server that maps type URLs to message definitions as follows: - // - // * If no scheme is provided, `https` is assumed. - // * An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // * Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) - // - // Note: this functionality is not currently available in the official - // protobuf release, and it is not used for type URLs beginning with - // type.googleapis.com. - // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. - // - string type_url = 1; - - // Must be a valid serialized protocol buffer of the above specified type. - 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/interchain_accounts/controller/v1/controller.proto b/third_party/proto/ibc/applications/interchain_accounts/controller/v1/controller.proto deleted file mode 100644 index 291f3e4fd9..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/controller/v1/controller.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.controller.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"; - -import "gogoproto/gogo.proto"; - -// Params defines the set of on-chain interchain accounts parameters. -// The following parameters may be used to disable the controller submodule. -message Params { - // controller_enabled enables or disables the controller submodule. - bool controller_enabled = 1 [(gogoproto.moretags) = "yaml:\"controller_enabled\""]; -} diff --git a/third_party/proto/ibc/applications/interchain_accounts/controller/v1/query.proto b/third_party/proto/ibc/applications/interchain_accounts/controller/v1/query.proto deleted file mode 100644 index d3960e9d14..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/controller/v1/query.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.controller.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"; - -import "ibc/applications/interchain_accounts/controller/v1/controller.proto"; -import "google/api/annotations.proto"; - -// Query provides defines the gRPC querier service. -service Query { - // Params queries all parameters of the ICA controller submodule. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/ibc/apps/interchain_accounts/controller/v1/params"; - } -} - -// 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/interchain_accounts/host/v1/host.proto b/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto deleted file mode 100644 index a9d951cef8..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/host/v1/host.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.host.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"; - -import "gogoproto/gogo.proto"; - -// Params defines the set of on-chain interchain accounts parameters. -// The following parameters may be used to disable the host submodule. -message Params { - // host_enabled enables or disables the host submodule. - bool host_enabled = 1 [(gogoproto.moretags) = "yaml:\"host_enabled\""]; - // allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. - repeated string allow_messages = 2 [(gogoproto.moretags) = "yaml:\"allow_messages\""]; -} diff --git a/third_party/proto/ibc/applications/interchain_accounts/host/v1/query.proto b/third_party/proto/ibc/applications/interchain_accounts/host/v1/query.proto deleted file mode 100644 index 5512d7b4fa..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/host/v1/query.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.host.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"; - -import "google/api/annotations.proto"; -import "ibc/applications/interchain_accounts/host/v1/host.proto"; - -// Query provides defines the gRPC querier service. -service Query { - // Params queries all parameters of the ICA host submodule. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/ibc/apps/interchain_accounts/host/v1/params"; - } -} - -// 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/interchain_accounts/v1/account.proto b/third_party/proto/ibc/applications/interchain_accounts/v1/account.proto deleted file mode 100644 index 75d2fbd89e..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/v1/account.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"; - -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "cosmos/auth/v1beta1/auth.proto"; - -// An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain -message InterchainAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - option (cosmos_proto.implements_interface) = "InterchainAccountI"; - - cosmos.auth.v1beta1.BaseAccount base_account = 1 - [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; - string account_owner = 2 [(gogoproto.moretags) = "yaml:\"account_owner\""]; -} diff --git a/third_party/proto/ibc/applications/interchain_accounts/v1/genesis.proto b/third_party/proto/ibc/applications/interchain_accounts/v1/genesis.proto deleted file mode 100644 index 3902f89070..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/v1/genesis.proto +++ /dev/null @@ -1,51 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"; - -import "gogoproto/gogo.proto"; -import "ibc/applications/interchain_accounts/controller/v1/controller.proto"; -import "ibc/applications/interchain_accounts/host/v1/host.proto"; - -// GenesisState defines the interchain accounts genesis state -message GenesisState { - ControllerGenesisState controller_genesis_state = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"controller_genesis_state\""]; - HostGenesisState host_genesis_state = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"host_genesis_state\""]; -} - -// ControllerGenesisState defines the interchain accounts controller genesis state -message ControllerGenesisState { - repeated ActiveChannel active_channels = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"active_channels\""]; - repeated RegisteredInterchainAccount interchain_accounts = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interchain_accounts\""]; - repeated string ports = 3; - ibc.applications.interchain_accounts.controller.v1.Params params = 4 [(gogoproto.nullable) = false]; -} - -// HostGenesisState defines the interchain accounts host genesis state -message HostGenesisState { - repeated ActiveChannel active_channels = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"active_channels\""]; - repeated RegisteredInterchainAccount interchain_accounts = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interchain_accounts\""]; - string port = 3; - ibc.applications.interchain_accounts.host.v1.Params params = 4 [(gogoproto.nullable) = false]; -} - -// ActiveChannel contains a connection ID, port ID and associated active channel ID -message ActiveChannel { - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - string port_id = 2 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; -} - -// RegisteredInterchainAccount contains a connection ID, port ID and associated interchain account address -message RegisteredInterchainAccount { - string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; - string port_id = 2 [(gogoproto.moretags) = "yaml:\"port_id\""]; - string account_address = 3 [(gogoproto.moretags) = "yaml:\"account_address\""]; -} \ No newline at end of file diff --git a/third_party/proto/ibc/applications/interchain_accounts/v1/metadata.proto b/third_party/proto/ibc/applications/interchain_accounts/v1/metadata.proto deleted file mode 100644 index 3eab1d04a6..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/v1/metadata.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"; - -import "gogoproto/gogo.proto"; - -// Metadata defines a set of protocol specific data encoded into the ICS27 channel version bytestring -// See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning -message Metadata { - // version defines the ICS27 protocol version - string version = 1; - // controller_connection_id is the connection identifier associated with the controller chain - string controller_connection_id = 2 [(gogoproto.moretags) = "yaml:\"controller_connection_id\""]; - // host_connection_id is the connection identifier associated with the host chain - string host_connection_id = 3 [(gogoproto.moretags) = "yaml:\"host_connection_id\""]; - // address defines the interchain account address to be fulfilled upon the OnChanOpenTry handshake step - // NOTE: the address field is empty on the OnChanOpenInit handshake step - string address = 4; - // encoding defines the supported codec format - string encoding = 5; - // tx_type defines the type of transactions the interchain account can execute - string tx_type = 6; -} diff --git a/third_party/proto/ibc/applications/interchain_accounts/v1/packet.proto b/third_party/proto/ibc/applications/interchain_accounts/v1/packet.proto deleted file mode 100644 index 51ff4279ae..0000000000 --- a/third_party/proto/ibc/applications/interchain_accounts/v1/packet.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.interchain_accounts.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"; - -import "google/protobuf/any.proto"; -import "gogoproto/gogo.proto"; - -// Type defines a classification of message issued from a controller chain to its associated interchain accounts -// host -enum Type { - option (gogoproto.goproto_enum_prefix) = false; - - // Default zero value enumeration - TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; - // Execute a transaction on an interchain accounts host chain - TYPE_EXECUTE_TX = 1 [(gogoproto.enumvalue_customname) = "EXECUTE_TX"]; -} - -// InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field. -message InterchainAccountPacketData { - Type type = 1; - bytes data = 2; - string memo = 3; -} - -// CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain. -message CosmosTx { - repeated google.protobuf.Any messages = 1; -} 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 0b5c0e0d12..0000000000 --- a/third_party/proto/ibc/applications/transfer/v1/genesis.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"; - -import "ibc/applications/transfer/v1/transfer.proto"; -import "gogoproto/gogo.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 2ed28049fd..0000000000 --- a/third_party/proto/ibc/applications/transfer/v1/query.proto +++ /dev/null @@ -1,86 +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/ibc-go/v3/modules/apps/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/apps/transfer/v1/denom_traces/{hash}"; - } - - // DenomTraces queries all denomination traces. - rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces"; - } - - // Params queries all parameters of the ibc-transfer module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/params"; - } - - // DenomHash queries a denomination hash information. - rpc DenomHash(QueryDenomHashRequest) returns (QueryDenomHashResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/denom_hashes/{trace}"; - } -} - -// 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; -} - -// QueryDenomHashRequest is the request type for the Query/DenomHash RPC -// method -message QueryDenomHashRequest { - // The denomination trace ([port_id]/[channel_id])+/[denom] - string trace = 1; -} - -// QueryDenomHashResponse is the response type for the Query/DenomHash RPC -// method. -message QueryDenomHashResponse { - // hash (in hex format) of the denomination trace information. - string hash = 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 7a99485c58..0000000000 --- a/third_party/proto/ibc/applications/transfer/v1/transfer.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"; - -import "gogoproto/gogo.proto"; - -// 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 8f1392b0cf..0000000000 --- a/third_party/proto/ibc/applications/transfer/v1/tx.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.transfer.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/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/ibc/tree/master/spec/app/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 absolute nanoseconds since unix epoch. - // 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/applications/transfer/v2/packet.proto b/third_party/proto/ibc/applications/transfer/v2/packet.proto deleted file mode 100644 index 850320df34..0000000000 --- a/third_party/proto/ibc/applications/transfer/v2/packet.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; - -package ibc.applications.transfer.v2; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"; - -// FungibleTokenPacketData defines a struct for the packet payload -// See FungibleTokenPacketData spec: -// https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures -message FungibleTokenPacketData { - // the token denomination to be transferred - string denom = 1; - // the token amount to be transferred - string amount = 2; - // the sender address - string sender = 3; - // the recipient address on the destination chain - string receiver = 4; -} 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 68c6ec17b1..0000000000 --- a/third_party/proto/ibc/core/channel/v1/channel.proto +++ /dev/null @@ -1,148 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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/ibc/tree/master/spec/core/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 d95c891b6c..0000000000 --- a/third_party/proto/ibc/core/channel/v1/genesis.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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 ceb13d0009..0000000000 --- a/third_party/proto/ibc/core/channel/v1/query.proto +++ /dev/null @@ -1,376 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"; - -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"; - -// 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/v1/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/v1/channels"; - } - - // ConnectionChannels queries all the channels associated with a connection - // end. - rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) { - option (google.api.http).get = "/ibc/core/channel/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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/v1/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; - // list of packet sequences - repeated uint64 packet_commitment_sequences = 4; -} - -// 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 d4d6df1d5e..0000000000 --- a/third_party/proto/ibc/core/channel/v1/tx.proto +++ /dev/null @@ -1,243 +0,0 @@ -syntax = "proto3"; - -package ibc.core.channel.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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); -} - -// ResponseResultType defines the possible outcomes of the execution of a message -enum ResponseResultType { - option (gogoproto.goproto_enum_prefix) = false; - - // Default zero value enumeration - RESPONSE_RESULT_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; - // The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) - RESPONSE_RESULT_NOOP = 1 [(gogoproto.enumvalue_customname) = "NOOP"]; - // The message was executed successfully - RESPONSE_RESULT_SUCCESS = 2 [(gogoproto.enumvalue_customname) = "SUCCESS"]; -} - -// 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 { - string channel_id = 1 [(gogoproto.moretags) = "yaml:\"channel_id\""]; -} - -// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel -// on Chain B. The version field within the Channel field has been deprecated. Its -// value will be ignored by core IBC. -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\""]; - // NOTE: the version field within the channel has been deprecated. Its value will be ignored by core IBC. - 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 { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} - -// 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 { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} - -// 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 { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} - -// 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 { - option (gogoproto.goproto_getters) = false; - - ResponseResultType result = 1; -} 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 657d99ed20..0000000000 --- a/third_party/proto/ibc/core/client/v1/client.proto +++ /dev/null @@ -1,100 +0,0 @@ -syntax = "proto3"; - -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "cosmos/upgrade/v1beta1/upgrade.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 substitute -// client's latest consensus state is copied over to the subject client. The proposal -// handler may fail if the subject and the substitute do not match in client and -// chain parameters (with exception to latest height, frozen height, and chain-id). -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 subject_client_id = 3 [(gogoproto.moretags) = "yaml:\"subject_client_id\""]; - // the substitute client identifier for the client standing in for the subject - // client - string substitute_client_id = 4 [(gogoproto.moretags) = "yaml:\"substitute_client_id\""]; -} - -// UpgradeProposal is a gov Content type for initiating an IBC breaking -// upgrade. -message UpgradeProposal { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.equal) = true; - - string title = 1; - string description = 2; - cosmos.upgrade.v1beta1.Plan plan = 3 [(gogoproto.nullable) = false]; - - // An UpgradedClientState must be provided to perform an IBC breaking upgrade. - // 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 = 4 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; -} - -// 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 0ca29d224b..0000000000 --- a/third_party/proto/ibc/core/client/v1/genesis.proto +++ /dev/null @@ -1,48 +0,0 @@ -syntax = "proto3"; - -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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\""]; -} 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 91a906fe54..0000000000 --- a/third_party/proto/ibc/core/client/v1/query.proto +++ /dev/null @@ -1,184 +0,0 @@ -syntax = "proto3"; - -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"; - -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"; - -// 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/v1/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/v1/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/v1/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/v1/consensus_states/{client_id}"; - } - - // Status queries the status of an IBC client. - rpc ClientStatus(QueryClientStatusRequest) returns (QueryClientStatusResponse) { - option (google.api.http).get = "/ibc/core/client/v1/client_status/{client_id}"; - } - - // ClientParams queries all parameters of the ibc client. - rpc ClientParams(QueryClientParamsRequest) returns (QueryClientParamsResponse) { - option (google.api.http).get = "/ibc/client/v1/params"; - } - - // UpgradedClientState queries an Upgraded IBC light client. - rpc UpgradedClientState(QueryUpgradedClientStateRequest) returns (QueryUpgradedClientStateResponse) { - option (google.api.http).get = "/ibc/core/client/v1/upgraded_client_states"; - } - - // UpgradedConsensusState queries an Upgraded IBC consensus state. - rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) { - option (google.api.http).get = "/ibc/core/client/v1/upgraded_consensus_states"; - } -} - -// 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; -} - -// QueryClientStatusRequest is the request type for the Query/ClientStatus RPC -// method -message QueryClientStatusRequest { - // client unique identifier - string client_id = 1; -} - -// QueryClientStatusResponse is the response type for the Query/ClientStatus RPC -// method. It returns the current status of the IBC client. -message QueryClientStatusResponse { - string status = 1; -} - -// 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; -} - -// QueryUpgradedClientStateRequest is the request type for the -// Query/UpgradedClientState RPC method -message QueryUpgradedClientStateRequest {} - -// QueryUpgradedClientStateResponse is the response type for the -// Query/UpgradedClientState RPC method. -message QueryUpgradedClientStateResponse { - // client state associated with the request identifier - google.protobuf.Any upgraded_client_state = 1; -} - -// QueryUpgradedConsensusStateRequest is the request type for the -// Query/UpgradedConsensusState RPC method -message QueryUpgradedConsensusStateRequest {} - -// QueryUpgradedConsensusStateResponse is the response type for the -// Query/UpgradedConsensusState RPC method. -message QueryUpgradedConsensusStateResponse { - // Consensus state associated with the request identifier - google.protobuf.Any upgraded_consensus_state = 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 06dbfbd0df..0000000000 --- a/third_party/proto/ibc/core/client/v1/tx.proto +++ /dev/null @@ -1,99 +0,0 @@ -syntax = "proto3"; - -package ibc.core.client.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.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 f0118b7165..0000000000 --- a/third_party/proto/ibc/core/commitment/v1/commitment.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; - -package ibc.core.commitment.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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; -} 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 7fd2a6909a..0000000000 --- a/third_party/proto/ibc/core/connection/v1/connection.proto +++ /dev/null @@ -1,114 +0,0 @@ -syntax = "proto3"; - -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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/ibc/blob/master/spec/core/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; -} - -// Params defines the set of Connection parameters. -message Params { - // maximum expected time per block (in nanoseconds), used to enforce block delay. This parameter should reflect the - // largest amount of time that the chain might reasonably take to produce the next block under normal operating - // conditions. A safe choice is 3-5x the expected time per block. - uint64 max_expected_time_per_block = 1 [(gogoproto.moretags) = "yaml:\"max_expected_time_per_block\""]; -} 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 1a53422c94..0000000000 --- a/third_party/proto/ibc/core/connection/v1/genesis.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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\""]; - Params params = 4 [(gogoproto.nullable) = false]; -} 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 f28578f5fc..0000000000 --- a/third_party/proto/ibc/core/connection/v1/query.proto +++ /dev/null @@ -1,138 +0,0 @@ -syntax = "proto3"; - -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"; - -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"; - -// 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/v1/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/v1/connections"; - } - - // ClientConnections queries the connection paths associated with a client - // state. - rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) { - option (google.api.http).get = "/ibc/core/connection/v1/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/v1/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/v1/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 e7e09c84cf..0000000000 --- a/third_party/proto/ibc/core/connection/v1/tx.proto +++ /dev/null @@ -1,119 +0,0 @@ -syntax = "proto3"; - -package ibc.core.connection.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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 fbddbf3035..0000000000 --- a/third_party/proto/ibc/core/types/v1/genesis.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; - -package ibc.core.types.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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 4305680154..0000000000 --- a/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package ibc.lightclients.localhost.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/light-clients/09-localhost/types"; - -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/client.proto"; - -// 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 c279f5e728..0000000000 --- a/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ /dev/null @@ -1,189 +0,0 @@ -syntax = "proto3"; - -package ibc.lightclients.solomachine.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/core/02-client/legacy/v100"; - -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/solomachine/v2/solomachine.proto b/third_party/proto/ibc/lightclients/solomachine/v2/solomachine.proto deleted file mode 100644 index e626c18ac6..0000000000 --- a/third_party/proto/ibc/lightclients/solomachine/v2/solomachine.proto +++ /dev/null @@ -1,189 +0,0 @@ -syntax = "proto3"; - -package ibc.lightclients.solomachine.v2; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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 - bool is_frozen = 2 [(gogoproto.moretags) = "yaml:\"is_frozen\""]; - 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 ac39341dbf..0000000000 --- a/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto3"; - -package ibc.lightclients.tendermint.v1; - -option go_package = "github.com/cosmos/ibc-go/v3/modules/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/third_party/proto/tendermint/abci/types.proto b/third_party/proto/tendermint/abci/types.proto deleted file mode 100644 index 8e3a909363..0000000000 --- a/third_party/proto/tendermint/abci/types.proto +++ /dev/null @@ -1,407 +0,0 @@ -syntax = "proto3"; -package tendermint.abci; - -option go_package = "github.com/tendermint/tendermint/abci/types"; - -// For more information on gogo.proto, see: -// https://github.com/gogo/protobuf/blob/master/extensions.md -import "tendermint/crypto/proof.proto"; -import "tendermint/types/types.proto"; -import "tendermint/crypto/keys.proto"; -import "tendermint/types/params.proto"; -import "google/protobuf/timestamp.proto"; -import "gogoproto/gogo.proto"; - -// This file is copied from http://github.com/tendermint/abci -// NOTE: When using custom types, mind the warnings. -// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues - -//---------------------------------------- -// Request types - -message Request { - oneof value { - RequestEcho echo = 1; - RequestFlush flush = 2; - RequestInfo info = 3; - RequestSetOption set_option = 4; - RequestInitChain init_chain = 5; - RequestQuery query = 6; - RequestBeginBlock begin_block = 7; - RequestCheckTx check_tx = 8; - RequestDeliverTx deliver_tx = 9; - RequestEndBlock end_block = 10; - RequestCommit commit = 11; - RequestListSnapshots list_snapshots = 12; - RequestOfferSnapshot offer_snapshot = 13; - RequestLoadSnapshotChunk load_snapshot_chunk = 14; - RequestApplySnapshotChunk apply_snapshot_chunk = 15; - } -} - -message RequestEcho { - string message = 1; -} - -message RequestFlush {} - -message RequestInfo { - string version = 1; - uint64 block_version = 2; - uint64 p2p_version = 3; -} - -// nondeterministic -message RequestSetOption { - string key = 1; - string value = 2; -} - -message RequestInitChain { - google.protobuf.Timestamp time = 1 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - string chain_id = 2; - ConsensusParams consensus_params = 3; - repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false]; - bytes app_state_bytes = 5; - int64 initial_height = 6; -} - -message RequestQuery { - bytes data = 1; - string path = 2; - int64 height = 3; - bool prove = 4; -} - -message RequestBeginBlock { - bytes hash = 1; - tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; - LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; - repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; -} - -enum CheckTxType { - NEW = 0 [(gogoproto.enumvalue_customname) = "New"]; - RECHECK = 1 [(gogoproto.enumvalue_customname) = "Recheck"]; -} - -message RequestCheckTx { - bytes tx = 1; - CheckTxType type = 2; -} - -message RequestDeliverTx { - bytes tx = 1; -} - -message RequestEndBlock { - int64 height = 1; -} - -message RequestCommit {} - -// lists available snapshots -message RequestListSnapshots { -} - -// offers a snapshot to the application -message RequestOfferSnapshot { - Snapshot snapshot = 1; // snapshot offered by peers - bytes app_hash = 2; // light client-verified app hash for snapshot height -} - -// loads a snapshot chunk -message RequestLoadSnapshotChunk { - uint64 height = 1; - uint32 format = 2; - uint32 chunk = 3; -} - -// Applies a snapshot chunk -message RequestApplySnapshotChunk { - uint32 index = 1; - bytes chunk = 2; - string sender = 3; -} - -//---------------------------------------- -// Response types - -message Response { - oneof value { - ResponseException exception = 1; - ResponseEcho echo = 2; - ResponseFlush flush = 3; - ResponseInfo info = 4; - ResponseSetOption set_option = 5; - ResponseInitChain init_chain = 6; - ResponseQuery query = 7; - ResponseBeginBlock begin_block = 8; - ResponseCheckTx check_tx = 9; - ResponseDeliverTx deliver_tx = 10; - ResponseEndBlock end_block = 11; - ResponseCommit commit = 12; - ResponseListSnapshots list_snapshots = 13; - ResponseOfferSnapshot offer_snapshot = 14; - ResponseLoadSnapshotChunk load_snapshot_chunk = 15; - ResponseApplySnapshotChunk apply_snapshot_chunk = 16; - } -} - -// nondeterministic -message ResponseException { - string error = 1; -} - -message ResponseEcho { - string message = 1; -} - -message ResponseFlush {} - -message ResponseInfo { - string data = 1; - - string version = 2; - uint64 app_version = 3; - - int64 last_block_height = 4; - bytes last_block_app_hash = 5; -} - -// nondeterministic -message ResponseSetOption { - uint32 code = 1; - // bytes data = 2; - string log = 3; - string info = 4; -} - -message ResponseInitChain { - ConsensusParams consensus_params = 1; - repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; - bytes app_hash = 3; -} - -message ResponseQuery { - uint32 code = 1; - // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 index = 5; - bytes key = 6; - bytes value = 7; - tendermint.crypto.ProofOps proof_ops = 8; - int64 height = 9; - string codespace = 10; -} - -message ResponseBeginBlock { - repeated Event events = 1 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; -} - -message ResponseCheckTx { - uint32 code = 1; - bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 gas_wanted = 5 [json_name = "gas_wanted"]; - int64 gas_used = 6 [json_name = "gas_used"]; - repeated Event events = 7 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; -} - -message ResponseDeliverTx { - uint32 code = 1; - bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 gas_wanted = 5 [json_name = "gas_wanted"]; - int64 gas_used = 6 [json_name = "gas_used"]; - repeated Event events = 7 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; // nondeterministic - string codespace = 8; -} - -message ResponseEndBlock { - repeated ValidatorUpdate validator_updates = 1 - [(gogoproto.nullable) = false]; - ConsensusParams consensus_param_updates = 2; - repeated Event events = 3 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; -} - -message ResponseCommit { - // reserve 1 - bytes data = 2; - int64 retain_height = 3; -} - -message ResponseListSnapshots { - repeated Snapshot snapshots = 1; -} - -message ResponseOfferSnapshot { - Result result = 1; - - enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Snapshot accepted, apply chunks - ABORT = 2; // Abort all snapshot restoration - REJECT = 3; // Reject this specific snapshot, try others - REJECT_FORMAT = 4; // Reject all snapshots of this format, try others - REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others - } -} - -message ResponseLoadSnapshotChunk { - bytes chunk = 1; -} - -message ResponseApplySnapshotChunk { - Result result = 1; - repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply - repeated string reject_senders = 3; // Chunk senders to reject and ban - - enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Chunk successfully accepted - ABORT = 2; // Abort all snapshot restoration - RETRY = 3; // Retry chunk (combine with refetch and reject) - RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) - REJECT_SNAPSHOT = 5; // Reject this snapshot, try others - } -} - -//---------------------------------------- -// Misc. - -// ConsensusParams contains all consensus-relevant parameters -// that can be adjusted by the abci app -message ConsensusParams { - BlockParams block = 1; - tendermint.types.EvidenceParams evidence = 2; - tendermint.types.ValidatorParams validator = 3; - tendermint.types.VersionParams version = 4; -} - -// BlockParams contains limits on the block size. -message BlockParams { - // Note: must be greater than 0 - int64 max_bytes = 1; - // Note: must be greater or equal to -1 - int64 max_gas = 2; -} - -message LastCommitInfo { - int32 round = 1; - repeated VoteInfo votes = 2 [(gogoproto.nullable) = false]; -} - -// Event allows application developers to attach additional information to -// ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. -// Later, transactions may be queried using these events. -message Event { - string type = 1; - repeated EventAttribute attributes = 2 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "attributes,omitempty" - ]; -} - -// EventAttribute is a single key-value pair, associated with an event. -message EventAttribute { - bytes key = 1; - bytes value = 2; - bool index = 3; // nondeterministic -} - -// TxResult contains results of executing the transaction. -// -// One usage is indexing transaction results. -message TxResult { - int64 height = 1; - uint32 index = 2; - bytes tx = 3; - ResponseDeliverTx result = 4 [(gogoproto.nullable) = false]; -} - -//---------------------------------------- -// Blockchain Types - -// Validator -message Validator { - bytes address = 1; // The first 20 bytes of SHA256(public key) - // PubKey pub_key = 2 [(gogoproto.nullable)=false]; - int64 power = 3; // The voting power -} - -// ValidatorUpdate -message ValidatorUpdate { - tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false]; - int64 power = 2; -} - -// VoteInfo -message VoteInfo { - Validator validator = 1 [(gogoproto.nullable) = false]; - bool signed_last_block = 2; -} - -enum EvidenceType { - UNKNOWN = 0; - DUPLICATE_VOTE = 1; - LIGHT_CLIENT_ATTACK = 2; -} - -message Evidence { - EvidenceType type = 1; - // The offending validator - Validator validator = 2 [(gogoproto.nullable) = false]; - // The height when the offense occurred - int64 height = 3; - // The corresponding time where the offense occurred - google.protobuf.Timestamp time = 4 [ - (gogoproto.nullable) = false, - (gogoproto.stdtime) = true - ]; - // Total voting power of the validator set in case the ABCI application does - // not store historical validators. - // https://github.com/tendermint/tendermint/issues/4581 - int64 total_voting_power = 5; -} - -//---------------------------------------- -// State Sync Types - -message Snapshot { - uint64 height = 1; // The height at which the snapshot was taken - uint32 format = 2; // The application-specific snapshot format - uint32 chunks = 3; // Number of chunks in the snapshot - bytes hash = 4; // Arbitrary snapshot hash, equal only if identical - bytes metadata = 5; // Arbitrary application metadata -} - -//---------------------------------------- -// Service Definition - -service ABCIApplication { - rpc Echo(RequestEcho) returns (ResponseEcho); - rpc Flush(RequestFlush) returns (ResponseFlush); - rpc Info(RequestInfo) returns (ResponseInfo); - rpc SetOption(RequestSetOption) returns (ResponseSetOption); - rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); - rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); - rpc Query(RequestQuery) returns (ResponseQuery); - rpc Commit(RequestCommit) returns (ResponseCommit); - rpc InitChain(RequestInitChain) returns (ResponseInitChain); - rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); - rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); - rpc ListSnapshots(RequestListSnapshots) returns (ResponseListSnapshots); - rpc OfferSnapshot(RequestOfferSnapshot) returns (ResponseOfferSnapshot); - rpc LoadSnapshotChunk(RequestLoadSnapshotChunk) returns (ResponseLoadSnapshotChunk); - rpc ApplySnapshotChunk(RequestApplySnapshotChunk) returns (ResponseApplySnapshotChunk); -} diff --git a/third_party/proto/tendermint/blockchain/types.proto b/third_party/proto/tendermint/blockchain/types.proto deleted file mode 100644 index f5c143cf5b..0000000000 --- a/third_party/proto/tendermint/blockchain/types.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; -package tendermint.blockchain; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/blockchain"; - -import "tendermint/types/block.proto"; - -// BlockRequest requests a block for a specific height -message BlockRequest { - int64 height = 1; -} - -// NoBlockResponse informs the node that the peer does not have block at the requested height -message NoBlockResponse { - int64 height = 1; -} - -// BlockResponse returns block to the requested -message BlockResponse { - tendermint.types.Block block = 1; -} - -// StatusRequest requests the status of a peer. -message StatusRequest { -} - -// StatusResponse is a peer response to inform their status. -message StatusResponse { - int64 height = 1; - int64 base = 2; -} - -message Message { - oneof sum { - BlockRequest block_request = 1; - NoBlockResponse no_block_response = 2; - BlockResponse block_response = 3; - StatusRequest status_request = 4; - StatusResponse status_response = 5; - } -} diff --git a/third_party/proto/tendermint/consensus/types.proto b/third_party/proto/tendermint/consensus/types.proto deleted file mode 100644 index 6e1f413711..0000000000 --- a/third_party/proto/tendermint/consensus/types.proto +++ /dev/null @@ -1,92 +0,0 @@ -syntax = "proto3"; -package tendermint.consensus; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/consensus"; - -import "gogoproto/gogo.proto"; -import "tendermint/types/types.proto"; -import "tendermint/libs/bits/types.proto"; - -// NewRoundStep is sent for every step taken in the ConsensusState. -// For every height/round/step transition -message NewRoundStep { - int64 height = 1; - int32 round = 2; - uint32 step = 3; - int64 seconds_since_start_time = 4; - int32 last_commit_round = 5; -} - -// NewValidBlock is sent when a validator observes a valid block B in some round r, -//i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. -// In case the block is also committed, then IsCommit flag is set to true. -message NewValidBlock { - int64 height = 1; - int32 round = 2; - tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false]; - tendermint.libs.bits.BitArray block_parts = 4; - bool is_commit = 5; -} - -// Proposal is sent when a new block is proposed. -message Proposal { - tendermint.types.Proposal proposal = 1 [(gogoproto.nullable) = false]; -} - -// ProposalPOL is sent when a previous proposal is re-proposed. -message ProposalPOL { - int64 height = 1; - int32 proposal_pol_round = 2; - tendermint.libs.bits.BitArray proposal_pol = 3 [(gogoproto.nullable) = false]; -} - -// BlockPart is sent when gossipping a piece of the proposed block. -message BlockPart { - int64 height = 1; - int32 round = 2; - tendermint.types.Part part = 3 [(gogoproto.nullable) = false]; -} - -// Vote is sent when voting for a proposal (or lack thereof). -message Vote { - tendermint.types.Vote vote = 1; -} - -// HasVote is sent to indicate that a particular vote has been received. -message HasVote { - int64 height = 1; - int32 round = 2; - tendermint.types.SignedMsgType type = 3; - int32 index = 4; -} - -// VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes. -message VoteSetMaj23 { - int64 height = 1; - int32 round = 2; - tendermint.types.SignedMsgType type = 3; - tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; -} - -// VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. -message VoteSetBits { - int64 height = 1; - int32 round = 2; - tendermint.types.SignedMsgType type = 3; - tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - tendermint.libs.bits.BitArray votes = 5 [(gogoproto.nullable) = false]; -} - -message Message { - oneof sum { - NewRoundStep new_round_step = 1; - NewValidBlock new_valid_block = 2; - Proposal proposal = 3; - ProposalPOL proposal_pol = 4; - BlockPart block_part = 5; - Vote vote = 6; - HasVote has_vote = 7; - VoteSetMaj23 vote_set_maj23 = 8; - VoteSetBits vote_set_bits = 9; - } -} diff --git a/third_party/proto/tendermint/consensus/wal.proto b/third_party/proto/tendermint/consensus/wal.proto deleted file mode 100644 index 44afa2c0c3..0000000000 --- a/third_party/proto/tendermint/consensus/wal.proto +++ /dev/null @@ -1,46 +0,0 @@ -syntax = "proto3"; -package tendermint.consensus; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/consensus"; - -import "gogoproto/gogo.proto"; -import "tendermint/consensus/types.proto"; -import "tendermint/types/events.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -// MsgInfo are msgs from the reactor which may update the state -message MsgInfo { - Message msg = 1 [(gogoproto.nullable) = false]; - string peer_id = 2 [(gogoproto.customname) = "PeerID"]; -} - -// TimeoutInfo internally generated messages which may update the state -message TimeoutInfo { - google.protobuf.Duration duration = 1 - [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - int64 height = 2; - int32 round = 3; - uint32 step = 4; -} - -// EndHeight marks the end of the given height inside WAL. -// @internal used by scripts/wal2json util. -message EndHeight { - int64 height = 1; -} - -message WALMessage { - oneof sum { - tendermint.types.EventDataRoundState event_data_round_state = 1; - MsgInfo msg_info = 2; - TimeoutInfo timeout_info = 3; - EndHeight end_height = 4; - } -} - -// TimedWALMessage wraps WALMessage and adds Time for debugging purposes. -message TimedWALMessage { - google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - WALMessage msg = 2; -} diff --git a/third_party/proto/tendermint/crypto/keys.pb.go b/third_party/proto/tendermint/crypto/keys.pb.go deleted file mode 100644 index ad2de6c876..0000000000 --- a/third_party/proto/tendermint/crypto/keys.pb.go +++ /dev/null @@ -1,677 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/crypto/keys.proto - -package crypto - -import ( - bytes "bytes" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// PublicKey defines the keys available for use with Tendermint Validators -type PublicKey struct { - // Types that are valid to be assigned to Sum: - // *PublicKey_Ed25519 - // *PublicKey_Secp256K1 - Sum isPublicKey_Sum `protobuf_oneof:"sum"` -} - -func (m *PublicKey) Reset() { *m = PublicKey{} } -func (m *PublicKey) String() string { return proto.CompactTextString(m) } -func (*PublicKey) ProtoMessage() {} -func (*PublicKey) Descriptor() ([]byte, []int) { - return fileDescriptor_cb048658b234868c, []int{0} -} - -func (m *PublicKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PublicKey.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *PublicKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PublicKey.Merge(m, src) -} - -func (m *PublicKey) XXX_Size() int { - return m.Size() -} - -func (m *PublicKey) XXX_DiscardUnknown() { - xxx_messageInfo_PublicKey.DiscardUnknown(m) -} - -var xxx_messageInfo_PublicKey proto.InternalMessageInfo - -type isPublicKey_Sum interface { - isPublicKey_Sum() - Equal(interface{}) bool - MarshalTo([]byte) (int, error) - Size() int - Compare(interface{}) int -} - -type PublicKey_Ed25519 struct { - Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"` -} -type PublicKey_Secp256K1 struct { - Secp256K1 []byte `protobuf:"bytes,2,opt,name=secp256k1,proto3,oneof" json:"secp256k1,omitempty"` -} - -func (*PublicKey_Ed25519) isPublicKey_Sum() {} -func (*PublicKey_Secp256K1) isPublicKey_Sum() {} - -func (m *PublicKey) GetSum() isPublicKey_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *PublicKey) GetEd25519() []byte { - if x, ok := m.GetSum().(*PublicKey_Ed25519); ok { - return x.Ed25519 - } - return nil -} - -func (m *PublicKey) GetSecp256K1() []byte { - if x, ok := m.GetSum().(*PublicKey_Secp256K1); ok { - return x.Secp256K1 - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*PublicKey) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*PublicKey_Ed25519)(nil), - (*PublicKey_Secp256K1)(nil), - } -} - -func init() { - proto.RegisterType((*PublicKey)(nil), "tendermint.crypto.PublicKey") -} - -func init() { proto.RegisterFile("tendermint/crypto/keys.proto", fileDescriptor_cb048658b234868c) } - -var fileDescriptor_cb048658b234868c = []byte{ - // 199 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0xcf, 0x4e, - 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x44, 0xc8, 0xea, 0x41, 0x64, 0xa5, - 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x52, 0x04, 0x17, 0x67, - 0x40, 0x69, 0x52, 0x4e, 0x66, 0xb2, 0x77, 0x6a, 0xa5, 0x90, 0x14, 0x17, 0x7b, 0x6a, 0x8a, 0x91, - 0xa9, 0xa9, 0xa1, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x8f, 0x07, 0x43, 0x10, 0x4c, 0x40, 0x48, - 0x8e, 0x8b, 0xb3, 0x38, 0x35, 0xb9, 0xc0, 0xc8, 0xd4, 0x2c, 0xdb, 0x50, 0x82, 0x09, 0x2a, 0x8b, - 0x10, 0xb2, 0xe2, 0x78, 0xb1, 0x40, 0x9e, 0xf1, 0xc5, 0x42, 0x79, 0x46, 0x27, 0x56, 0x2e, 0xe6, - 0xe2, 0xd2, 0x5c, 0xa7, 0xa0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, - 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2, - 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0xf2, 0x05, 0x12, 0x13, - 0xe2, 0x4c, 0x0c, 0x1f, 0x26, 0xb1, 0x81, 0x25, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe8, - 0x1d, 0x1e, 0xe2, 0xfd, 0x00, 0x00, 0x00, -} - -func (this *PublicKey) Compare(that interface{}) int { - if that == nil { - if this == nil { - return 0 - } - return 1 - } - - that1, ok := that.(*PublicKey) - if !ok { - that2, ok := that.(PublicKey) - if ok { - that1 = &that2 - } else { - return 1 - } - } - if that1 == nil { - if this == nil { - return 0 - } - return 1 - } else if this == nil { - return -1 - } - if that1.Sum == nil { - if this.Sum != nil { - return 1 - } - } else if this.Sum == nil { - return -1 - } else { - thisType := -1 - switch this.Sum.(type) { - case *PublicKey_Ed25519: - thisType = 0 - case *PublicKey_Secp256K1: - thisType = 1 - default: - panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Sum)) - } - that1Type := -1 - switch that1.Sum.(type) { - case *PublicKey_Ed25519: - that1Type = 0 - case *PublicKey_Secp256K1: - that1Type = 1 - default: - panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.Sum)) - } - if thisType == that1Type { - if c := this.Sum.Compare(that1.Sum); c != 0 { - return c - } - } else if thisType < that1Type { - return -1 - } else if thisType > that1Type { - return 1 - } - } - return 0 -} - -func (this *PublicKey_Ed25519) Compare(that interface{}) int { - if that == nil { - if this == nil { - return 0 - } - return 1 - } - - that1, ok := that.(*PublicKey_Ed25519) - if !ok { - that2, ok := that.(PublicKey_Ed25519) - if ok { - that1 = &that2 - } else { - return 1 - } - } - if that1 == nil { - if this == nil { - return 0 - } - return 1 - } else if this == nil { - return -1 - } - if c := bytes.Compare(this.Ed25519, that1.Ed25519); c != 0 { - return c - } - return 0 -} - -func (this *PublicKey_Secp256K1) Compare(that interface{}) int { - if that == nil { - if this == nil { - return 0 - } - return 1 - } - - that1, ok := that.(*PublicKey_Secp256K1) - if !ok { - that2, ok := that.(PublicKey_Secp256K1) - if ok { - that1 = &that2 - } else { - return 1 - } - } - if that1 == nil { - if this == nil { - return 0 - } - return 1 - } else if this == nil { - return -1 - } - if c := bytes.Compare(this.Secp256K1, that1.Secp256K1); c != 0 { - return c - } - return 0 -} - -func (this *PublicKey) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey) - if !ok { - that2, ok := that.(PublicKey) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if that1.Sum == nil { - if this.Sum != nil { - return false - } - } else if this.Sum == nil { - return false - } else if !this.Sum.Equal(that1.Sum) { - return false - } - return true -} - -func (this *PublicKey_Ed25519) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey_Ed25519) - if !ok { - that2, ok := that.(PublicKey_Ed25519) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.Ed25519, that1.Ed25519) { - return false - } - return true -} - -func (this *PublicKey_Secp256K1) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey_Secp256K1) - if !ok { - that2, ok := that.(PublicKey_Secp256K1) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.Secp256K1, that1.Secp256K1) { - return false - } - return true -} - -func (m *PublicKey) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PublicKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *PublicKey_Ed25519) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey_Ed25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Ed25519 != nil { - i -= len(m.Ed25519) - copy(dAtA[i:], m.Ed25519) - i = encodeVarintKeys(dAtA, i, uint64(len(m.Ed25519))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PublicKey_Secp256K1) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey_Secp256K1) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Secp256K1 != nil { - i -= len(m.Secp256K1) - copy(dAtA[i:], m.Secp256K1) - i = encodeVarintKeys(dAtA, i, uint64(len(m.Secp256K1))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { - offset -= sovKeys(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *PublicKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *PublicKey_Ed25519) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Ed25519 != nil { - l = len(m.Ed25519) - n += 1 + l + sovKeys(uint64(l)) - } - return n -} - -func (m *PublicKey_Secp256K1) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Secp256K1 != nil { - l = len(m.Secp256K1) - n += 1 + l + sovKeys(uint64(l)) - } - return n -} - -func sovKeys(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozKeys(x uint64) (n int) { - return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *PublicKey) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowKeys - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PublicKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PublicKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowKeys - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthKeys - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthKeys - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Sum = &PublicKey_Ed25519{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Secp256K1", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowKeys - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthKeys - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthKeys - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Sum = &PublicKey_Secp256K1{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipKeys(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthKeys - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipKeys(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowKeys - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowKeys - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowKeys - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthKeys - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupKeys - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthKeys - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/crypto/keys.proto b/third_party/proto/tendermint/crypto/keys.proto deleted file mode 100644 index 16fd7adf3e..0000000000 --- a/third_party/proto/tendermint/crypto/keys.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package tendermint.crypto; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; - -import "gogoproto/gogo.proto"; - -// PublicKey defines the keys available for use with Tendermint Validators -message PublicKey { - option (gogoproto.compare) = true; - option (gogoproto.equal) = true; - - oneof sum { - bytes ed25519 = 1; - bytes secp256k1 = 2; - } -} diff --git a/third_party/proto/tendermint/crypto/proof.pb.go b/third_party/proto/tendermint/crypto/proof.pb.go deleted file mode 100644 index 7437cfafec..0000000000 --- a/third_party/proto/tendermint/crypto/proof.pb.go +++ /dev/null @@ -1,1458 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/crypto/proof.proto - -package crypto - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Proof struct { - Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - Index int64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` - LeafHash []byte `protobuf:"bytes,3,opt,name=leaf_hash,json=leafHash,proto3" json:"leaf_hash,omitempty"` - Aunts [][]byte `protobuf:"bytes,4,rep,name=aunts,proto3" json:"aunts,omitempty"` -} - -func (m *Proof) Reset() { *m = Proof{} } -func (m *Proof) String() string { return proto.CompactTextString(m) } -func (*Proof) ProtoMessage() {} -func (*Proof) Descriptor() ([]byte, []int) { - return fileDescriptor_6b60b6ba2ab5b856, []int{0} -} - -func (m *Proof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Proof.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Proof) XXX_Merge(src proto.Message) { - xxx_messageInfo_Proof.Merge(m, src) -} - -func (m *Proof) XXX_Size() int { - return m.Size() -} - -func (m *Proof) XXX_DiscardUnknown() { - xxx_messageInfo_Proof.DiscardUnknown(m) -} - -var xxx_messageInfo_Proof proto.InternalMessageInfo - -func (m *Proof) GetTotal() int64 { - if m != nil { - return m.Total - } - return 0 -} - -func (m *Proof) GetIndex() int64 { - if m != nil { - return m.Index - } - return 0 -} - -func (m *Proof) GetLeafHash() []byte { - if m != nil { - return m.LeafHash - } - return nil -} - -func (m *Proof) GetAunts() [][]byte { - if m != nil { - return m.Aunts - } - return nil -} - -type ValueOp struct { - // Encoded in ProofOp.Key. - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // To encode in ProofOp.Data - Proof *Proof `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` -} - -func (m *ValueOp) Reset() { *m = ValueOp{} } -func (m *ValueOp) String() string { return proto.CompactTextString(m) } -func (*ValueOp) ProtoMessage() {} -func (*ValueOp) Descriptor() ([]byte, []int) { - return fileDescriptor_6b60b6ba2ab5b856, []int{1} -} - -func (m *ValueOp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ValueOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValueOp.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ValueOp) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValueOp.Merge(m, src) -} - -func (m *ValueOp) XXX_Size() int { - return m.Size() -} - -func (m *ValueOp) XXX_DiscardUnknown() { - xxx_messageInfo_ValueOp.DiscardUnknown(m) -} - -var xxx_messageInfo_ValueOp proto.InternalMessageInfo - -func (m *ValueOp) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *ValueOp) GetProof() *Proof { - if m != nil { - return m.Proof - } - return nil -} - -type DominoOp struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Input string `protobuf:"bytes,2,opt,name=input,proto3" json:"input,omitempty"` - Output string `protobuf:"bytes,3,opt,name=output,proto3" json:"output,omitempty"` -} - -func (m *DominoOp) Reset() { *m = DominoOp{} } -func (m *DominoOp) String() string { return proto.CompactTextString(m) } -func (*DominoOp) ProtoMessage() {} -func (*DominoOp) Descriptor() ([]byte, []int) { - return fileDescriptor_6b60b6ba2ab5b856, []int{2} -} - -func (m *DominoOp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *DominoOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DominoOp.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *DominoOp) XXX_Merge(src proto.Message) { - xxx_messageInfo_DominoOp.Merge(m, src) -} - -func (m *DominoOp) XXX_Size() int { - return m.Size() -} - -func (m *DominoOp) XXX_DiscardUnknown() { - xxx_messageInfo_DominoOp.DiscardUnknown(m) -} - -var xxx_messageInfo_DominoOp proto.InternalMessageInfo - -func (m *DominoOp) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *DominoOp) GetInput() string { - if m != nil { - return m.Input - } - return "" -} - -func (m *DominoOp) GetOutput() string { - if m != nil { - return m.Output - } - return "" -} - -// ProofOp defines an operation used for calculating Merkle root -// The data could be arbitrary format, providing necessary data -// for example neighbouring node hash -type ProofOp struct { - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *ProofOp) Reset() { *m = ProofOp{} } -func (m *ProofOp) String() string { return proto.CompactTextString(m) } -func (*ProofOp) ProtoMessage() {} -func (*ProofOp) Descriptor() ([]byte, []int) { - return fileDescriptor_6b60b6ba2ab5b856, []int{3} -} - -func (m *ProofOp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ProofOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProofOp.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ProofOp) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProofOp.Merge(m, src) -} - -func (m *ProofOp) XXX_Size() int { - return m.Size() -} - -func (m *ProofOp) XXX_DiscardUnknown() { - xxx_messageInfo_ProofOp.DiscardUnknown(m) -} - -var xxx_messageInfo_ProofOp proto.InternalMessageInfo - -func (m *ProofOp) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *ProofOp) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *ProofOp) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -// ProofOps is Merkle proof defined by the list of ProofOps -type ProofOps struct { - Ops []ProofOp `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops"` -} - -func (m *ProofOps) Reset() { *m = ProofOps{} } -func (m *ProofOps) String() string { return proto.CompactTextString(m) } -func (*ProofOps) ProtoMessage() {} -func (*ProofOps) Descriptor() ([]byte, []int) { - return fileDescriptor_6b60b6ba2ab5b856, []int{4} -} - -func (m *ProofOps) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ProofOps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProofOps.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ProofOps) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProofOps.Merge(m, src) -} - -func (m *ProofOps) XXX_Size() int { - return m.Size() -} - -func (m *ProofOps) XXX_DiscardUnknown() { - xxx_messageInfo_ProofOps.DiscardUnknown(m) -} - -var xxx_messageInfo_ProofOps proto.InternalMessageInfo - -func (m *ProofOps) GetOps() []ProofOp { - if m != nil { - return m.Ops - } - return nil -} - -func init() { - proto.RegisterType((*Proof)(nil), "tendermint.crypto.Proof") - proto.RegisterType((*ValueOp)(nil), "tendermint.crypto.ValueOp") - proto.RegisterType((*DominoOp)(nil), "tendermint.crypto.DominoOp") - proto.RegisterType((*ProofOp)(nil), "tendermint.crypto.ProofOp") - proto.RegisterType((*ProofOps)(nil), "tendermint.crypto.ProofOps") -} - -func init() { proto.RegisterFile("tendermint/crypto/proof.proto", fileDescriptor_6b60b6ba2ab5b856) } - -var fileDescriptor_6b60b6ba2ab5b856 = []byte{ - // 351 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xbb, 0x4e, 0xc3, 0x30, - 0x14, 0x4d, 0xea, 0xf4, 0x75, 0xdb, 0x01, 0xac, 0x0a, 0x45, 0x45, 0x84, 0x28, 0x53, 0xa6, 0x44, - 0x2a, 0x0b, 0x13, 0x43, 0x61, 0x40, 0x30, 0x14, 0x79, 0x60, 0x60, 0x41, 0x6e, 0xeb, 0x36, 0x11, - 0x6d, 0x6c, 0x25, 0x8e, 0x44, 0xff, 0x82, 0xcf, 0xea, 0xd8, 0x91, 0x09, 0xa1, 0xf6, 0x47, 0x90, - 0xed, 0xa0, 0x16, 0x55, 0x6c, 0xe7, 0x71, 0x7d, 0x7c, 0xac, 0x6b, 0xb8, 0x90, 0x2c, 0x9b, 0xb2, - 0x7c, 0x99, 0x66, 0x32, 0x9e, 0xe4, 0x2b, 0x21, 0x79, 0x2c, 0x72, 0xce, 0x67, 0x91, 0xc8, 0xb9, - 0xe4, 0xf8, 0x74, 0x6f, 0x47, 0xc6, 0xee, 0xf7, 0xe6, 0x7c, 0xce, 0xb5, 0x1b, 0x2b, 0x64, 0x06, - 0x83, 0x19, 0xd4, 0x9f, 0xd4, 0x39, 0xdc, 0x83, 0xba, 0xe4, 0x92, 0x2e, 0x5c, 0xdb, 0xb7, 0x43, - 0x44, 0x0c, 0x51, 0x6a, 0x9a, 0x4d, 0xd9, 0xbb, 0x5b, 0x33, 0xaa, 0x26, 0xf8, 0x1c, 0xda, 0x0b, - 0x46, 0x67, 0xaf, 0x09, 0x2d, 0x12, 0x17, 0xf9, 0x76, 0xd8, 0x25, 0x2d, 0x25, 0xdc, 0xd3, 0x22, - 0x51, 0x47, 0x68, 0x99, 0xc9, 0xc2, 0x75, 0x7c, 0x14, 0x76, 0x89, 0x21, 0xc1, 0x23, 0x34, 0x9f, - 0xe9, 0xa2, 0x64, 0x23, 0x81, 0x4f, 0x00, 0xbd, 0xb1, 0x95, 0xbe, 0xa7, 0x4b, 0x14, 0xc4, 0x11, - 0xd4, 0x75, 0x79, 0x7d, 0x4b, 0x67, 0xe0, 0x46, 0x47, 0xed, 0x23, 0x5d, 0x92, 0x98, 0xb1, 0xe0, - 0x01, 0x5a, 0x77, 0x7c, 0x99, 0x66, 0xfc, 0x6f, 0x5a, 0xdb, 0xa4, 0xe9, 0xce, 0xa2, 0x94, 0x3a, - 0xad, 0x4d, 0x0c, 0xc1, 0x67, 0xd0, 0xe0, 0xa5, 0x54, 0x32, 0xd2, 0x72, 0xc5, 0x82, 0x5b, 0x68, - 0xea, 0xec, 0x91, 0xc0, 0x18, 0x1c, 0xb9, 0x12, 0xac, 0xca, 0xd2, 0xf8, 0x37, 0xbe, 0xb6, 0x2f, - 0x8b, 0xc1, 0x99, 0x52, 0x49, 0xab, 0x77, 0x6b, 0x1c, 0xdc, 0x40, 0xab, 0x0a, 0x29, 0xf0, 0x00, - 0x10, 0x17, 0x85, 0x6b, 0xfb, 0x28, 0xec, 0x0c, 0xfa, 0xff, 0x3d, 0x65, 0x24, 0x86, 0xce, 0xfa, - 0xeb, 0xd2, 0x22, 0x6a, 0x78, 0x48, 0xd6, 0x5b, 0xcf, 0xde, 0x6c, 0x3d, 0xfb, 0x7b, 0xeb, 0xd9, - 0x1f, 0x3b, 0xcf, 0xda, 0xec, 0x3c, 0xeb, 0x73, 0xe7, 0x59, 0x2f, 0xd7, 0xf3, 0x54, 0x26, 0xe5, - 0x38, 0x9a, 0xf0, 0x65, 0x7c, 0xb0, 0xf2, 0x03, 0x68, 0x56, 0x7a, 0xf4, 0x1d, 0xc6, 0x0d, 0x6d, - 0x5c, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x43, 0x5d, 0xb9, 0x45, 0x2a, 0x02, 0x00, 0x00, -} - -func (m *Proof) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Proof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Aunts) > 0 { - for iNdEx := len(m.Aunts) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Aunts[iNdEx]) - copy(dAtA[i:], m.Aunts[iNdEx]) - i = encodeVarintProof(dAtA, i, uint64(len(m.Aunts[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.LeafHash) > 0 { - i -= len(m.LeafHash) - copy(dAtA[i:], m.LeafHash) - i = encodeVarintProof(dAtA, i, uint64(len(m.LeafHash))) - i-- - dAtA[i] = 0x1a - } - if m.Index != 0 { - i = encodeVarintProof(dAtA, i, uint64(m.Index)) - i-- - dAtA[i] = 0x10 - } - if m.Total != 0 { - i = encodeVarintProof(dAtA, i, uint64(m.Total)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ValueOp) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ValueOp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValueOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proof != nil { - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProof(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProof(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DominoOp) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DominoOp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DominoOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Output) > 0 { - i -= len(m.Output) - copy(dAtA[i:], m.Output) - i = encodeVarintProof(dAtA, i, uint64(len(m.Output))) - i-- - dAtA[i] = 0x1a - } - if len(m.Input) > 0 { - i -= len(m.Input) - copy(dAtA[i:], m.Input) - i = encodeVarintProof(dAtA, i, uint64(len(m.Input))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProof(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProofOp) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProofOp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProofOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintProof(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x1a - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProof(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0x12 - } - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintProof(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProofOps) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProofOps) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProofOps) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Ops) > 0 { - for iNdEx := len(m.Ops) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Ops[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProof(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintProof(dAtA []byte, offset int, v uint64) int { - offset -= sovProof(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *Proof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Total != 0 { - n += 1 + sovProof(uint64(m.Total)) - } - if m.Index != 0 { - n += 1 + sovProof(uint64(m.Index)) - } - l = len(m.LeafHash) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - if len(m.Aunts) > 0 { - for _, b := range m.Aunts { - l = len(b) - n += 1 + l + sovProof(uint64(l)) - } - } - return n -} - -func (m *ValueOp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - if m.Proof != nil { - l = m.Proof.Size() - n += 1 + l + sovProof(uint64(l)) - } - return n -} - -func (m *DominoOp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - l = len(m.Input) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - l = len(m.Output) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - return n -} - -func (m *ProofOp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Type) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovProof(uint64(l)) - } - return n -} - -func (m *ProofOps) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Ops) > 0 { - for _, e := range m.Ops { - l = e.Size() - n += 1 + l + sovProof(uint64(l)) - } - } - return n -} - -func sovProof(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozProof(x uint64) (n int) { - return sovProof(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Proof) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Proof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Proof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) - } - m.Total = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Total |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - m.Index = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Index |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LeafHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LeafHash = append(m.LeafHash[:0], dAtA[iNdEx:postIndex]...) - if m.LeafHash == nil { - m.LeafHash = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Aunts", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Aunts = append(m.Aunts, make([]byte, postIndex-iNdEx)) - copy(m.Aunts[len(m.Aunts)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProof(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ValueOp) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ValueOp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValueOp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Proof == nil { - m.Proof = &Proof{} - } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProof(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *DominoOp) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DominoOp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DominoOp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Input", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Input = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Output", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Output = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProof(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ProofOp) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProofOp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProofOp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProof(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ProofOps) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProofOps: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProofOps: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ops", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProof - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProof - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProof - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ops = append(m.Ops, ProofOp{}) - if err := m.Ops[len(m.Ops)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProof(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProof - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipProof(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProof - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProof - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProof - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthProof - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupProof - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthProof - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthProof = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowProof = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupProof = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/crypto/proof.proto b/third_party/proto/tendermint/crypto/proof.proto deleted file mode 100644 index 975df76853..0000000000 --- a/third_party/proto/tendermint/crypto/proof.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; -package tendermint.crypto; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; - -import "gogoproto/gogo.proto"; - -message Proof { - int64 total = 1; - int64 index = 2; - bytes leaf_hash = 3; - repeated bytes aunts = 4; -} - -message ValueOp { - // Encoded in ProofOp.Key. - bytes key = 1; - - // To encode in ProofOp.Data - Proof proof = 2; -} - -message DominoOp { - string key = 1; - string input = 2; - string output = 3; -} - -// ProofOp defines an operation used for calculating Merkle root -// The data could be arbitrary format, providing nessecary data -// for example neighbouring node hash -message ProofOp { - string type = 1; - bytes key = 2; - bytes data = 3; -} - -// ProofOps is Merkle proof defined by the list of ProofOps -message ProofOps { - repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/tendermint/libs/bits/types.pb.go b/third_party/proto/tendermint/libs/bits/types.pb.go deleted file mode 100644 index af529c7936..0000000000 --- a/third_party/proto/tendermint/libs/bits/types.pb.go +++ /dev/null @@ -1,421 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/libs/bits/types.proto - -package bits - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type BitArray struct { - Bits int64 `protobuf:"varint,1,opt,name=bits,proto3" json:"bits,omitempty"` - Elems []uint64 `protobuf:"varint,2,rep,packed,name=elems,proto3" json:"elems,omitempty"` -} - -func (m *BitArray) Reset() { *m = BitArray{} } -func (m *BitArray) String() string { return proto.CompactTextString(m) } -func (*BitArray) ProtoMessage() {} -func (*BitArray) Descriptor() ([]byte, []int) { - return fileDescriptor_e91ab2672920d7d4, []int{0} -} - -func (m *BitArray) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *BitArray) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BitArray.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *BitArray) XXX_Merge(src proto.Message) { - xxx_messageInfo_BitArray.Merge(m, src) -} - -func (m *BitArray) XXX_Size() int { - return m.Size() -} - -func (m *BitArray) XXX_DiscardUnknown() { - xxx_messageInfo_BitArray.DiscardUnknown(m) -} - -var xxx_messageInfo_BitArray proto.InternalMessageInfo - -func (m *BitArray) GetBits() int64 { - if m != nil { - return m.Bits - } - return 0 -} - -func (m *BitArray) GetElems() []uint64 { - if m != nil { - return m.Elems - } - return nil -} - -func init() { - proto.RegisterType((*BitArray)(nil), "tendermint.libs.bits.BitArray") -} - -func init() { proto.RegisterFile("tendermint/libs/bits/types.proto", fileDescriptor_e91ab2672920d7d4) } - -var fileDescriptor_e91ab2672920d7d4 = []byte{ - // 168 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0xcf, 0xc9, 0x4c, 0x2a, 0xd6, 0x4f, 0xca, 0x2c, 0x29, - 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8, - 0xd0, 0x03, 0xa9, 0xd0, 0x03, 0xa9, 0x50, 0x32, 0xe1, 0xe2, 0x70, 0xca, 0x2c, 0x71, 0x2c, 0x2a, - 0x4a, 0xac, 0x14, 0x12, 0xe2, 0x62, 0x01, 0x89, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x81, - 0xd9, 0x42, 0x22, 0x5c, 0xac, 0xa9, 0x39, 0xa9, 0xb9, 0xc5, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0x2c, - 0x41, 0x10, 0x8e, 0x53, 0xe8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, - 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, - 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x39, 0x09, 0x89, 0x09, - 0x76, 0x8d, 0x3e, 0x36, 0xe7, 0x26, 0xb1, 0x81, 0xe5, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x5b, 0x0c, 0xe3, 0x3e, 0xcd, 0x00, 0x00, 0x00, -} - -func (m *BitArray) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BitArray) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BitArray) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Elems) > 0 { - dAtA2 := make([]byte, len(m.Elems)*10) - var j1 int - for _, num := range m.Elems { - for num >= 1<<7 { - dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j1++ - } - dAtA2[j1] = uint8(num) - j1++ - } - i -= j1 - copy(dAtA[i:], dAtA2[:j1]) - i = encodeVarintTypes(dAtA, i, uint64(j1)) - i-- - dAtA[i] = 0x12 - } - if m.Bits != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Bits)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *BitArray) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Bits != 0 { - n += 1 + sovTypes(uint64(m.Bits)) - } - if len(m.Elems) > 0 { - l = 0 - for _, e := range m.Elems { - l += sovTypes(uint64(e)) - } - n += 1 + sovTypes(uint64(l)) + l - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *BitArray) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BitArray: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BitArray: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType) - } - m.Bits = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Bits |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Elems = append(m.Elems, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Elems) == 0 { - m.Elems = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Elems = append(m.Elems, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Elems", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/libs/bits/types.proto b/third_party/proto/tendermint/libs/bits/types.proto deleted file mode 100644 index 3111d113a5..0000000000 --- a/third_party/proto/tendermint/libs/bits/types.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; -package tendermint.libs.bits; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits"; - -message BitArray { - int64 bits = 1; - repeated uint64 elems = 2; -} diff --git a/third_party/proto/tendermint/mempool/types.pb.go b/third_party/proto/tendermint/mempool/types.pb.go deleted file mode 100644 index 95374d3343..0000000000 --- a/third_party/proto/tendermint/mempool/types.pb.go +++ /dev/null @@ -1,576 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/mempool/types.proto - -package mempool - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Txs struct { - Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` -} - -func (m *Txs) Reset() { *m = Txs{} } -func (m *Txs) String() string { return proto.CompactTextString(m) } -func (*Txs) ProtoMessage() {} -func (*Txs) Descriptor() ([]byte, []int) { - return fileDescriptor_2af51926fdbcbc05, []int{0} -} - -func (m *Txs) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Txs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Txs.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Txs) XXX_Merge(src proto.Message) { - xxx_messageInfo_Txs.Merge(m, src) -} - -func (m *Txs) XXX_Size() int { - return m.Size() -} - -func (m *Txs) XXX_DiscardUnknown() { - xxx_messageInfo_Txs.DiscardUnknown(m) -} - -var xxx_messageInfo_Txs proto.InternalMessageInfo - -func (m *Txs) GetTxs() [][]byte { - if m != nil { - return m.Txs - } - return nil -} - -type Message struct { - // Types that are valid to be assigned to Sum: - // *Message_Txs - Sum isMessage_Sum `protobuf_oneof:"sum"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_2af51926fdbcbc05, []int{1} -} - -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} - -func (m *Message) XXX_Size() int { - return m.Size() -} - -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -type isMessage_Sum interface { - isMessage_Sum() - MarshalTo([]byte) (int, error) - Size() int -} - -type Message_Txs struct { - Txs *Txs `protobuf:"bytes,1,opt,name=txs,proto3,oneof" json:"txs,omitempty"` -} - -func (*Message_Txs) isMessage_Sum() {} - -func (m *Message) GetSum() isMessage_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *Message) GetTxs() *Txs { - if x, ok := m.GetSum().(*Message_Txs); ok { - return x.Txs - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Message) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Message_Txs)(nil), - } -} - -func init() { - proto.RegisterType((*Txs)(nil), "tendermint.mempool.Txs") - proto.RegisterType((*Message)(nil), "tendermint.mempool.Message") -} - -func init() { proto.RegisterFile("tendermint/mempool/types.proto", fileDescriptor_2af51926fdbcbc05) } - -var fileDescriptor_2af51926fdbcbc05 = []byte{ - // 179 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0xcf, 0x4d, 0xcd, 0x2d, 0xc8, 0xcf, 0xcf, 0xd1, 0x2f, - 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0xc8, 0xeb, 0x41, - 0xe5, 0x95, 0xc4, 0xb9, 0x98, 0x43, 0x2a, 0x8a, 0x85, 0x04, 0xb8, 0x98, 0x4b, 0x2a, 0x8a, 0x25, - 0x18, 0x15, 0x98, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x25, 0x5b, 0x2e, 0x76, 0xdf, 0xd4, 0xe2, 0xe2, - 0xc4, 0xf4, 0x54, 0x21, 0x6d, 0x98, 0x24, 0xa3, 0x06, 0xb7, 0x91, 0xb8, 0x1e, 0xa6, 0x29, 0x7a, - 0x21, 0x15, 0xc5, 0x1e, 0x0c, 0x60, 0x7d, 0x4e, 0xac, 0x5c, 0xcc, 0xc5, 0xa5, 0xb9, 0x4e, 0xc1, - 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, - 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x99, 0x9e, 0x59, 0x92, 0x51, - 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xe4, 0x60, 0x24, 0x26, 0xd8, 0xb5, 0xfa, 0x98, 0x9e, - 0x49, 0x62, 0x03, 0xcb, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xca, 0xc3, 0xa0, 0xfc, 0xe9, - 0x00, 0x00, 0x00, -} - -func (m *Txs) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Txs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Txs) > 0 { - for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Txs[iNdEx]) - copy(dAtA[i:], m.Txs[iNdEx]) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Txs[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Message) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Message_Txs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Txs != nil { - { - size, err := m.Txs.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *Txs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Txs) > 0 { - for _, b := range m.Txs { - l = len(b) - n += 1 + l + sovTypes(uint64(l)) - } - } - return n -} - -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *Message_Txs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Txs != nil { - l = m.Txs.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Txs) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Txs: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Txs: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Txs = append(m.Txs, make([]byte, postIndex-iNdEx)) - copy(m.Txs[len(m.Txs)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *Message) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Txs{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_Txs{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/mempool/types.proto b/third_party/proto/tendermint/mempool/types.proto deleted file mode 100644 index b55d9717b1..0000000000 --- a/third_party/proto/tendermint/mempool/types.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; -package tendermint.mempool; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/mempool"; - -message Txs { - repeated bytes txs = 1; -} - -message Message { - oneof sum { - Txs txs = 1; - } -} diff --git a/third_party/proto/tendermint/p2p/conn.proto b/third_party/proto/tendermint/p2p/conn.proto deleted file mode 100644 index b12de6c827..0000000000 --- a/third_party/proto/tendermint/p2p/conn.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package tendermint.p2p; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - -import "gogoproto/gogo.proto"; -import "tendermint/crypto/keys.proto"; - -message PacketPing {} - -message PacketPong {} - -message PacketMsg { - int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"]; - bool eof = 2 [(gogoproto.customname) = "EOF"]; - bytes data = 3; -} - -message Packet { - oneof sum { - PacketPing packet_ping = 1; - PacketPong packet_pong = 2; - PacketMsg packet_msg = 3; - } -} - -message AuthSigMessage { - tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false]; - bytes sig = 2; -} diff --git a/third_party/proto/tendermint/p2p/pex.pb.go b/third_party/proto/tendermint/p2p/pex.pb.go deleted file mode 100644 index 3252f41a29..0000000000 --- a/third_party/proto/tendermint/p2p/pex.pb.go +++ /dev/null @@ -1,796 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/p2p/pex.proto - -package p2p - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type PexRequest struct{} - -func (m *PexRequest) Reset() { *m = PexRequest{} } -func (m *PexRequest) String() string { return proto.CompactTextString(m) } -func (*PexRequest) ProtoMessage() {} -func (*PexRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_81c2f011fd13be57, []int{0} -} - -func (m *PexRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *PexRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PexRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *PexRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PexRequest.Merge(m, src) -} - -func (m *PexRequest) XXX_Size() int { - return m.Size() -} - -func (m *PexRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PexRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PexRequest proto.InternalMessageInfo - -type PexAddrs struct { - Addrs []NetAddress `protobuf:"bytes,1,rep,name=addrs,proto3" json:"addrs"` -} - -func (m *PexAddrs) Reset() { *m = PexAddrs{} } -func (m *PexAddrs) String() string { return proto.CompactTextString(m) } -func (*PexAddrs) ProtoMessage() {} -func (*PexAddrs) Descriptor() ([]byte, []int) { - return fileDescriptor_81c2f011fd13be57, []int{1} -} - -func (m *PexAddrs) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *PexAddrs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PexAddrs.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *PexAddrs) XXX_Merge(src proto.Message) { - xxx_messageInfo_PexAddrs.Merge(m, src) -} - -func (m *PexAddrs) XXX_Size() int { - return m.Size() -} - -func (m *PexAddrs) XXX_DiscardUnknown() { - xxx_messageInfo_PexAddrs.DiscardUnknown(m) -} - -var xxx_messageInfo_PexAddrs proto.InternalMessageInfo - -func (m *PexAddrs) GetAddrs() []NetAddress { - if m != nil { - return m.Addrs - } - return nil -} - -type Message struct { - // Types that are valid to be assigned to Sum: - // *Message_PexRequest - // *Message_PexAddrs - Sum isMessage_Sum `protobuf_oneof:"sum"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_81c2f011fd13be57, []int{2} -} - -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} - -func (m *Message) XXX_Size() int { - return m.Size() -} - -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -type isMessage_Sum interface { - isMessage_Sum() - MarshalTo([]byte) (int, error) - Size() int -} - -type Message_PexRequest struct { - PexRequest *PexRequest `protobuf:"bytes,1,opt,name=pex_request,json=pexRequest,proto3,oneof" json:"pex_request,omitempty"` -} -type Message_PexAddrs struct { - PexAddrs *PexAddrs `protobuf:"bytes,2,opt,name=pex_addrs,json=pexAddrs,proto3,oneof" json:"pex_addrs,omitempty"` -} - -func (*Message_PexRequest) isMessage_Sum() {} -func (*Message_PexAddrs) isMessage_Sum() {} - -func (m *Message) GetSum() isMessage_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *Message) GetPexRequest() *PexRequest { - if x, ok := m.GetSum().(*Message_PexRequest); ok { - return x.PexRequest - } - return nil -} - -func (m *Message) GetPexAddrs() *PexAddrs { - if x, ok := m.GetSum().(*Message_PexAddrs); ok { - return x.PexAddrs - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Message) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Message_PexRequest)(nil), - (*Message_PexAddrs)(nil), - } -} - -func init() { - proto.RegisterType((*PexRequest)(nil), "tendermint.p2p.PexRequest") - proto.RegisterType((*PexAddrs)(nil), "tendermint.p2p.PexAddrs") - proto.RegisterType((*Message)(nil), "tendermint.p2p.Message") -} - -func init() { proto.RegisterFile("tendermint/p2p/pex.proto", fileDescriptor_81c2f011fd13be57) } - -var fileDescriptor_81c2f011fd13be57 = []byte{ - // 268 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x30, 0x2a, 0xd0, 0x2f, 0x48, 0xad, 0xd0, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x43, 0xc8, 0xe8, 0x15, 0x18, 0x15, 0x48, 0x49, 0xa1, 0xa9, - 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0xa8, 0x95, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x33, 0xf5, - 0x41, 0x2c, 0x88, 0xa8, 0x12, 0x0f, 0x17, 0x57, 0x40, 0x6a, 0x45, 0x50, 0x6a, 0x61, 0x69, 0x6a, - 0x71, 0x89, 0x92, 0x13, 0x17, 0x47, 0x40, 0x6a, 0x85, 0x63, 0x4a, 0x4a, 0x51, 0xb1, 0x90, 0x19, - 0x17, 0x6b, 0x22, 0x88, 0x21, 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xa5, 0x87, 0x6a, 0x97, - 0x9e, 0x5f, 0x6a, 0x09, 0x48, 0x61, 0x6a, 0x71, 0xb1, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, - 0x10, 0xe5, 0x4a, 0x1d, 0x8c, 0x5c, 0xec, 0xbe, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x42, 0xb6, - 0x5c, 0xdc, 0x05, 0xa9, 0x15, 0xf1, 0x45, 0x10, 0xe3, 0x25, 0x18, 0x15, 0x18, 0xb1, 0x99, 0x84, - 0x70, 0x80, 0x07, 0x43, 0x10, 0x57, 0x01, 0x9c, 0x27, 0x64, 0xce, 0xc5, 0x09, 0xd2, 0x0e, 0x71, - 0x06, 0x13, 0x58, 0xb3, 0x04, 0x16, 0xcd, 0x60, 0xf7, 0x7a, 0x30, 0x04, 0x71, 0x14, 0x40, 0xd9, - 0x4e, 0xac, 0x5c, 0xcc, 0xc5, 0xa5, 0xb9, 0x4e, 0xfe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, - 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, - 0x2c, 0xc7, 0x10, 0x65, 0x9a, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, - 0x14, 0x66, 0xc8, 0xc1, 0x07, 0x0e, 0x29, 0xd4, 0xf0, 0x4c, 0x62, 0x03, 0x8b, 0x1a, 0x03, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x3c, 0x0b, 0xcb, 0x40, 0x92, 0x01, 0x00, 0x00, -} - -func (m *PexRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PexRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PexRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *PexAddrs) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PexAddrs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PexAddrs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Addrs) > 0 { - for iNdEx := len(m.Addrs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Addrs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPex(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Message) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Message_PexRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_PexRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PexRequest != nil { - { - size, err := m.PexRequest.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPex(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_PexAddrs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_PexAddrs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PexAddrs != nil { - { - size, err := m.PexAddrs.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPex(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func encodeVarintPex(dAtA []byte, offset int, v uint64) int { - offset -= sovPex(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *PexRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *PexAddrs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Addrs) > 0 { - for _, e := range m.Addrs { - l = e.Size() - n += 1 + l + sovPex(uint64(l)) - } - } - return n -} - -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *Message_PexRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PexRequest != nil { - l = m.PexRequest.Size() - n += 1 + l + sovPex(uint64(l)) - } - return n -} - -func (m *Message_PexAddrs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PexAddrs != nil { - l = m.PexAddrs.Size() - n += 1 + l + sovPex(uint64(l)) - } - return n -} - -func sovPex(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozPex(x uint64) (n int) { - return sovPex(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *PexRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PexRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PexRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipPex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *PexAddrs) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PexAddrs: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PexAddrs: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPex - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addrs = append(m.Addrs, NetAddress{}) - if err := m.Addrs[len(m.Addrs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *Message) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PexRequest", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPex - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PexRequest{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_PexRequest{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PexAddrs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPex - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PexAddrs{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_PexAddrs{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipPex(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPex - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPex - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPex - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthPex - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPex - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthPex - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthPex = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPex = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPex = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/p2p/pex.proto b/third_party/proto/tendermint/p2p/pex.proto deleted file mode 100644 index dfe238dbe6..0000000000 --- a/third_party/proto/tendermint/p2p/pex.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; -package tendermint.p2p; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - -import "tendermint/p2p/types.proto"; -import "gogoproto/gogo.proto"; - -message PexRequest {} - -message PexAddrs { - repeated NetAddress addrs = 1 [(gogoproto.nullable) = false]; -} - -message Message { - oneof sum { - PexRequest pex_request = 1; - PexAddrs pex_addrs = 2; - } -} diff --git a/third_party/proto/tendermint/p2p/types.pb.go b/third_party/proto/tendermint/p2p/types.pb.go deleted file mode 100644 index 8fc8ec4679..0000000000 --- a/third_party/proto/tendermint/p2p/types.pb.go +++ /dev/null @@ -1,1430 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/p2p/types.proto - -package p2p - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type NetAddress struct { - ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - IP string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` - Port uint32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` -} - -func (m *NetAddress) Reset() { *m = NetAddress{} } -func (m *NetAddress) String() string { return proto.CompactTextString(m) } -func (*NetAddress) ProtoMessage() {} -func (*NetAddress) Descriptor() ([]byte, []int) { - return fileDescriptor_c8a29e659aeca578, []int{0} -} - -func (m *NetAddress) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *NetAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NetAddress.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *NetAddress) XXX_Merge(src proto.Message) { - xxx_messageInfo_NetAddress.Merge(m, src) -} - -func (m *NetAddress) XXX_Size() int { - return m.Size() -} - -func (m *NetAddress) XXX_DiscardUnknown() { - xxx_messageInfo_NetAddress.DiscardUnknown(m) -} - -var xxx_messageInfo_NetAddress proto.InternalMessageInfo - -func (m *NetAddress) GetID() string { - if m != nil { - return m.ID - } - return "" -} - -func (m *NetAddress) GetIP() string { - if m != nil { - return m.IP - } - return "" -} - -func (m *NetAddress) GetPort() uint32 { - if m != nil { - return m.Port - } - return 0 -} - -type ProtocolVersion struct { - P2P uint64 `protobuf:"varint,1,opt,name=p2p,proto3" json:"p2p,omitempty"` - Block uint64 `protobuf:"varint,2,opt,name=block,proto3" json:"block,omitempty"` - App uint64 `protobuf:"varint,3,opt,name=app,proto3" json:"app,omitempty"` -} - -func (m *ProtocolVersion) Reset() { *m = ProtocolVersion{} } -func (m *ProtocolVersion) String() string { return proto.CompactTextString(m) } -func (*ProtocolVersion) ProtoMessage() {} -func (*ProtocolVersion) Descriptor() ([]byte, []int) { - return fileDescriptor_c8a29e659aeca578, []int{1} -} - -func (m *ProtocolVersion) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ProtocolVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProtocolVersion.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ProtocolVersion) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProtocolVersion.Merge(m, src) -} - -func (m *ProtocolVersion) XXX_Size() int { - return m.Size() -} - -func (m *ProtocolVersion) XXX_DiscardUnknown() { - xxx_messageInfo_ProtocolVersion.DiscardUnknown(m) -} - -var xxx_messageInfo_ProtocolVersion proto.InternalMessageInfo - -func (m *ProtocolVersion) GetP2P() uint64 { - if m != nil { - return m.P2P - } - return 0 -} - -func (m *ProtocolVersion) GetBlock() uint64 { - if m != nil { - return m.Block - } - return 0 -} - -func (m *ProtocolVersion) GetApp() uint64 { - if m != nil { - return m.App - } - return 0 -} - -type DefaultNodeInfo struct { - ProtocolVersion ProtocolVersion `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version"` - DefaultNodeID string `protobuf:"bytes,2,opt,name=default_node_id,json=defaultNodeId,proto3" json:"default_node_id,omitempty"` - ListenAddr string `protobuf:"bytes,3,opt,name=listen_addr,json=listenAddr,proto3" json:"listen_addr,omitempty"` - Network string `protobuf:"bytes,4,opt,name=network,proto3" json:"network,omitempty"` - Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` - Channels []byte `protobuf:"bytes,6,opt,name=channels,proto3" json:"channels,omitempty"` - Moniker string `protobuf:"bytes,7,opt,name=moniker,proto3" json:"moniker,omitempty"` - Other DefaultNodeInfoOther `protobuf:"bytes,8,opt,name=other,proto3" json:"other"` -} - -func (m *DefaultNodeInfo) Reset() { *m = DefaultNodeInfo{} } -func (m *DefaultNodeInfo) String() string { return proto.CompactTextString(m) } -func (*DefaultNodeInfo) ProtoMessage() {} -func (*DefaultNodeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_c8a29e659aeca578, []int{2} -} - -func (m *DefaultNodeInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *DefaultNodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DefaultNodeInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *DefaultNodeInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_DefaultNodeInfo.Merge(m, src) -} - -func (m *DefaultNodeInfo) XXX_Size() int { - return m.Size() -} - -func (m *DefaultNodeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_DefaultNodeInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_DefaultNodeInfo proto.InternalMessageInfo - -func (m *DefaultNodeInfo) GetProtocolVersion() ProtocolVersion { - if m != nil { - return m.ProtocolVersion - } - return ProtocolVersion{} -} - -func (m *DefaultNodeInfo) GetDefaultNodeID() string { - if m != nil { - return m.DefaultNodeID - } - return "" -} - -func (m *DefaultNodeInfo) GetListenAddr() string { - if m != nil { - return m.ListenAddr - } - return "" -} - -func (m *DefaultNodeInfo) GetNetwork() string { - if m != nil { - return m.Network - } - return "" -} - -func (m *DefaultNodeInfo) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *DefaultNodeInfo) GetChannels() []byte { - if m != nil { - return m.Channels - } - return nil -} - -func (m *DefaultNodeInfo) GetMoniker() string { - if m != nil { - return m.Moniker - } - return "" -} - -func (m *DefaultNodeInfo) GetOther() DefaultNodeInfoOther { - if m != nil { - return m.Other - } - return DefaultNodeInfoOther{} -} - -type DefaultNodeInfoOther struct { - TxIndex string `protobuf:"bytes,1,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` - RPCAddress string `protobuf:"bytes,2,opt,name=rpc_address,json=rpcAddress,proto3" json:"rpc_address,omitempty"` -} - -func (m *DefaultNodeInfoOther) Reset() { *m = DefaultNodeInfoOther{} } -func (m *DefaultNodeInfoOther) String() string { return proto.CompactTextString(m) } -func (*DefaultNodeInfoOther) ProtoMessage() {} -func (*DefaultNodeInfoOther) Descriptor() ([]byte, []int) { - return fileDescriptor_c8a29e659aeca578, []int{3} -} - -func (m *DefaultNodeInfoOther) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *DefaultNodeInfoOther) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DefaultNodeInfoOther.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *DefaultNodeInfoOther) XXX_Merge(src proto.Message) { - xxx_messageInfo_DefaultNodeInfoOther.Merge(m, src) -} - -func (m *DefaultNodeInfoOther) XXX_Size() int { - return m.Size() -} - -func (m *DefaultNodeInfoOther) XXX_DiscardUnknown() { - xxx_messageInfo_DefaultNodeInfoOther.DiscardUnknown(m) -} - -var xxx_messageInfo_DefaultNodeInfoOther proto.InternalMessageInfo - -func (m *DefaultNodeInfoOther) GetTxIndex() string { - if m != nil { - return m.TxIndex - } - return "" -} - -func (m *DefaultNodeInfoOther) GetRPCAddress() string { - if m != nil { - return m.RPCAddress - } - return "" -} - -func init() { - proto.RegisterType((*NetAddress)(nil), "tendermint.p2p.NetAddress") - proto.RegisterType((*ProtocolVersion)(nil), "tendermint.p2p.ProtocolVersion") - proto.RegisterType((*DefaultNodeInfo)(nil), "tendermint.p2p.DefaultNodeInfo") - proto.RegisterType((*DefaultNodeInfoOther)(nil), "tendermint.p2p.DefaultNodeInfoOther") -} - -func init() { proto.RegisterFile("tendermint/p2p/types.proto", fileDescriptor_c8a29e659aeca578) } - -var fileDescriptor_c8a29e659aeca578 = []byte{ - // 479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x3d, 0x8f, 0xda, 0x40, - 0x10, 0xc5, 0xc6, 0x7c, 0xdc, 0x10, 0x8e, 0xcb, 0x0a, 0x45, 0x3e, 0x0a, 0x1b, 0xa1, 0x14, 0x54, - 0x20, 0x39, 0x4a, 0x91, 0x2e, 0x21, 0x34, 0x34, 0x77, 0xd6, 0x2a, 0x4a, 0x91, 0xc6, 0x02, 0xef, - 0x1e, 0xac, 0x30, 0xbb, 0xab, 0xf5, 0x5e, 0x42, 0xfe, 0x45, 0x7e, 0xd6, 0x95, 0x57, 0xa6, 0xb2, - 0x22, 0x53, 0xe6, 0x4f, 0x44, 0x5e, 0xfb, 0x12, 0x1f, 0x4a, 0x37, 0x6f, 0xbe, 0xde, 0xcc, 0xd3, - 0x83, 0x91, 0xa6, 0x9c, 0x50, 0x75, 0x60, 0x5c, 0xcf, 0x65, 0x20, 0xe7, 0xfa, 0xbb, 0xa4, 0xe9, - 0x4c, 0x2a, 0xa1, 0x05, 0xba, 0xfc, 0x57, 0x9b, 0xc9, 0x40, 0x8e, 0x86, 0x5b, 0xb1, 0x15, 0xa6, - 0x34, 0x2f, 0xa2, 0xb2, 0x6b, 0x12, 0x02, 0xdc, 0x50, 0xfd, 0x81, 0x10, 0x45, 0xd3, 0x14, 0xbd, - 0x02, 0x9b, 0x11, 0xd7, 0x1a, 0x5b, 0xd3, 0x8b, 0x45, 0x3b, 0xcf, 0x7c, 0x7b, 0xb5, 0xc4, 0x36, - 0x23, 0x26, 0x2f, 0x5d, 0xbb, 0x96, 0x0f, 0xb1, 0xcd, 0x24, 0x42, 0xe0, 0x48, 0xa1, 0xb4, 0xdb, - 0x1c, 0x5b, 0xd3, 0x3e, 0x36, 0xf1, 0xe4, 0x13, 0x0c, 0xc2, 0x62, 0x75, 0x2c, 0x92, 0xcf, 0x54, - 0xa5, 0x4c, 0x70, 0x74, 0x0d, 0x4d, 0x19, 0x48, 0xb3, 0xd7, 0x59, 0x74, 0xf2, 0xcc, 0x6f, 0x86, - 0x41, 0x88, 0x8b, 0x1c, 0x1a, 0x42, 0x6b, 0x93, 0x88, 0x78, 0x6f, 0x96, 0x3b, 0xb8, 0x04, 0xe8, - 0x0a, 0x9a, 0x6b, 0x29, 0xcd, 0x5a, 0x07, 0x17, 0xe1, 0xe4, 0xb7, 0x0d, 0x83, 0x25, 0xbd, 0x5b, - 0xdf, 0x27, 0xfa, 0x46, 0x10, 0xba, 0xe2, 0x77, 0x02, 0x85, 0x70, 0x25, 0x2b, 0xa6, 0xe8, 0x6b, - 0x49, 0x65, 0x38, 0x7a, 0x81, 0x3f, 0x7b, 0xfe, 0xfc, 0xec, 0xec, 0xa2, 0x85, 0xf3, 0x90, 0xf9, - 0x0d, 0x3c, 0x90, 0x67, 0x87, 0xbe, 0x83, 0x01, 0x29, 0x49, 0x22, 0x2e, 0x08, 0x8d, 0x18, 0xa9, - 0x9e, 0x7e, 0x99, 0x67, 0x7e, 0xbf, 0xce, 0xbf, 0xc4, 0x7d, 0x52, 0x83, 0x04, 0xf9, 0xd0, 0x4b, - 0x58, 0xaa, 0x29, 0x8f, 0xd6, 0x84, 0x28, 0x73, 0xfa, 0x05, 0x86, 0x32, 0x55, 0xc8, 0x8b, 0x5c, - 0xe8, 0x70, 0xaa, 0xbf, 0x09, 0xb5, 0x77, 0x1d, 0x53, 0x7c, 0x82, 0x45, 0xe5, 0xe9, 0xfc, 0x56, - 0x59, 0xa9, 0x20, 0x1a, 0x41, 0x37, 0xde, 0xad, 0x39, 0xa7, 0x49, 0xea, 0xb6, 0xc7, 0xd6, 0xf4, - 0x05, 0xfe, 0x8b, 0x8b, 0xa9, 0x83, 0xe0, 0x6c, 0x4f, 0x95, 0xdb, 0x29, 0xa7, 0x2a, 0x88, 0xde, - 0x43, 0x4b, 0xe8, 0x1d, 0x55, 0x6e, 0xd7, 0x88, 0xf1, 0xfa, 0x5c, 0x8c, 0x33, 0x1d, 0x6f, 0x8b, - 0xde, 0x4a, 0x91, 0x72, 0x70, 0xb2, 0x81, 0xe1, 0xff, 0x9a, 0xd0, 0x35, 0x74, 0xf5, 0x31, 0x62, - 0x9c, 0xd0, 0x63, 0xe9, 0x12, 0xdc, 0xd1, 0xc7, 0x55, 0x01, 0xd1, 0x1c, 0x7a, 0x4a, 0xc6, 0xe6, - 0x79, 0x9a, 0xa6, 0x95, 0x6c, 0x97, 0x79, 0xe6, 0x03, 0x0e, 0x3f, 0x56, 0xfe, 0xc2, 0xa0, 0x64, - 0x5c, 0xc5, 0x8b, 0xdb, 0x87, 0xdc, 0xb3, 0x1e, 0x73, 0xcf, 0xfa, 0x95, 0x7b, 0xd6, 0x8f, 0x93, - 0xd7, 0x78, 0x3c, 0x79, 0x8d, 0x9f, 0x27, 0xaf, 0xf1, 0xe5, 0xed, 0x96, 0xe9, 0xdd, 0xfd, 0x66, - 0x16, 0x8b, 0xc3, 0xbc, 0x66, 0xf0, 0xba, 0xd7, 0x8d, 0x8d, 0x9f, 0x9b, 0x7f, 0xd3, 0x36, 0xd9, - 0x37, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xb3, 0x68, 0x97, 0x15, 0x03, 0x00, 0x00, -} - -func (m *NetAddress) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NetAddress) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NetAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Port != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Port)) - i-- - dAtA[i] = 0x18 - } - if len(m.IP) > 0 { - i -= len(m.IP) - copy(dAtA[i:], m.IP) - i = encodeVarintTypes(dAtA, i, uint64(len(m.IP))) - i-- - dAtA[i] = 0x12 - } - if len(m.ID) > 0 { - i -= len(m.ID) - copy(dAtA[i:], m.ID) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProtocolVersion) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProtocolVersion) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProtocolVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.App != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.App)) - i-- - dAtA[i] = 0x18 - } - if m.Block != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Block)) - i-- - dAtA[i] = 0x10 - } - if m.P2P != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.P2P)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *DefaultNodeInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DefaultNodeInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DefaultNodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Other.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Moniker))) - i-- - dAtA[i] = 0x3a - } - if len(m.Channels) > 0 { - i -= len(m.Channels) - copy(dAtA[i:], m.Channels) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Channels))) - i-- - dAtA[i] = 0x32 - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0x2a - } - if len(m.Network) > 0 { - i -= len(m.Network) - copy(dAtA[i:], m.Network) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Network))) - i-- - dAtA[i] = 0x22 - } - if len(m.ListenAddr) > 0 { - i -= len(m.ListenAddr) - copy(dAtA[i:], m.ListenAddr) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ListenAddr))) - i-- - dAtA[i] = 0x1a - } - if len(m.DefaultNodeID) > 0 { - i -= len(m.DefaultNodeID) - copy(dAtA[i:], m.DefaultNodeID) - i = encodeVarintTypes(dAtA, i, uint64(len(m.DefaultNodeID))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.ProtocolVersion.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DefaultNodeInfoOther) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DefaultNodeInfoOther) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DefaultNodeInfoOther) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RPCAddress) > 0 { - i -= len(m.RPCAddress) - copy(dAtA[i:], m.RPCAddress) - i = encodeVarintTypes(dAtA, i, uint64(len(m.RPCAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.TxIndex) > 0 { - i -= len(m.TxIndex) - copy(dAtA[i:], m.TxIndex) - i = encodeVarintTypes(dAtA, i, uint64(len(m.TxIndex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *NetAddress) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ID) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.IP) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Port != 0 { - n += 1 + sovTypes(uint64(m.Port)) - } - return n -} - -func (m *ProtocolVersion) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.P2P != 0 { - n += 1 + sovTypes(uint64(m.P2P)) - } - if m.Block != 0 { - n += 1 + sovTypes(uint64(m.Block)) - } - if m.App != 0 { - n += 1 + sovTypes(uint64(m.App)) - } - return n -} - -func (m *DefaultNodeInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ProtocolVersion.Size() - n += 1 + l + sovTypes(uint64(l)) - l = len(m.DefaultNodeID) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.ListenAddr) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Network) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Version) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Channels) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Moniker) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = m.Other.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} - -func (m *DefaultNodeInfoOther) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.TxIndex) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.RPCAddress) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *NetAddress) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NetAddress: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NetAddress: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.IP = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) - } - m.Port = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Port |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ProtocolVersion) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProtocolVersion: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProtocolVersion: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field P2P", wireType) - } - m.P2P = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.P2P |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - m.Block = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Block |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field App", wireType) - } - m.App = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.App |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *DefaultNodeInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DefaultNodeInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DefaultNodeInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolVersion", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProtocolVersion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DefaultNodeID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DefaultNodeID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ListenAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ListenAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Network", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Network = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Channels", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Channels = append(m.Channels[:0], dAtA[iNdEx:postIndex]...) - if m.Channels == nil { - m.Channels = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Moniker = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Other", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Other.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *DefaultNodeInfoOther) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DefaultNodeInfoOther: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DefaultNodeInfoOther: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxIndex", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TxIndex = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RPCAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RPCAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/p2p/types.proto b/third_party/proto/tendermint/p2p/types.proto deleted file mode 100644 index 0d42ea4002..0000000000 --- a/third_party/proto/tendermint/p2p/types.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; -package tendermint.p2p; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; - -import "gogoproto/gogo.proto"; - -message NetAddress { - string id = 1 [(gogoproto.customname) = "ID"]; - string ip = 2 [(gogoproto.customname) = "IP"]; - uint32 port = 3; -} - -message ProtocolVersion { - uint64 p2p = 1 [(gogoproto.customname) = "P2P"]; - uint64 block = 2; - uint64 app = 3; -} - -message DefaultNodeInfo { - ProtocolVersion protocol_version = 1 [(gogoproto.nullable) = false]; - string default_node_id = 2 [(gogoproto.customname) = "DefaultNodeID"]; - string listen_addr = 3; - string network = 4; - string version = 5; - bytes channels = 6; - string moniker = 7; - DefaultNodeInfoOther other = 8 [(gogoproto.nullable) = false]; -} - -message DefaultNodeInfoOther { - string tx_index = 1; - string rpc_address = 2 [(gogoproto.customname) = "RPCAddress"]; -} diff --git a/third_party/proto/tendermint/privval/types.proto b/third_party/proto/tendermint/privval/types.proto deleted file mode 100644 index 0fc8b61dc9..0000000000 --- a/third_party/proto/tendermint/privval/types.proto +++ /dev/null @@ -1,76 +0,0 @@ -syntax = "proto3"; -package tendermint.privval; - -import "tendermint/crypto/keys.proto"; -import "tendermint/types/types.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/privval"; - -enum Errors { - ERRORS_UNKNOWN = 0; - ERRORS_UNEXPECTED_RESPONSE = 1; - ERRORS_NO_CONNECTION = 2; - ERRORS_CONNECTION_TIMEOUT = 3; - ERRORS_READ_TIMEOUT = 4; - ERRORS_WRITE_TIMEOUT = 5; -} - -message RemoteSignerError { - int32 code = 1; - string description = 2; -} - -// PubKeyRequest requests the consensus public key from the remote signer. -message PubKeyRequest { - string chain_id = 1; -} - -// PubKeyResponse is a response message containing the public key. -message PubKeyResponse { - tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false]; - RemoteSignerError error = 2; -} - -// SignVoteRequest is a request to sign a vote -message SignVoteRequest { - tendermint.types.Vote vote = 1; - string chain_id = 2; -} - -// SignedVoteResponse is a response containing a signed vote or an error -message SignedVoteResponse { - tendermint.types.Vote vote = 1 [(gogoproto.nullable) = false]; - RemoteSignerError error = 2; -} - -// SignProposalRequest is a request to sign a proposal -message SignProposalRequest { - tendermint.types.Proposal proposal = 1; - string chain_id = 2; -} - -// SignedProposalResponse is response containing a signed proposal or an error -message SignedProposalResponse { - tendermint.types.Proposal proposal = 1 [(gogoproto.nullable) = false]; - RemoteSignerError error = 2; -} - -// PingRequest is a request to confirm that the connection is alive. -message PingRequest {} - -// PingResponse is a response to confirm that the connection is alive. -message PingResponse {} - -message Message { - oneof sum { - PubKeyRequest pub_key_request = 1; - PubKeyResponse pub_key_response = 2; - SignVoteRequest sign_vote_request = 3; - SignedVoteResponse signed_vote_response = 4; - SignProposalRequest sign_proposal_request = 5; - SignedProposalResponse signed_proposal_response = 6; - PingRequest ping_request = 7; - PingResponse ping_response = 8; - } -} diff --git a/third_party/proto/tendermint/rpc/grpc/types.proto b/third_party/proto/tendermint/rpc/grpc/types.proto deleted file mode 100644 index ee948a4065..0000000000 --- a/third_party/proto/tendermint/rpc/grpc/types.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package tendermint.rpc.grpc; -option go_package = "github.com/tendermint/tendermint/rpc/grpc;coregrpc"; - -import "tendermint/abci/types.proto"; - -//---------------------------------------- -// Request types - -message RequestPing {} - -message RequestBroadcastTx { - bytes tx = 1; -} - -//---------------------------------------- -// Response types - -message ResponsePing {} - -message ResponseBroadcastTx { - tendermint.abci.ResponseCheckTx check_tx = 1; - tendermint.abci.ResponseDeliverTx deliver_tx = 2; -} - -//---------------------------------------- -// Service Definition - -service BroadcastAPI { - rpc Ping(RequestPing) returns (ResponsePing); - rpc BroadcastTx(RequestBroadcastTx) returns (ResponseBroadcastTx); -} diff --git a/third_party/proto/tendermint/state/types.proto b/third_party/proto/tendermint/state/types.proto deleted file mode 100644 index 919da91e52..0000000000 --- a/third_party/proto/tendermint/state/types.proto +++ /dev/null @@ -1,75 +0,0 @@ -syntax = "proto3"; -package tendermint.state; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/state"; - -import "gogoproto/gogo.proto"; -import "tendermint/abci/types.proto"; -import "tendermint/types/types.proto"; -import "tendermint/types/validator.proto"; -import "tendermint/types/params.proto"; -import "tendermint/version/types.proto"; -import "google/protobuf/timestamp.proto"; - -// ABCIResponses retains the responses -// of the various ABCI calls during block processing. -// It is persisted to disk for each height before calling Commit. -message ABCIResponses { - repeated tendermint.abci.ResponseDeliverTx deliver_txs = 1; - tendermint.abci.ResponseEndBlock end_block = 2; - tendermint.abci.ResponseBeginBlock begin_block = 3; -} - -// ValidatorsInfo represents the latest validator set, or the last height it changed -message ValidatorsInfo { - tendermint.types.ValidatorSet validator_set = 1; - int64 last_height_changed = 2; -} - -// ConsensusParamsInfo represents the latest consensus params, or the last height it changed -message ConsensusParamsInfo { - tendermint.types.ConsensusParams consensus_params = 1 [(gogoproto.nullable) = false]; - int64 last_height_changed = 2; -} - -message Version { - tendermint.version.Consensus consensus = 1 [(gogoproto.nullable) = false]; - string software = 2; -} - -message State { - Version version = 1 [(gogoproto.nullable) = false]; - - // immutable - string chain_id = 2 [(gogoproto.customname) = "ChainID"]; - int64 initial_height = 14; - - // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) - int64 last_block_height = 3; - tendermint.types.BlockID last_block_id = 4 - [(gogoproto.nullable) = false, (gogoproto.customname) = "LastBlockID"]; - google.protobuf.Timestamp last_block_time = 5 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - - // LastValidators is used to validate block.LastCommit. - // Validators are persisted to the database separately every time they change, - // so we can query for historical validator sets. - // Note that if s.LastBlockHeight causes a valset change, - // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1 - // Extra +1 due to nextValSet delay. - tendermint.types.ValidatorSet next_validators = 6; - tendermint.types.ValidatorSet validators = 7; - tendermint.types.ValidatorSet last_validators = 8; - int64 last_height_validators_changed = 9; - - // Consensus parameters used for validating blocks. - // Changes returned by EndBlock and updated after Commit. - tendermint.types.ConsensusParams consensus_params = 10 [(gogoproto.nullable) = false]; - int64 last_height_consensus_params_changed = 11; - - // Merkle root of the results from executing prev block - bytes last_results_hash = 12; - - // the latest AppHash we've received from calling abci.Commit() - bytes app_hash = 13; -} diff --git a/third_party/proto/tendermint/statesync/types.pb.go b/third_party/proto/tendermint/statesync/types.pb.go deleted file mode 100644 index ba43116ba8..0000000000 --- a/third_party/proto/tendermint/statesync/types.pb.go +++ /dev/null @@ -1,1672 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/statesync/types.proto - -package statesync - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Message struct { - // Types that are valid to be assigned to Sum: - // *Message_SnapshotsRequest - // *Message_SnapshotsResponse - // *Message_ChunkRequest - // *Message_ChunkResponse - Sum isMessage_Sum `protobuf_oneof:"sum"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_a1c2869546ca7914, []int{0} -} - -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} - -func (m *Message) XXX_Size() int { - return m.Size() -} - -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -type isMessage_Sum interface { - isMessage_Sum() - MarshalTo([]byte) (int, error) - Size() int -} - -type Message_SnapshotsRequest struct { - SnapshotsRequest *SnapshotsRequest `protobuf:"bytes,1,opt,name=snapshots_request,json=snapshotsRequest,proto3,oneof" json:"snapshots_request,omitempty"` -} -type Message_SnapshotsResponse struct { - SnapshotsResponse *SnapshotsResponse `protobuf:"bytes,2,opt,name=snapshots_response,json=snapshotsResponse,proto3,oneof" json:"snapshots_response,omitempty"` -} -type Message_ChunkRequest struct { - ChunkRequest *ChunkRequest `protobuf:"bytes,3,opt,name=chunk_request,json=chunkRequest,proto3,oneof" json:"chunk_request,omitempty"` -} -type Message_ChunkResponse struct { - ChunkResponse *ChunkResponse `protobuf:"bytes,4,opt,name=chunk_response,json=chunkResponse,proto3,oneof" json:"chunk_response,omitempty"` -} - -func (*Message_SnapshotsRequest) isMessage_Sum() {} -func (*Message_SnapshotsResponse) isMessage_Sum() {} -func (*Message_ChunkRequest) isMessage_Sum() {} -func (*Message_ChunkResponse) isMessage_Sum() {} - -func (m *Message) GetSum() isMessage_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *Message) GetSnapshotsRequest() *SnapshotsRequest { - if x, ok := m.GetSum().(*Message_SnapshotsRequest); ok { - return x.SnapshotsRequest - } - return nil -} - -func (m *Message) GetSnapshotsResponse() *SnapshotsResponse { - if x, ok := m.GetSum().(*Message_SnapshotsResponse); ok { - return x.SnapshotsResponse - } - return nil -} - -func (m *Message) GetChunkRequest() *ChunkRequest { - if x, ok := m.GetSum().(*Message_ChunkRequest); ok { - return x.ChunkRequest - } - return nil -} - -func (m *Message) GetChunkResponse() *ChunkResponse { - if x, ok := m.GetSum().(*Message_ChunkResponse); ok { - return x.ChunkResponse - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Message) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Message_SnapshotsRequest)(nil), - (*Message_SnapshotsResponse)(nil), - (*Message_ChunkRequest)(nil), - (*Message_ChunkResponse)(nil), - } -} - -type SnapshotsRequest struct{} - -func (m *SnapshotsRequest) Reset() { *m = SnapshotsRequest{} } -func (m *SnapshotsRequest) String() string { return proto.CompactTextString(m) } -func (*SnapshotsRequest) ProtoMessage() {} -func (*SnapshotsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a1c2869546ca7914, []int{1} -} - -func (m *SnapshotsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *SnapshotsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *SnapshotsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotsRequest.Merge(m, src) -} - -func (m *SnapshotsRequest) XXX_Size() int { - return m.Size() -} - -func (m *SnapshotsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotsRequest proto.InternalMessageInfo - -type SnapshotsResponse struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` - Chunks uint32 `protobuf:"varint,3,opt,name=chunks,proto3" json:"chunks,omitempty"` - Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"` - Metadata []byte `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` -} - -func (m *SnapshotsResponse) Reset() { *m = SnapshotsResponse{} } -func (m *SnapshotsResponse) String() string { return proto.CompactTextString(m) } -func (*SnapshotsResponse) ProtoMessage() {} -func (*SnapshotsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a1c2869546ca7914, []int{2} -} - -func (m *SnapshotsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *SnapshotsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *SnapshotsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotsResponse.Merge(m, src) -} - -func (m *SnapshotsResponse) XXX_Size() int { - return m.Size() -} - -func (m *SnapshotsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotsResponse proto.InternalMessageInfo - -func (m *SnapshotsResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *SnapshotsResponse) GetFormat() uint32 { - if m != nil { - return m.Format - } - return 0 -} - -func (m *SnapshotsResponse) GetChunks() uint32 { - if m != nil { - return m.Chunks - } - return 0 -} - -func (m *SnapshotsResponse) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -func (m *SnapshotsResponse) GetMetadata() []byte { - if m != nil { - return m.Metadata - } - return nil -} - -type ChunkRequest struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` - Index uint32 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` -} - -func (m *ChunkRequest) Reset() { *m = ChunkRequest{} } -func (m *ChunkRequest) String() string { return proto.CompactTextString(m) } -func (*ChunkRequest) ProtoMessage() {} -func (*ChunkRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a1c2869546ca7914, []int{3} -} - -func (m *ChunkRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ChunkRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ChunkRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ChunkRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChunkRequest.Merge(m, src) -} - -func (m *ChunkRequest) XXX_Size() int { - return m.Size() -} - -func (m *ChunkRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ChunkRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ChunkRequest proto.InternalMessageInfo - -func (m *ChunkRequest) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *ChunkRequest) GetFormat() uint32 { - if m != nil { - return m.Format - } - return 0 -} - -func (m *ChunkRequest) GetIndex() uint32 { - if m != nil { - return m.Index - } - return 0 -} - -type ChunkResponse struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` - Index uint32 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` - Chunk []byte `protobuf:"bytes,4,opt,name=chunk,proto3" json:"chunk,omitempty"` - Missing bool `protobuf:"varint,5,opt,name=missing,proto3" json:"missing,omitempty"` -} - -func (m *ChunkResponse) Reset() { *m = ChunkResponse{} } -func (m *ChunkResponse) String() string { return proto.CompactTextString(m) } -func (*ChunkResponse) ProtoMessage() {} -func (*ChunkResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a1c2869546ca7914, []int{4} -} - -func (m *ChunkResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ChunkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ChunkResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ChunkResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChunkResponse.Merge(m, src) -} - -func (m *ChunkResponse) XXX_Size() int { - return m.Size() -} - -func (m *ChunkResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ChunkResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ChunkResponse proto.InternalMessageInfo - -func (m *ChunkResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *ChunkResponse) GetFormat() uint32 { - if m != nil { - return m.Format - } - return 0 -} - -func (m *ChunkResponse) GetIndex() uint32 { - if m != nil { - return m.Index - } - return 0 -} - -func (m *ChunkResponse) GetChunk() []byte { - if m != nil { - return m.Chunk - } - return nil -} - -func (m *ChunkResponse) GetMissing() bool { - if m != nil { - return m.Missing - } - return false -} - -func init() { - proto.RegisterType((*Message)(nil), "tendermint.statesync.Message") - proto.RegisterType((*SnapshotsRequest)(nil), "tendermint.statesync.SnapshotsRequest") - proto.RegisterType((*SnapshotsResponse)(nil), "tendermint.statesync.SnapshotsResponse") - proto.RegisterType((*ChunkRequest)(nil), "tendermint.statesync.ChunkRequest") - proto.RegisterType((*ChunkResponse)(nil), "tendermint.statesync.ChunkResponse") -} - -func init() { proto.RegisterFile("tendermint/statesync/types.proto", fileDescriptor_a1c2869546ca7914) } - -var fileDescriptor_a1c2869546ca7914 = []byte{ - // 393 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6a, 0xdb, 0x40, - 0x18, 0x94, 0xfc, 0xcf, 0x57, 0xab, 0xd8, 0x8b, 0x29, 0xa2, 0x07, 0x61, 0x54, 0x68, 0x7b, 0x92, - 0xa0, 0x3d, 0xf6, 0xe6, 0x5e, 0x5c, 0x68, 0x2f, 0xdb, 0x18, 0x42, 0x2e, 0x61, 0x2d, 0x6f, 0x24, - 0x11, 0xb4, 0x52, 0xf4, 0xad, 0x20, 0x7e, 0x80, 0x9c, 0x72, 0xc9, 0x63, 0xe5, 0xe8, 0x63, 0xc8, - 0x29, 0xd8, 0x2f, 0x12, 0xb4, 0x92, 0x65, 0xc5, 0x31, 0x09, 0x81, 0xdc, 0x76, 0xc6, 0xe3, 0xd1, - 0xcc, 0xc0, 0x07, 0x63, 0xc9, 0xc5, 0x82, 0xa7, 0x51, 0x28, 0xa4, 0x8b, 0x92, 0x49, 0x8e, 0x4b, - 0xe1, 0xb9, 0x72, 0x99, 0x70, 0x74, 0x92, 0x34, 0x96, 0x31, 0x19, 0xed, 0x14, 0x4e, 0xa5, 0xb0, - 0xef, 0x1b, 0xd0, 0xfd, 0xc7, 0x11, 0x99, 0xcf, 0xc9, 0x0c, 0x86, 0x28, 0x58, 0x82, 0x41, 0x2c, - 0xf1, 0x34, 0xe5, 0x17, 0x19, 0x47, 0x69, 0xea, 0x63, 0xfd, 0xfb, 0x87, 0x1f, 0x5f, 0x9d, 0x43, - 0xff, 0x76, 0xfe, 0x6f, 0xe5, 0xb4, 0x50, 0x4f, 0x35, 0x3a, 0xc0, 0x3d, 0x8e, 0x1c, 0x03, 0xa9, - 0xdb, 0x62, 0x12, 0x0b, 0xe4, 0x66, 0x43, 0xf9, 0x7e, 0x7b, 0xd5, 0xb7, 0x90, 0x4f, 0x35, 0x3a, - 0xc4, 0x7d, 0x92, 0xfc, 0x01, 0xc3, 0x0b, 0x32, 0x71, 0x5e, 0x85, 0x6d, 0x2a, 0x53, 0xfb, 0xb0, - 0xe9, 0xef, 0x5c, 0xba, 0x0b, 0xda, 0xf7, 0x6a, 0x98, 0xfc, 0x85, 0x8f, 0x5b, 0xab, 0x32, 0x60, - 0x4b, 0x79, 0x7d, 0x79, 0xd1, 0xab, 0x0a, 0x67, 0x78, 0x75, 0x62, 0xd2, 0x86, 0x26, 0x66, 0x91, - 0x4d, 0x60, 0xb0, 0xbf, 0x90, 0x7d, 0xad, 0xc3, 0xf0, 0x59, 0x3d, 0xf2, 0x09, 0x3a, 0x01, 0x0f, - 0xfd, 0xa0, 0xd8, 0xbb, 0x45, 0x4b, 0x94, 0xf3, 0x67, 0x71, 0x1a, 0x31, 0xa9, 0xf6, 0x32, 0x68, - 0x89, 0x72, 0x5e, 0x7d, 0x11, 0x55, 0x65, 0x83, 0x96, 0x88, 0x10, 0x68, 0x05, 0x0c, 0x03, 0x15, - 0xbe, 0x4f, 0xd5, 0x9b, 0x7c, 0x86, 0x5e, 0xc4, 0x25, 0x5b, 0x30, 0xc9, 0xcc, 0xb6, 0xe2, 0x2b, - 0x6c, 0x1f, 0x41, 0xbf, 0x3e, 0xcb, 0x9b, 0x73, 0x8c, 0xa0, 0x1d, 0x8a, 0x05, 0xbf, 0x2c, 0x63, - 0x14, 0xc0, 0xbe, 0xd2, 0xc1, 0x78, 0xb2, 0xd0, 0xfb, 0xf8, 0xe6, 0xac, 0xea, 0x59, 0xd6, 0x2b, - 0x00, 0x31, 0xa1, 0x1b, 0x85, 0x88, 0xa1, 0xf0, 0x55, 0xbd, 0x1e, 0xdd, 0xc2, 0xc9, 0xec, 0x76, - 0x6d, 0xe9, 0xab, 0xb5, 0xa5, 0x3f, 0xac, 0x2d, 0xfd, 0x66, 0x63, 0x69, 0xab, 0x8d, 0xa5, 0xdd, - 0x6d, 0x2c, 0xed, 0xe4, 0x97, 0x1f, 0xca, 0x20, 0x9b, 0x3b, 0x5e, 0x1c, 0xb9, 0xb5, 0xcb, 0xa9, - 0x3d, 0xd5, 0xd1, 0xb8, 0x87, 0xae, 0x6a, 0xde, 0x51, 0xbf, 0xfd, 0x7c, 0x0c, 0x00, 0x00, 0xff, - 0xff, 0xcc, 0x16, 0xc2, 0x8b, 0x74, 0x03, 0x00, 0x00, -} - -func (m *Message) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Message_SnapshotsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_SnapshotsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SnapshotsRequest != nil { - { - size, err := m.SnapshotsRequest.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_SnapshotsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_SnapshotsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SnapshotsResponse != nil { - { - size, err := m.SnapshotsResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func (m *Message_ChunkRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_ChunkRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ChunkRequest != nil { - { - size, err := m.ChunkRequest.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} - -func (m *Message_ChunkResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_ChunkResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ChunkResponse != nil { - { - size, err := m.ChunkResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} - -func (m *SnapshotsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SnapshotsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *SnapshotsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SnapshotsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) - i-- - dAtA[i] = 0x2a - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x22 - } - if m.Chunks != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Chunks)) - i-- - dAtA[i] = 0x18 - } - if m.Format != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Format)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ChunkRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ChunkRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ChunkRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Index != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Index)) - i-- - dAtA[i] = 0x18 - } - if m.Format != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Format)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ChunkResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ChunkResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ChunkResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Missing { - i-- - if m.Missing { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if len(m.Chunk) > 0 { - i -= len(m.Chunk) - copy(dAtA[i:], m.Chunk) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Chunk))) - i-- - dAtA[i] = 0x22 - } - if m.Index != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Index)) - i-- - dAtA[i] = 0x18 - } - if m.Format != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Format)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *Message_SnapshotsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SnapshotsRequest != nil { - l = m.SnapshotsRequest.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *Message_SnapshotsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SnapshotsResponse != nil { - l = m.SnapshotsResponse.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *Message_ChunkRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChunkRequest != nil { - l = m.ChunkRequest.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *Message_ChunkResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChunkResponse != nil { - l = m.ChunkResponse.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *SnapshotsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *SnapshotsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - if m.Format != 0 { - n += 1 + sovTypes(uint64(m.Format)) - } - if m.Chunks != 0 { - n += 1 + sovTypes(uint64(m.Chunks)) - } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *ChunkRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - if m.Format != 0 { - n += 1 + sovTypes(uint64(m.Format)) - } - if m.Index != 0 { - n += 1 + sovTypes(uint64(m.Index)) - } - return n -} - -func (m *ChunkResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - if m.Format != 0 { - n += 1 + sovTypes(uint64(m.Format)) - } - if m.Index != 0 { - n += 1 + sovTypes(uint64(m.Index)) - } - l = len(m.Chunk) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Missing { - n += 2 - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Message) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotsRequest", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotsRequest{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_SnapshotsRequest{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotsResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotsResponse{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_SnapshotsResponse{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChunkRequest", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ChunkRequest{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_ChunkRequest{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChunkResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ChunkResponse{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_ChunkResponse{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *SnapshotsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SnapshotsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *SnapshotsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SnapshotsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - m.Format = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Format |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Chunks", wireType) - } - m.Chunks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Chunks |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ChunkRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ChunkRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ChunkRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - m.Format = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Format |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - m.Index = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Index |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ChunkResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ChunkResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ChunkResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - m.Format = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Format |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - m.Index = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Index |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Chunk = append(m.Chunk[:0], dAtA[iNdEx:postIndex]...) - if m.Chunk == nil { - m.Chunk = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Missing", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Missing = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/statesync/types.proto b/third_party/proto/tendermint/statesync/types.proto deleted file mode 100644 index 8d4a714c1d..0000000000 --- a/third_party/proto/tendermint/statesync/types.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; -package tendermint.statesync; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/statesync"; - -message Message { - oneof sum { - SnapshotsRequest snapshots_request = 1; - SnapshotsResponse snapshots_response = 2; - ChunkRequest chunk_request = 3; - ChunkResponse chunk_response = 4; - } -} - -message SnapshotsRequest {} - -message SnapshotsResponse { - uint64 height = 1; - uint32 format = 2; - uint32 chunks = 3; - bytes hash = 4; - bytes metadata = 5; -} - -message ChunkRequest { - uint64 height = 1; - uint32 format = 2; - uint32 index = 3; -} - -message ChunkResponse { - uint64 height = 1; - uint32 format = 2; - uint32 index = 3; - bytes chunk = 4; - bool missing = 5; -} diff --git a/third_party/proto/tendermint/store/types.pb.go b/third_party/proto/tendermint/store/types.pb.go deleted file mode 100644 index 108bb24a8c..0000000000 --- a/third_party/proto/tendermint/store/types.pb.go +++ /dev/null @@ -1,347 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/store/types.proto - -package store - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type BlockStoreState struct { - Base int64 `protobuf:"varint,1,opt,name=base,proto3" json:"base,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *BlockStoreState) Reset() { *m = BlockStoreState{} } -func (m *BlockStoreState) String() string { return proto.CompactTextString(m) } -func (*BlockStoreState) ProtoMessage() {} -func (*BlockStoreState) Descriptor() ([]byte, []int) { - return fileDescriptor_ff9e53a0a74267f7, []int{0} -} - -func (m *BlockStoreState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *BlockStoreState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockStoreState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *BlockStoreState) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockStoreState.Merge(m, src) -} - -func (m *BlockStoreState) XXX_Size() int { - return m.Size() -} - -func (m *BlockStoreState) XXX_DiscardUnknown() { - xxx_messageInfo_BlockStoreState.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockStoreState proto.InternalMessageInfo - -func (m *BlockStoreState) GetBase() int64 { - if m != nil { - return m.Base - } - return 0 -} - -func (m *BlockStoreState) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func init() { - proto.RegisterType((*BlockStoreState)(nil), "tendermint.store.BlockStoreState") -} - -func init() { proto.RegisterFile("tendermint/store/types.proto", fileDescriptor_ff9e53a0a74267f7) } - -var fileDescriptor_ff9e53a0a74267f7 = []byte{ - // 165 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2f, 0xa9, 0x2c, - 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0xc8, 0xea, 0x81, 0x65, 0x95, - 0x6c, 0xb9, 0xf8, 0x9d, 0x72, 0xf2, 0x93, 0xb3, 0x83, 0x41, 0xbc, 0xe0, 0x92, 0xc4, 0x92, 0x54, - 0x21, 0x21, 0x2e, 0x96, 0xa4, 0xc4, 0xe2, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xe6, 0x20, 0x30, - 0x5b, 0x48, 0x8c, 0x8b, 0x2d, 0x23, 0x35, 0x33, 0x3d, 0xa3, 0x44, 0x82, 0x09, 0x2c, 0x0a, 0xe5, - 0x39, 0x05, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, - 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x79, 0x7a, 0x66, - 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x92, 0x9b, 0x90, 0x98, 0x60, 0x27, 0xe9, - 0xa3, 0xbb, 0x37, 0x89, 0x0d, 0x2c, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xef, 0xa6, 0x30, - 0x63, 0xca, 0x00, 0x00, 0x00, -} - -func (m *BlockStoreState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BlockStoreState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockStoreState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x10 - } - if m.Base != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Base)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *BlockStoreState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Base != 0 { - n += 1 + sovTypes(uint64(m.Base)) - } - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *BlockStoreState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BlockStoreState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockStoreState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType) - } - m.Base = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Base |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/store/types.proto b/third_party/proto/tendermint/store/types.proto deleted file mode 100644 index af2f97ad08..0000000000 --- a/third_party/proto/tendermint/store/types.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; -package tendermint.store; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/store"; - -message BlockStoreState { - int64 base = 1; - int64 height = 2; -} diff --git a/third_party/proto/tendermint/types/block.pb.go b/third_party/proto/tendermint/types/block.pb.go deleted file mode 100644 index 2b4ace2d93..0000000000 --- a/third_party/proto/tendermint/types/block.pb.go +++ /dev/null @@ -1,503 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/types/block.proto - -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Block struct { - Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` - Data Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data"` - Evidence EvidenceList `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence"` - LastCommit *Commit `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"` -} - -func (m *Block) Reset() { *m = Block{} } -func (m *Block) String() string { return proto.CompactTextString(m) } -func (*Block) ProtoMessage() {} -func (*Block) Descriptor() ([]byte, []int) { - return fileDescriptor_70840e82f4357ab1, []int{0} -} - -func (m *Block) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Block.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Block) XXX_Merge(src proto.Message) { - xxx_messageInfo_Block.Merge(m, src) -} - -func (m *Block) XXX_Size() int { - return m.Size() -} - -func (m *Block) XXX_DiscardUnknown() { - xxx_messageInfo_Block.DiscardUnknown(m) -} - -var xxx_messageInfo_Block proto.InternalMessageInfo - -func (m *Block) GetHeader() Header { - if m != nil { - return m.Header - } - return Header{} -} - -func (m *Block) GetData() Data { - if m != nil { - return m.Data - } - return Data{} -} - -func (m *Block) GetEvidence() EvidenceList { - if m != nil { - return m.Evidence - } - return EvidenceList{} -} - -func (m *Block) GetLastCommit() *Commit { - if m != nil { - return m.LastCommit - } - return nil -} - -func init() { - proto.RegisterType((*Block)(nil), "tendermint.types.Block") -} - -func init() { proto.RegisterFile("tendermint/types/block.proto", fileDescriptor_70840e82f4357ab1) } - -var fileDescriptor_70840e82f4357ab1 = []byte{ - // 266 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xca, 0xc9, - 0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0xc8, 0xea, 0x81, 0x65, 0xa5, - 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x14, 0xa6, 0x29, 0x60, - 0x12, 0x2a, 0x2b, 0x8f, 0x21, 0x9b, 0x5a, 0x96, 0x99, 0x92, 0x9a, 0x97, 0x9c, 0x0a, 0x51, 0xa0, - 0xf4, 0x8e, 0x91, 0x8b, 0xd5, 0x09, 0x64, 0xad, 0x90, 0x19, 0x17, 0x5b, 0x46, 0x6a, 0x62, 0x4a, - 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x84, 0x1e, 0xba, 0x0b, 0xf4, 0x3c, 0xc0, - 0xf2, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x55, 0x0b, 0x19, 0x70, 0xb1, 0xa4, 0x24, - 0x96, 0x24, 0x4a, 0x30, 0x81, 0x75, 0x89, 0x61, 0xea, 0x72, 0x49, 0x2c, 0x49, 0x84, 0xea, 0x01, - 0xab, 0x14, 0x72, 0xe0, 0xe2, 0x80, 0xb9, 0x42, 0x82, 0x19, 0xac, 0x4b, 0x0e, 0x53, 0x97, 0x2b, - 0x54, 0x85, 0x4f, 0x66, 0x71, 0x09, 0x54, 0x37, 0x5c, 0x97, 0x90, 0x25, 0x17, 0x77, 0x4e, 0x62, - 0x71, 0x49, 0x7c, 0x72, 0x7e, 0x6e, 0x6e, 0x66, 0x89, 0x04, 0x0b, 0x2e, 0x07, 0x3b, 0x83, 0xe5, - 0x83, 0xb8, 0x40, 0x8a, 0x21, 0x6c, 0xa7, 0xc0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, - 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, - 0x63, 0x88, 0x32, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x0e, - 0x36, 0x04, 0x13, 0x12, 0xf8, 0xe8, 0x41, 0x9a, 0xc4, 0x06, 0x16, 0x37, 0x06, 0x04, 0x00, 0x00, - 0xff, 0xff, 0x79, 0x8c, 0xb5, 0x43, 0xd1, 0x01, 0x00, 0x00, -} - -func (m *Block) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Block) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LastCommit != nil { - { - size, err := m.LastCommit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintBlock(dAtA []byte, offset int, v uint64) int { - offset -= sovBlock(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *Block) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Header.Size() - n += 1 + l + sovBlock(uint64(l)) - l = m.Data.Size() - n += 1 + l + sovBlock(uint64(l)) - l = m.Evidence.Size() - n += 1 + l + sovBlock(uint64(l)) - if m.LastCommit != nil { - l = m.LastCommit.Size() - n += 1 + l + sovBlock(uint64(l)) - } - return n -} - -func sovBlock(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozBlock(x uint64) (n int) { - return sovBlock(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Block) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Block: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Block: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastCommit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LastCommit == nil { - m.LastCommit = &Commit{} - } - if err := m.LastCommit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipBlock(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowBlock - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowBlock - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowBlock - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthBlock - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupBlock - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthBlock - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthBlock = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowBlock = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupBlock = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/types/block.proto b/third_party/proto/tendermint/types/block.proto deleted file mode 100644 index 84e9bb15d8..0000000000 --- a/third_party/proto/tendermint/types/block.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "tendermint/types/types.proto"; -import "tendermint/types/evidence.proto"; - -message Block { - Header header = 1 [(gogoproto.nullable) = false]; - Data data = 2 [(gogoproto.nullable) = false]; - tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false]; - Commit last_commit = 4; -} diff --git a/third_party/proto/tendermint/types/canonical.pb.go b/third_party/proto/tendermint/types/canonical.pb.go deleted file mode 100644 index 27c593e585..0000000000 --- a/third_party/proto/tendermint/types/canonical.pb.go +++ /dev/null @@ -1,1409 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/types/canonical.proto - -package types - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - time "time" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf - _ = time.Kitchen -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type CanonicalBlockID struct { - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - PartSetHeader CanonicalPartSetHeader `protobuf:"bytes,2,opt,name=part_set_header,json=partSetHeader,proto3" json:"part_set_header"` -} - -func (m *CanonicalBlockID) Reset() { *m = CanonicalBlockID{} } -func (m *CanonicalBlockID) String() string { return proto.CompactTextString(m) } -func (*CanonicalBlockID) ProtoMessage() {} -func (*CanonicalBlockID) Descriptor() ([]byte, []int) { - return fileDescriptor_8d1a1a84ff7267ed, []int{0} -} - -func (m *CanonicalBlockID) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *CanonicalBlockID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CanonicalBlockID.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *CanonicalBlockID) XXX_Merge(src proto.Message) { - xxx_messageInfo_CanonicalBlockID.Merge(m, src) -} - -func (m *CanonicalBlockID) XXX_Size() int { - return m.Size() -} - -func (m *CanonicalBlockID) XXX_DiscardUnknown() { - xxx_messageInfo_CanonicalBlockID.DiscardUnknown(m) -} - -var xxx_messageInfo_CanonicalBlockID proto.InternalMessageInfo - -func (m *CanonicalBlockID) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -func (m *CanonicalBlockID) GetPartSetHeader() CanonicalPartSetHeader { - if m != nil { - return m.PartSetHeader - } - return CanonicalPartSetHeader{} -} - -type CanonicalPartSetHeader struct { - Total uint32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` -} - -func (m *CanonicalPartSetHeader) Reset() { *m = CanonicalPartSetHeader{} } -func (m *CanonicalPartSetHeader) String() string { return proto.CompactTextString(m) } -func (*CanonicalPartSetHeader) ProtoMessage() {} -func (*CanonicalPartSetHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_8d1a1a84ff7267ed, []int{1} -} - -func (m *CanonicalPartSetHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *CanonicalPartSetHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CanonicalPartSetHeader.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *CanonicalPartSetHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_CanonicalPartSetHeader.Merge(m, src) -} - -func (m *CanonicalPartSetHeader) XXX_Size() int { - return m.Size() -} - -func (m *CanonicalPartSetHeader) XXX_DiscardUnknown() { - xxx_messageInfo_CanonicalPartSetHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_CanonicalPartSetHeader proto.InternalMessageInfo - -func (m *CanonicalPartSetHeader) GetTotal() uint32 { - if m != nil { - return m.Total - } - return 0 -} - -func (m *CanonicalPartSetHeader) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -type CanonicalProposal struct { - Type SignedMsgType `protobuf:"varint,1,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` - Height int64 `protobuf:"fixed64,2,opt,name=height,proto3" json:"height,omitempty"` - Round int64 `protobuf:"fixed64,3,opt,name=round,proto3" json:"round,omitempty"` - POLRound int64 `protobuf:"varint,4,opt,name=pol_round,json=polRound,proto3" json:"pol_round,omitempty"` - BlockID *CanonicalBlockID `protobuf:"bytes,5,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` - Timestamp time.Time `protobuf:"bytes,6,opt,name=timestamp,proto3,stdtime" json:"timestamp"` - ChainID string `protobuf:"bytes,7,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *CanonicalProposal) Reset() { *m = CanonicalProposal{} } -func (m *CanonicalProposal) String() string { return proto.CompactTextString(m) } -func (*CanonicalProposal) ProtoMessage() {} -func (*CanonicalProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_8d1a1a84ff7267ed, []int{2} -} - -func (m *CanonicalProposal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *CanonicalProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CanonicalProposal.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *CanonicalProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_CanonicalProposal.Merge(m, src) -} - -func (m *CanonicalProposal) XXX_Size() int { - return m.Size() -} - -func (m *CanonicalProposal) XXX_DiscardUnknown() { - xxx_messageInfo_CanonicalProposal.DiscardUnknown(m) -} - -var xxx_messageInfo_CanonicalProposal proto.InternalMessageInfo - -func (m *CanonicalProposal) GetType() SignedMsgType { - if m != nil { - return m.Type - } - return UnknownType -} - -func (m *CanonicalProposal) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *CanonicalProposal) GetRound() int64 { - if m != nil { - return m.Round - } - return 0 -} - -func (m *CanonicalProposal) GetPOLRound() int64 { - if m != nil { - return m.POLRound - } - return 0 -} - -func (m *CanonicalProposal) GetBlockID() *CanonicalBlockID { - if m != nil { - return m.BlockID - } - return nil -} - -func (m *CanonicalProposal) GetTimestamp() time.Time { - if m != nil { - return m.Timestamp - } - return time.Time{} -} - -func (m *CanonicalProposal) GetChainID() string { - if m != nil { - return m.ChainID - } - return "" -} - -type CanonicalVote struct { - Type SignedMsgType `protobuf:"varint,1,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` - Height int64 `protobuf:"fixed64,2,opt,name=height,proto3" json:"height,omitempty"` - Round int64 `protobuf:"fixed64,3,opt,name=round,proto3" json:"round,omitempty"` - BlockID *CanonicalBlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` - Timestamp time.Time `protobuf:"bytes,5,opt,name=timestamp,proto3,stdtime" json:"timestamp"` - ChainID string `protobuf:"bytes,6,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *CanonicalVote) Reset() { *m = CanonicalVote{} } -func (m *CanonicalVote) String() string { return proto.CompactTextString(m) } -func (*CanonicalVote) ProtoMessage() {} -func (*CanonicalVote) Descriptor() ([]byte, []int) { - return fileDescriptor_8d1a1a84ff7267ed, []int{3} -} - -func (m *CanonicalVote) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *CanonicalVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CanonicalVote.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *CanonicalVote) XXX_Merge(src proto.Message) { - xxx_messageInfo_CanonicalVote.Merge(m, src) -} - -func (m *CanonicalVote) XXX_Size() int { - return m.Size() -} - -func (m *CanonicalVote) XXX_DiscardUnknown() { - xxx_messageInfo_CanonicalVote.DiscardUnknown(m) -} - -var xxx_messageInfo_CanonicalVote proto.InternalMessageInfo - -func (m *CanonicalVote) GetType() SignedMsgType { - if m != nil { - return m.Type - } - return UnknownType -} - -func (m *CanonicalVote) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *CanonicalVote) GetRound() int64 { - if m != nil { - return m.Round - } - return 0 -} - -func (m *CanonicalVote) GetBlockID() *CanonicalBlockID { - if m != nil { - return m.BlockID - } - return nil -} - -func (m *CanonicalVote) GetTimestamp() time.Time { - if m != nil { - return m.Timestamp - } - return time.Time{} -} - -func (m *CanonicalVote) GetChainID() string { - if m != nil { - return m.ChainID - } - return "" -} - -func init() { - proto.RegisterType((*CanonicalBlockID)(nil), "tendermint.types.CanonicalBlockID") - proto.RegisterType((*CanonicalPartSetHeader)(nil), "tendermint.types.CanonicalPartSetHeader") - proto.RegisterType((*CanonicalProposal)(nil), "tendermint.types.CanonicalProposal") - proto.RegisterType((*CanonicalVote)(nil), "tendermint.types.CanonicalVote") -} - -func init() { proto.RegisterFile("tendermint/types/canonical.proto", fileDescriptor_8d1a1a84ff7267ed) } - -var fileDescriptor_8d1a1a84ff7267ed = []byte{ - // 487 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x53, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xce, 0xa5, 0x4e, 0xe2, 0x5c, 0x1b, 0x08, 0xa7, 0xaa, 0xb2, 0x22, 0x64, 0x5b, 0x1e, 0x90, - 0x59, 0x6c, 0xa9, 0x1d, 0xd8, 0x5d, 0x06, 0x82, 0x40, 0x94, 0x6b, 0xd5, 0x81, 0x25, 0xba, 0xd8, - 0x87, 0x6d, 0xe1, 0xf8, 0x4e, 0xf6, 0x65, 0xe8, 0xc2, 0x6f, 0xe8, 0xef, 0xe0, 0x97, 0x74, 0xec, - 0x08, 0x4b, 0x40, 0xce, 0x1f, 0x41, 0x77, 0x4e, 0xec, 0xa8, 0x01, 0x16, 0x10, 0xcb, 0xe9, 0xfd, - 0x78, 0xee, 0x79, 0x1f, 0x3d, 0xaf, 0x5e, 0x68, 0x0b, 0x9a, 0x47, 0xb4, 0x58, 0xa4, 0xb9, 0xf0, - 0xc5, 0x0d, 0xa7, 0xa5, 0x1f, 0x92, 0x9c, 0xe5, 0x69, 0x48, 0x32, 0x8f, 0x17, 0x4c, 0x30, 0x34, - 0x6e, 0x11, 0x9e, 0x42, 0x4c, 0x8e, 0x63, 0x16, 0x33, 0xd5, 0xf4, 0x65, 0x54, 0xe3, 0x26, 0x4f, - 0xf7, 0x98, 0xd4, 0xbb, 0xe9, 0x5a, 0x31, 0x63, 0x71, 0x46, 0x7d, 0x95, 0xcd, 0x97, 0x1f, 0x7d, - 0x91, 0x2e, 0x68, 0x29, 0xc8, 0x82, 0xd7, 0x00, 0xe7, 0x33, 0x1c, 0x9f, 0x6f, 0x27, 0x07, 0x19, - 0x0b, 0x3f, 0x4d, 0x5f, 0x22, 0x04, 0xb5, 0x84, 0x94, 0x89, 0x01, 0x6c, 0xe0, 0x1e, 0x61, 0x15, - 0xa3, 0x6b, 0xf8, 0x98, 0x93, 0x42, 0xcc, 0x4a, 0x2a, 0x66, 0x09, 0x25, 0x11, 0x2d, 0x8c, 0xae, - 0x0d, 0xdc, 0xc3, 0x53, 0xd7, 0x7b, 0x28, 0xd4, 0x6b, 0x08, 0x2f, 0x48, 0x21, 0x2e, 0xa9, 0x78, - 0xa5, 0xf0, 0x81, 0x76, 0xb7, 0xb2, 0x3a, 0x78, 0xc4, 0x77, 0x8b, 0x4e, 0x00, 0x4f, 0x7e, 0x0d, - 0x47, 0xc7, 0xb0, 0x27, 0x98, 0x20, 0x99, 0x92, 0x31, 0xc2, 0x75, 0xd2, 0x68, 0xeb, 0xb6, 0xda, - 0x9c, 0x6f, 0x5d, 0xf8, 0xa4, 0x25, 0x29, 0x18, 0x67, 0x25, 0xc9, 0xd0, 0x19, 0xd4, 0xa4, 0x1c, - 0xf5, 0xfd, 0xd1, 0xa9, 0xb5, 0x2f, 0xf3, 0x32, 0x8d, 0x73, 0x1a, 0xbd, 0x2d, 0xe3, 0xab, 0x1b, - 0x4e, 0xb1, 0x02, 0xa3, 0x13, 0xd8, 0x4f, 0x68, 0x1a, 0x27, 0x42, 0x0d, 0x18, 0xe3, 0x4d, 0x26, - 0xc5, 0x14, 0x6c, 0x99, 0x47, 0xc6, 0x81, 0x2a, 0xd7, 0x09, 0x7a, 0x0e, 0x87, 0x9c, 0x65, 0xb3, - 0xba, 0xa3, 0xd9, 0xc0, 0x3d, 0x08, 0x8e, 0xaa, 0x95, 0xa5, 0x5f, 0xbc, 0x7b, 0x83, 0x65, 0x0d, - 0xeb, 0x9c, 0x65, 0x2a, 0x42, 0xaf, 0xa1, 0x3e, 0x97, 0xf6, 0xce, 0xd2, 0xc8, 0xe8, 0x29, 0xe3, - 0x9c, 0x3f, 0x18, 0xb7, 0xd9, 0x44, 0x70, 0x58, 0xad, 0xac, 0xc1, 0x26, 0xc1, 0x03, 0x45, 0x30, - 0x8d, 0x50, 0x00, 0x87, 0xcd, 0x1a, 0x8d, 0xbe, 0x22, 0x9b, 0x78, 0xf5, 0xa2, 0xbd, 0xed, 0xa2, - 0xbd, 0xab, 0x2d, 0x22, 0xd0, 0xa5, 0xef, 0xb7, 0xdf, 0x2d, 0x80, 0xdb, 0x6f, 0xe8, 0x19, 0xd4, - 0xc3, 0x84, 0xa4, 0xb9, 0xd4, 0x33, 0xb0, 0x81, 0x3b, 0xac, 0x67, 0x9d, 0xcb, 0x9a, 0x9c, 0xa5, - 0x9a, 0xd3, 0xc8, 0xf9, 0xd2, 0x85, 0xa3, 0x46, 0xd6, 0x35, 0x13, 0xf4, 0x7f, 0xf8, 0xba, 0x6b, - 0x96, 0xf6, 0x2f, 0xcd, 0xea, 0xfd, 0xbd, 0x59, 0xfd, 0xdf, 0x9b, 0x15, 0xbc, 0xbf, 0xab, 0x4c, - 0x70, 0x5f, 0x99, 0xe0, 0x47, 0x65, 0x82, 0xdb, 0xb5, 0xd9, 0xb9, 0x5f, 0x9b, 0x9d, 0xaf, 0x6b, - 0xb3, 0xf3, 0xe1, 0x45, 0x9c, 0x8a, 0x64, 0x39, 0xf7, 0x42, 0xb6, 0xf0, 0x77, 0x0f, 0xb6, 0x0d, - 0xeb, 0xc3, 0x7e, 0x78, 0xcc, 0xf3, 0xbe, 0xaa, 0x9f, 0xfd, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x6d, - 0xdd, 0x12, 0x5d, 0x31, 0x04, 0x00, 0x00, -} - -func (m *CanonicalBlockID) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CanonicalBlockID) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CanonicalBlockID) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PartSetHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCanonical(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintCanonical(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *CanonicalPartSetHeader) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CanonicalPartSetHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CanonicalPartSetHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintCanonical(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x12 - } - if m.Total != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.Total)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *CanonicalProposal) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CanonicalProposal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CanonicalProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ChainID) > 0 { - i -= len(m.ChainID) - copy(dAtA[i:], m.ChainID) - i = encodeVarintCanonical(dAtA, i, uint64(len(m.ChainID))) - i-- - dAtA[i] = 0x3a - } - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintCanonical(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x32 - if m.BlockID != nil { - { - size, err := m.BlockID.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCanonical(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.POLRound != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.POLRound)) - i-- - dAtA[i] = 0x20 - } - if m.Round != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Round)) - i-- - dAtA[i] = 0x19 - } - if m.Height != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Height)) - i-- - dAtA[i] = 0x11 - } - if m.Type != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *CanonicalVote) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CanonicalVote) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CanonicalVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ChainID) > 0 { - i -= len(m.ChainID) - copy(dAtA[i:], m.ChainID) - i = encodeVarintCanonical(dAtA, i, uint64(len(m.ChainID))) - i-- - dAtA[i] = 0x32 - } - n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err4 != nil { - return 0, err4 - } - i -= n4 - i = encodeVarintCanonical(dAtA, i, uint64(n4)) - i-- - dAtA[i] = 0x2a - if m.BlockID != nil { - { - size, err := m.BlockID.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCanonical(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.Round != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Round)) - i-- - dAtA[i] = 0x19 - } - if m.Height != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Height)) - i-- - dAtA[i] = 0x11 - } - if m.Type != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintCanonical(dAtA []byte, offset int, v uint64) int { - offset -= sovCanonical(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *CanonicalBlockID) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovCanonical(uint64(l)) - } - l = m.PartSetHeader.Size() - n += 1 + l + sovCanonical(uint64(l)) - return n -} - -func (m *CanonicalPartSetHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Total != 0 { - n += 1 + sovCanonical(uint64(m.Total)) - } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovCanonical(uint64(l)) - } - return n -} - -func (m *CanonicalProposal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovCanonical(uint64(m.Type)) - } - if m.Height != 0 { - n += 9 - } - if m.Round != 0 { - n += 9 - } - if m.POLRound != 0 { - n += 1 + sovCanonical(uint64(m.POLRound)) - } - if m.BlockID != nil { - l = m.BlockID.Size() - n += 1 + l + sovCanonical(uint64(l)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) - n += 1 + l + sovCanonical(uint64(l)) - l = len(m.ChainID) - if l > 0 { - n += 1 + l + sovCanonical(uint64(l)) - } - return n -} - -func (m *CanonicalVote) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovCanonical(uint64(m.Type)) - } - if m.Height != 0 { - n += 9 - } - if m.Round != 0 { - n += 9 - } - if m.BlockID != nil { - l = m.BlockID.Size() - n += 1 + l + sovCanonical(uint64(l)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) - n += 1 + l + sovCanonical(uint64(l)) - l = len(m.ChainID) - if l > 0 { - n += 1 + l + sovCanonical(uint64(l)) - } - return n -} - -func sovCanonical(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozCanonical(x uint64) (n int) { - return sovCanonical(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *CanonicalBlockID) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CanonicalBlockID: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CanonicalBlockID: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartSetHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCanonical(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *CanonicalPartSetHeader) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CanonicalPartSetHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CanonicalPartSetHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) - } - m.Total = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Total |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCanonical(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *CanonicalProposal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CanonicalProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CanonicalProposal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= SignedMsgType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Height = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) - } - m.Round = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Round = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field POLRound", wireType) - } - m.POLRound = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.POLRound |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockID", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockID == nil { - m.BlockID = &CanonicalBlockID{} - } - if err := m.BlockID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCanonical(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *CanonicalVote) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CanonicalVote: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CanonicalVote: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= SignedMsgType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Height = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) - } - m.Round = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Round = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockID", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockID == nil { - m.BlockID = &CanonicalBlockID{} - } - if err := m.BlockID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCanonical - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCanonical - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCanonical(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCanonical - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipCanonical(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCanonical - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCanonical - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCanonical - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthCanonical - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCanonical - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthCanonical - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthCanonical = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCanonical = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCanonical = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/types/canonical.proto b/third_party/proto/tendermint/types/canonical.proto deleted file mode 100644 index e88fd6ffe3..0000000000 --- a/third_party/proto/tendermint/types/canonical.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "tendermint/types/types.proto"; -import "google/protobuf/timestamp.proto"; - -message CanonicalBlockID { - bytes hash = 1; - CanonicalPartSetHeader part_set_header = 2 [(gogoproto.nullable) = false]; -} - -message CanonicalPartSetHeader { - uint32 total = 1; - bytes hash = 2; -} - -message CanonicalProposal { - SignedMsgType type = 1; // type alias for byte - sfixed64 height = 2; // canonicalization requires fixed size encoding here - sfixed64 round = 3; // canonicalization requires fixed size encoding here - int64 pol_round = 4 [(gogoproto.customname) = "POLRound"]; - CanonicalBlockID block_id = 5 [(gogoproto.customname) = "BlockID"]; - google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - string chain_id = 7 [(gogoproto.customname) = "ChainID"]; -} - -message CanonicalVote { - SignedMsgType type = 1; // type alias for byte - sfixed64 height = 2; // canonicalization requires fixed size encoding here - sfixed64 round = 3; // canonicalization requires fixed size encoding here - CanonicalBlockID block_id = 4 [(gogoproto.customname) = "BlockID"]; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - string chain_id = 6 [(gogoproto.customname) = "ChainID"]; -} diff --git a/third_party/proto/tendermint/types/events.pb.go b/third_party/proto/tendermint/types/events.pb.go deleted file mode 100644 index 8200a4d45a..0000000000 --- a/third_party/proto/tendermint/types/events.pb.go +++ /dev/null @@ -1,399 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/types/events.proto - -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type EventDataRoundState struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` - Step string `protobuf:"bytes,3,opt,name=step,proto3" json:"step,omitempty"` -} - -func (m *EventDataRoundState) Reset() { *m = EventDataRoundState{} } -func (m *EventDataRoundState) String() string { return proto.CompactTextString(m) } -func (*EventDataRoundState) ProtoMessage() {} -func (*EventDataRoundState) Descriptor() ([]byte, []int) { - return fileDescriptor_72cfafd446dedf7c, []int{0} -} - -func (m *EventDataRoundState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *EventDataRoundState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventDataRoundState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *EventDataRoundState) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventDataRoundState.Merge(m, src) -} - -func (m *EventDataRoundState) XXX_Size() int { - return m.Size() -} - -func (m *EventDataRoundState) XXX_DiscardUnknown() { - xxx_messageInfo_EventDataRoundState.DiscardUnknown(m) -} - -var xxx_messageInfo_EventDataRoundState proto.InternalMessageInfo - -func (m *EventDataRoundState) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *EventDataRoundState) GetRound() int32 { - if m != nil { - return m.Round - } - return 0 -} - -func (m *EventDataRoundState) GetStep() string { - if m != nil { - return m.Step - } - return "" -} - -func init() { - proto.RegisterType((*EventDataRoundState)(nil), "tendermint.types.EventDataRoundState") -} - -func init() { proto.RegisterFile("tendermint/types/events.proto", fileDescriptor_72cfafd446dedf7c) } - -var fileDescriptor_72cfafd446dedf7c = []byte{ - // 189 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x2d, 0x4b, - 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x48, 0xeb, 0x81, 0xa5, - 0x95, 0xc2, 0xb9, 0x84, 0x5d, 0x41, 0x2a, 0x5c, 0x12, 0x4b, 0x12, 0x83, 0xf2, 0x4b, 0xf3, 0x52, - 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xc4, 0xb8, 0xd8, 0x32, 0x52, 0x33, 0xd3, 0x33, 0x4a, 0x24, - 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0xa0, 0x3c, 0x21, 0x11, 0x2e, 0xd6, 0x22, 0x90, 0x2a, 0x09, - 0x26, 0x05, 0x46, 0x0d, 0xd6, 0x20, 0x08, 0x47, 0x48, 0x88, 0x8b, 0xa5, 0xb8, 0x24, 0xb5, 0x40, - 0x82, 0x59, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x76, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, - 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, - 0xc6, 0x63, 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, - 0x7d, 0x64, 0xe7, 0x22, 0x98, 0x60, 0xc7, 0xea, 0xa3, 0x7b, 0x25, 0x89, 0x0d, 0x2c, 0x6e, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xe9, 0x14, 0x02, 0xe5, 0x00, 0x00, 0x00, -} - -func (m *EventDataRoundState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventDataRoundState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventDataRoundState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Step) > 0 { - i -= len(m.Step) - copy(dAtA[i:], m.Step) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Step))) - i-- - dAtA[i] = 0x1a - } - if m.Round != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Round)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { - offset -= sovEvents(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *EventDataRoundState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovEvents(uint64(m.Height)) - } - if m.Round != 0 { - n += 1 + sovEvents(uint64(m.Round)) - } - l = len(m.Step) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - return n -} - -func sovEvents(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozEvents(x uint64) (n int) { - return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *EventDataRoundState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventDataRoundState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventDataRoundState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) - } - m.Round = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Round |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Step", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Step = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipEvents(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvents - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEvents - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEvents - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEvents - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/types/events.proto b/third_party/proto/tendermint/types/events.proto deleted file mode 100644 index a1e5cc498d..0000000000 --- a/third_party/proto/tendermint/types/events.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -message EventDataRoundState { - int64 height = 1; - int32 round = 2; - string step = 3; -} diff --git a/third_party/proto/tendermint/types/evidence.pb.go b/third_party/proto/tendermint/types/evidence.pb.go deleted file mode 100644 index af134db418..0000000000 --- a/third_party/proto/tendermint/types/evidence.pb.go +++ /dev/null @@ -1,1429 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/types/evidence.proto - -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - time "time" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf - _ = time.Kitchen -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Evidence struct { - // Types that are valid to be assigned to Sum: - // *Evidence_DuplicateVoteEvidence - // *Evidence_LightClientAttackEvidence - Sum isEvidence_Sum `protobuf_oneof:"sum"` -} - -func (m *Evidence) Reset() { *m = Evidence{} } -func (m *Evidence) String() string { return proto.CompactTextString(m) } -func (*Evidence) ProtoMessage() {} -func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_6825fabc78e0a168, []int{0} -} - -func (m *Evidence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Evidence.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Evidence) XXX_Merge(src proto.Message) { - xxx_messageInfo_Evidence.Merge(m, src) -} - -func (m *Evidence) XXX_Size() int { - return m.Size() -} - -func (m *Evidence) XXX_DiscardUnknown() { - xxx_messageInfo_Evidence.DiscardUnknown(m) -} - -var xxx_messageInfo_Evidence proto.InternalMessageInfo - -type isEvidence_Sum interface { - isEvidence_Sum() - MarshalTo([]byte) (int, error) - Size() int -} - -type Evidence_DuplicateVoteEvidence struct { - DuplicateVoteEvidence *DuplicateVoteEvidence `protobuf:"bytes,1,opt,name=duplicate_vote_evidence,json=duplicateVoteEvidence,proto3,oneof" json:"duplicate_vote_evidence,omitempty"` -} -type Evidence_LightClientAttackEvidence struct { - LightClientAttackEvidence *LightClientAttackEvidence `protobuf:"bytes,2,opt,name=light_client_attack_evidence,json=lightClientAttackEvidence,proto3,oneof" json:"light_client_attack_evidence,omitempty"` -} - -func (*Evidence_DuplicateVoteEvidence) isEvidence_Sum() {} -func (*Evidence_LightClientAttackEvidence) isEvidence_Sum() {} - -func (m *Evidence) GetSum() isEvidence_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *Evidence) GetDuplicateVoteEvidence() *DuplicateVoteEvidence { - if x, ok := m.GetSum().(*Evidence_DuplicateVoteEvidence); ok { - return x.DuplicateVoteEvidence - } - return nil -} - -func (m *Evidence) GetLightClientAttackEvidence() *LightClientAttackEvidence { - if x, ok := m.GetSum().(*Evidence_LightClientAttackEvidence); ok { - return x.LightClientAttackEvidence - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Evidence) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Evidence_DuplicateVoteEvidence)(nil), - (*Evidence_LightClientAttackEvidence)(nil), - } -} - -// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. -type DuplicateVoteEvidence struct { - VoteA *Vote `protobuf:"bytes,1,opt,name=vote_a,json=voteA,proto3" json:"vote_a,omitempty"` - VoteB *Vote `protobuf:"bytes,2,opt,name=vote_b,json=voteB,proto3" json:"vote_b,omitempty"` - TotalVotingPower int64 `protobuf:"varint,3,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` - ValidatorPower int64 `protobuf:"varint,4,opt,name=validator_power,json=validatorPower,proto3" json:"validator_power,omitempty"` - Timestamp time.Time `protobuf:"bytes,5,opt,name=timestamp,proto3,stdtime" json:"timestamp"` -} - -func (m *DuplicateVoteEvidence) Reset() { *m = DuplicateVoteEvidence{} } -func (m *DuplicateVoteEvidence) String() string { return proto.CompactTextString(m) } -func (*DuplicateVoteEvidence) ProtoMessage() {} -func (*DuplicateVoteEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_6825fabc78e0a168, []int{1} -} - -func (m *DuplicateVoteEvidence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *DuplicateVoteEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DuplicateVoteEvidence.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *DuplicateVoteEvidence) XXX_Merge(src proto.Message) { - xxx_messageInfo_DuplicateVoteEvidence.Merge(m, src) -} - -func (m *DuplicateVoteEvidence) XXX_Size() int { - return m.Size() -} - -func (m *DuplicateVoteEvidence) XXX_DiscardUnknown() { - xxx_messageInfo_DuplicateVoteEvidence.DiscardUnknown(m) -} - -var xxx_messageInfo_DuplicateVoteEvidence proto.InternalMessageInfo - -func (m *DuplicateVoteEvidence) GetVoteA() *Vote { - if m != nil { - return m.VoteA - } - return nil -} - -func (m *DuplicateVoteEvidence) GetVoteB() *Vote { - if m != nil { - return m.VoteB - } - return nil -} - -func (m *DuplicateVoteEvidence) GetTotalVotingPower() int64 { - if m != nil { - return m.TotalVotingPower - } - return 0 -} - -func (m *DuplicateVoteEvidence) GetValidatorPower() int64 { - if m != nil { - return m.ValidatorPower - } - return 0 -} - -func (m *DuplicateVoteEvidence) GetTimestamp() time.Time { - if m != nil { - return m.Timestamp - } - return time.Time{} -} - -// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. -type LightClientAttackEvidence struct { - ConflictingBlock *LightBlock `protobuf:"bytes,1,opt,name=conflicting_block,json=conflictingBlock,proto3" json:"conflicting_block,omitempty"` - CommonHeight int64 `protobuf:"varint,2,opt,name=common_height,json=commonHeight,proto3" json:"common_height,omitempty"` - ByzantineValidators []*Validator `protobuf:"bytes,3,rep,name=byzantine_validators,json=byzantineValidators,proto3" json:"byzantine_validators,omitempty"` - TotalVotingPower int64 `protobuf:"varint,4,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` - Timestamp time.Time `protobuf:"bytes,5,opt,name=timestamp,proto3,stdtime" json:"timestamp"` -} - -func (m *LightClientAttackEvidence) Reset() { *m = LightClientAttackEvidence{} } -func (m *LightClientAttackEvidence) String() string { return proto.CompactTextString(m) } -func (*LightClientAttackEvidence) ProtoMessage() {} -func (*LightClientAttackEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_6825fabc78e0a168, []int{2} -} - -func (m *LightClientAttackEvidence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *LightClientAttackEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LightClientAttackEvidence.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *LightClientAttackEvidence) XXX_Merge(src proto.Message) { - xxx_messageInfo_LightClientAttackEvidence.Merge(m, src) -} - -func (m *LightClientAttackEvidence) XXX_Size() int { - return m.Size() -} - -func (m *LightClientAttackEvidence) XXX_DiscardUnknown() { - xxx_messageInfo_LightClientAttackEvidence.DiscardUnknown(m) -} - -var xxx_messageInfo_LightClientAttackEvidence proto.InternalMessageInfo - -func (m *LightClientAttackEvidence) GetConflictingBlock() *LightBlock { - if m != nil { - return m.ConflictingBlock - } - return nil -} - -func (m *LightClientAttackEvidence) GetCommonHeight() int64 { - if m != nil { - return m.CommonHeight - } - return 0 -} - -func (m *LightClientAttackEvidence) GetByzantineValidators() []*Validator { - if m != nil { - return m.ByzantineValidators - } - return nil -} - -func (m *LightClientAttackEvidence) GetTotalVotingPower() int64 { - if m != nil { - return m.TotalVotingPower - } - return 0 -} - -func (m *LightClientAttackEvidence) GetTimestamp() time.Time { - if m != nil { - return m.Timestamp - } - return time.Time{} -} - -type EvidenceList struct { - Evidence []Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"` -} - -func (m *EvidenceList) Reset() { *m = EvidenceList{} } -func (m *EvidenceList) String() string { return proto.CompactTextString(m) } -func (*EvidenceList) ProtoMessage() {} -func (*EvidenceList) Descriptor() ([]byte, []int) { - return fileDescriptor_6825fabc78e0a168, []int{3} -} - -func (m *EvidenceList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *EvidenceList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EvidenceList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *EvidenceList) XXX_Merge(src proto.Message) { - xxx_messageInfo_EvidenceList.Merge(m, src) -} - -func (m *EvidenceList) XXX_Size() int { - return m.Size() -} - -func (m *EvidenceList) XXX_DiscardUnknown() { - xxx_messageInfo_EvidenceList.DiscardUnknown(m) -} - -var xxx_messageInfo_EvidenceList proto.InternalMessageInfo - -func (m *EvidenceList) GetEvidence() []Evidence { - if m != nil { - return m.Evidence - } - return nil -} - -func init() { - proto.RegisterType((*Evidence)(nil), "tendermint.types.Evidence") - proto.RegisterType((*DuplicateVoteEvidence)(nil), "tendermint.types.DuplicateVoteEvidence") - proto.RegisterType((*LightClientAttackEvidence)(nil), "tendermint.types.LightClientAttackEvidence") - proto.RegisterType((*EvidenceList)(nil), "tendermint.types.EvidenceList") -} - -func init() { proto.RegisterFile("tendermint/types/evidence.proto", fileDescriptor_6825fabc78e0a168) } - -var fileDescriptor_6825fabc78e0a168 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xed, 0x3a, 0xa9, 0xc2, 0xb6, 0x40, 0x58, 0x5a, 0x48, 0x43, 0xe4, 0x44, 0xe1, 0xd0, - 0x48, 0x80, 0x2d, 0x95, 0x03, 0x17, 0x2e, 0x35, 0x20, 0x15, 0x29, 0x42, 0x60, 0xa1, 0x1e, 0xb8, - 0x58, 0x6b, 0x7b, 0xeb, 0xac, 0x6a, 0xef, 0x5a, 0xf1, 0x24, 0xa8, 0x3c, 0x45, 0x1e, 0xab, 0x17, - 0xa4, 0x1e, 0x39, 0x01, 0x4a, 0x78, 0x10, 0xe4, 0xf5, 0x9f, 0x44, 0x75, 0xcc, 0x89, 0x4b, 0xe4, - 0xcc, 0xfc, 0xbe, 0x9d, 0x99, 0xcf, 0xb3, 0x46, 0x7d, 0xa0, 0xdc, 0xa7, 0xd3, 0x88, 0x71, 0x30, - 0xe1, 0x2a, 0xa6, 0x89, 0x49, 0xe7, 0xcc, 0xa7, 0xdc, 0xa3, 0x46, 0x3c, 0x15, 0x20, 0x70, 0x7b, - 0x0d, 0x18, 0x12, 0xe8, 0x1e, 0x04, 0x22, 0x10, 0x32, 0x69, 0xa6, 0x4f, 0x19, 0xd7, 0xed, 0x07, - 0x42, 0x04, 0x21, 0x35, 0xe5, 0x3f, 0x77, 0x76, 0x61, 0x02, 0x8b, 0x68, 0x02, 0x24, 0x8a, 0x73, - 0xa0, 0x57, 0xa9, 0x24, 0x7f, 0xf3, 0xec, 0xa0, 0x92, 0x9d, 0x93, 0x90, 0xf9, 0x04, 0xc4, 0x34, - 0x23, 0x86, 0x7f, 0x54, 0xd4, 0x7a, 0x97, 0xf7, 0x86, 0x09, 0x7a, 0xec, 0xcf, 0xe2, 0x90, 0x79, - 0x04, 0xa8, 0x33, 0x17, 0x40, 0x9d, 0xa2, 0xed, 0x8e, 0x3a, 0x50, 0x47, 0x7b, 0x27, 0xc7, 0xc6, - 0xed, 0xbe, 0x8d, 0xb7, 0x85, 0xe0, 0x5c, 0x00, 0x2d, 0x4e, 0x3a, 0x53, 0xec, 0x43, 0x7f, 0x5b, - 0x02, 0x73, 0xd4, 0x0b, 0x59, 0x30, 0x01, 0xc7, 0x0b, 0x19, 0xe5, 0xe0, 0x10, 0x00, 0xe2, 0x5d, - 0xae, 0xeb, 0xec, 0xc8, 0x3a, 0xcf, 0xaa, 0x75, 0xc6, 0xa9, 0xea, 0x8d, 0x14, 0x9d, 0x4a, 0xcd, - 0x46, 0xad, 0xa3, 0xb0, 0x2e, 0x69, 0x35, 0x91, 0x96, 0xcc, 0xa2, 0xe1, 0x62, 0x07, 0x1d, 0x6e, - 0xed, 0x14, 0xbf, 0x40, 0xbb, 0x72, 0x52, 0x92, 0x8f, 0xf8, 0xa8, 0x5a, 0x3a, 0xe5, 0xed, 0x66, - 0x4a, 0x9d, 0x96, 0xb8, 0x9b, 0x77, 0xfa, 0x4f, 0xdc, 0xc2, 0xcf, 0x11, 0x06, 0x01, 0x24, 0x4c, - 0xdd, 0x64, 0x3c, 0x70, 0x62, 0xf1, 0x95, 0x4e, 0x3b, 0xda, 0x40, 0x1d, 0x69, 0x76, 0x5b, 0x66, - 0xce, 0x65, 0xe2, 0x63, 0x1a, 0xc7, 0xc7, 0xe8, 0x7e, 0xf9, 0x7e, 0x72, 0xb4, 0x21, 0xd1, 0x7b, - 0x65, 0x38, 0x03, 0x2d, 0x74, 0xa7, 0x5c, 0x84, 0x4e, 0x53, 0x36, 0xd2, 0x35, 0xb2, 0x55, 0x31, - 0x8a, 0x55, 0x31, 0x3e, 0x17, 0x84, 0xd5, 0xba, 0xfe, 0xd9, 0x57, 0x16, 0xbf, 0xfa, 0xaa, 0xbd, - 0x96, 0x0d, 0xbf, 0xef, 0xa0, 0xa3, 0x5a, 0x53, 0xf1, 0x7b, 0xf4, 0xc0, 0x13, 0xfc, 0x22, 0x64, - 0x9e, 0xec, 0xdb, 0x0d, 0x85, 0x77, 0x99, 0x3b, 0xd4, 0xab, 0x79, 0x39, 0x56, 0xca, 0xd8, 0xed, - 0x0d, 0x99, 0x8c, 0xe0, 0xa7, 0xe8, 0xae, 0x27, 0xa2, 0x48, 0x70, 0x67, 0x42, 0x53, 0x4e, 0x3a, - 0xa7, 0xd9, 0xfb, 0x59, 0xf0, 0x4c, 0xc6, 0xf0, 0x07, 0x74, 0xe0, 0x5e, 0x7d, 0x23, 0x1c, 0x18, - 0xa7, 0x4e, 0x39, 0x6d, 0xd2, 0xd1, 0x06, 0xda, 0x68, 0xef, 0xe4, 0xc9, 0x16, 0x97, 0x0b, 0xc6, - 0x7e, 0x58, 0x0a, 0xcb, 0x58, 0x52, 0x63, 0x7c, 0xa3, 0xc6, 0xf8, 0xff, 0xe1, 0xe7, 0x18, 0xed, - 0x17, 0xee, 0x8d, 0x59, 0x02, 0xf8, 0x35, 0x6a, 0x6d, 0xdc, 0x1e, 0x4d, 0x1e, 0x59, 0x99, 0xa2, - 0xdc, 0xd3, 0x46, 0x7a, 0xa4, 0x5d, 0x2a, 0xac, 0x4f, 0xd7, 0x4b, 0x5d, 0xbd, 0x59, 0xea, 0xea, - 0xef, 0xa5, 0xae, 0x2e, 0x56, 0xba, 0x72, 0xb3, 0xd2, 0x95, 0x1f, 0x2b, 0x5d, 0xf9, 0xf2, 0x2a, - 0x60, 0x30, 0x99, 0xb9, 0x86, 0x27, 0x22, 0x73, 0xf3, 0x7a, 0xaf, 0x1f, 0xb3, 0xaf, 0xc8, 0xed, - 0xab, 0xef, 0xee, 0xca, 0xf8, 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x21, 0x16, 0x68, - 0x9d, 0x04, 0x00, 0x00, -} - -func (m *Evidence) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Evidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Evidence_DuplicateVoteEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Evidence_DuplicateVoteEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.DuplicateVoteEvidence != nil { - { - size, err := m.DuplicateVoteEvidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Evidence_LightClientAttackEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Evidence_LightClientAttackEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.LightClientAttackEvidence != nil { - { - size, err := m.LightClientAttackEvidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func (m *DuplicateVoteEvidence) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DuplicateVoteEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DuplicateVoteEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err3 != nil { - return 0, err3 - } - i -= n3 - i = encodeVarintEvidence(dAtA, i, uint64(n3)) - i-- - dAtA[i] = 0x2a - if m.ValidatorPower != 0 { - i = encodeVarintEvidence(dAtA, i, uint64(m.ValidatorPower)) - i-- - dAtA[i] = 0x20 - } - if m.TotalVotingPower != 0 { - i = encodeVarintEvidence(dAtA, i, uint64(m.TotalVotingPower)) - i-- - dAtA[i] = 0x18 - } - if m.VoteB != nil { - { - size, err := m.VoteB.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.VoteA != nil { - { - size, err := m.VoteA.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LightClientAttackEvidence) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LightClientAttackEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LightClientAttackEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err6 != nil { - return 0, err6 - } - i -= n6 - i = encodeVarintEvidence(dAtA, i, uint64(n6)) - i-- - dAtA[i] = 0x2a - if m.TotalVotingPower != 0 { - i = encodeVarintEvidence(dAtA, i, uint64(m.TotalVotingPower)) - i-- - dAtA[i] = 0x20 - } - if len(m.ByzantineValidators) > 0 { - for iNdEx := len(m.ByzantineValidators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ByzantineValidators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.CommonHeight != 0 { - i = encodeVarintEvidence(dAtA, i, uint64(m.CommonHeight)) - i-- - dAtA[i] = 0x10 - } - if m.ConflictingBlock != nil { - { - size, err := m.ConflictingBlock.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EvidenceList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EvidenceList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EvidenceList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Evidence) > 0 { - for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvidence(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintEvidence(dAtA []byte, offset int, v uint64) int { - offset -= sovEvidence(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *Evidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *Evidence_DuplicateVoteEvidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DuplicateVoteEvidence != nil { - l = m.DuplicateVoteEvidence.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - return n -} - -func (m *Evidence_LightClientAttackEvidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.LightClientAttackEvidence != nil { - l = m.LightClientAttackEvidence.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - return n -} - -func (m *DuplicateVoteEvidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VoteA != nil { - l = m.VoteA.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - if m.VoteB != nil { - l = m.VoteB.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - if m.TotalVotingPower != 0 { - n += 1 + sovEvidence(uint64(m.TotalVotingPower)) - } - if m.ValidatorPower != 0 { - n += 1 + sovEvidence(uint64(m.ValidatorPower)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) - n += 1 + l + sovEvidence(uint64(l)) - return n -} - -func (m *LightClientAttackEvidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ConflictingBlock != nil { - l = m.ConflictingBlock.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - if m.CommonHeight != 0 { - n += 1 + sovEvidence(uint64(m.CommonHeight)) - } - if len(m.ByzantineValidators) > 0 { - for _, e := range m.ByzantineValidators { - l = e.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - } - if m.TotalVotingPower != 0 { - n += 1 + sovEvidence(uint64(m.TotalVotingPower)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) - n += 1 + l + sovEvidence(uint64(l)) - return n -} - -func (m *EvidenceList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Evidence) > 0 { - for _, e := range m.Evidence { - l = e.Size() - n += 1 + l + sovEvidence(uint64(l)) - } - } - return n -} - -func sovEvidence(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozEvidence(x uint64) (n int) { - return sovEvidence(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Evidence) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Evidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DuplicateVoteEvidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &DuplicateVoteEvidence{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Evidence_DuplicateVoteEvidence{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LightClientAttackEvidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &LightClientAttackEvidence{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Evidence_LightClientAttackEvidence{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvidence(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvidence - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *DuplicateVoteEvidence) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DuplicateVoteEvidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DuplicateVoteEvidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VoteA", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.VoteA == nil { - m.VoteA = &Vote{} - } - if err := m.VoteA.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VoteB", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.VoteB == nil { - m.VoteB = &Vote{} - } - if err := m.VoteB.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType) - } - m.TotalVotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalVotingPower |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorPower", wireType) - } - m.ValidatorPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ValidatorPower |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvidence(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvidence - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *LightClientAttackEvidence) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LightClientAttackEvidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LightClientAttackEvidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConflictingBlock", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConflictingBlock == nil { - m.ConflictingBlock = &LightBlock{} - } - if err := m.ConflictingBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CommonHeight", wireType) - } - m.CommonHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CommonHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ByzantineValidators", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ByzantineValidators = append(m.ByzantineValidators, &Validator{}) - if err := m.ByzantineValidators[len(m.ByzantineValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType) - } - m.TotalVotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalVotingPower |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvidence(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvidence - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *EvidenceList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EvidenceList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EvidenceList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvidence - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Evidence = append(m.Evidence, Evidence{}) - if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvidence(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvidence - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipEvidence(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvidence - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvidence - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvidence - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEvidence - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEvidence - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEvidence - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEvidence = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEvidence = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEvidence = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/types/evidence.proto b/third_party/proto/tendermint/types/evidence.proto deleted file mode 100644 index 3b234571ba..0000000000 --- a/third_party/proto/tendermint/types/evidence.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; -import "tendermint/types/types.proto"; -import "tendermint/types/validator.proto"; - -message Evidence { - oneof sum { - DuplicateVoteEvidence duplicate_vote_evidence = 1; - LightClientAttackEvidence light_client_attack_evidence = 2; - } -} - -// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. -message DuplicateVoteEvidence { - tendermint.types.Vote vote_a = 1; - tendermint.types.Vote vote_b = 2; - int64 total_voting_power = 3; - int64 validator_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} - -// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. -message LightClientAttackEvidence { - tendermint.types.LightBlock conflicting_block = 1; - int64 common_height = 2; - repeated tendermint.types.Validator byzantine_validators = 3; - int64 total_voting_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} - -message EvidenceList { - repeated Evidence evidence = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/tendermint/types/params.pb.go b/third_party/proto/tendermint/types/params.pb.go deleted file mode 100644 index 49bd916f1e..0000000000 --- a/third_party/proto/tendermint/types/params.pb.go +++ /dev/null @@ -1,1834 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/types/params.proto - -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - time "time" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/duration" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf - _ = time.Kitchen -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// ConsensusParams contains consensus critical parameters that determine the -// validity of blocks. -type ConsensusParams struct { - Block BlockParams `protobuf:"bytes,1,opt,name=block,proto3" json:"block"` - Evidence EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence"` - Validator ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator"` - Version VersionParams `protobuf:"bytes,4,opt,name=version,proto3" json:"version"` -} - -func (m *ConsensusParams) Reset() { *m = ConsensusParams{} } -func (m *ConsensusParams) String() string { return proto.CompactTextString(m) } -func (*ConsensusParams) ProtoMessage() {} -func (*ConsensusParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{0} -} - -func (m *ConsensusParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ConsensusParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ConsensusParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ConsensusParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConsensusParams.Merge(m, src) -} - -func (m *ConsensusParams) XXX_Size() int { - return m.Size() -} - -func (m *ConsensusParams) XXX_DiscardUnknown() { - xxx_messageInfo_ConsensusParams.DiscardUnknown(m) -} - -var xxx_messageInfo_ConsensusParams proto.InternalMessageInfo - -func (m *ConsensusParams) GetBlock() BlockParams { - if m != nil { - return m.Block - } - return BlockParams{} -} - -func (m *ConsensusParams) GetEvidence() EvidenceParams { - if m != nil { - return m.Evidence - } - return EvidenceParams{} -} - -func (m *ConsensusParams) GetValidator() ValidatorParams { - if m != nil { - return m.Validator - } - return ValidatorParams{} -} - -func (m *ConsensusParams) GetVersion() VersionParams { - if m != nil { - return m.Version - } - return VersionParams{} -} - -// BlockParams contains limits on the block size. -type BlockParams struct { - // Max block size, in bytes. - // Note: must be greater than 0 - MaxBytes int64 `protobuf:"varint,1,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"` - // Max gas per block. - // Note: must be greater or equal to -1 - MaxGas int64 `protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3" json:"max_gas,omitempty"` - // Minimum time increment between consecutive blocks (in milliseconds) If the - // block header timestamp is ahead of the system clock, decrease this value. - // - // Not exposed to the application. - TimeIotaMs int64 `protobuf:"varint,3,opt,name=time_iota_ms,json=timeIotaMs,proto3" json:"time_iota_ms,omitempty"` -} - -func (m *BlockParams) Reset() { *m = BlockParams{} } -func (m *BlockParams) String() string { return proto.CompactTextString(m) } -func (*BlockParams) ProtoMessage() {} -func (*BlockParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{1} -} - -func (m *BlockParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *BlockParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *BlockParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockParams.Merge(m, src) -} - -func (m *BlockParams) XXX_Size() int { - return m.Size() -} - -func (m *BlockParams) XXX_DiscardUnknown() { - xxx_messageInfo_BlockParams.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockParams proto.InternalMessageInfo - -func (m *BlockParams) GetMaxBytes() int64 { - if m != nil { - return m.MaxBytes - } - return 0 -} - -func (m *BlockParams) GetMaxGas() int64 { - if m != nil { - return m.MaxGas - } - return 0 -} - -func (m *BlockParams) GetTimeIotaMs() int64 { - if m != nil { - return m.TimeIotaMs - } - return 0 -} - -// EvidenceParams determine how we handle evidence of malfeasance. -type EvidenceParams struct { - // Max age of evidence, in blocks. - // - // The basic formula for calculating this is: MaxAgeDuration / {average block - // time}. - MaxAgeNumBlocks int64 `protobuf:"varint,1,opt,name=max_age_num_blocks,json=maxAgeNumBlocks,proto3" json:"max_age_num_blocks,omitempty"` - // Max age of evidence, in time. - // - // It should correspond with an app's "unbonding period" or other similar - // mechanism for handling [Nothing-At-Stake - // attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). - MaxAgeDuration time.Duration `protobuf:"bytes,2,opt,name=max_age_duration,json=maxAgeDuration,proto3,stdduration" json:"max_age_duration"` - // This sets the maximum size of total evidence in bytes that can be committed in a single block. - // and should fall comfortably under the max block bytes. - // Default is 1048576 or 1MB - MaxBytes int64 `protobuf:"varint,3,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"` -} - -func (m *EvidenceParams) Reset() { *m = EvidenceParams{} } -func (m *EvidenceParams) String() string { return proto.CompactTextString(m) } -func (*EvidenceParams) ProtoMessage() {} -func (*EvidenceParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{2} -} - -func (m *EvidenceParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *EvidenceParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EvidenceParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *EvidenceParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_EvidenceParams.Merge(m, src) -} - -func (m *EvidenceParams) XXX_Size() int { - return m.Size() -} - -func (m *EvidenceParams) XXX_DiscardUnknown() { - xxx_messageInfo_EvidenceParams.DiscardUnknown(m) -} - -var xxx_messageInfo_EvidenceParams proto.InternalMessageInfo - -func (m *EvidenceParams) GetMaxAgeNumBlocks() int64 { - if m != nil { - return m.MaxAgeNumBlocks - } - return 0 -} - -func (m *EvidenceParams) GetMaxAgeDuration() time.Duration { - if m != nil { - return m.MaxAgeDuration - } - return 0 -} - -func (m *EvidenceParams) GetMaxBytes() int64 { - if m != nil { - return m.MaxBytes - } - return 0 -} - -// ValidatorParams restrict the public key types validators can use. -// NOTE: uses ABCI pubkey naming, not Amino names. -type ValidatorParams struct { - PubKeyTypes []string `protobuf:"bytes,1,rep,name=pub_key_types,json=pubKeyTypes,proto3" json:"pub_key_types,omitempty"` -} - -func (m *ValidatorParams) Reset() { *m = ValidatorParams{} } -func (m *ValidatorParams) String() string { return proto.CompactTextString(m) } -func (*ValidatorParams) ProtoMessage() {} -func (*ValidatorParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{3} -} - -func (m *ValidatorParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *ValidatorParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValidatorParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *ValidatorParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidatorParams.Merge(m, src) -} - -func (m *ValidatorParams) XXX_Size() int { - return m.Size() -} - -func (m *ValidatorParams) XXX_DiscardUnknown() { - xxx_messageInfo_ValidatorParams.DiscardUnknown(m) -} - -var xxx_messageInfo_ValidatorParams proto.InternalMessageInfo - -func (m *ValidatorParams) GetPubKeyTypes() []string { - if m != nil { - return m.PubKeyTypes - } - return nil -} - -// VersionParams contains the ABCI application version. -type VersionParams struct { - AppVersion uint64 `protobuf:"varint,1,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` -} - -func (m *VersionParams) Reset() { *m = VersionParams{} } -func (m *VersionParams) String() string { return proto.CompactTextString(m) } -func (*VersionParams) ProtoMessage() {} -func (*VersionParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{4} -} - -func (m *VersionParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *VersionParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VersionParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *VersionParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_VersionParams.Merge(m, src) -} - -func (m *VersionParams) XXX_Size() int { - return m.Size() -} - -func (m *VersionParams) XXX_DiscardUnknown() { - xxx_messageInfo_VersionParams.DiscardUnknown(m) -} - -var xxx_messageInfo_VersionParams proto.InternalMessageInfo - -func (m *VersionParams) GetAppVersion() uint64 { - if m != nil { - return m.AppVersion - } - return 0 -} - -// HashedParams is a subset of ConsensusParams. -// -// It is hashed into the Header.ConsensusHash. -type HashedParams struct { - BlockMaxBytes int64 `protobuf:"varint,1,opt,name=block_max_bytes,json=blockMaxBytes,proto3" json:"block_max_bytes,omitempty"` - BlockMaxGas int64 `protobuf:"varint,2,opt,name=block_max_gas,json=blockMaxGas,proto3" json:"block_max_gas,omitempty"` -} - -func (m *HashedParams) Reset() { *m = HashedParams{} } -func (m *HashedParams) String() string { return proto.CompactTextString(m) } -func (*HashedParams) ProtoMessage() {} -func (*HashedParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12598271a686f57, []int{5} -} - -func (m *HashedParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *HashedParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HashedParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *HashedParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_HashedParams.Merge(m, src) -} - -func (m *HashedParams) XXX_Size() int { - return m.Size() -} - -func (m *HashedParams) XXX_DiscardUnknown() { - xxx_messageInfo_HashedParams.DiscardUnknown(m) -} - -var xxx_messageInfo_HashedParams proto.InternalMessageInfo - -func (m *HashedParams) GetBlockMaxBytes() int64 { - if m != nil { - return m.BlockMaxBytes - } - return 0 -} - -func (m *HashedParams) GetBlockMaxGas() int64 { - if m != nil { - return m.BlockMaxGas - } - return 0 -} - -func init() { - proto.RegisterType((*ConsensusParams)(nil), "tendermint.types.ConsensusParams") - proto.RegisterType((*BlockParams)(nil), "tendermint.types.BlockParams") - proto.RegisterType((*EvidenceParams)(nil), "tendermint.types.EvidenceParams") - proto.RegisterType((*ValidatorParams)(nil), "tendermint.types.ValidatorParams") - proto.RegisterType((*VersionParams)(nil), "tendermint.types.VersionParams") - proto.RegisterType((*HashedParams)(nil), "tendermint.types.HashedParams") -} - -func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) } - -var fileDescriptor_e12598271a686f57 = []byte{ - // 537 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x18, 0xcd, 0xd5, 0xa5, 0x4d, 0xbe, 0x34, 0x4d, 0x75, 0x42, 0x22, 0x14, 0xd5, 0x0e, 0x1e, 0x50, - 0x25, 0x24, 0x5b, 0x82, 0x01, 0xd1, 0xa5, 0xc2, 0x50, 0x15, 0x84, 0x82, 0x90, 0x05, 0x0c, 0x5d, - 0xac, 0x73, 0x72, 0xb8, 0x56, 0x73, 0x3e, 0xcb, 0x77, 0x8e, 0x92, 0x7f, 0xc1, 0xd8, 0xb1, 0x23, - 0xfc, 0x03, 0x7e, 0x42, 0xc7, 0x8e, 0x4c, 0x80, 0x92, 0x85, 0x9f, 0x81, 0x7c, 0xce, 0xe1, 0x38, - 0x65, 0xf3, 0x7d, 0xdf, 0x7b, 0xef, 0xfc, 0xde, 0xd3, 0xc1, 0x81, 0xa4, 0xc9, 0x88, 0x66, 0x2c, - 0x4e, 0xa4, 0x2b, 0x67, 0x29, 0x15, 0x6e, 0x4a, 0x32, 0xc2, 0x84, 0x93, 0x66, 0x5c, 0x72, 0xbc, - 0x57, 0xad, 0x1d, 0xb5, 0xde, 0xbf, 0x1b, 0xf1, 0x88, 0xab, 0xa5, 0x5b, 0x7c, 0x95, 0xb8, 0x7d, - 0x33, 0xe2, 0x3c, 0x1a, 0x53, 0x57, 0x9d, 0xc2, 0xfc, 0xb3, 0x3b, 0xca, 0x33, 0x22, 0x63, 0x9e, - 0x94, 0x7b, 0xfb, 0x72, 0x03, 0xba, 0x2f, 0x79, 0x22, 0x68, 0x22, 0x72, 0xf1, 0x5e, 0xdd, 0x80, - 0x9f, 0xc3, 0x9d, 0x70, 0xcc, 0x87, 0x17, 0x3d, 0xd4, 0x47, 0x87, 0xed, 0x27, 0x07, 0xce, 0xfa, - 0x5d, 0x8e, 0x57, 0xac, 0x4b, 0xb4, 0xb7, 0x79, 0xfd, 0xd3, 0x6a, 0xf8, 0x25, 0x03, 0x7b, 0xd0, - 0xa4, 0x93, 0x78, 0x44, 0x93, 0x21, 0xed, 0x6d, 0x28, 0x76, 0xff, 0x36, 0xfb, 0x64, 0x89, 0xa8, - 0x09, 0xfc, 0xe3, 0xe1, 0x13, 0x68, 0x4d, 0xc8, 0x38, 0x1e, 0x11, 0xc9, 0xb3, 0x9e, 0xa1, 0x44, - 0x1e, 0xde, 0x16, 0xf9, 0xa4, 0x21, 0x35, 0x95, 0x8a, 0x89, 0x8f, 0x61, 0x7b, 0x42, 0x33, 0x11, - 0xf3, 0xa4, 0xb7, 0xa9, 0x44, 0xac, 0xff, 0x88, 0x94, 0x80, 0x9a, 0x84, 0x66, 0xd9, 0x14, 0xda, - 0x2b, 0x3e, 0xf1, 0x03, 0x68, 0x31, 0x32, 0x0d, 0xc2, 0x99, 0xa4, 0x42, 0x25, 0x63, 0xf8, 0x4d, - 0x46, 0xa6, 0x5e, 0x71, 0xc6, 0xf7, 0x60, 0xbb, 0x58, 0x46, 0x44, 0x28, 0xdb, 0x86, 0xbf, 0xc5, - 0xc8, 0xf4, 0x94, 0x08, 0xdc, 0x87, 0x1d, 0x19, 0x33, 0x1a, 0xc4, 0x5c, 0x92, 0x80, 0x09, 0xe5, - 0xc7, 0xf0, 0xa1, 0x98, 0xbd, 0xe1, 0x92, 0x0c, 0x84, 0xfd, 0x0d, 0xc1, 0x6e, 0x3d, 0x11, 0xfc, - 0x18, 0x70, 0xa1, 0x46, 0x22, 0x1a, 0x24, 0x39, 0x0b, 0x54, 0xb4, 0xfa, 0xce, 0x2e, 0x23, 0xd3, - 0x17, 0x11, 0x7d, 0x97, 0x33, 0xf5, 0x73, 0x02, 0x0f, 0x60, 0x4f, 0x83, 0x75, 0xb7, 0xcb, 0xe8, - 0xef, 0x3b, 0x65, 0xf9, 0x8e, 0x2e, 0xdf, 0x79, 0xb5, 0x04, 0x78, 0xcd, 0xc2, 0xea, 0xe5, 0x2f, - 0x0b, 0xf9, 0xbb, 0xa5, 0x9e, 0xde, 0xd4, 0x6d, 0x1a, 0x75, 0x9b, 0xf6, 0x31, 0x74, 0xd7, 0x72, - 0xc7, 0x36, 0x74, 0xd2, 0x3c, 0x0c, 0x2e, 0xe8, 0x2c, 0x50, 0x99, 0xf6, 0x50, 0xdf, 0x38, 0x6c, - 0xf9, 0xed, 0x34, 0x0f, 0xdf, 0xd2, 0xd9, 0x87, 0x62, 0x74, 0xd4, 0xfc, 0x7e, 0x65, 0xa1, 0x3f, - 0x57, 0x16, 0xb2, 0x8f, 0xa0, 0x53, 0xcb, 0x1c, 0x5b, 0xd0, 0x26, 0x69, 0x1a, 0xe8, 0xa6, 0x0a, - 0x8f, 0x9b, 0x3e, 0x90, 0x34, 0x5d, 0xc2, 0x56, 0xb8, 0x67, 0xb0, 0xf3, 0x9a, 0x88, 0x73, 0x3a, - 0x5a, 0x52, 0x1f, 0x41, 0x57, 0x25, 0x13, 0xac, 0xd7, 0xd2, 0x51, 0xe3, 0x81, 0xee, 0xc6, 0x86, - 0x4e, 0x85, 0xab, 0x1a, 0x6a, 0x6b, 0xd4, 0x29, 0x11, 0xde, 0xc7, 0xaf, 0x73, 0x13, 0x5d, 0xcf, - 0x4d, 0x74, 0x33, 0x37, 0xd1, 0xef, 0xb9, 0x89, 0xbe, 0x2c, 0xcc, 0xc6, 0xcd, 0xc2, 0x6c, 0xfc, - 0x58, 0x98, 0x8d, 0xb3, 0x67, 0x51, 0x2c, 0xcf, 0xf3, 0xd0, 0x19, 0x72, 0xe6, 0xae, 0x3e, 0xcb, - 0xea, 0xb3, 0x7c, 0x77, 0xeb, 0x4f, 0x36, 0xdc, 0x52, 0xf3, 0xa7, 0x7f, 0x03, 0x00, 0x00, 0xff, - 0xff, 0xfe, 0xe0, 0x3d, 0x9c, 0xcd, 0x03, 0x00, 0x00, -} - -func (this *ConsensusParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ConsensusParams) - if !ok { - that2, ok := that.(ConsensusParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Block.Equal(&that1.Block) { - return false - } - if !this.Evidence.Equal(&that1.Evidence) { - return false - } - if !this.Validator.Equal(&that1.Validator) { - return false - } - if !this.Version.Equal(&that1.Version) { - return false - } - return true -} - -func (this *BlockParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*BlockParams) - if !ok { - that2, ok := that.(BlockParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.MaxBytes != that1.MaxBytes { - return false - } - if this.MaxGas != that1.MaxGas { - return false - } - if this.TimeIotaMs != that1.TimeIotaMs { - return false - } - return true -} - -func (this *EvidenceParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*EvidenceParams) - if !ok { - that2, ok := that.(EvidenceParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.MaxAgeNumBlocks != that1.MaxAgeNumBlocks { - return false - } - if this.MaxAgeDuration != that1.MaxAgeDuration { - return false - } - if this.MaxBytes != that1.MaxBytes { - return false - } - return true -} - -func (this *ValidatorParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ValidatorParams) - if !ok { - that2, ok := that.(ValidatorParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.PubKeyTypes) != len(that1.PubKeyTypes) { - return false - } - for i := range this.PubKeyTypes { - if this.PubKeyTypes[i] != that1.PubKeyTypes[i] { - return false - } - } - return true -} - -func (this *VersionParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*VersionParams) - if !ok { - that2, ok := that.(VersionParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.AppVersion != that1.AppVersion { - return false - } - return true -} - -func (this *HashedParams) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*HashedParams) - if !ok { - that2, ok := that.(HashedParams) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.BlockMaxBytes != that1.BlockMaxBytes { - return false - } - if this.BlockMaxGas != that1.BlockMaxGas { - return false - } - return true -} - -func (m *ConsensusParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ConsensusParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ConsensusParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Version.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.Validator.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *BlockParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BlockParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TimeIotaMs != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.TimeIotaMs)) - i-- - dAtA[i] = 0x18 - } - if m.MaxGas != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxGas)) - i-- - dAtA[i] = 0x10 - } - if m.MaxBytes != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxBytes)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EvidenceParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EvidenceParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MaxBytes != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxBytes)) - i-- - dAtA[i] = 0x18 - } - n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAgeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintParams(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x12 - if m.MaxAgeNumBlocks != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxAgeNumBlocks)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ValidatorParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ValidatorParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValidatorParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PubKeyTypes) > 0 { - for iNdEx := len(m.PubKeyTypes) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.PubKeyTypes[iNdEx]) - copy(dAtA[i:], m.PubKeyTypes[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.PubKeyTypes[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *VersionParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VersionParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VersionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AppVersion != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.AppVersion)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *HashedParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HashedParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HashedParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlockMaxGas != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.BlockMaxGas)) - i-- - dAtA[i] = 0x10 - } - if m.BlockMaxBytes != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.BlockMaxBytes)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func NewPopulatedValidatorParams(r randyParams, easy bool) *ValidatorParams { - this := &ValidatorParams{} - v1 := r.Intn(10) - this.PubKeyTypes = make([]string, v1) - for i := 0; i < v1; i++ { - this.PubKeyTypes[i] = string(randStringParams(r)) - } - if !easy && r.Intn(10) != 0 { - } - return this -} - -func NewPopulatedVersionParams(r randyParams, easy bool) *VersionParams { - this := &VersionParams{} - this.AppVersion = uint64(uint64(r.Uint32())) - if !easy && r.Intn(10) != 0 { - } - return this -} - -type randyParams interface { - Float32() float32 - Float64() float64 - Int63() int64 - Int31() int32 - Uint32() uint32 - Intn(n int) int -} - -func randUTF8RuneParams(r randyParams) rune { - ru := r.Intn(62) - if ru < 10 { - return rune(ru + 48) - } else if ru < 36 { - return rune(ru + 55) - } - return rune(ru + 61) -} - -func randStringParams(r randyParams) string { - v2 := r.Intn(100) - tmps := make([]rune, v2) - for i := 0; i < v2; i++ { - tmps[i] = randUTF8RuneParams(r) - } - return string(tmps) -} - -func randUnrecognizedParams(r randyParams, maxFieldNumber int) (dAtA []byte) { - l := r.Intn(5) - for i := 0; i < l; i++ { - wire := r.Intn(4) - if wire == 3 { - wire = 5 - } - fieldNumber := maxFieldNumber + r.Intn(100) - dAtA = randFieldParams(dAtA, r, fieldNumber, wire) - } - return dAtA -} - -func randFieldParams(dAtA []byte, r randyParams, fieldNumber int, wire int) []byte { - key := uint32(fieldNumber)<<3 | uint32(wire) - switch wire { - case 0: - dAtA = encodeVarintPopulateParams(dAtA, uint64(key)) - v3 := r.Int63() - if r.Intn(2) == 0 { - v3 *= -1 - } - dAtA = encodeVarintPopulateParams(dAtA, uint64(v3)) - case 1: - dAtA = encodeVarintPopulateParams(dAtA, uint64(key)) - dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) - case 2: - dAtA = encodeVarintPopulateParams(dAtA, uint64(key)) - ll := r.Intn(100) - dAtA = encodeVarintPopulateParams(dAtA, uint64(ll)) - for j := 0; j < ll; j++ { - dAtA = append(dAtA, byte(r.Intn(256))) - } - default: - dAtA = encodeVarintPopulateParams(dAtA, uint64(key)) - dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) - } - return dAtA -} - -func encodeVarintPopulateParams(dAtA []byte, v uint64) []byte { - for v >= 1<<7 { - dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) - v >>= 7 - } - dAtA = append(dAtA, uint8(v)) - return dAtA -} - -func (m *ConsensusParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Block.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.Evidence.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.Validator.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.Version.Size() - n += 1 + l + sovParams(uint64(l)) - return n -} - -func (m *BlockParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MaxBytes != 0 { - n += 1 + sovParams(uint64(m.MaxBytes)) - } - if m.MaxGas != 0 { - n += 1 + sovParams(uint64(m.MaxGas)) - } - if m.TimeIotaMs != 0 { - n += 1 + sovParams(uint64(m.TimeIotaMs)) - } - return n -} - -func (m *EvidenceParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MaxAgeNumBlocks != 0 { - n += 1 + sovParams(uint64(m.MaxAgeNumBlocks)) - } - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration) - n += 1 + l + sovParams(uint64(l)) - if m.MaxBytes != 0 { - n += 1 + sovParams(uint64(m.MaxBytes)) - } - return n -} - -func (m *ValidatorParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PubKeyTypes) > 0 { - for _, s := range m.PubKeyTypes { - l = len(s) - n += 1 + l + sovParams(uint64(l)) - } - } - return n -} - -func (m *VersionParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AppVersion != 0 { - n += 1 + sovParams(uint64(m.AppVersion)) - } - return n -} - -func (m *HashedParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockMaxBytes != 0 { - n += 1 + sovParams(uint64(m.BlockMaxBytes)) - } - if m.BlockMaxGas != 0 { - n += 1 + sovParams(uint64(m.BlockMaxGas)) - } - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *ConsensusParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ConsensusParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ConsensusParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Validator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *BlockParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BlockParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxBytes", wireType) - } - m.MaxBytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxBytes |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxGas", wireType) - } - m.MaxGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxGas |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeIotaMs", wireType) - } - m.TimeIotaMs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeIotaMs |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *EvidenceParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EvidenceParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EvidenceParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxAgeNumBlocks", wireType) - } - m.MaxAgeNumBlocks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxAgeNumBlocks |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxAgeDuration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAgeDuration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxBytes", wireType) - } - m.MaxBytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxBytes |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *ValidatorParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ValidatorParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValidatorParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKeyTypes", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PubKeyTypes = append(m.PubKeyTypes, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *VersionParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VersionParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VersionParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) - } - m.AppVersion = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AppVersion |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *HashedParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HashedParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HashedParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockMaxBytes", wireType) - } - m.BlockMaxBytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockMaxBytes |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockMaxGas", wireType) - } - m.BlockMaxGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockMaxGas |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/types/params.proto b/third_party/proto/tendermint/types/params.proto deleted file mode 100644 index 0de7d846fb..0000000000 --- a/third_party/proto/tendermint/types/params.proto +++ /dev/null @@ -1,80 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/duration.proto"; - -option (gogoproto.equal_all) = true; - -// ConsensusParams contains consensus critical parameters that determine the -// validity of blocks. -message ConsensusParams { - BlockParams block = 1 [(gogoproto.nullable) = false]; - EvidenceParams evidence = 2 [(gogoproto.nullable) = false]; - ValidatorParams validator = 3 [(gogoproto.nullable) = false]; - VersionParams version = 4 [(gogoproto.nullable) = false]; -} - -// BlockParams contains limits on the block size. -message BlockParams { - // Max block size, in bytes. - // Note: must be greater than 0 - int64 max_bytes = 1; - // Max gas per block. - // Note: must be greater or equal to -1 - int64 max_gas = 2; - // Minimum time increment between consecutive blocks (in milliseconds) If the - // block header timestamp is ahead of the system clock, decrease this value. - // - // Not exposed to the application. - int64 time_iota_ms = 3; -} - -// EvidenceParams determine how we handle evidence of malfeasance. -message EvidenceParams { - // Max age of evidence, in blocks. - // - // The basic formula for calculating this is: MaxAgeDuration / {average block - // time}. - int64 max_age_num_blocks = 1; - - // Max age of evidence, in time. - // - // It should correspond with an app's "unbonding period" or other similar - // mechanism for handling [Nothing-At-Stake - // attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). - google.protobuf.Duration max_age_duration = 2 - [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - - // This sets the maximum size of total evidence in bytes that can be committed in a single block. - // and should fall comfortably under the max block bytes. - // Default is 1048576 or 1MB - int64 max_bytes = 3; -} - -// ValidatorParams restrict the public key types validators can use. -// NOTE: uses ABCI pubkey naming, not Amino names. -message ValidatorParams { - option (gogoproto.populate) = true; - option (gogoproto.equal) = true; - - repeated string pub_key_types = 1; -} - -// VersionParams contains the ABCI application version. -message VersionParams { - option (gogoproto.populate) = true; - option (gogoproto.equal) = true; - - uint64 app_version = 1; -} - -// HashedParams is a subset of ConsensusParams. -// -// It is hashed into the Header.ConsensusHash. -message HashedParams { - int64 block_max_bytes = 1; - int64 block_max_gas = 2; -} diff --git a/third_party/proto/tendermint/types/types.proto b/third_party/proto/tendermint/types/types.proto deleted file mode 100644 index 7f7ea74cac..0000000000 --- a/third_party/proto/tendermint/types/types.proto +++ /dev/null @@ -1,157 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; -import "tendermint/crypto/proof.proto"; -import "tendermint/version/types.proto"; -import "tendermint/types/validator.proto"; - -// BlockIdFlag indicates which BlcokID the signature is for -enum BlockIDFlag { - option (gogoproto.goproto_enum_stringer) = true; - option (gogoproto.goproto_enum_prefix) = false; - - BLOCK_ID_FLAG_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "BlockIDFlagUnknown"]; - BLOCK_ID_FLAG_ABSENT = 1 [(gogoproto.enumvalue_customname) = "BlockIDFlagAbsent"]; - BLOCK_ID_FLAG_COMMIT = 2 [(gogoproto.enumvalue_customname) = "BlockIDFlagCommit"]; - BLOCK_ID_FLAG_NIL = 3 [(gogoproto.enumvalue_customname) = "BlockIDFlagNil"]; -} - -// SignedMsgType is a type of signed message in the consensus. -enum SignedMsgType { - option (gogoproto.goproto_enum_stringer) = true; - option (gogoproto.goproto_enum_prefix) = false; - - SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"]; - // Votes - SIGNED_MSG_TYPE_PREVOTE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"]; - SIGNED_MSG_TYPE_PRECOMMIT = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"]; - - // Proposals - SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"]; -} - -// PartsetHeader -message PartSetHeader { - uint32 total = 1; - bytes hash = 2; -} - -message Part { - uint32 index = 1; - bytes bytes = 2; - tendermint.crypto.Proof proof = 3 [(gogoproto.nullable) = false]; -} - -// BlockID -message BlockID { - bytes hash = 1; - PartSetHeader part_set_header = 2 [(gogoproto.nullable) = false]; -} - -// -------------------------------- - -// Header defines the structure of a Tendermint block header. -message Header { - // basic block info - tendermint.version.Consensus version = 1 [(gogoproto.nullable) = false]; - string chain_id = 2 [(gogoproto.customname) = "ChainID"]; - int64 height = 3; - google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - - // prev block info - BlockID last_block_id = 5 [(gogoproto.nullable) = false]; - - // hashes of block data - bytes last_commit_hash = 6; // commit from validators from the last block - bytes data_hash = 7; // transactions - - // hashes from the app output from the prev block - bytes validators_hash = 8; // validators for the current block - bytes next_validators_hash = 9; // validators for the next block - bytes consensus_hash = 10; // consensus params for current block - bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block - - // consensus info - bytes evidence_hash = 13; // evidence included in the block - bytes proposer_address = 14; // original proposer of the block -} - -// Data contains the set of transactions included in the block -message Data { - // Txs that will be applied by state @ block.Height+1. - // NOTE: not all txs here are valid. We're just agreeing on the order first. - // This means that block.AppHash does not include these txs. - repeated bytes txs = 1; -} - -// Vote represents a prevote, precommit, or commit vote from validators for -// consensus. -message Vote { - SignedMsgType type = 1; - int64 height = 2; - int32 round = 3; - BlockID block_id = 4 - [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. - google.protobuf.Timestamp timestamp = 5 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes validator_address = 6; - int32 validator_index = 7; - bytes signature = 8; -} - -// Commit contains the evidence that a block was committed by a set of validators. -message Commit { - int64 height = 1; - int32 round = 2; - BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; - repeated CommitSig signatures = 4 [(gogoproto.nullable) = false]; -} - -// CommitSig is a part of the Vote included in a Commit. -message CommitSig { - BlockIDFlag block_id_flag = 1; - bytes validator_address = 2; - google.protobuf.Timestamp timestamp = 3 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 4; -} - -message Proposal { - SignedMsgType type = 1; - int64 height = 2; - int32 round = 3; - int32 pol_round = 4; - BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - google.protobuf.Timestamp timestamp = 6 - [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 7; -} - -message SignedHeader { - Header header = 1; - Commit commit = 2; -} - -message LightBlock { - SignedHeader signed_header = 1; - tendermint.types.ValidatorSet validator_set = 2; -} - -message BlockMeta { - BlockID block_id = 1 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - int64 block_size = 2; - Header header = 3 [(gogoproto.nullable) = false]; - int64 num_txs = 4; -} - -// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. -message TxProof { - bytes root_hash = 1; - bytes data = 2; - tendermint.crypto.Proof proof = 3; -} diff --git a/third_party/proto/tendermint/types/validator.proto b/third_party/proto/tendermint/types/validator.proto deleted file mode 100644 index 49860b96d6..0000000000 --- a/third_party/proto/tendermint/types/validator.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; -package tendermint.types; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; - -import "gogoproto/gogo.proto"; -import "tendermint/crypto/keys.proto"; - -message ValidatorSet { - repeated Validator validators = 1; - Validator proposer = 2; - int64 total_voting_power = 3; -} - -message Validator { - bytes address = 1; - tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false]; - int64 voting_power = 3; - int64 proposer_priority = 4; -} - -message SimpleValidator { - tendermint.crypto.PublicKey pub_key = 1; - int64 voting_power = 2; -} diff --git a/third_party/proto/tendermint/version/types.pb.go b/third_party/proto/tendermint/version/types.pb.go deleted file mode 100644 index 33e74d817a..0000000000 --- a/third_party/proto/tendermint/version/types.pb.go +++ /dev/null @@ -1,596 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: tendermint/version/types.proto - -package version - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - -var ( - _ = fmt.Errorf - _ = math.Inf -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// App includes the protocol and software version for the application. -// This information is included in ResponseInfo. The App.Protocol can be -// updated in ResponseEndBlock. -type App struct { - Protocol uint64 `protobuf:"varint,1,opt,name=protocol,proto3" json:"protocol,omitempty"` - Software string `protobuf:"bytes,2,opt,name=software,proto3" json:"software,omitempty"` -} - -func (m *App) Reset() { *m = App{} } -func (m *App) String() string { return proto.CompactTextString(m) } -func (*App) ProtoMessage() {} -func (*App) Descriptor() ([]byte, []int) { - return fileDescriptor_f9b42966edc5edad, []int{0} -} - -func (m *App) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *App) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_App.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *App) XXX_Merge(src proto.Message) { - xxx_messageInfo_App.Merge(m, src) -} - -func (m *App) XXX_Size() int { - return m.Size() -} - -func (m *App) XXX_DiscardUnknown() { - xxx_messageInfo_App.DiscardUnknown(m) -} - -var xxx_messageInfo_App proto.InternalMessageInfo - -func (m *App) GetProtocol() uint64 { - if m != nil { - return m.Protocol - } - return 0 -} - -func (m *App) GetSoftware() string { - if m != nil { - return m.Software - } - return "" -} - -// Consensus captures the consensus rules for processing a block in the blockchain, -// including all blockchain data structures and the rules of the application's -// state transition machine. -type Consensus struct { - Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` - App uint64 `protobuf:"varint,2,opt,name=app,proto3" json:"app,omitempty"` -} - -func (m *Consensus) Reset() { *m = Consensus{} } -func (m *Consensus) String() string { return proto.CompactTextString(m) } -func (*Consensus) ProtoMessage() {} -func (*Consensus) Descriptor() ([]byte, []int) { - return fileDescriptor_f9b42966edc5edad, []int{1} -} - -func (m *Consensus) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Consensus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Consensus.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Consensus) XXX_Merge(src proto.Message) { - xxx_messageInfo_Consensus.Merge(m, src) -} - -func (m *Consensus) XXX_Size() int { - return m.Size() -} - -func (m *Consensus) XXX_DiscardUnknown() { - xxx_messageInfo_Consensus.DiscardUnknown(m) -} - -var xxx_messageInfo_Consensus proto.InternalMessageInfo - -func (m *Consensus) GetBlock() uint64 { - if m != nil { - return m.Block - } - return 0 -} - -func (m *Consensus) GetApp() uint64 { - if m != nil { - return m.App - } - return 0 -} - -func init() { - proto.RegisterType((*App)(nil), "tendermint.version.App") - proto.RegisterType((*Consensus)(nil), "tendermint.version.Consensus") -} - -func init() { proto.RegisterFile("tendermint/version/types.proto", fileDescriptor_f9b42966edc5edad) } - -var fileDescriptor_f9b42966edc5edad = []byte{ - // 218 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0x2a, 0xce, 0xcc, 0xcf, 0xd3, 0x2f, - 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0xc8, 0xeb, 0x41, - 0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xd2, 0xfa, 0x20, 0x16, 0x44, 0xa5, 0x92, 0x2d, - 0x17, 0xb3, 0x63, 0x41, 0x81, 0x90, 0x14, 0x17, 0x07, 0x98, 0x9f, 0x9c, 0x9f, 0x23, 0xc1, 0xa8, - 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0xe7, 0x83, 0xe4, 0x8a, 0xf3, 0xd3, 0x4a, 0xca, 0x13, 0x8b, 0x52, - 0x25, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, 0xe0, 0x7c, 0x25, 0x4b, 0x2e, 0x4e, 0xe7, 0xfc, 0xbc, - 0xe2, 0xd4, 0xbc, 0xe2, 0xd2, 0x62, 0x21, 0x11, 0x2e, 0xd6, 0xa4, 0x9c, 0xfc, 0xe4, 0x6c, 0xa8, - 0x09, 0x10, 0x8e, 0x90, 0x00, 0x17, 0x73, 0x62, 0x41, 0x01, 0x58, 0x27, 0x4b, 0x10, 0x88, 0x69, - 0xc5, 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, - 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, - 0x31, 0x44, 0x59, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x79, - 0x14, 0x89, 0x09, 0xf1, 0x06, 0x66, 0x20, 0x24, 0xb1, 0x81, 0x65, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x42, 0x43, 0x65, 0xc7, 0x21, 0x01, 0x00, 0x00, -} - -func (this *Consensus) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Consensus) - if !ok { - that2, ok := that.(Consensus) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Block != that1.Block { - return false - } - if this.App != that1.App { - return false - } - return true -} - -func (m *App) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *App) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *App) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Software) > 0 { - i -= len(m.Software) - copy(dAtA[i:], m.Software) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Software))) - i-- - dAtA[i] = 0x12 - } - if m.Protocol != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Protocol)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Consensus) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Consensus) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Consensus) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.App != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.App)) - i-- - dAtA[i] = 0x10 - } - if m.Block != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Block)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *App) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Protocol != 0 { - n += 1 + sovTypes(uint64(m.Protocol)) - } - l = len(m.Software) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *Consensus) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Block != 0 { - n += 1 + sovTypes(uint64(m.Block)) - } - if m.App != 0 { - n += 1 + sovTypes(uint64(m.App)) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *App) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: App: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: App: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) - } - m.Protocol = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Protocol |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Software", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Software = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *Consensus) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Consensus: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Consensus: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - m.Block = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Block |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field App", wireType) - } - m.App = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.App |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/third_party/proto/tendermint/version/types.proto b/third_party/proto/tendermint/version/types.proto deleted file mode 100644 index 6061868bd4..0000000000 --- a/third_party/proto/tendermint/version/types.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; -package tendermint.version; - -option go_package = "github.com/tendermint/tendermint/proto/tendermint/version"; - -import "gogoproto/gogo.proto"; - -// App includes the protocol and software version for the application. -// This information is included in ResponseInfo. The App.Protocol can be -// updated in ResponseEndBlock. -message App { - uint64 protocol = 1; - string software = 2; -} - -// Consensus captures the consensus rules for processing a block in the blockchain, -// including all blockchain data structures and the rules of the application's -// state transition machine. -message Consensus { - option (gogoproto.equal) = true; - - uint64 block = 1; - uint64 app = 2; -} diff --git a/x/wasm/alias.go b/x/wasm/alias.go index 01f6a74518..248ab83906 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -1,6 +1,11 @@ -// nolint +// Package wasm nolint package wasm +// autogenerated code using github.com/rigelrozanski/multitool +// aliases generated for the following subdirectories: +// ALIASGEN: github.com/Cosmwasm/wasmd/x/wasm/types +// ALIASGEN: github.com/CosmWasm/wasmd/x/wasm/keeper + import ( "github.com/line/wasmd/x/wasm/keeper" "github.com/line/wasmd/x/wasm/lbmtypes" @@ -52,12 +57,14 @@ var ( NewMessageHandler = keeper.NewDefaultMessageHandler DefaultEncoders = keeper.DefaultEncoders EncodeBankMsg = keeper.EncodeBankMsg + NoCustomMsg = keeper.NoCustomMsg EncodeStakingMsg = keeper.EncodeStakingMsg EncodeWasmMsg = keeper.EncodeWasmMsg NewKeeper = keeper.NewKeeper NewLegacyQuerier = keeper.NewLegacyQuerier DefaultQueryPlugins = keeper.DefaultQueryPlugins BankQuerier = keeper.BankQuerier + NoCustomQuerier = keeper.NoCustomQuerier StakingQuerier = keeper.StakingQuerier WasmQuerier = keeper.WasmQuerier CreateTestInput = keeper.CreateTestInput @@ -89,41 +96,43 @@ var ( ) type ( - ProposalType = types.ProposalType - GenesisState = types.GenesisState - Code = types.Code - Contract = types.Contract - MsgStoreCode = types.MsgStoreCode - MsgStoreCodeResponse = types.MsgStoreCodeResponse - MsgInstantiateContract = types.MsgInstantiateContract - MsgInstantiateContractResponse = types.MsgInstantiateContractResponse + ProposalType = types.ProposalType + GenesisState = types.GenesisState + Code = types.Code + Contract = types.Contract + MsgStoreCode = types.MsgStoreCode + MsgStoreCodeResponse = types.MsgStoreCodeResponse + MsgInstantiateContract = types.MsgInstantiateContract + MsgInstantiateContract2 = types.MsgInstantiateContract2 + MsgInstantiateContractResponse = types.MsgInstantiateContractResponse + MsgExecuteContract = types.MsgExecuteContract + MsgExecuteContractResponse = types.MsgExecuteContractResponse + MsgMigrateContract = types.MsgMigrateContract + MsgMigrateContractResponse = types.MsgMigrateContractResponse + MsgUpdateAdmin = types.MsgUpdateAdmin + MsgUpdateAdminResponse = types.MsgUpdateAdminResponse + MsgClearAdmin = types.MsgClearAdmin + MsgWasmIBCCall = types.MsgIBCSend + MsgClearAdminResponse = types.MsgClearAdminResponse + MsgServer = types.MsgServer + Model = types.Model + CodeInfo = types.CodeInfo + ContractInfo = types.ContractInfo + CreatedAt = types.AbsoluteTxPosition + Config = types.WasmConfig + CodeInfoResponse = types.CodeInfoResponse + MessageHandler = keeper.SDKMessageHandler + BankEncoder = keeper.BankEncoder + CustomEncoder = keeper.CustomEncoder + StakingEncoder = keeper.StakingEncoder + WasmEncoder = keeper.WasmEncoder + MessageEncoders = keeper.MessageEncoders + Keeper = keeper.Keeper + QueryHandler = keeper.QueryHandler + CustomQuerier = keeper.CustomQuerier + QueryPlugins = keeper.QueryPlugins + Option = keeper.Option + MsgStoreCodeAndInstantiateContract = lbmtypes.MsgStoreCodeAndInstantiateContract MsgStoreCodeAndInstantiateContractResponse = lbmtypes.MsgStoreCodeAndInstantiateContractResponse - MsgExecuteContract = types.MsgExecuteContract - MsgExecuteContractResponse = types.MsgExecuteContractResponse - MsgMigrateContract = types.MsgMigrateContract - MsgMigrateContractResponse = types.MsgMigrateContractResponse - MsgUpdateAdmin = types.MsgUpdateAdmin - MsgUpdateAdminResponse = types.MsgUpdateAdminResponse - MsgClearAdmin = types.MsgClearAdmin - MsgWasmIBCCall = types.MsgIBCSend - MsgClearAdminResponse = types.MsgClearAdminResponse - MsgServer = types.MsgServer - Model = types.Model - CodeInfo = types.CodeInfo - ContractInfo = types.ContractInfo - CreatedAt = types.AbsoluteTxPosition - Config = types.WasmConfig - CodeInfoResponse = types.CodeInfoResponse - MessageHandler = keeper.SDKMessageHandler - BankEncoder = keeper.BankEncoder - CustomEncoder = keeper.CustomEncoder - StakingEncoder = keeper.StakingEncoder - WasmEncoder = keeper.WasmEncoder - MessageEncoders = keeper.MessageEncoders - Keeper = keeper.Keeper - QueryHandler = keeper.QueryHandler - CustomQuerier = keeper.CustomQuerier - QueryPlugins = keeper.QueryPlugins - Option = keeper.Option ) diff --git a/x/wasm/client/cli/genesis_msg.go b/x/wasm/client/cli/genesis_msg.go index 3656a22757..01b1d090cc 100644 --- a/x/wasm/client/cli/genesis_msg.go +++ b/x/wasm/client/cli/genesis_msg.go @@ -21,6 +21,7 @@ import ( genutiltypes "github.com/line/lbm-sdk/x/genutil/types" octypes "github.com/line/ostracon/types" + "github.com/line/wasmd/x/wasm/ioutils" "github.com/line/wasmd/x/wasm/keeper" "github.com/line/wasmd/x/wasm/types" ) @@ -73,6 +74,7 @@ func GenesisStoreCodeCmd(defaultNodeHome string, genesisMutator GenesisMutator) cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional") cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional") cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional") + cmd.Flags().StringSlice(flagInstantiateByAnyOfAddress, []string{}, "Any of the addresses can instantiate a contract from the code, optional") cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)") @@ -102,7 +104,7 @@ func GenesisInstantiateContractCmd(defaultNodeHome string, genesisMutator Genesi } return genesisMutator.AlterWasmModuleState(cmd, func(state *types.GenesisState, appState map[string]json.RawMessage) error { - // simple sanity check that sender has some balance although it may be consumed by appState previous message already + // simple sanity check that sender has some balance, although it may be consumed by appState previous message already switch ok, err := hasAccountBalance(cmd, appState, senderAddr, msg.Funds); { case err != nil: return err @@ -111,7 +113,7 @@ func GenesisInstantiateContractCmd(defaultNodeHome string, genesisMutator Genesi } // does code id exists? - codeInfos, err := getAllCodes(state) + codeInfos := GetAllCodes(state) if err != nil { return err } @@ -130,7 +132,7 @@ func GenesisInstantiateContractCmd(defaultNodeHome string, genesisMutator Genesi return fmt.Errorf("permissions were not granted for %s", senderAddr) } state.GenMsgs = append(state.GenMsgs, types.GenesisState_GenMsgs{ - Sum: &types.GenesisState_GenMsgs_InstantiateContract{InstantiateContract: &msg}, + Sum: &types.GenesisState_GenMsgs_InstantiateContract{InstantiateContract: msg}, }) return nil }) @@ -170,7 +172,7 @@ func GenesisExecuteContractCmd(defaultNodeHome string, genesisMutator GenesisMut } return genesisMutator.AlterWasmModuleState(cmd, func(state *types.GenesisState, appState map[string]json.RawMessage) error { - // simple sanity check that sender has some balance although it may be consumed by appState previous message already + // simple sanity check that sender has some balance, although it may be consumed by appState previous message already switch ok, err := hasAccountBalance(cmd, appState, senderAddr, msg.Funds); { case err != nil: return err @@ -210,7 +212,7 @@ func GenesisListCodesCmd(defaultNodeHome string, genReader GenesisReader) *cobra if err != nil { return err } - all, err := getAllCodes(g.WasmModuleState) + all := GetAllCodes(g.WasmModuleState) if err != nil { return err } @@ -235,7 +237,7 @@ func GenesisListContractsCmd(defaultNodeHome string, genReader GenesisReader) *c return err } state := g.WasmModuleState - all := getAllContracts(state) + all := GetAllContracts(state) return printJSONOutput(cmd, all) }, } @@ -244,7 +246,7 @@ func GenesisListContractsCmd(defaultNodeHome string, genReader GenesisReader) *c return cmd } -// clientCtx marshaller works only with proto or bytes so we marshal the output ourself +// clientCtx marshaller works only with proto or bytes, so we marshal the output ourselves func printJSONOutput(cmd *cobra.Command, obj interface{}) error { clientCtx := client.GetClientContextFromCmd(cmd) bz, err := json.MarshalIndent(obj, "", " ") @@ -259,7 +261,7 @@ type CodeMeta struct { Info types.CodeInfo `json:"info"` } -func getAllCodes(state *types.GenesisState) ([]CodeMeta, error) { +func GetAllCodes(state *types.GenesisState) []CodeMeta { all := make([]CodeMeta, len(state.Codes)) for i, c := range state.Codes { all[i] = CodeMeta{ @@ -276,13 +278,18 @@ func getAllCodes(state *types.GenesisState) ([]CodeMeta, error) { accessConfig = *msg.InstantiatePermission } else { // default - creator, err := sdk.AccAddressFromBech32(msg.Sender) + creator := sdk.MustAccAddressFromBech32(msg.Sender) + accessConfig = state.Params.InstantiateDefaultPermission.With(creator) + } + bz := msg.WASMByteCode + if ioutils.IsGzip(msg.WASMByteCode) { + var err error + bz, err = ioutils.Uncompress(msg.WASMByteCode, uint64(types.MaxWasmSize)) if err != nil { - return nil, fmt.Errorf("sender: %s", err) + panic(fmt.Sprintf("failed to unzip wasm binary: %s", err)) } - accessConfig = state.Params.InstantiateDefaultPermission.With(creator) } - hash := sha256.Sum256(msg.WASMByteCode) + hash := sha256.Sum256(bz) all = append(all, CodeMeta{ CodeID: seq, Info: types.CodeInfo{ @@ -294,7 +301,7 @@ func getAllCodes(state *types.GenesisState) ([]CodeMeta, error) { seq++ } } - return all, nil + return all } type ContractMeta struct { @@ -302,7 +309,7 @@ type ContractMeta struct { Info types.ContractInfo `json:"info"` } -func getAllContracts(state *types.GenesisState) []ContractMeta { +func GetAllContracts(state *types.GenesisState) []ContractMeta { all := make([]ContractMeta, len(state.Contracts)) for i, c := range state.Contracts { all[i] = ContractMeta{ @@ -315,7 +322,7 @@ func getAllContracts(state *types.GenesisState) []ContractMeta { for _, m := range state.GenMsgs { if msg := m.GetInstantiateContract(); msg != nil { all = append(all, ContractMeta{ - ContractAddress: keeper.BuildContractAddress(msg.CodeID, seq).String(), + ContractAddress: keeper.BuildContractAddressClassic(msg.CodeID, seq).String(), Info: types.ContractInfo{ CodeID: msg.CodeID, Creator: msg.Sender, @@ -356,7 +363,7 @@ func hasContract(state *types.GenesisState, contractAddr string) bool { seq := contractSeqValue(state) for _, m := range state.GenMsgs { if msg := m.GetInstantiateContract(); msg != nil { - if keeper.BuildContractAddress(msg.CodeID, seq).String() == contractAddr { + if keeper.BuildContractAddressClassic(msg.CodeID, seq).String() == contractAddr { return true } seq++ @@ -404,8 +411,10 @@ func (d DefaultGenesisReader) ReadWasmGenesis(cmd *cobra.Command) (*GenesisData, ), nil } -var _ GenesisReader = DefaultGenesisIO{} -var _ GenesisMutator = DefaultGenesisIO{} +var ( + _ GenesisReader = DefaultGenesisIO{} + _ GenesisMutator = DefaultGenesisIO{} +) // DefaultGenesisIO implements both interfaces to read and modify the genesis state for this module. // This implementation uses the default data structure that is used by the module.go genesis import/ export. diff --git a/x/wasm/client/cli/genesis_msg_test.go b/x/wasm/client/cli/genesis_msg_test.go index 94cd9d2110..52a1a85273 100644 --- a/x/wasm/client/cli/genesis_msg_test.go +++ b/x/wasm/client/cli/genesis_msg_test.go @@ -46,7 +46,7 @@ func TestGenesisStoreCodeCmd(t *testing.T) { anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) - require.NoError(t, anyValidWasmFile.Close()) + require.NoError(t, os.RemoveAll(anyValidWasmFile.Name())) specs := map[string]struct { srcGenesis types.GenesisState @@ -113,7 +113,7 @@ func TestInstantiateContractCmd(t *testing.T) { anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) - require.NoError(t, anyValidWasmFile.Close()) + require.NoError(t, os.RemoveAll(anyValidWasmFile.Name())) specs := map[string]struct { srcGenesis types.GenesisState @@ -372,7 +372,7 @@ func TestExecuteContractCmd(t *testing.T) { anyValidWasmFile, err := os.CreateTemp(t.TempDir(), "wasm") require.NoError(t, err) anyValidWasmFile.Write(wasmIdent) - require.NoError(t, anyValidWasmFile.Close()) + require.NoError(t, os.RemoveAll(anyValidWasmFile.Name())) specs := map[string]struct { srcGenesis types.GenesisState @@ -565,6 +565,7 @@ func TestExecuteContractCmd(t *testing.T) { }) } } + func TestGetAllContracts(t *testing.T) { specs := map[string]struct { src types.GenesisState @@ -603,11 +604,11 @@ func TestGetAllContracts(t *testing.T) { }, exp: []ContractMeta{ { - ContractAddress: keeper.BuildContractAddress(0, 1).String(), + ContractAddress: keeper.BuildContractAddressClassic(0, 1).String(), Info: types.ContractInfo{Label: "first"}, }, { - ContractAddress: keeper.BuildContractAddress(0, 2).String(), + ContractAddress: keeper.BuildContractAddressClassic(0, 2).String(), Info: types.ContractInfo{Label: "second"}, }, }, @@ -623,7 +624,7 @@ func TestGetAllContracts(t *testing.T) { }, exp: []ContractMeta{ { - ContractAddress: keeper.BuildContractAddress(0, 100).String(), + ContractAddress: keeper.BuildContractAddressClassic(0, 100).String(), Info: types.ContractInfo{Label: "hundred"}, }, }, @@ -649,7 +650,7 @@ func TestGetAllContracts(t *testing.T) { Info: types.ContractInfo{Label: "first"}, }, { - ContractAddress: keeper.BuildContractAddress(0, 100).String(), + ContractAddress: keeper.BuildContractAddressClassic(0, 100).String(), Info: types.ContractInfo{Label: "hundred"}, }, }, @@ -657,18 +658,17 @@ func TestGetAllContracts(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - got := getAllContracts(&spec.src) + got := GetAllContracts(&spec.src) assert.Equal(t, spec.exp, got) }) } - } func setupGenesis(t *testing.T, wasmGenesis types.GenesisState) string { appCodec := keeper.MakeEncodingConfig(t).Marshaler homeDir := t.TempDir() - require.NoError(t, os.Mkdir(path.Join(homeDir, "config"), 0700)) + require.NoError(t, os.Mkdir(path.Join(homeDir, "config"), 0o700)) genFilename := path.Join(homeDir, "config", "genesis.json") appState := make(map[string]json.RawMessage) appState[types.ModuleName] = appCodec.MustMarshalJSON(&wasmGenesis) @@ -712,7 +712,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{}.WithJSONCodec(appCodec).WithHomeDir(homeDir) + clientCtx := client.Context{}.WithCodec(appCodec).WithHomeDir(homeDir) ctx := context.Background() ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 43d7990ca9..fb11db3d2c 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -58,12 +58,18 @@ func ProposalStoreCodeCmd() *cobra.Command { return err } + unpinCode, err := cmd.Flags().GetBool(flagUnpinCode) + if err != nil { + return err + } + content := types.StoreCodeProposal{ Title: proposalTitle, Description: proposalDescr, RunAs: runAs, WASMByteCode: src.WASMByteCode, InstantiatePermission: src.InstantiatePermission, + UnpinCode: unpinCode, } msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) @@ -82,14 +88,12 @@ func ProposalStoreCodeCmd() *cobra.Command { cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional") cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional") cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional") + cmd.Flags().Bool(flagUnpinCode, false, "Unpin code on upload, optional") // proposal flags cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -165,9 +169,6 @@ func ProposalInstantiateContractCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -228,9 +229,6 @@ func ProposalMigrateContractCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -307,9 +305,6 @@ func ProposalExecuteContractCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -367,9 +362,6 @@ func ProposalSudoContractCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -428,9 +420,6 @@ func ProposalUpdateContractAdminCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -483,9 +472,6 @@ func ProposalClearContractAdminCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -542,9 +528,6 @@ func ProposalPinCodesCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } @@ -613,33 +596,41 @@ func ProposalUnpinCodesCmd() *cobra.Command { cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } -func parseAccessConfig(config string) (types.AccessConfig, error) { - switch config { +func parseAccessConfig(raw string) (c types.AccessConfig, err error) { + switch raw { case "nobody": return types.AllowNobody, nil case "everybody": return types.AllowEverybody, nil default: - address, err := sdk.AccAddressFromBech32(config) - if err != nil { - return types.AccessConfig{}, fmt.Errorf("unable to parse address %s", config) + parts := strings.Split(raw, ",") + addrs := make([]sdk.AccAddress, len(parts)) + for i, v := range parts { + addr, err := sdk.AccAddressFromBech32(v) + if err != nil { + return types.AccessConfig{}, fmt.Errorf("unable to parse address %q: %s", v, err) + } + addrs[i] = addr } - return types.AccessTypeOnlyAddress.With(address), nil + defer func() { // convert panic in ".With" to error for better output + if r := recover(); r != nil { + err = r.(error) + } + }() + cfg := types.AccessTypeAnyOfAddresses.With(addrs...) + return cfg, cfg.ValidateBasic() } } func parseAccessConfigUpdates(args []string) ([]types.AccessConfigUpdate, error) { updates := make([]types.AccessConfigUpdate, len(args)) for i, c := range args { - // format: code_id,access_config - // access_config: nobody|everybody|address - parts := strings.Split(c, ",") + // format: code_id:access_config + // access_config: nobody|everybody|address(es) + parts := strings.Split(c, ":") if len(parts) != 2 { return nil, fmt.Errorf("invalid format") } @@ -664,15 +655,15 @@ func parseAccessConfigUpdates(args []string) ([]types.AccessConfigUpdate, error) func ProposalUpdateInstantiateConfigCmd() *cobra.Command { bech32Prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() cmd := &cobra.Command{ - Use: "update-instantiate-config [code-id,permission]...", + Use: "update-instantiate-config [code-id:permission]...", Short: "Submit an update instantiate config proposal.", Args: cobra.MinimumNArgs(1), Long: strings.TrimSpace( fmt.Sprintf(`Submit an update instantiate config proposal for multiple code ids. Example: -$ %s tx gov submit-proposal update-instantiate-config 1,nobody 2,everybody 3,%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm -`, version.AppName, bech32Prefix)), +$ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm,%s1vx8knpllrj7n963p9ttd80w47kpacrhuts497x +`, version.AppName, bech32Prefix, bech32Prefix)), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -720,9 +711,6 @@ $ %s tx gov submit-proposal update-instantiate-config 1,nobody 2,everybody 3,%s1 cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") - // type values must match the "ProposalHandler" "routes" in cli - cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } diff --git a/x/wasm/client/cli/gov_tx_test.go b/x/wasm/client/cli/gov_tx_test.go new file mode 100644 index 0000000000..bf1c7c92a2 --- /dev/null +++ b/x/wasm/client/cli/gov_tx_test.go @@ -0,0 +1,97 @@ +package cli + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/line/wasmd/x/wasm/types" +) + +func TestParseAccessConfigUpdates(t *testing.T) { + specs := map[string]struct { + src []string + exp []types.AccessConfigUpdate + expErr bool + }{ + "nobody": { + src: []string{"1:nobody"}, + exp: []types.AccessConfigUpdate{{ + CodeID: 1, + InstantiatePermission: types.AccessConfig{Permission: types.AccessTypeNobody}, + }}, + }, + "everybody": { + src: []string{"1:everybody"}, + exp: []types.AccessConfigUpdate{{ + CodeID: 1, + InstantiatePermission: types.AccessConfig{Permission: types.AccessTypeEverybody}, + }}, + }, + "any of addresses - single": { + src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, + exp: []types.AccessConfigUpdate{ + { + CodeID: 1, + InstantiatePermission: types.AccessConfig{ + Permission: types.AccessTypeAnyOfAddresses, + Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, + }, + }, + }, + }, + "any of addresses - multiple": { + src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, + exp: []types.AccessConfigUpdate{ + { + CodeID: 1, + InstantiatePermission: types.AccessConfig{ + Permission: types.AccessTypeAnyOfAddresses, + Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x", "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, + }, + }, + }, + }, + "multiple code ids with different permissions": { + src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "2:nobody"}, + exp: []types.AccessConfigUpdate{ + { + CodeID: 1, + InstantiatePermission: types.AccessConfig{ + Permission: types.AccessTypeAnyOfAddresses, + Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x", "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, + }, + }, { + CodeID: 2, + InstantiatePermission: types.AccessConfig{ + Permission: types.AccessTypeNobody, + }, + }, + }, + }, + "any of addresses - empty list": { + src: []string{"1:"}, + expErr: true, + }, + "any of addresses - invalid address": { + src: []string{"1:foo"}, + expErr: true, + }, + "any of addresses - duplicate address": { + src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + got, gotErr := parseAccessConfigUpdates(spec.src) + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + assert.Equal(t, spec.exp, got) + }) + } +} diff --git a/x/wasm/client/cli/query.go b/x/wasm/client/cli/query.go index 05ade84a7c..5edce271ea 100644 --- a/x/wasm/client/cli/query.go +++ b/x/wasm/client/cli/query.go @@ -18,6 +18,7 @@ import ( sdk "github.com/line/lbm-sdk/types" wasmvm "github.com/line/wasmvm" + "github.com/line/wasmd/x/wasm/keeper" "github.com/line/wasmd/x/wasm/lbmtypes" "github.com/line/wasmd/x/wasm/types" ) @@ -40,6 +41,8 @@ func GetQueryCmd() *cobra.Command { GetCmdGetContractState(), GetCmdListPinnedCode(), GetCmdLibVersion(), + GetCmdQueryParams(), + GetCmdBuildAddress(), GetCmdListInactiveContracts(), GetCmdIsInactiveContract(), ) @@ -66,6 +69,47 @@ func GetCmdLibVersion() *cobra.Command { return cmd } +// GetCmdBuildAddress build a contract address +func GetCmdBuildAddress() *cobra.Command { + decoder := newArgDecoder(hex.DecodeString) + cmd := &cobra.Command{ + Use: "build-address [code-hash] [creator-address] [salt-hex-encoded] [json_encoded_init_args (required when set as fixed)]", + Short: "build contract address", + Aliases: []string{"address"}, + Args: cobra.RangeArgs(3, 4), + RunE: func(cmd *cobra.Command, args []string) error { + codeHash, err := hex.DecodeString(args[0]) + if err != nil { + return fmt.Errorf("code-hash: %s", err) + } + creator, err := sdk.AccAddressFromBech32(args[1]) + if err != nil { + return fmt.Errorf("creator: %s", err) + } + salt, err := hex.DecodeString(args[2]) + switch { + case err != nil: + return fmt.Errorf("salt: %s", err) + case len(salt) == 0: + return errors.New("empty salt") + } + + if len(args) == 3 { + cmd.Println(keeper.BuildContractAddressPredictable(codeHash, creator, salt, []byte{}).String()) + return nil + } + msg := types.RawContractMessage(args[3]) + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("init message: %s", err) + } + cmd.Println(keeper.BuildContractAddressPredictable(codeHash, creator, salt, msg).String()) + return nil + }, + } + decoder.RegisterFlags(cmd.PersistentFlags(), "salt") + return cmd +} + // GetCmdListCode lists all wasm code uploaded func GetCmdListCode() *cobra.Command { cmd := &cobra.Command{ @@ -120,6 +164,9 @@ func GetCmdListContractByCode() *cobra.Command { if err != nil { return err } + if codeID == 0 { + return errors.New("empty code id") + } pageReq, err := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags())) if err != nil { @@ -498,7 +545,7 @@ func newArgDecoder(def func(string) ([]byte, error)) *argumentDecoder { func (a *argumentDecoder) RegisterFlags(f *flag.FlagSet, argName string) { f.BoolVar(&a.asciiF, "ascii", false, "ascii encoded "+argName) - f.BoolVar(&a.hexF, "hex", false, "hex encoded "+argName) + f.BoolVar(&a.hexF, "hex", false, "hex encoded "+argName) f.BoolVar(&a.b64F, "b64", false, "base64 encoded "+argName) } @@ -539,7 +586,8 @@ func withPageKeyDecoded(flagSet *flag.FlagSet) *flag.FlagSet { if err != nil { panic(err.Error()) } - if err = flagSet.Set(flags.FlagPageKey, string(raw)); err != nil { + err = flagSet.Set(flags.FlagPageKey, string(raw)) + if err != nil { panic(err.Error()) } return flagSet @@ -605,3 +653,32 @@ func GetCmdIsInactiveContract() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +// GetCmdQueryParams implements a command to return the current wasm +// parameters. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current wasm parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryParamsRequest{} + res, err := queryClient.Params(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/wasm/client/cli/tx.go b/x/wasm/client/cli/tx.go index b2f9eb7f1d..a69fccb0b3 100644 --- a/x/wasm/client/cli/tx.go +++ b/x/wasm/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "encoding/hex" "errors" "fmt" "strconv" @@ -13,6 +14,7 @@ import ( "github.com/line/lbm-sdk/client/tx" sdk "github.com/line/lbm-sdk/types" sdkerrors "github.com/line/lbm-sdk/types/errors" + "github.com/line/lbm-sdk/version" "github.com/line/wasmd/x/wasm/client/cli/os" "github.com/line/wasmd/x/wasm/ioutils" @@ -21,15 +23,18 @@ import ( ) const ( - flagAmount = "amount" - flagLabel = "label" - flagAdmin = "admin" - flagNoAdmin = "no-admin" - flagRunAs = "run-as" - flagInstantiateByEverybody = "instantiate-everybody" - flagInstantiateNobody = "instantiate-nobody" - flagInstantiateByAddress = "instantiate-only-address" - flagProposalType = "type" + flagAmount = "amount" + flagLabel = "label" + flagAdmin = "admin" + flagNoAdmin = "no-admin" + flagFixMsg = "fix-msg" + flagRunAs = "run-as" + flagInstantiateByEverybody = "instantiate-everybody" + flagInstantiateNobody = "instantiate-nobody" + flagInstantiateByAddress = "instantiate-only-address" + flagInstantiateByAnyOfAddress = "instantiate-anyof-addresses" + flagUnpinCode = "unpin-code" + flagProposalType = "type" ) // GetTxCmd returns the transaction commands for this module @@ -44,6 +49,7 @@ func GetTxCmd() *cobra.Command { txCmd.AddCommand( StoreCodeCmd(), InstantiateContractCmd(), + InstantiateContract2Cmd(), StoreCodeAndInstantiateContractCmd(), ExecuteContractCmd(), MigrateContractCmd(), @@ -78,7 +84,8 @@ func StoreCodeCmd() *cobra.Command { cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional") cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional") - cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional") + cmd.Flags().String(flagInstantiateByAddress, "", "Deprecated: Only this address can instantiate a contract from the code, optional") + cmd.Flags().StringSlice(flagInstantiateByAnyOfAddress, []string{}, "Any of the addresses can instantiate a contract from the code, optional") flags.AddTxFlagsToCmd(cmd) return cmd } @@ -100,62 +107,89 @@ func parseStoreCodeArgs(file string, sender sdk.AccAddress, flags *flag.FlagSet) return types.MsgStoreCode{}, fmt.Errorf("invalid input file. Use wasm binary or gzip") } - var perm *types.AccessConfig + perm, err := parseAccessConfigFlags(flags) + if err != nil { + return types.MsgStoreCode{}, err + } + + msg := types.MsgStoreCode{ + Sender: sender.String(), + WASMByteCode: wasm, + InstantiatePermission: perm, + } + return msg, nil +} + +func parseAccessConfigFlags(flags *flag.FlagSet) (*types.AccessConfig, error) { + addrs, err := flags.GetStringSlice(flagInstantiateByAnyOfAddress) + if err != nil { + return nil, fmt.Errorf("flag any of: %s", err) + } + if len(addrs) != 0 { + acceptedAddrs := make([]sdk.AccAddress, len(addrs)) + for i, v := range addrs { + acceptedAddrs[i], err = sdk.AccAddressFromBech32(v) + if err != nil { + return nil, fmt.Errorf("parse %q: %w", v, err) + } + } + x := types.AccessTypeAnyOfAddresses.With(acceptedAddrs...) + return &x, nil + } + onlyAddrStr, err := flags.GetString(flagInstantiateByAddress) if err != nil { - return types.MsgStoreCode{}, fmt.Errorf("instantiate by address: %s", err) + return nil, fmt.Errorf("instantiate by address: %s", err) } if onlyAddrStr != "" { allowedAddr, err := sdk.AccAddressFromBech32(onlyAddrStr) if err != nil { - return types.MsgStoreCode{}, sdkerrors.Wrap(err, flagInstantiateByAddress) + return nil, sdkerrors.Wrap(err, flagInstantiateByAddress) } x := types.AccessTypeOnlyAddress.With(allowedAddr) - perm = &x - } else { - everybodyStr, err := flags.GetString(flagInstantiateByEverybody) + return &x, nil + } + everybodyStr, err := flags.GetString(flagInstantiateByEverybody) + if err != nil { + return nil, fmt.Errorf("instantiate by everybody: %s", err) + } + if everybodyStr != "" { + ok, err := strconv.ParseBool(everybodyStr) if err != nil { - return types.MsgStoreCode{}, fmt.Errorf("instantiate by everybody: %s", err) + return nil, fmt.Errorf("boolean value expected for instantiate by everybody: %s", err) } - if everybodyStr != "" { - ok, err := strconv.ParseBool(everybodyStr) - if err != nil { - return types.MsgStoreCode{}, fmt.Errorf("boolean value expected for instantiate by everybody: %s", err) - } - if ok { - perm = &types.AllowEverybody - } + if ok { + return &types.AllowEverybody, nil } + } - nobodyStr, err := flags.GetString(flagInstantiateNobody) + nobodyStr, err := flags.GetString(flagInstantiateNobody) + if err != nil { + return nil, fmt.Errorf("instantiate by nobody: %s", err) + } + if nobodyStr != "" { + ok, err := strconv.ParseBool(nobodyStr) if err != nil { - return types.MsgStoreCode{}, fmt.Errorf("instantiate by nobody: %s", err) + return nil, fmt.Errorf("boolean value expected for instantiate by nobody: %s", err) } - if nobodyStr != "" { - ok, err := strconv.ParseBool(nobodyStr) - if err != nil { - return types.MsgStoreCode{}, fmt.Errorf("boolean value expected for instantiate by nobody: %s", err) - } - if ok { - perm = &types.AllowNobody - } + if ok { + return &types.AllowNobody, nil } - - } - - msg := types.MsgStoreCode{ - Sender: sender.String(), - WASMByteCode: wasm, - InstantiatePermission: perm, } - return msg, nil + return nil, nil } // InstantiateContractCmd will instantiate a contract from previously uploaded code. func InstantiateContractCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "instantiate [code_id_int64] [json_encoded_init_args] --label [text] --admin [address,optional] --amount [coins,optional]", - Short: "Instantiate a wasm contract", + Use: "instantiate [code_id_int64] [json_encoded_init_args] --label [text] --admin [address,optional] --amount [coins,optional] ", + Short: "Instantiate a wasm contract", + Long: fmt.Sprintf(`Creates a new instance of an uploaded wasm code with the given 'constructor' message. +Each contract instance has a unique address assigned. +Example: +$ %s wasmd tx wasm instantiate 1 '{"foo":"bar"}' --admin="$(%s keys show mykey -a)" \ + --from mykey --amount="100ustake" --label "local0.1.0" +`, version.AppName, version.AppName), Aliases: []string{"start", "init", "inst", "i"}, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -163,7 +197,6 @@ func InstantiateContractCmd() *cobra.Command { if err != nil { return err } - msg, err := parseInstantiateArgs(args[0], args[1], clientCtx.GetFromAddress(), cmd.Flags()) if err != nil { return err @@ -171,7 +204,67 @@ func InstantiateContractCmd() *cobra.Command { if err := msg.ValidateBasic(); err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagAmount, "", "Coins to send to the contract during instantiation") + cmd.Flags().String(flagLabel, "", "A human-readable name for this contract in lists") + cmd.Flags().String(flagAdmin, "", "Address of an admin") + cmd.Flags().Bool(flagNoAdmin, false, "You must set this explicitly if you don't want an admin") + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// InstantiateContract2Cmd will instantiate a contract from previously uploaded code with predicable address generated +func InstantiateContract2Cmd() *cobra.Command { + decoder := newArgDecoder(hex.DecodeString) + cmd := &cobra.Command{ + Use: "instantiate2 [code_id_int64] [json_encoded_init_args] [salt] --label [text] --admin [address,optional] --amount [coins,optional] " + + "--fix-msg [bool,optional]", + Short: "Instantiate a wasm contract with predictable address", + Long: fmt.Sprintf(`Creates a new instance of an uploaded wasm code with the given 'constructor' message. +Each contract instance has a unique address assigned. They are assigned automatically but in order to have predictable addresses +for special use cases, the given 'salt' argument and '--fix-msg' parameters can be used to generate a custom address. + +Predictable address example (also see '%s query wasm build-address -h'): +$ %s wasmd tx wasm instantiate2 1 '{"foo":"bar"}' $(echo -n "testing" | xxd -ps) --admin="$(%s keys show mykey -a)" \ + --from mykey --amount="100ustake" --label "local0.1.0" \ + --fix-msg +`, version.AppName, version.AppName, version.AppName), + Aliases: []string{"start", "init", "inst", "i"}, + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + salt, err := decoder.DecodeString(args[2]) + if err != nil { + return fmt.Errorf("salt: %w", err) + } + fixMsg, err := cmd.Flags().GetBool(flagFixMsg) + if err != nil { + return fmt.Errorf("fix msg: %w", err) + } + data, err := parseInstantiateArgs(args[0], args[1], clientCtx.GetFromAddress(), cmd.Flags()) + if err != nil { + return err + } + msg := &types.MsgInstantiateContract2{ + Sender: data.Sender, + Admin: data.Admin, + CodeID: data.CodeID, + Label: data.Label, + Msg: data.Msg, + Funds: data.Funds, + Salt: salt, + FixMsg: fixMsg, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -179,47 +272,49 @@ func InstantiateContractCmd() *cobra.Command { cmd.Flags().String(flagLabel, "", "A human-readable name for this contract in lists") cmd.Flags().String(flagAdmin, "", "Address of an admin") cmd.Flags().Bool(flagNoAdmin, false, "You must set this explicitly if you don't want an admin") + cmd.Flags().Bool(flagFixMsg, false, "An optional flag to include the json_encoded_init_args for the predictable address generation mode") + decoder.RegisterFlags(cmd.PersistentFlags(), "salt") flags.AddTxFlagsToCmd(cmd) return cmd } -func parseInstantiateArgs(rawCodeID, initMsg string, sender sdk.AccAddress, flags *flag.FlagSet) (types.MsgInstantiateContract, error) { +func parseInstantiateArgs(rawCodeID, initMsg string, sender sdk.AccAddress, flags *flag.FlagSet) (*types.MsgInstantiateContract, error) { // get the id of the code to instantiate codeID, err := strconv.ParseUint(rawCodeID, 10, 64) if err != nil { - return types.MsgInstantiateContract{}, err + return nil, err } amountStr, err := flags.GetString(flagAmount) if err != nil { - return types.MsgInstantiateContract{}, fmt.Errorf("amount: %s", err) + return nil, fmt.Errorf("amount: %s", err) } amount, err := sdk.ParseCoinsNormalized(amountStr) if err != nil { - return types.MsgInstantiateContract{}, fmt.Errorf("amount: %s", err) + return nil, fmt.Errorf("amount: %s", err) } label, err := flags.GetString(flagLabel) if err != nil { - return types.MsgInstantiateContract{}, fmt.Errorf("label: %s", err) + return nil, fmt.Errorf("label: %s", err) } if label == "" { - return types.MsgInstantiateContract{}, errors.New("label is required on all contracts") + return nil, errors.New("label is required on all contracts") } adminStr, err := flags.GetString(flagAdmin) if err != nil { - return types.MsgInstantiateContract{}, fmt.Errorf("admin: %s", err) + return nil, fmt.Errorf("admin: %s", err) } noAdmin, err := flags.GetBool(flagNoAdmin) if err != nil { - return types.MsgInstantiateContract{}, fmt.Errorf("no-admin: %s", err) + return nil, fmt.Errorf("no-admin: %s", err) } // ensure sensible admin is set (or explicitly immutable) if adminStr == "" && !noAdmin { - return types.MsgInstantiateContract{}, fmt.Errorf("you must set an admin or explicitly pass --no-admin to make it immutible (wasmd issue #719)") + return nil, fmt.Errorf("you must set an admin or explicitly pass --no-admin to make it immutible (wasmd issue #719)") } if adminStr != "" && noAdmin { - return types.MsgInstantiateContract{}, fmt.Errorf("you set an admin and passed --no-admin, those cannot both be true") + return nil, fmt.Errorf("you set an admin and passed --no-admin, those cannot both be true") } // build and sign the transaction, then broadcast to Ostracon @@ -231,7 +326,7 @@ func parseInstantiateArgs(rawCodeID, initMsg string, sender sdk.AccAddress, flag Msg: []byte(initMsg), Admin: adminStr, } - return msg, nil + return &msg, nil } // StoreCodeAndInstantiateContractCmd will upload code and instantiate a contract using it diff --git a/x/wasm/client/cli/tx_test.go b/x/wasm/client/cli/tx_test.go new file mode 100644 index 0000000000..ae8ec62658 --- /dev/null +++ b/x/wasm/client/cli/tx_test.go @@ -0,0 +1,59 @@ +package cli + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/line/wasmd/x/wasm/types" +) + +func TestParseAccessConfigFlags(t *testing.T) { + specs := map[string]struct { + args []string + expCfg *types.AccessConfig + expErr bool + }{ + "nobody": { + args: []string{"--instantiate-nobody=true"}, + expCfg: &types.AccessConfig{Permission: types.AccessTypeNobody}, + }, + "everybody": { + args: []string{"--instantiate-everybody=true"}, + expCfg: &types.AccessConfig{Permission: types.AccessTypeEverybody}, + }, + "only address": { + args: []string{"--instantiate-only-address=cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, + expCfg: &types.AccessConfig{Permission: types.AccessTypeOnlyAddress, Address: "cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, + }, + "only address - invalid": { + args: []string{"--instantiate-only-address=foo"}, + expErr: true, + }, + "any of address": { + args: []string{"--instantiate-anyof-addresses=cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, + expCfg: &types.AccessConfig{Permission: types.AccessTypeAnyOfAddresses, Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x", "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}}, + }, + "any of address - invalid": { + args: []string{"--instantiate-anyof-addresses=cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,foo"}, + expErr: true, + }, + "not set": { + args: []string{}, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + flags := StoreCodeCmd().Flags() + require.NoError(t, flags.Parse(spec.args)) + gotCfg, gotErr := parseAccessConfigFlags(flags) + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + assert.Equal(t, spec.expCfg, gotCfg) + }) + } +} diff --git a/x/wasm/genesis_test.go b/x/wasm/genesis_test.go index 8d71c769fc..ba5722cd36 100644 --- a/x/wasm/genesis_test.go +++ b/x/wasm/genesis_test.go @@ -44,6 +44,7 @@ func TestInitGenesis(t *testing.T) { CodeID: firstCodeID, Msg: initMsgBz, Funds: deposit, + Label: "testing", } res, err = h(data.ctx, &initCmd) require.NoError(t, err) diff --git a/x/wasm/handler.go b/x/wasm/handler.go index 102233d7d9..9c3dd19067 100644 --- a/x/wasm/handler.go +++ b/x/wasm/handler.go @@ -30,6 +30,8 @@ func NewHandler(k types.ContractOpsKeeper) sdk.Handler { res, err = msgServer.StoreCode(sdk.WrapSDKContext(ctx), msg) case *MsgInstantiateContract: res, err = msgServer.InstantiateContract(sdk.WrapSDKContext(ctx), msg) + case *MsgInstantiateContract2: + res, err = msgServer.InstantiateContract2(sdk.WrapSDKContext(ctx), msg) case *MsgStoreCodeAndInstantiateContract: lbmMsgServer, ok := msgServer.(lbmtypes.MsgServer) if !ok { diff --git a/x/wasm/ibc.go b/x/wasm/ibc.go index 0c5120f407..fde924f632 100644 --- a/x/wasm/ibc.go +++ b/x/wasm/ibc.go @@ -298,17 +298,6 @@ func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, return 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 { timeout := wasmvmtypes.IBCTimeout{ Timestamp: packet.TimeoutTimestamp, diff --git a/x/wasm/ibctesting/chain.go b/x/wasm/ibctesting/chain.go index cb88428b0f..7be1bfcc7e 100644 --- a/x/wasm/ibctesting/chain.go +++ b/x/wasm/ibctesting/chain.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/line/lbm-sdk/baseapp" "github.com/line/lbm-sdk/client" "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/crypto/keys/secp256k1" @@ -24,12 +23,9 @@ import ( commitmenttypes "github.com/line/lbm-sdk/x/ibc/core/23-commitment/types" host "github.com/line/lbm-sdk/x/ibc/core/24-host" "github.com/line/lbm-sdk/x/ibc/core/exported" - ibckeeper "github.com/line/lbm-sdk/x/ibc/core/keeper" "github.com/line/lbm-sdk/x/ibc/core/types" ibcoctypes "github.com/line/lbm-sdk/x/ibc/light-clients/99-ostracon/types" - ibctesting "github.com/line/lbm-sdk/x/ibc/testing" "github.com/line/lbm-sdk/x/ibc/testing/mock" - stakingkeeper "github.com/line/lbm-sdk/x/staking/keeper" "github.com/line/lbm-sdk/x/staking/teststaking" stakingtypes "github.com/line/lbm-sdk/x/staking/types" abci "github.com/line/ostracon/abci/types" @@ -39,7 +35,8 @@ import ( octypes "github.com/line/ostracon/types" ocversion "github.com/line/ostracon/version" - wasmd "github.com/line/wasmd/app" + "github.com/line/wasmd/app" + "github.com/line/wasmd/app/params" "github.com/line/wasmd/x/wasm" ) @@ -52,7 +49,7 @@ type TestChain struct { t *testing.T Coordinator *Coordinator - App ibctesting.TestingApp + App *app.WasmApp ChainID string LastHeader *ibcoctypes.Header // header for last block height committed CurrentHeader ocproto.Header // header for current block height @@ -64,7 +61,7 @@ type TestChain struct { Voters *octypes.VoterSet Signers []octypes.PrivValidator - senderPrivKey cryptotypes.PrivKey + SenderPrivKey cryptotypes.PrivKey SenderAccount authtypes.AccountI PendingSendPackets []channeltypes.Packet @@ -91,7 +88,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm require.NoError(t, err) // create validator set with single validator - validator := ibctesting.NewTestValidator(pubKey, 1) + validator := octypes.NewValidator(pubKey, 1) valSet := octypes.NewValidatorSet([]*octypes.Validator{validator}) voterSet := octypes.WrapValidatorsToVoterSet(valSet.Validators) signers := []octypes.PrivValidator{privVal} @@ -107,7 +104,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)), } - app := NewTestingAppDecorator(t, wasmd.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opts, balance)) + wasmApp := app.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opts, balance) // create current header and call begin block header := ocproto.Header{ @@ -116,22 +113,22 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm Time: coord.CurrentTime.UTC(), } - txConfig := app.GetTxConfig() + txConfig := params.MakeEncodingConfig().TxConfig // create an account to send transactions from chain := &TestChain{ t: t, Coordinator: coord, ChainID: chainID, - App: app, + App: wasmApp, CurrentHeader: header, - QueryServer: app.GetIBCKeeper(), + QueryServer: wasmApp.IBCKeeper, TxConfig: txConfig, - Codec: app.AppCodec(), + Codec: wasmApp.AppCodec(), Vals: valSet, Voters: voterSet, Signers: signers, - senderPrivKey: senderPrivKey, + SenderPrivKey: senderPrivKey, SenderAccount: acc, } @@ -142,7 +139,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm // GetContext returns the current context for the application. func (chain *TestChain) GetContext() sdk.Context { - return chain.App.GetBaseApp().NewContext(false, chain.CurrentHeader) + return chain.App.BaseApp.NewContext(false, chain.CurrentHeader) } // QueryProof performs an abci query with the given key and returns the proto encoded merkle proof @@ -235,14 +232,6 @@ func (chain *TestChain) NextBlock() { chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) } -func (chain *TestChain) CommitBlock() { - chain.App.EndBlock(abci.RequestEndBlock{Height: chain.CurrentHeader.Height}) - chain.App.Commit() - - chain.App.BeginRecheckTx(abci.RequestBeginRecheckTx{Header: chain.CurrentHeader}) - chain.App.EndRecheckTx(abci.RequestEndRecheckTx{Height: chain.CurrentHeader.Height}) -} - // sendMsgs delivers a transaction through the application without returning the result. func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { _, err := chain.SendMsgs(msgs...) @@ -256,16 +245,16 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { // ensure the chain has the latest time chain.Coordinator.UpdateTimeForChain(chain) - _, r, err := wasmd.SignAndDeliver( + _, r, err := app.SignAndDeliver( chain.t, chain.TxConfig, - chain.App.GetBaseApp(), + chain.App.BaseApp, chain.GetContext().BlockHeader(), msgs, chain.ChainID, []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{chain.SenderAccount.GetSequence()}, - true, true, chain.senderPrivKey, + true, true, chain.SenderPrivKey, ) if err != nil { return nil, err @@ -303,7 +292,7 @@ func (chain *TestChain) captureIBCEvents(r *sdk.Result) { // 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 := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID) + clientState, found := chain.App.IBCKeeper.ClientKeeper.GetClientState(chain.GetContext(), clientID) require.True(chain.t, found) return clientState @@ -312,13 +301,13 @@ 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 chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height) + return chain.App.IBCKeeper.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) (*octypes.ValidatorSet, bool) { - histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) + histInfo, ok := chain.App.StakingKeeper.GetHistoricalInfo(chain.GetContext(), height) if !ok { return nil, false } @@ -333,7 +322,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*octypes.ValidatorSet, bo } func (chain *TestChain) GetVotersAtHeight(height int64) (*octypes.VoterSet, bool) { - histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) + histInfo, ok := chain.App.StakingKeeper.GetHistoricalInfo(chain.GetContext(), height) if !ok { return nil, false } @@ -355,7 +344,7 @@ func (chain *TestChain) GetVotersAtHeight(height int64) (*octypes.VoterSet, bool // 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 := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + ack, found := chain.App.IBCKeeper.ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) require.True(chain.t, found) return ack @@ -363,7 +352,7 @@ 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(chain.App.GetIBCKeeper().ConnectionKeeper.GetCommitmentPrefix().Bytes()) + return commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()) } // ConstructUpdateOCClientHeader will construct a valid 99-ostracon Header to update the @@ -467,7 +456,6 @@ func (chain *TestChain) CreateOCClientHeader(chainID string, blockHeight int64, EvidenceHash: tmhash.Sum([]byte("evidence_hash")), ProposerAddress: tmValSet.SelectProposer([]byte{}, blockHeight, 0).Address, //nolint:staticcheck } - hhash := tmHeader.Hash() blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) voteSet := octypes.NewVoteSet(chainID, blockHeight, 1, ocproto.PrecommitType, tmVoterSet) @@ -549,10 +537,10 @@ func CreateSortedSignerArray(altPrivVal, suitePrivVal octypes.PrivValidator, // Other applications must bind to the port in InitGenesis or modify this code. func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string) { // check if the portId is already binded, if not bind it - _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + _, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID)) if !ok { // create capability using the IBC capability keeper - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) + cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), host.PortPath(portID)) require.NoError(chain.t, err) // claim capability using the scopedKeeper @@ -560,7 +548,7 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope require.NoError(chain.t, err) } - chain.CommitBlock() + chain.App.Commit() chain.NextBlock() } @@ -568,7 +556,7 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope // 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.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID)) require.True(chain.t, ok) return cap @@ -580,15 +568,15 @@ func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capabi 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.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName) + _, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), capName) if !ok { - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) + cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), capName) require.NoError(chain.t, err) err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) require.NoError(chain.t, err) } - chain.CommitBlock() + chain.App.Commit() chain.NextBlock() } @@ -596,55 +584,55 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc // 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.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) + cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) require.True(chain.t, ok) return cap } func (chain *TestChain) Balance(acc sdk.AccAddress, denom string) sdk.Coin { - return chain.GetTestSupport().BankKeeper().GetBalance(chain.GetContext(), acc, denom) + return chain.App.BankKeeper.GetBalance(chain.GetContext(), acc, denom) } func (chain *TestChain) AllBalances(acc sdk.AccAddress) sdk.Coins { - return chain.GetTestSupport().BankKeeper().GetAllBalances(chain.GetContext(), acc) -} - -func (chain TestChain) GetTestSupport() *wasmd.TestSupport { - return chain.App.(*TestingAppDecorator).TestSupport() + return chain.App.BankKeeper.GetAllBalances(chain.GetContext(), acc) } -var _ ibctesting.TestingApp = TestingAppDecorator{} +//func (chain TestChain) GetTestSupport() *app.TestSupport { +// return chain.App.(*TestingAppDecorator).TestSupport() +//} -type TestingAppDecorator struct { - *wasmd.WasmApp - t *testing.T -} - -func NewTestingAppDecorator(t *testing.T, simApp *wasmd.WasmApp) *TestingAppDecorator { - return &TestingAppDecorator{WasmApp: simApp, t: t} -} - -func (a TestingAppDecorator) GetBaseApp() *baseapp.BaseApp { - return a.TestSupport().GetBaseApp() -} - -func (a TestingAppDecorator) GetStakingKeeper() stakingkeeper.Keeper { - return a.TestSupport().StakingKeeper() -} - -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) -} +//var _ ibctesting.TestingApp = TestingAppDecorator{} +// +//type TestingAppDecorator struct { +// *app.WasmApp +// t *testing.T +//} +// +//func NewTestingAppDecorator(t *testing.T, simApp *app.WasmApp) *TestingAppDecorator { +// return &TestingAppDecorator{WasmApp: simApp, t: t} +//} +// +//func (a TestingAppDecorator) GetBaseApp() *baseapp.BaseApp { +// return a.TestSupport().GetBaseApp() +//} +// +//func (a TestingAppDecorator) GetStakingKeeper() stakingkeeper.Keeper { +// return a.TestSupport().StakingKeeper() +//} +// +//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() *app.TestSupport { +// return app.NewTestSupport(a.t, a.WasmApp) +//} diff --git a/x/wasm/ibctesting/endpoint.go b/x/wasm/ibctesting/endpoint.go index 88a0af3159..28fdf0f1e3 100644 --- a/x/wasm/ibctesting/endpoint.go +++ b/x/wasm/ibctesting/endpoint.go @@ -379,7 +379,7 @@ 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) + err := endpoint.Chain.App.IBCKeeper.ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet) if err != nil { return err } @@ -413,7 +413,7 @@ func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, pac 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) + err := endpoint.Chain.App.IBCKeeper.ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack) if err != nil { return err } @@ -450,7 +450,7 @@ func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { } proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) - nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) + nextSeqRecv, found := endpoint.Counterparty.Chain.App.IBCKeeper.ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) require.True(endpoint.Chain.t, found) timeoutMsg := channeltypes.NewMsgTimeout( @@ -466,7 +466,7 @@ 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.App.IBCKeeper.ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) @@ -481,7 +481,7 @@ func (endpoint *Endpoint) GetClientState() exported.ClientState { // 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) + endpoint.Chain.App.IBCKeeper.ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState) } // GetConsensusState retrieves the Consensus State for this endpoint at the provided height. @@ -495,13 +495,13 @@ func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.Con // 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) + endpoint.Chain.App.IBCKeeper.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) + connection, found := endpoint.Chain.App.IBCKeeper.ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID) require.True(endpoint.Chain.t, found) return connection @@ -509,13 +509,13 @@ func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd { // 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) + endpoint.Chain.App.IBCKeeper.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) + channel, found := endpoint.Chain.App.IBCKeeper.ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) require.True(endpoint.Chain.t, found) return channel @@ -523,7 +523,7 @@ func (endpoint *Endpoint) GetChannel() channeltypes.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) + endpoint.Chain.App.IBCKeeper.ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) } // QueryClientStateProof performs and abci query for a client stat associated diff --git a/x/wasm/ibctesting/path.go b/x/wasm/ibctesting/path.go index 2707cb161b..7a7021595b 100644 --- a/x/wasm/ibctesting/path.go +++ b/x/wasm/ibctesting/path.go @@ -40,7 +40,7 @@ func (path *Path) SetChannelOrdered() { // 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()) + pc := path.EndpointA.Chain.App.IBCKeeper.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 @@ -59,7 +59,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error { } - pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + pc = path.EndpointB.Chain.App.IBCKeeper.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 diff --git a/x/wasm/ibctesting/wasm.go b/x/wasm/ibctesting/wasm.go index 282097dcab..2a6e5ca6b8 100644 --- a/x/wasm/ibctesting/wasm.go +++ b/x/wasm/ibctesting/wasm.go @@ -16,7 +16,6 @@ import ( abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/rand" - wasmd "github.com/line/wasmd/app" "github.com/line/wasmd/x/wasm/types" ) @@ -63,6 +62,7 @@ func (chain *TestChain) StoreCode(byteCode []byte) types.MsgStoreCodeResponse { var pInstResp types.MsgStoreCodeResponse require.NoError(chain.t, pInstResp.Unmarshal(protoResult.Data[0].Data)) require.NotEmpty(chain.t, pInstResp.CodeID) + require.NotEmpty(chain.t, pInstResp.Checksum) return pInstResp } @@ -134,8 +134,5 @@ 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 { - type testSupporter interface { - TestSupport() *wasmd.TestSupport - } - return chain.App.(testSupporter).TestSupport().WasmKeeper().GetContractInfo(chain.GetContext(), contractAddr) + return chain.App.WasmKeeper.GetContractInfo(chain.GetContext(), contractAddr) } diff --git a/x/wasm/ioutils/ioutil.go b/x/wasm/ioutils/ioutil.go index 42a7015471..154996ca09 100644 --- a/x/wasm/ioutils/ioutil.go +++ b/x/wasm/ioutils/ioutil.go @@ -8,18 +8,12 @@ import ( "github.com/line/wasmd/x/wasm/types" ) -// Uncompress returns gzip uncompressed content if input was gzip, or original src otherwise -func Uncompress(src []byte, limit uint64) ([]byte, error) { - switch n := uint64(len(src)); { - case n < 3: - return src, nil - case n > limit: +// Uncompress expects a valid gzip source to unpack or fails. See IsGzip +func Uncompress(gzipSrc []byte, limit uint64) ([]byte, error) { + if uint64(len(gzipSrc)) > limit { return nil, types.ErrLimit } - if !bytes.Equal(gzipIdent, src[0:3]) { - return src, nil - } - zr, err := gzip.NewReader(bytes.NewReader(src)) + zr, err := gzip.NewReader(bytes.NewReader(gzipSrc)) if err != nil { return nil, err } diff --git a/x/wasm/ioutils/ioutil_test.go b/x/wasm/ioutils/ioutil_test.go index 5f1f9500b5..d3accaae5c 100644 --- a/x/wasm/ioutils/ioutil_test.go +++ b/x/wasm/ioutils/ioutil_test.go @@ -6,7 +6,6 @@ import ( "errors" "io" "os" - "strings" "testing" "github.com/stretchr/testify/assert" @@ -29,30 +28,10 @@ func TestUncompress(t *testing.T) { expError error expResult []byte }{ - "handle wasm uncompressed": { - src: wasmRaw, - expResult: wasmRaw, - }, "handle wasm compressed": { src: wasmGzipped, expResult: wasmRaw, }, - "handle nil slice": { - src: nil, - expResult: nil, - }, - "handle short unidentified": { - src: []byte{0x1, 0x2}, - expResult: []byte{0x1, 0x2}, - }, - "handle input slice exceeding limit": { - src: []byte(strings.Repeat("a", maxSize+1)), - expError: types.ErrLimit, - }, - "handle input slice at limit": { - src: []byte(strings.Repeat("a", maxSize)), - expResult: []byte(strings.Repeat("a", maxSize)), - }, "handle gzip identifier only": { src: gzipIdent, expError: io.ErrUnexpectedEOF, diff --git a/x/wasm/ioutils/utils.go b/x/wasm/ioutils/utils.go index d4b8abf349..197c44c360 100644 --- a/x/wasm/ioutils/utils.go +++ b/x/wasm/ioutils/utils.go @@ -17,7 +17,7 @@ var ( // IsGzip returns checks if the file contents are gzip compressed func IsGzip(input []byte) bool { - return bytes.Equal(input[:3], gzipIdent) + return len(input) >= 3 && bytes.Equal(gzipIdent, input[0:3]) } // IsWasm checks if the file contents are of wasm binary diff --git a/x/wasm/ioutils/utils_test.go b/x/wasm/ioutils/utils_test.go index 6d9fa52bb0..2dea0c5c0f 100644 --- a/x/wasm/ioutils/utils_test.go +++ b/x/wasm/ioutils/utils_test.go @@ -9,7 +9,6 @@ import ( func GetTestData() ([]byte, []byte, []byte, error) { wasmCode, err := os.ReadFile("../keeper/testdata/hackatom.wasm") - if err != nil { return nil, nil, nil, err } @@ -42,13 +41,17 @@ func TestIsGzip(t *testing.T) { require.False(t, IsGzip(wasmCode)) require.False(t, IsGzip(someRandomStr)) + require.False(t, IsGzip(nil)) + require.True(t, IsGzip(gzipData[0:3])) require.True(t, IsGzip(gzipData)) } func TestGzipIt(t *testing.T) { wasmCode, someRandomStr, _, err := GetTestData() - originalGzipData := []byte{31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 202, 72, 205, 201, 201, 87, 40, 207, 47, 202, 73, 1, - 4, 0, 0, 255, 255, 133, 17, 74, 13, 11, 0, 0, 0} + originalGzipData := []byte{ + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 202, 72, 205, 201, 201, 87, 40, 207, 47, 202, 73, 1, + 4, 0, 0, 255, 255, 133, 17, 74, 13, 11, 0, 0, 0, + } require.NoError(t, err) diff --git a/x/wasm/keeper/addresses.go b/x/wasm/keeper/addresses.go new file mode 100644 index 0000000000..d51b9a44b1 --- /dev/null +++ b/x/wasm/keeper/addresses.go @@ -0,0 +1,76 @@ +package keeper + +import ( + "encoding/binary" + "fmt" + + sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/types/address" + + "github.com/line/wasmd/x/wasm/types" +) + +// AddressGenerator abstract address generator to be used for a single contract address +type AddressGenerator func(ctx sdk.Context, codeID uint64, checksum []byte) sdk.AccAddress + +// ClassicAddressGenerator generates a contract address using codeID and instanceID sequence +func (k Keeper) ClassicAddressGenerator() AddressGenerator { + return func(ctx sdk.Context, codeID uint64, _ []byte) sdk.AccAddress { + instanceID := k.autoIncrementID(ctx, types.KeyLastInstanceID) + return BuildContractAddressClassic(codeID, instanceID) + } +} + +// PredicableAddressGenerator generates a predictable contract address +func PredicableAddressGenerator(creator sdk.AccAddress, salt []byte, msg []byte, fixMsg bool) AddressGenerator { + return func(ctx sdk.Context, _ uint64, checksum []byte) sdk.AccAddress { + if !fixMsg { // clear msg to not be included in the address generation + msg = []byte{} + } + return BuildContractAddressPredictable(checksum, creator, salt, msg) + } +} + +// BuildContractAddressClassic builds an sdk account address for a contract. +func BuildContractAddressClassic(codeID, instanceID uint64) sdk.AccAddress { + contractID := make([]byte, 16) + binary.BigEndian.PutUint64(contractID[:8], codeID) + binary.BigEndian.PutUint64(contractID[8:], instanceID) + return address.Module(types.ModuleName, contractID)[:types.ContractAddrLen] +} + +// BuildContractAddressPredictable generates a contract address for the wasm module with len = types.ContractAddrLen using the +// Cosmos SDK address.Module function. +// Internally a key is built containing: +// (len(checksum) | checksum | len(sender_address) | sender_address | len(salt) | salt| len(initMsg) | initMsg). +// +// All method parameter values must be valid and not nil. +func BuildContractAddressPredictable(checksum []byte, creator sdk.AccAddress, salt, initMsg types.RawContractMessage) sdk.AccAddress { + if len(checksum) != 32 { + panic("invalid checksum") + } + if err := sdk.VerifyAddressFormat(creator); err != nil { + panic(fmt.Sprintf("creator: %s", err)) + } + if err := types.ValidateSalt(salt); err != nil { + panic(fmt.Sprintf("salt: %s", err)) + } + if err := initMsg.ValidateBasic(); len(initMsg) != 0 && err != nil { + panic(fmt.Sprintf("initMsg: %s", err)) + } + checksum = UInt64LengthPrefix(checksum) + creator = UInt64LengthPrefix(creator) + salt = UInt64LengthPrefix(salt) + initMsg = UInt64LengthPrefix(initMsg) + key := make([]byte, len(checksum)+len(creator)+len(salt)+len(initMsg)) + copy(key[0:], checksum) + copy(key[len(checksum):], creator) + copy(key[len(checksum)+len(creator):], salt) + copy(key[len(checksum)+len(creator)+len(salt):], initMsg) + return address.Module(types.ModuleName, key)[:types.ContractAddrLen] +} + +// UInt64LengthPrefix prepend big endian encoded byte length +func UInt64LengthPrefix(bz []byte) []byte { + return append(sdk.Uint64ToBigEndian(uint64(len(bz))), bz...) +} diff --git a/x/wasm/keeper/addresses_test.go b/x/wasm/keeper/addresses_test.go new file mode 100644 index 0000000000..c305a881dd --- /dev/null +++ b/x/wasm/keeper/addresses_test.go @@ -0,0 +1,433 @@ +package keeper + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + tmbytes "github.com/tendermint/tendermint/libs/bytes" + + sdk "github.com/line/lbm-sdk/types" +) + +func TestBuildContractAddress(t *testing.T) { + x, y := sdk.GetConfig().GetBech32AccountAddrPrefix(), sdk.GetConfig().GetBech32AccountPubPrefix() + t.Cleanup(func() { + sdk.GetConfig().SetBech32PrefixForAccount(x, y) + }) + sdk.GetConfig().SetBech32PrefixForAccount("purple", "purple") + + // test vectors generated via cosmjs: https://github.com/cosmos/cosmjs/pull/1253/files + type Spec struct { + In struct { + Checksum tmbytes.HexBytes `json:"checksum"` + Creator sdk.AccAddress `json:"creator"` + Salt tmbytes.HexBytes `json:"salt"` + Msg string `json:"msg"` + } `json:"in"` + Out struct { + Address sdk.AccAddress `json:"address"` + } `json:"out"` + } + var specs []Spec + require.NoError(t, json.Unmarshal([]byte(goldenMasterPredictableContractAddr), &specs)) + require.NotEmpty(t, specs) + for i, spec := range specs { + t.Run(fmt.Sprintf("case %d", i), func(t *testing.T) { + // when + gotAddr := BuildContractAddressPredictable(spec.In.Checksum, spec.In.Creator, spec.In.Salt.Bytes(), []byte(spec.In.Msg)) + + require.Equal(t, spec.Out.Address.String(), gotAddr.String()) + require.NoError(t, sdk.VerifyAddressFormat(gotAddr)) + }) + } +} + +const goldenMasterPredictableContractAddr = `[ + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": null + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000001610000000000000000", + "addressData": "5e865d3e45ad3e961f77fd77d46543417ced44d924dc3e079b5415ff6775f847" + }, + "out": { + "address": "purple1t6r960j945lfv8mhl4mage2rg97w63xeynwrupum2s2l7em4lprs9ce5hk" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc00000000000000016100000000000000027b7d", + "addressData": "0995499608947a5281e2c7ebd71bdb26a1ad981946dad57f6c4d3ee35de77835" + }, + "out": { + "address": "purple1px25n9sgj3a99q0zcl4awx7my6s6mxqegmdd2lmvf5lwxh080q6suttktr" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc000000000000000161000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "83326e554723b15bac664ceabc8a5887e27003abe9fbd992af8c7bcea4745167" + }, + "out": { + "address": "purple1svexu428ywc4htrxfn4tezjcsl38qqata8aany4033auafr529ns4v254c" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": null + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae0000000000000000", + "addressData": "9384c6248c0bb171e306fd7da0993ec1e20eba006452a3a9e078883eb3594564" + }, + "out": { + "address": "purple1jwzvvfyvpwchrccxl476pxf7c83qawsqv3f2820q0zyrav6eg4jqdcq7gc" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae00000000000000027b7d", + "addressData": "9a8d5f98fb186825401a26206158e7a1213311a9b6a87944469913655af52ffb" + }, + "out": { + "address": "purple1n2x4lx8mrp5z2sq6ycsxzk885ysnxydfk658j3zxnyfk2kh49lasesxf6j" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "932f07bc53f7d0b0b43cb5a54ac3e245b205e6ae6f7c1d991dc6af4a2ff9ac18" + }, + "out": { + "address": "purple1jvhs00zn7lgtpdpukkj54slzgkeqte4wda7pmxgac6h55tle4svq8cmp60" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": null + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000001610000000000000000", + "addressData": "9725e94f528d8b78d33c25f3dfcd60e6142d8be60ab36f6a5b59036fd51560db" + }, + "out": { + "address": "purple1juj7jn6j3k9h35euyhealntquc2zmzlxp2ek76jmtypkl4g4vrdsfwmwxk" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff00000000000000016100000000000000027b7d", + "addressData": "b056e539bbaf447ba18f3f13b792970111fc78933eb6700f4d227b5216d63658" + }, + "out": { + "address": "purple1kptw2wdm4az8hgv08ufm0y5hqyglc7yn86m8qr6dyfa4y9kkxevqmkm9q3" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff000000000000000161000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "6c98434180f052294ff89fb6d2dae34f9f4468b0b8e6e7c002b2a44adee39abd" + }, + "out": { + "address": "purple1djvyxsvq7pfzjnlcn7md9khrf705g69shrnw0sqzk2jy4hhrn27sjh2ysy" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": null + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae0000000000000000", + "addressData": "0aaf1c31c5d529d21d898775bc35b3416f47bfd99188c334c6c716102cbd3101" + }, + "out": { + "address": "purple1p2h3cvw9655ay8vfsa6mcddng9h5007ejxyvxdxxcutpqt9axyqsagmmay" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae00000000000000027b7d", + "addressData": "36fe6ab732187cdfed46290b448b32eb7f4798e7a4968b0537de8a842cbf030e" + }, + "out": { + "address": "purple1xmlx4dejrp7dlm2x9y95fzejadl50x885jtgkpfhm69ggt9lqv8qk3vn4f" + } + }, + { + "in": { + "checksum": "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d00000000000000002013a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a500000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "a0d0c942adac6f3e5e7c23116c4c42a24e96e0ab75f53690ec2d3de16067c751" + }, + "out": { + "address": "purple15rgvjs4d43hnuhnuyvgkcnzz5f8fdc9twh6ndy8v9577zcr8cags40l9dt" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": null + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000001610000000000000000", + "addressData": "b95c467218d408a0f93046f227b6ece7fe18133ff30113db4d2a7becdfeca141" + }, + "out": { + "address": "purple1h9wyvusc6sy2p7fsgmez0dhvullpsyel7vq38k6d9fa7ehlv59qsvnyh36" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc00000000000000016100000000000000027b7d", + "addressData": "23fe45dbbd45dc6cd25244a74b6e99e7a65bf0bac2f2842a05049d37555a3ae6" + }, + "out": { + "address": "purple1y0lytkaaghwxe5jjgjn5km5eu7n9hu96ctegg2s9qjwnw4268tnqxhg60a" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "61", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc000000000000000161000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "6faea261ed63baa65b05726269e83b217fa6205dc7d9fb74f9667d004a69c082" + }, + "out": { + "address": "purple1d7h2yc0dvwa2vkc9wf3xn6pmy9l6vgzaclvlka8eve7sqjnfczpqqsdnwu" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": null + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae0000000000000000", + "addressData": "67a3ab6384729925fdb144574628ce96836fe098d2c6be4e84ac106b2728d96c" + }, + "out": { + "address": "purple1v736kcuyw2vjtld3g3t5v2xwj6pklcyc6trtun5y4sgxkfegm9kq7vgpnt" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae00000000000000027b7d", + "addressData": "23a121263bfce05c144f4af86f3d8a9f87dc56f9dc48dbcffc8c5a614da4c661" + }, + "out": { + "address": "purple1ywsjzf3mlns9c9z0ftux70v2n7rac4hem3ydhnlu33dxzndycesssc7x2m" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvhxf2py", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbcccccccccc", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000149999999999aaaaaaaaaabbbbbbbbbbcccccccccc0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "dd90dba6d6fcd5fb9c9c8f536314eb1bb29cb5aa084b633c5806b926a5636b58" + }, + "out": { + "address": "purple1mkgdhfkkln2lh8yu3afkx98trwefedd2pp9kx0zcq6ujdftrddvq50esay" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": null + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000001610000000000000000", + "addressData": "547a743022f4f1af05b102f57bf1c1c7d7ee81bae427dc20d36b2c4ec57612ae" + }, + "out": { + "address": "purple123a8gvpz7nc67pd3qt6hhuwpclt7aqd6usnacgxndvkya3tkz2hq5hz38f" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff00000000000000016100000000000000027b7d", + "addressData": "416e169110e4b411bc53162d7503b2bbf14d6b36b1413a4f4c9af622696e9665" + }, + "out": { + "address": "purple1g9hpdygsuj6pr0znzckh2qajh0c566ekk9qn5n6vntmzy6twjejsrl9alk" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "61", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff000000000000000161000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "619a0988b92d8796cea91dea63cbb1f1aefa4a6b6ee5c5d1e937007252697220" + }, + "out": { + "address": "purple1vxdqnz9e9kredn4frh4x8ja37xh05jntdmjut50fxuq8y5nfwgsquu9mxh" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": null + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae0000000000000000", + "addressData": "d8af856a6a04852d19b647ad6d4336eb26e077f740aef1a0331db34d299a885a" + }, + "out": { + "address": "purple1mzhc26n2qjzj6xdkg7kk6sekavnwqalhgzh0rgpnrke562v63pdq8grp8q" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae00000000000000027b7d", + "addressData": "c7fb7bea96daab23e416c4fcf328215303005e1d0d5424257335568e5381e33c" + }, + "out": { + "address": "purple1clahh65km24j8eqkcn70x2pp2vpsqhsap42zgftnx4tgu5upuv7q9ywjws" + } + }, + { + "in": { + "checksum": "1da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b", + "creator": "purple1nxvenxve42424242hwamhwamenxvenxvmhwamhwaamhwamhwlllsatsy6m", + "creatorData": "9999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff", + "salt": "aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae", + "msg": "{\"some\":123,\"structure\":{\"nested\":[\"ok\",true]}}" + }, + "intermediate": { + "key": "7761736d0000000000000000201da6c16de2cbaf7ad8cbb66f0925ba33f5c278cb2491762d04658c1480ea229b00000000000000209999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffff0000000000000040aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbccddeeffffeeddbbccddaa66551155aaaabbcc787878789900aabbbbcc221100acadae000000000000002f7b22736f6d65223a3132332c22737472756374757265223a7b226e6573746564223a5b226f6b222c747275655d7d7d", + "addressData": "ccdf9dea141a6c2475870529ab38fae9dec30df28e005894fe6578b66133ab4a" + }, + "out": { + "address": "purple1en0em6s5rfkzgav8q556kw86a80vxr0j3cq93987v4utvcfn4d9q0tql4w" + } + } +] +` diff --git a/x/wasm/keeper/authz_policy.go b/x/wasm/keeper/authz_policy.go index 740195b19a..e485dbc827 100644 --- a/x/wasm/keeper/authz_policy.go +++ b/x/wasm/keeper/authz_policy.go @@ -10,10 +10,10 @@ type AuthorizationPolicy interface { CanCreateCode(c types.AccessConfig, creator sdk.AccAddress) bool CanInstantiateContract(c types.AccessConfig, actor sdk.AccAddress) bool CanModifyContract(admin, actor sdk.AccAddress) bool + CanModifyCodeAccessConfig(creator, actor sdk.AccAddress, isSubset bool) bool } -type DefaultAuthorizationPolicy struct { -} +type DefaultAuthorizationPolicy struct{} func (p DefaultAuthorizationPolicy) CanCreateCode(config types.AccessConfig, actor sdk.AccAddress) bool { return config.Allowed(actor) @@ -27,21 +27,24 @@ func (p DefaultAuthorizationPolicy) CanModifyContract(admin, actor sdk.AccAddres return admin != nil && admin.Equals(actor) } -// GovAuthorizationPolicy is for the gov handler(proposal_handler.go) authorities -type GovAuthorizationPolicy struct { +func (p DefaultAuthorizationPolicy) CanModifyCodeAccessConfig(creator, actor sdk.AccAddress, isSubset bool) bool { + return creator != nil && creator.Equals(actor) && isSubset } +type GovAuthorizationPolicy struct{} + func (p GovAuthorizationPolicy) CanCreateCode(types.AccessConfig, sdk.AccAddress) bool { - // The gov handler can create code regardless of the current access config return true } func (p GovAuthorizationPolicy) CanInstantiateContract(types.AccessConfig, sdk.AccAddress) bool { - // The gov handler can instantiate contract regardless of the code access config return true } func (p GovAuthorizationPolicy) CanModifyContract(sdk.AccAddress, sdk.AccAddress) bool { - // The gov handler can migrate contract regardless of the contract admin + return true +} + +func (p GovAuthorizationPolicy) CanModifyCodeAccessConfig(sdk.AccAddress, sdk.AccAddress, bool) bool { return true } diff --git a/x/wasm/keeper/authz_policy_test.go b/x/wasm/keeper/authz_policy_test.go new file mode 100644 index 0000000000..662727ba55 --- /dev/null +++ b/x/wasm/keeper/authz_policy_test.go @@ -0,0 +1,312 @@ +package keeper + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + sdk "github.com/line/lbm-sdk/types" + + "github.com/line/wasmd/x/wasm/types" +) + +func TestDefaultAuthzPolicyCanCreateCode(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + specs := map[string]struct { + config types.AccessConfig + actor sdk.AccAddress + exp bool + panics bool + }{ + "nobody": { + config: types.AllowNobody, + exp: false, + }, + "everybody": { + config: types.AllowEverybody, + exp: true, + }, + "only address - same": { + config: types.AccessTypeOnlyAddress.With(myActorAddress), + exp: true, + }, + "only address - different": { + config: types.AccessTypeOnlyAddress.With(otherAddress), + exp: false, + }, + "any address - included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress, myActorAddress), + exp: true, + }, + "any address - not included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress), + exp: false, + }, + "undefined config - panics": { + config: types.AccessConfig{}, + panics: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := DefaultAuthorizationPolicy{} + if !spec.panics { + got := policy.CanCreateCode(spec.config, myActorAddress) + assert.Equal(t, spec.exp, got) + return + } + assert.Panics(t, func() { + policy.CanCreateCode(spec.config, myActorAddress) + }) + }) + } +} + +func TestDefaultAuthzPolicyCanInstantiateContract(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + specs := map[string]struct { + config types.AccessConfig + actor sdk.AccAddress + exp bool + panics bool + }{ + "nobody": { + config: types.AllowNobody, + exp: false, + }, + "everybody": { + config: types.AllowEverybody, + exp: true, + }, + "only address - same": { + config: types.AccessTypeOnlyAddress.With(myActorAddress), + exp: true, + }, + "only address - different": { + config: types.AccessTypeOnlyAddress.With(otherAddress), + exp: false, + }, + "any address - included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress, myActorAddress), + exp: true, + }, + "any address - not included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress), + exp: false, + }, + "undefined config - panics": { + config: types.AccessConfig{}, + panics: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := DefaultAuthorizationPolicy{} + if !spec.panics { + got := policy.CanInstantiateContract(spec.config, myActorAddress) + assert.Equal(t, spec.exp, got) + return + } + assert.Panics(t, func() { + policy.CanInstantiateContract(spec.config, myActorAddress) + }) + }) + } +} + +func TestDefaultAuthzPolicyCanModifyContract(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + + specs := map[string]struct { + admin sdk.AccAddress + exp bool + }{ + "same as actor": { + admin: myActorAddress, + exp: true, + }, + "different admin": { + admin: otherAddress, + exp: false, + }, + "no admin": { + exp: false, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := DefaultAuthorizationPolicy{} + got := policy.CanModifyContract(spec.admin, myActorAddress) + assert.Equal(t, spec.exp, got) + }) + } +} + +func TestDefaultAuthzPolicyCanModifyCodeAccessConfig(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + + specs := map[string]struct { + admin sdk.AccAddress + subset bool + exp bool + }{ + "same as actor - subset": { + admin: myActorAddress, + subset: true, + exp: true, + }, + "same as actor - not subset": { + admin: myActorAddress, + subset: false, + exp: false, + }, + "different admin": { + admin: otherAddress, + exp: false, + }, + "no admin": { + exp: false, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := DefaultAuthorizationPolicy{} + got := policy.CanModifyCodeAccessConfig(spec.admin, myActorAddress, spec.subset) + assert.Equal(t, spec.exp, got) + }) + } +} + +func TestGovAuthzPolicyCanCreateCode(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + specs := map[string]struct { + config types.AccessConfig + actor sdk.AccAddress + }{ + "nobody": { + config: types.AllowNobody, + }, + "everybody": { + config: types.AllowEverybody, + }, + "only address - same": { + config: types.AccessTypeOnlyAddress.With(myActorAddress), + }, + "only address - different": { + config: types.AccessTypeOnlyAddress.With(otherAddress), + }, + "any address - included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress, myActorAddress), + }, + "any address - not included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress), + }, + "undefined config - panics": { + config: types.AccessConfig{}, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := GovAuthorizationPolicy{} + got := policy.CanCreateCode(spec.config, myActorAddress) + assert.True(t, got) + }) + } +} + +func TestGovAuthzPolicyCanInstantiateContract(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + specs := map[string]struct { + config types.AccessConfig + actor sdk.AccAddress + }{ + "nobody": { + config: types.AllowNobody, + }, + "everybody": { + config: types.AllowEverybody, + }, + "only address - same": { + config: types.AccessTypeOnlyAddress.With(myActorAddress), + }, + "only address - different": { + config: types.AccessTypeOnlyAddress.With(otherAddress), + }, + "any address - included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress, myActorAddress), + }, + "any address - not included": { + config: types.AccessTypeAnyOfAddresses.With(otherAddress), + }, + "undefined config - panics": { + config: types.AccessConfig{}, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := GovAuthorizationPolicy{} + got := policy.CanInstantiateContract(spec.config, myActorAddress) + assert.True(t, got) + }) + } +} + +func TestGovAuthzPolicyCanModifyContract(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + + specs := map[string]struct { + admin sdk.AccAddress + }{ + "same as actor": { + admin: myActorAddress, + }, + "different admin": { + admin: otherAddress, + }, + "no admin": {}, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := GovAuthorizationPolicy{} + got := policy.CanModifyContract(spec.admin, myActorAddress) + assert.True(t, got) + }) + } +} + +func TestGovAuthzPolicyCanModifyCodeAccessConfig(t *testing.T) { + myActorAddress := RandomAccountAddress(t) + otherAddress := RandomAccountAddress(t) + + specs := map[string]struct { + admin sdk.AccAddress + subset bool + }{ + "same as actor - subset": { + admin: myActorAddress, + subset: true, + }, + "same as actor - not subset": { + admin: myActorAddress, + subset: false, + }, + "different admin": { + admin: otherAddress, + }, + "no admin": {}, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + policy := GovAuthorizationPolicy{} + got := policy.CanModifyCodeAccessConfig(spec.admin, myActorAddress, spec.subset) + assert.True(t, got) + }) + } +} diff --git a/x/wasm/keeper/bench_test.go b/x/wasm/keeper/bench_test.go index 7ce5513526..631968aaff 100644 --- a/x/wasm/keeper/bench_test.go +++ b/x/wasm/keeper/bench_test.go @@ -68,7 +68,7 @@ func BenchmarkInstantiationOverhead(b *testing.B) { for name, spec := range specs { b.Run(name, func(b *testing.B) { wasmConfig := types.WasmConfig{MemoryCacheSize: 0} - ctx, keepers := createTestInput(b, false, SupportedFeatures, nil, nil, wasmConfig, spec.db()) + ctx, keepers := createTestInput(b, false, AvailableCapabilities, nil, nil, wasmConfig, spec.db()) example := InstantiateHackatomExampleContract(b, ctx, keepers) if spec.pinned { require.NoError(b, keepers.ContractKeeper.PinCode(ctx, example.CodeID)) @@ -90,15 +90,12 @@ func BenchmarkCompilation(b *testing.B) { db func() dbm.DB }{ "hackatom": { - db: func() dbm.DB { return dbm.NewMemDB() }, wasmFile: "./testdata/hackatom.wasm", }, "burner": { - db: func() dbm.DB { return dbm.NewMemDB() }, wasmFile: "./testdata/burner.wasm", }, "ibc_reflect": { - db: func() dbm.DB { return dbm.NewMemDB() }, wasmFile: "./testdata/ibc_reflect.wasm", }, } @@ -106,7 +103,8 @@ func BenchmarkCompilation(b *testing.B) { for name, spec := range specs { b.Run(name, func(b *testing.B) { wasmConfig := types.WasmConfig{MemoryCacheSize: 0} - ctx, keepers := createTestInput(b, false, SupportedFeatures, nil, nil, wasmConfig, spec.db()) + db := dbm.NewMemDB() + ctx, keepers := createTestInput(b, false, AvailableCapabilities, nil, nil, wasmConfig, db) // print out code size for comparisons code, err := os.ReadFile(spec.wasmFile) diff --git a/x/wasm/keeper/contract_keeper.go b/x/wasm/keeper/contract_keeper.go index c8dab777eb..667475b0b5 100644 --- a/x/wasm/keeper/contract_keeper.go +++ b/x/wasm/keeper/contract_keeper.go @@ -10,8 +10,19 @@ var _ types.ContractOpsKeeper = PermissionedKeeper{} // decoratedKeeper contains a subset of the wasm keeper that are already or can be guarded by an authorization policy in the future type decoratedKeeper interface { - create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ AuthorizationPolicy) (codeID uint64, err error) - instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins, authZ AuthorizationPolicy) (sdk.AccAddress, []byte, error) + create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ AuthorizationPolicy) (codeID uint64, checksum []byte, err error) + + instantiate( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, + addressGenerator AddressGenerator, + authZ AuthorizationPolicy, + ) (sdk.AccAddress, []byte, error) + migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, newCodeID uint64, msg []byte, authZ AuthorizationPolicy) ([]byte, error) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ AuthorizationPolicy) error pinCode(ctx sdk.Context, codeID uint64) error @@ -19,7 +30,8 @@ type decoratedKeeper interface { execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) setContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error - setAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error + setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, autz AuthorizationPolicy) error + ClassicAddressGenerator() AddressGenerator activateContract(ctx sdk.Context, contractAddress sdk.AccAddress) error deactivateContract(ctx sdk.Context, contractAddress sdk.AccAddress) error @@ -42,12 +54,44 @@ func NewDefaultPermissionKeeper(nested decoratedKeeper) *PermissionedKeeper { return NewPermissionedKeeper(nested, DefaultAuthorizationPolicy{}) } -func (p PermissionedKeeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig) (codeID uint64, err error) { +func (p PermissionedKeeper) Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig) (codeID uint64, checksum []byte, err error) { return p.nested.create(ctx, creator, wasmCode, instantiateAccess, p.authZPolicy) } -func (p PermissionedKeeper) Instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins) (sdk.AccAddress, []byte, error) { - return p.nested.instantiate(ctx, codeID, creator, admin, initMsg, label, deposit, p.authZPolicy) +// Instantiate creates an instance of a WASM contract using the classic sequence based address generator +func (p PermissionedKeeper) Instantiate( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, +) (sdk.AccAddress, []byte, error) { + return p.nested.instantiate(ctx, codeID, creator, admin, initMsg, label, deposit, p.nested.ClassicAddressGenerator(), p.authZPolicy) +} + +// Instantiate2 creates an instance of a WASM contract using the predictable address generator +func (p PermissionedKeeper) Instantiate2( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, + salt []byte, + fixMsg bool, +) (sdk.AccAddress, []byte, error) { + return p.nested.instantiate( + ctx, + codeID, + creator, + admin, + initMsg, + label, + deposit, + PredicableAddressGenerator(creator, salt, initMsg, fixMsg), + p.authZPolicy, + ) } func (p PermissionedKeeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) { @@ -78,14 +122,14 @@ func (p PermissionedKeeper) UnpinCode(ctx sdk.Context, codeID uint64) error { return p.nested.unpinCode(ctx, codeID) } -// SetExtraContractAttributes updates the extra attributes that can be stored with the contract info +// SetContractInfoExtension updates the extra attributes that can be stored with the contract info func (p PermissionedKeeper) SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error { return p.nested.setContractInfoExtension(ctx, contract, extra) } // SetAccessConfig updates the access config of a code id. -func (p PermissionedKeeper) SetAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error { - return p.nested.setAccessConfig(ctx, codeID, config) +func (p PermissionedKeeper) SetAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig) error { + return p.nested.setAccessConfig(ctx, codeID, caller, newConfig, p.authZPolicy) } func (p PermissionedKeeper) DeactivateContract(ctx sdk.Context, contractAddress sdk.AccAddress) error { diff --git a/x/wasm/keeper/contract_keeper_test.go b/x/wasm/keeper/contract_keeper_test.go new file mode 100644 index 0000000000..a37bdebc1b --- /dev/null +++ b/x/wasm/keeper/contract_keeper_test.go @@ -0,0 +1,168 @@ +package keeper + +import ( + "encoding/json" + "fmt" + "math" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + sdk "github.com/line/lbm-sdk/types" + + "github.com/line/wasmd/x/wasm/keeper/wasmtesting" + "github.com/line/wasmd/x/wasm/types" +) + +func TestInstantiate2(t *testing.T) { + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + example := StoreHackatomExampleContract(t, parentCtx, keepers) + otherExample := StoreReflectContract(t, parentCtx, keepers) + mock := &wasmtesting.MockWasmer{} + wasmtesting.MakeInstantiable(mock) + keepers.WasmKeeper.wasmVM = mock // set mock to not fail on contract init message + + verifierAddr := RandomAccountAddress(t) + beneficiaryAddr := RandomAccountAddress(t) + initMsg := mustMarshal(t, HackatomExampleInitMsg{Verifier: verifierAddr, Beneficiary: beneficiaryAddr}) + + otherAddr := keepers.Faucet.NewFundedAccount(parentCtx, sdk.NewInt64Coin("denom", 1_000_000_000)) + + const ( + mySalt = "my salt" + myLabel = "my label" + ) + // create instances for duplicate checks + exampleContract := func(t *testing.T, ctx sdk.Context, fixMsg bool) { + _, _, err := keepers.ContractKeeper.Instantiate2( + ctx, + example.CodeID, + example.CreatorAddr, + nil, + initMsg, + myLabel, + sdk.NewCoins(sdk.NewInt64Coin("denom", 1)), + []byte(mySalt), + fixMsg, + ) + require.NoError(t, err) + } + exampleWithFixMsg := func(t *testing.T, ctx sdk.Context) { + exampleContract(t, ctx, true) + } + exampleWithoutFixMsg := func(t *testing.T, ctx sdk.Context) { + exampleContract(t, ctx, false) + } + specs := map[string]struct { + setup func(t *testing.T, ctx sdk.Context) + codeID uint64 + sender sdk.AccAddress + salt []byte + initMsg json.RawMessage + fixMsg bool + expErr error + }{ + "fix msg - generates different address than without fixMsg": { + setup: exampleWithoutFixMsg, + codeID: example.CodeID, + sender: example.CreatorAddr, + salt: []byte(mySalt), + initMsg: initMsg, + fixMsg: true, + }, + "fix msg - different sender": { + setup: exampleWithFixMsg, + codeID: example.CodeID, + sender: otherAddr, + salt: []byte(mySalt), + initMsg: initMsg, + fixMsg: true, + }, + "fix msg - different code": { + setup: exampleWithFixMsg, + codeID: otherExample.CodeID, + sender: example.CreatorAddr, + salt: []byte(mySalt), + initMsg: []byte(`{}`), + fixMsg: true, + }, + "fix msg - different salt": { + setup: exampleWithFixMsg, + codeID: example.CodeID, + sender: example.CreatorAddr, + salt: []byte("other salt"), + initMsg: initMsg, + fixMsg: true, + }, + "fix msg - different init msg": { + setup: exampleWithFixMsg, + codeID: example.CodeID, + sender: example.CreatorAddr, + salt: []byte(mySalt), + initMsg: mustMarshal(t, HackatomExampleInitMsg{Verifier: otherAddr, Beneficiary: beneficiaryAddr}), + fixMsg: true, + }, + "different sender": { + setup: exampleWithoutFixMsg, + codeID: example.CodeID, + sender: otherAddr, + salt: []byte(mySalt), + initMsg: initMsg, + }, + "different code": { + setup: exampleWithoutFixMsg, + codeID: otherExample.CodeID, + sender: example.CreatorAddr, + salt: []byte(mySalt), + initMsg: []byte(`{}`), + }, + "different salt": { + setup: exampleWithoutFixMsg, + codeID: example.CodeID, + sender: example.CreatorAddr, + salt: []byte(`other salt`), + initMsg: initMsg, + }, + "different init msg - reject same address": { + setup: exampleWithoutFixMsg, + codeID: example.CodeID, + sender: example.CreatorAddr, + salt: []byte(mySalt), + initMsg: mustMarshal(t, HackatomExampleInitMsg{Verifier: otherAddr, Beneficiary: beneficiaryAddr}), + expErr: types.ErrDuplicate, + }, + "fix msg - long msg": { + setup: exampleWithFixMsg, + codeID: example.CodeID, + sender: otherAddr, + salt: []byte(mySalt), + initMsg: []byte(fmt.Sprintf(`{"foo":%q}`, strings.Repeat("b", math.MaxInt16+1))), // too long kills CI + fixMsg: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() + spec.setup(t, ctx) + gotAddr, _, gotErr := keepers.ContractKeeper.Instantiate2( + ctx, + spec.codeID, + spec.sender, + nil, + spec.initMsg, + myLabel, + sdk.NewCoins(sdk.NewInt64Coin("denom", 2)), + spec.salt, + spec.fixMsg, + ) + if spec.expErr != nil { + assert.ErrorIs(t, gotErr, spec.expErr) + return + } + require.NoError(t, gotErr) + assert.NotEmpty(t, gotAddr) + }) + } +} diff --git a/x/wasm/keeper/gas_register.go b/x/wasm/keeper/gas_register.go index 116a549fe3..ca937a3f53 100644 --- a/x/wasm/keeper/gas_register.go +++ b/x/wasm/keeper/gas_register.go @@ -2,7 +2,10 @@ package keeper import ( sdk "github.com/line/lbm-sdk/types" + sdkerrors "github.com/line/lbm-sdk/types/errors" wasmvmtypes "github.com/line/wasmvm/types" + + "github.com/line/wasmd/x/wasm/types" ) const ( @@ -23,15 +26,30 @@ const ( DefaultEventAttributeDataFreeTier = 100 ) +// default: 0.15 gas. +// see https://github.com/CosmWasm/wasmd/pull/898#discussion_r937727200 +var defaultPerByteUncompressCost = wasmvmtypes.UFraction{ + Numerator: 15, + Denominator: 100, +} + +// DefaultPerByteUncompressCost is how much SDK gas we charge per source byte to unpack +func DefaultPerByteUncompressCost() wasmvmtypes.UFraction { + return defaultPerByteUncompressCost +} + // GasRegister abstract source for gas costs type GasRegister interface { - // NewContractInstanceCosts costs to crate a new contract instance from code + // UncompressCosts costs to unpack a new wasm contract + UncompressCosts(byteLength int) sdk.Gas // EventCosts costs to persist an event EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas } // WasmGasRegisterConfig config type type WasmGasRegisterConfig struct { + // UncompressCost costs per byte to unpack a contract + UncompressCost wasmvmtypes.UFraction // EventPerAttributeCost is how much SDK gas is charged *per byte* for attribute data in events. // This is used with len(key) + len(value) EventPerAttributeCost sdk.Gas @@ -55,6 +73,7 @@ func DefaultGasRegisterConfig() WasmGasRegisterConfig { EventAttributeDataCost: DefaultEventAttributeDataCost, EventAttributeDataFreeTier: DefaultEventAttributeDataFreeTier, ContractMessageDataCost: DefaultContractMessageDataCost, + UncompressCost: DefaultPerByteUncompressCost(), } } @@ -75,6 +94,14 @@ func NewWasmGasRegister(c WasmGasRegisterConfig) WasmGasRegister { } } +// UncompressCosts costs to unpack a new wasm contract +func (g WasmGasRegister) UncompressCosts(byteLength int) sdk.Gas { + if byteLength < 0 { + panic(sdkerrors.Wrap(types.ErrInvalid, "negative length")) + } + return g.c.UncompressCost.Mul(uint64(byteLength)).Floor() +} + // EventCosts costs to persist an event func (g WasmGasRegister) EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas { gas, remainingFreeTier := g.eventAttributeCosts(attrs, g.c.EventAttributeDataFreeTier) diff --git a/x/wasm/keeper/genesis_test.go b/x/wasm/keeper/genesis_test.go index eaad499160..87cf6920e2 100644 --- a/x/wasm/keeper/genesis_test.go +++ b/x/wasm/keeper/genesis_test.go @@ -67,7 +67,7 @@ func TestGenesisExportImport(t *testing.T) { creatorAddr, err := sdk.AccAddressFromBech32(codeInfo.Creator) require.NoError(t, err) - codeID, err := contractKeeper.Create(srcCtx, creatorAddr, wasmCode, &codeInfo.InstantiateConfig) + codeID, _, err := contractKeeper.Create(srcCtx, creatorAddr, wasmCode, &codeInfo.InstantiateConfig) require.NoError(t, err) if pinned { contractKeeper.PinCode(srcCtx, codeID) @@ -82,7 +82,7 @@ func TestGenesisExportImport(t *testing.T) { } contract.CodeID = codeID - contractAddr := wasmKeeper.generateContractAddress(srcCtx, codeID) + contractAddr := wasmKeeper.ClassicAddressGenerator()(srcCtx, codeID, nil) wasmKeeper.storeContractInfo(srcCtx, contractAddr, &contract) wasmKeeper.appendToContractHistory(srcCtx, contractAddr, history...) wasmKeeper.importContractState(srcCtx, contractAddr, stateModels) @@ -128,7 +128,7 @@ func TestGenesisExportImport(t *testing.T) { }) // re-import - var importState types.GenesisState + var importState wasmTypes.GenesisState err = dstKeeper.cdc.UnmarshalJSON(exportedGenesis, &importState) require.NoError(t, err) InitGenesis(dstCtx, dstKeeper, importState, &StakingKeeperMock{}, TestHandler(contractKeeper)) @@ -269,7 +269,7 @@ func TestGenesisInit(t *testing.T) { }}, Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, }, @@ -290,10 +290,10 @@ func TestGenesisInit(t *testing.T) { }}, Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, { - ContractAddress: BuildContractAddress(1, 2).String(), + ContractAddress: BuildContractAddressClassic(1, 2).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, }, @@ -309,7 +309,7 @@ func TestGenesisInit(t *testing.T) { src: types.GenesisState{ Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, }, @@ -325,10 +325,10 @@ func TestGenesisInit(t *testing.T) { }}, Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, }, @@ -344,7 +344,7 @@ func TestGenesisInit(t *testing.T) { }}, Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), ContractState: []types.Model{ { @@ -392,7 +392,7 @@ func TestGenesisInit(t *testing.T) { }}, Contracts: []types.Contract{ { - ContractAddress: BuildContractAddress(1, 1).String(), + ContractAddress: BuildContractAddressClassic(1, 1).String(), ContractInfo: types.ContractInfoFixture(func(c *wasmTypes.ContractInfo) { c.CodeID = 1 }, types.OnlyGenesisFields), }, }, @@ -404,7 +404,7 @@ func TestGenesisInit(t *testing.T) { }, }, "validator set update called for any genesis messages": { - src: types.GenesisState{ + src: wasmTypes.GenesisState{ GenMsgs: []types.GenesisState_GenMsgs{ {Sum: &types.GenesisState_GenMsgs_StoreCode{ StoreCode: types.MsgStoreCodeFixture(), @@ -413,8 +413,10 @@ func TestGenesisInit(t *testing.T) { Params: types.DefaultParams(), }, stakingMock: StakingKeeperMock{expCalls: 1, validatorUpdate: []abci.ValidatorUpdate{ - {PubKey: crypto.PublicKey{Sum: &crypto.PublicKey_Ed25519{ - Ed25519: []byte("a valid key")}}, + { + PubKey: crypto.PublicKey{Sum: &crypto.PublicKey_Ed25519{ + Ed25519: []byte("a valid key"), + }}, Power: 100, }, }}, @@ -422,7 +424,7 @@ func TestGenesisInit(t *testing.T) { expSuccess: true, }, "validator set update not called on genesis msg handler errors": { - src: types.GenesisState{ + src: wasmTypes.GenesisState{ GenMsgs: []types.GenesisState_GenMsgs{ {Sum: &types.GenesisState_GenMsgs_StoreCode{ StoreCode: types.MsgStoreCodeFixture(), @@ -507,7 +509,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { enc64 := base64.StdEncoding.EncodeToString genesisStr := fmt.Sprintf(genesisTemplate, enc64(wasmCodeHash[:]), enc64(wasmCode)) - var importState types.GenesisState + var importState wasmTypes.GenesisState err = keeper.cdc.UnmarshalJSON([]byte(genesisStr), &importState) require.NoError(t, err) require.NoError(t, importState.ValidateBasic(), genesisStr) @@ -603,7 +605,7 @@ func TestSupportedGenMsgTypes(t *testing.T) { Sum: &types.GenesisState_GenMsgs_ExecuteContract{ ExecuteContract: &types.MsgExecuteContract{ Sender: verifierAddress.String(), - Contract: BuildContractAddress(1, 1).String(), + Contract: BuildContractAddressClassic(1, 1).String(), Msg: []byte(`{"release":{}}`), }, }, @@ -628,7 +630,7 @@ func TestSupportedGenMsgTypes(t *testing.T) { require.NotNil(t, codeInfo) // verify contract instantiated - cInfo := keeper.GetContractInfo(ctx, BuildContractAddress(1, 1)) + cInfo := keeper.GetContractInfo(ctx, BuildContractAddressClassic(1, 1)) require.NotNil(t, cInfo) // verify contract executed @@ -643,7 +645,7 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { t.Cleanup(func() { os.RemoveAll(tempDir) }) var ( keyParams = sdk.NewKVStoreKey(paramtypes.StoreKey) - tkeyParams = sdk.NewKVStoreKey(paramtypes.TStoreKey) + tkeyParams = sdk.NewTransientStoreKey(paramtypes.TStoreKey) keyWasm = sdk.NewKVStoreKey(wasmTypes.StoreKey) ) @@ -651,6 +653,7 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) { ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(keyWasm, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) require.NoError(t, ms.LoadLatestVersion()) ctx := sdk.NewContext(ms, ocproto.Header{ @@ -670,7 +673,26 @@ 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.ModuleName), authkeeper.AccountKeeper{}, bankpluskeeper.BaseKeeper{}, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, tempDir, wasmConfig, SupportedFeatures, nil, nil) + srcKeeper := NewKeeper( + encodingConfig.Marshaler, + keyWasm, + pk.Subspace(wasmTypes.ModuleName), + authkeeper.AccountKeeper{}, + &bankpluskeeper.BaseKeeper{}, + stakingkeeper.Keeper{}, + distributionkeeper.Keeper{}, + nil, + nil, + nil, + nil, + nil, + nil, + tempDir, + wasmConfig, + AvailableCapabilities, + nil, + nil, + ) return &srcKeeper, ctx, []sdk.StoreKey{keyWasm, keyParams} } diff --git a/x/wasm/keeper/ibc_test.go b/x/wasm/keeper/ibc_test.go index db20c36e2b..1f0e8208cd 100644 --- a/x/wasm/keeper/ibc_test.go +++ b/x/wasm/keeper/ibc_test.go @@ -11,14 +11,14 @@ import ( ) func TestDontBindPortNonIBCContract(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) example := InstantiateHackatomExampleContract(t, ctx, keepers) // ensure we bound the port _, _, err := keepers.IBCKeeper.PortKeeper.LookupModuleByPort(ctx, keepers.WasmKeeper.GetContractInfo(ctx, example.Contract).IBCPortID) require.Error(t, err) } func TestBindingPortForIBCContractOnInstantiate(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) example := InstantiateIBCReflectContract(t, ctx, keepers) // ensure we bound the port owner, _, err := keepers.IBCKeeper.PortKeeper.LookupModuleByPort(ctx, keepers.WasmKeeper.GetContractInfo(ctx, example.Contract).IBCPortID) require.NoError(t, err) @@ -41,7 +41,7 @@ func TestBindingPortForIBCContractOnInstantiate(t *testing.T) { } func TestContractFromPortID(t *testing.T) { - contractAddr := BuildContractAddress(1, 100) + contractAddr := BuildContractAddressClassic(1, 100) specs := map[string]struct { srcPort string expAddr sdk.AccAddress diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 30a063c8f3..c7e3421a91 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -4,9 +4,11 @@ import ( "bytes" "context" "encoding/binary" + "encoding/hex" "fmt" "math" "path/filepath" + "reflect" "strconv" "strings" "time" @@ -15,9 +17,10 @@ import ( "github.com/line/lbm-sdk/store/prefix" storetypes "github.com/line/lbm-sdk/store/types" sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/types/address" sdkerrors "github.com/line/lbm-sdk/types/errors" authkeeper "github.com/line/lbm-sdk/x/auth/keeper" + authtypes "github.com/line/lbm-sdk/x/auth/types" + vestingexported "github.com/line/lbm-sdk/x/auth/vesting/exported" bankpluskeeper "github.com/line/lbm-sdk/x/bankplus/keeper" paramtypes "github.com/line/lbm-sdk/x/params/types" "github.com/line/ostracon/libs/log" @@ -57,6 +60,15 @@ type CoinTransferrer interface { DeleteFromInactiveAddr(ctx sdk.Context, address sdk.AccAddress) } +// AccountPruner handles the balances and data cleanup for accounts that are pruned on contract instantiate. +// This is an extension point to attach custom logic +type AccountPruner interface { + // CleanupExistingAccount handles the cleanup process for balances and data of the given account. The persisted account + // type is already reset to base account at this stage. + // The method returns true when the account address can be reused. Unsupported account types are rejected by returning false + CleanupExistingAccount(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) +} + // WasmVMResponseHandler is an extension point to handles the response data returned by a contract call. type WasmVMResponseHandler interface { // Handle processes the data returned by a contract invocation. @@ -69,6 +81,12 @@ type WasmVMResponseHandler interface { ) ([]byte, error) } +// list of account types that are accepted for wasm contracts. Chains importing wasmd +// can overwrite this list with the WithAcceptedAccountTypesOnContractInstantiation option. +var defaultAcceptedAccountTypes = map[reflect.Type]struct{}{ + reflect.TypeOf(&authtypes.BaseAccount{}): {}, +} + // Keeper will have a reference to Wasmer with it's own data directory. type Keeper struct { storeKey sdk.StoreKey @@ -83,10 +101,12 @@ type Keeper struct { messenger Messenger metrics *Metrics // queryGasLimit is the max wasmvm gas that can be spent on executing a query with a contract - queryGasLimit uint64 - paramSpace paramtypes.Subspace - gasRegister WasmGasRegister - maxQueryStackSize uint32 + queryGasLimit uint64 + paramSpace paramtypes.Subspace + gasRegister WasmGasRegister + maxQueryStackSize uint32 + acceptedAccountTypes map[reflect.Type]struct{} + accountPruner AccountPruner } // NewKeeper creates a new contract Keeper instance @@ -107,12 +127,12 @@ func NewKeeper( queryRouter GRPCQueryRouter, homeDir string, wasmConfig types.WasmConfig, - supportedFeatures string, + availableCapabilities string, customEncoders *MessageEncoders, customPlugins *QueryPlugins, opts ...Option, ) Keeper { - wasmer, err := wasmvm.NewVM(filepath.Join(homeDir, "wasm"), supportedFeatures, contractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) + wasmer, err := wasmvm.NewVM(filepath.Join(homeDir, "wasm"), availableCapabilities, contractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) if err != nil { panic(err) } @@ -122,19 +142,21 @@ func NewKeeper( } keeper := &Keeper{ - storeKey: storeKey, - cdc: cdc, - wasmVM: wasmer, - accountKeeper: accountKeeper, - bank: NewBankCoinTransferrer(bankKeeper), - portKeeper: portKeeper, - capabilityKeeper: capabilityKeeper, - messenger: NewDefaultMessageHandler(router, channelKeeper, capabilityKeeper, bankKeeper, cdc, portSource, customEncoders), - queryGasLimit: wasmConfig.SmartQueryGasLimit, - paramSpace: paramSpace, - metrics: NopMetrics(), - gasRegister: NewDefaultWasmGasRegister(), - maxQueryStackSize: types.DefaultMaxQueryStackSize, + storeKey: storeKey, + cdc: cdc, + wasmVM: wasmer, + accountKeeper: accountKeeper, + bank: NewBankCoinTransferrer(bankKeeper), + accountPruner: NewVestingCoinBurner(bankKeeper), + portKeeper: portKeeper, + capabilityKeeper: capabilityKeeper, + messenger: NewDefaultMessageHandler(router, channelKeeper, capabilityKeeper, bankKeeper, cdc, portSource), + queryGasLimit: wasmConfig.SmartQueryGasLimit, + paramSpace: paramSpace, + metrics: NopMetrics(), + gasRegister: NewDefaultWasmGasRegister(), + maxQueryStackSize: types.DefaultMaxQueryStackSize, + acceptedAccountTypes: defaultAcceptedAccountTypes, } keeper.wasmVMQueryHandler = DefaultQueryPlugins(bankKeeper, stakingKeeper, distKeeper, channelKeeper, queryRouter, keeper).Merge(customPlugins) for _, o := range opts { @@ -228,13 +250,13 @@ func (k Keeper) SetParams(ctx sdk.Context, ps types.Params) { k.paramSpace.SetParamSet(ctx, &ps) } -func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ AuthorizationPolicy) (codeID uint64, err error) { +func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *types.AccessConfig, authZ AuthorizationPolicy) (codeID uint64, checksum []byte, err error) { if creator == nil { - return 0, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot be empty") + return 0, checksum, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot be nil") } if !authZ.CanCreateCode(k.getUploadAccessConfig(ctx), creator) { - return 0, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not create code") + return 0, checksum, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not create code") } // figure out proper instantiate access defaultAccessConfig := k.getInstantiateAccessConfig(ctx).With(creator) @@ -242,38 +264,44 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess = &defaultAccessConfig } else if !instantiateAccess.IsSubset(defaultAccessConfig) { // we enforce this must be subset of default upload access - return 0, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "instantiate access must be subset of default upload access") + return 0, checksum, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "instantiate access must be subset of default upload access") } - wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize)) - if err != nil { - return 0, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + if ioutils.IsGzip(wasmCode) { + ctx.GasMeter().ConsumeGas(k.gasRegister.UncompressCosts(len(wasmCode)), "Uncompress gzip bytecode") + wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize)) + if err != nil { + return 0, checksum, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + } } ctx.GasMeter().ConsumeGas(k.compileCosts(ctx, len(wasmCode)), "Compiling WASM Bytecode") - checksum, err := k.wasmVM.Create(wasmCode) + //ctx.GasMeter().ConsumeGas(k.gasRegister.CompileCosts(len(wasmCode)), "Compiling wasm bytecode") + //checksum, err = k.wasmVM.Create(wasmCode) + checksum, err = k.wasmVM.Create(wasmCode) if err != nil { - return 0, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + return 0, checksum, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) } report, err := k.wasmVM.AnalyzeCode(checksum) if err != nil { - return 0, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + return 0, checksum, sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) } codeID = k.autoIncrementID(ctx, types.KeyLastCodeID) - k.Logger(ctx).Debug("storing new contract", "features", report.RequiredFeatures, "code_id", codeID) + k.Logger(ctx).Debug("storing new contract", "capabilities", report.RequiredCapabilities, "code_id", codeID) codeInfo := types.NewCodeInfo(checksum, creator, *instantiateAccess) k.storeCodeInfo(ctx, codeID, codeInfo) evt := sdk.NewEvent( types.EventTypeStoreCode, - sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)), + sdk.NewAttribute(types.AttributeKeyChecksum, hex.EncodeToString(checksum)), + sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)), // last element to be compatible with scripts ) - for _, f := range strings.Split(report.RequiredFeatures, ",") { - evt.AppendAttributes(sdk.NewAttribute(types.AttributeKeyFeature, strings.TrimSpace(f))) + for _, f := range strings.Split(report.RequiredCapabilities, ",") { + evt.AppendAttributes(sdk.NewAttribute(types.AttributeKeyRequiredCapability, strings.TrimSpace(f))) } ctx.EventManager().EmitEvent(evt) - return codeID, nil + return codeID, checksum, nil } func (k Keeper) storeCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo) { @@ -283,9 +311,12 @@ func (k Keeper) storeCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.Cod } func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo, wasmCode []byte) error { - wasmCode, err := ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize)) - if err != nil { - return sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + if ioutils.IsGzip(wasmCode) { + var err error + wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize)) + if err != nil { + return sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) + } } newCodeHash, err := k.wasmVM.Create(wasmCode) if err != nil { @@ -305,42 +336,75 @@ func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeIn return nil } -func (k Keeper) instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins, authZ AuthorizationPolicy) (sdk.AccAddress, []byte, error) { +func (k Keeper) instantiate( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, + addressGenerator AddressGenerator, + authPolicy AuthorizationPolicy, +) (sdk.AccAddress, []byte, error) { defer func(begin time.Time) { k.metrics.InstantiateElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now()) + if creator == nil { + return nil, nil, types.ErrEmpty.Wrap("creator") + } instanceCosts := k.newContractInstanceCosts(k.gasRegister, ctx, k.IsPinnedCode(ctx, codeID), len(initMsg)) ctx.GasMeter().ConsumeGas(instanceCosts, "Loading CosmWasm module: instantiate") - // create contract address - contractAddress := k.generateContractAddress(ctx, codeID) - existingAcct := k.accountKeeper.GetAccount(ctx, contractAddress) - if existingAcct != nil { - return nil, nil, sdkerrors.Wrap(types.ErrAccountExists, existingAcct.GetAddress().String()) + // get contact info + codeInfo := k.GetCodeInfo(ctx, codeID) + if codeInfo == nil { + return nil, nil, sdkerrors.Wrap(types.ErrNotFound, "code") + } + if !authPolicy.CanInstantiateContract(codeInfo.InstantiateConfig, creator) { + return nil, nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not instantiate") } - // deposit initial contract funds - if !deposit.IsZero() { - if err := k.bank.TransferCoins(ctx, creator, contractAddress, deposit); err != nil { - return nil, nil, err + contractAddress := addressGenerator(ctx, codeID, codeInfo.CodeHash) + if k.HasContractInfo(ctx, contractAddress) { + return nil, nil, types.ErrDuplicate.Wrap("instance with this code id, sender and label exists: try a different label") + } + + // check account + // every cosmos module can define custom account types when needed. The cosmos-sdk comes with extension points + // to support this and a set of base and vesting account types that we integrated in our default lists. + // But not all account types of other modules are known or may make sense for contracts, therefore we kept this + // decision logic also very flexible and extendable. We provide new options to overwrite the default settings via WithAcceptedAccountTypesOnContractInstantiation and + // WithPruneAccountTypesOnContractInstantiation as constructor arguments + existingAcct := k.accountKeeper.GetAccount(ctx, contractAddress) + if existingAcct != nil { + if existingAcct.GetSequence() != 0 || existingAcct.GetPubKey() != nil { + return nil, nil, types.ErrAccountExists.Wrap("address is claimed by external account") + } + if _, accept := k.acceptedAccountTypes[reflect.TypeOf(existingAcct)]; accept { + // keep account and balance as it is + k.Logger(ctx).Info("instantiate contract with existing account", "address", contractAddress.String()) + } else { + // consider an account in the wasmd namespace spam and overwrite it. + k.Logger(ctx).Info("pruning existing account for contract instantiation", "address", contractAddress.String()) + contractAccount := k.accountKeeper.NewAccountWithAddress(ctx, contractAddress) + k.accountKeeper.SetAccount(ctx, contractAccount) + // also handle balance to not open cases where these accounts are abused and become liquid + switch handled, err := k.accountPruner.CleanupExistingAccount(ctx, existingAcct); { + case err != nil: + return nil, nil, sdkerrors.Wrap(err, "prune balance") + case !handled: + return nil, nil, types.ErrAccountExists.Wrap("address is claimed by external account") + } } } else { // create an empty account (so we don't have issues later) - // TODO: can we remove this? contractAccount := k.accountKeeper.NewAccountWithAddress(ctx, contractAddress) k.accountKeeper.SetAccount(ctx, contractAccount) } - - // get contact info - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.GetCodeKey(codeID)) - if bz == nil { - return nil, nil, sdkerrors.Wrap(types.ErrNotFound, "code") - } - var codeInfo types.CodeInfo - k.cdc.MustUnmarshal(bz, &codeInfo) - - if !authZ.CanInstantiateContract(codeInfo.InstantiateConfig, creator) { - return nil, nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not instantiate") + // deposit initial contract funds + if !deposit.IsZero() { + if err := k.bank.TransferCoins(ctx, creator, contractAddress, deposit); err != nil { + return nil, nil, err + } } // prepare params for contract instantiate call @@ -348,17 +412,16 @@ func (k Keeper) instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.A info := types.NewInfo(creator, deposit) // create prefixed data store - // 0x03 | BuildContractAddress (sdk.AccAddress) + // 0x03 | BuildContractAddressClassic (sdk.AccAddress) prefixStoreKey := types.GetContractStorePrefix(contractAddress) prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) - wasmStore := types.NewWasmStore(prefixStore) // prepare querier querier := k.newQueryHandler(ctx, contractAddress) // instantiate wasm contract gas := k.runtimeGasForContract(ctx) - res, gasUsed, err := k.wasmVM.Instantiate(codeInfo.CodeHash, env, info, initMsg, wasmStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) + res, gasUsed, err := k.wasmVM.Instantiate(codeInfo.CodeHash, env, info, initMsg, prefixStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if err != nil { return nil, nil, sdkerrors.Wrap(types.ErrInstantiateFailed, err.Error()) @@ -429,8 +492,7 @@ func (k Keeper) execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller // prepare querier querier := k.newQueryHandler(ctx, contractAddress) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.Execute(codeInfo.CodeHash, env, info, msg, wasmStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.Execute(codeInfo.CodeHash, env, info, msg, prefixStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { return nil, sdkerrors.Wrap(types.ErrExecuteFailed, execErr.Error()) @@ -470,6 +532,10 @@ func (k Keeper) migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unknown code") } + if !authZ.CanInstantiateContract(newCodeInfo.InstantiateConfig, caller) { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "to use new code") + } + // check for IBC flag switch report, err := k.wasmVM.AnalyzeCode(newCodeInfo.CodeHash); { case err != nil: @@ -494,8 +560,7 @@ func (k Keeper) migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller prefixStoreKey := types.GetContractStorePrefix(contractAddress) prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, err := k.wasmVM.Migrate(newCodeInfo.CodeHash, env, msg, &wasmStore, k.cosmwasmAPI(ctx), &querier, k.gasMeter(ctx), gas, costJSONDeserialization) + res, gasUsed, err := k.wasmVM.Migrate(newCodeInfo.CodeHash, env, msg, &prefixStore, k.cosmwasmAPI(ctx), &querier, k.gasMeter(ctx), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if err != nil { return nil, sdkerrors.Wrap(types.ErrMigrationFailed, err.Error()) @@ -540,9 +605,8 @@ func (k Keeper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte // prepare querier querier := k.newQueryHandler(ctx, contractAddress) - wasmStore := types.NewWasmStore(prefixStore) gas := k.runtimeGasForContract(ctx) - res, gasUsed, execErr := k.wasmVM.Sudo(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.Sudo(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { return nil, sdkerrors.Wrap(types.ErrExecuteFailed, execErr.Error()) @@ -577,8 +641,7 @@ func (k Keeper) reply(ctx sdk.Context, contractAddress sdk.AccAddress, reply was // prepare querier querier := k.newQueryHandler(ctx, contractAddress) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.Reply(codeInfo.CodeHash, env, reply, wasmStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.Reply(codeInfo.CodeHash, env, reply, prefixStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { return nil, sdkerrors.Wrap(types.ErrExecuteFailed, execErr.Error()) @@ -647,7 +710,7 @@ func (k Keeper) appendToContractHistory(ctx sdk.Context, contractAddr sdk.AccAdd defer iter.Close() if iter.Valid() { - pos = sdk.BigEndianToUint64(iter.Value()) + pos = sdk.BigEndianToUint64(iter.Key()) } // then store with incrementing position for i := range newEntries { @@ -708,8 +771,7 @@ func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []b querier := k.newQueryHandler(ctx, contractAddr) env := types.NewEnv(ctx, contractAddr) - wasmStore := types.NewWasmStore(prefixStore) - queryResult, gasUsed, qErr := k.wasmVM.Query(codeInfo.CodeHash, env, req, wasmStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), k.runtimeGasForContract(ctx), costJSONDeserialization) + queryResult, gasUsed, qErr := k.wasmVM.Query(codeInfo.CodeHash, env, req, prefixStore, k.cosmwasmAPI(ctx), querier, k.gasMeter(ctx), k.runtimeGasForContract(ctx), costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if qErr != nil { return nil, sdkerrors.Wrap(types.ErrQueryFailed, qErr.Error()) @@ -961,12 +1023,17 @@ func (k Keeper) setContractInfoExtension(ctx sdk.Context, contractAddr sdk.AccAd } // setAccessConfig updates the access config of a code id. -func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error { +func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig types.AccessConfig, authz AuthorizationPolicy) error { info := k.GetCodeInfo(ctx, codeID) if info == nil { return sdkerrors.Wrap(types.ErrNotFound, "code info") } - info.InstantiateConfig = config + isSubset := newConfig.Permission.IsSubset(k.getInstantiateAccessConfig(ctx)) + if !authz.CanModifyCodeAccessConfig(sdk.MustAccAddressFromBech32(info.Creator), caller, isSubset) { + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not modify code access config") + } + + info.InstantiateConfig = newConfig k.storeCodeInfo(ctx, codeID, *info) return nil } @@ -1006,7 +1073,6 @@ func (k Keeper) runtimeGasForContract(ctx sdk.Context) uint64 { if meter.IsOutOfGas() { return 0 } - if meter.Limit() == 0 { // infinite gas meter with limit=0 and not out of gas return math.MaxUint64 } @@ -1023,20 +1089,6 @@ func (k Keeper) consumeRuntimeGas(ctx sdk.Context, gas uint64) { } } -// generates a contract address from codeID + instanceID -func (k Keeper) generateContractAddress(ctx sdk.Context, codeID uint64) sdk.AccAddress { - instanceID := k.autoIncrementID(ctx, types.KeyLastInstanceID) - return BuildContractAddress(codeID, instanceID) -} - -// BuildContractAddress builds an sdk account address for a contract. -func BuildContractAddress(codeID, instanceID uint64) sdk.AccAddress { - contractID := make([]byte, 16) - binary.BigEndian.PutUint64(contractID[:8], codeID) - binary.BigEndian.PutUint64(contractID[8:], instanceID) - return address.Module(types.ModuleName, contractID)[:types.ContractAddrLen] -} - func (k Keeper) autoIncrementID(ctx sdk.Context, lastIDKey []byte) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get(lastIDKey) @@ -1201,6 +1253,43 @@ func (c BankCoinTransferrer) DeleteFromInactiveAddr(ctx sdk.Context, address sdk c.keeper.DeleteFromInactiveAddr(ctx, address) } +var _ AccountPruner = VestingCoinBurner{} + +// VestingCoinBurner default implementation for AccountPruner to burn the coins +type VestingCoinBurner struct { + bank types.BankKeeper +} + +// NewVestingCoinBurner constructor +func NewVestingCoinBurner(bank types.BankKeeper) VestingCoinBurner { + if bank == nil { + panic("bank keeper must not be nil") + } + return VestingCoinBurner{bank: bank} +} + +// CleanupExistingAccount accepts only vesting account types to burns all their original vesting coin balances. +// Other account types will be rejected and returned as unhandled. +func (b VestingCoinBurner) CleanupExistingAccount(ctx sdk.Context, existingAcc authtypes.AccountI) (handled bool, err error) { + v, ok := existingAcc.(vestingexported.VestingAccount) + if !ok { + return false, nil + } + + ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + coinsToBurn := sdk.NewCoins() + for _, orig := range v.GetOriginalVesting() { // focus on the coin denoms that were setup originally; getAllBalances has some issues + coinsToBurn = append(coinsToBurn, b.bank.GetBalance(ctx, existingAcc.GetAddress(), orig.Denom)) + } + if err := b.bank.SendCoinsFromAccountToModule(ctx, existingAcc.GetAddress(), types.ModuleName, coinsToBurn); err != nil { + return false, sdkerrors.Wrap(err, "prune account balance") + } + if err := b.bank.BurnCoins(ctx, types.ModuleName, coinsToBurn); err != nil { + return false, sdkerrors.Wrap(err, "burn account balance") + } + return true, nil +} + type msgDispatcher interface { DispatchSubmessages(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, msgs []wasmvmtypes.SubMsg) ([]byte, error) } diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 375d5bd899..71e360fb78 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -2,10 +2,11 @@ package keeper import ( "bytes" + _ "embed" "encoding/json" "errors" "fmt" - "math" + fuzz "github.com/google/gofuzz" "os" "testing" "time" @@ -13,12 +14,18 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/line/lbm-sdk/baseapp" + "github.com/line/lbm-sdk/crypto/keys/ed25519" stypes "github.com/line/lbm-sdk/store/types" sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/types/address" sdkerrors "github.com/line/lbm-sdk/types/errors" authtypes "github.com/line/lbm-sdk/x/auth/types" + "github.com/line/lbm-sdk/x/auth/vesting" + vestingtypes "github.com/line/lbm-sdk/x/auth/vesting/types" banktypes "github.com/line/lbm-sdk/x/bank/types" distributiontypes "github.com/line/lbm-sdk/x/distribution/types" + "github.com/line/ostracon/libs/rand" ocproto "github.com/line/ostracon/proto/ostracon/types" wasmvm "github.com/line/wasmvm" wasmvmtypes "github.com/line/wasmvm/types" @@ -36,24 +43,25 @@ func init() { hackatomWasm = b } +//go:embed testdata/hackatom.wasm var hackatomWasm []byte -const SupportedFeatures = "iterator,staking,stargate" +const AvailableCapabilities = "iterator,staking,stargate,cosmwasm_1_1" func TestNewKeeper(t *testing.T) { - _, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + _, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) require.NotNil(t, keepers.ContractKeeper) } func TestCreateSuccess(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) em := sdk.NewEventManager() - contractID, err := keeper.Create(ctx.WithEventManager(em), creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx.WithEventManager(em), creator, hackatomWasm, nil) require.NoError(t, err) require.Equal(t, uint64(1), contractID) // and verify content @@ -61,32 +69,33 @@ func TestCreateSuccess(t *testing.T) { require.NoError(t, err) require.Equal(t, hackatomWasm, storedCode) // and events emitted - exp := sdk.Events{sdk.NewEvent("store_code", sdk.NewAttribute("code_id", "1"))} + codeHash := "13a1fc994cc6d1c81b746ee0c0ff6f90043875e0bf1d9be6b7d779fc978dc2a5" + exp := sdk.Events{sdk.NewEvent("store_code", sdk.NewAttribute("code_checksum", codeHash), sdk.NewAttribute("code_id", "1"))} assert.Equal(t, exp, em.Events()) } func TestCreateNilCreatorAddress(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) - _, err := keepers.ContractKeeper.Create(ctx, nil, hackatomWasm, nil) + _, _, err := keepers.ContractKeeper.Create(ctx, nil, hackatomWasm, nil) require.Error(t, err, "nil creator is not allowed") } func TestCreateNilWasmCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) - _, err := keepers.ContractKeeper.Create(ctx, creator, nil, nil) + _, _, err := keepers.ContractKeeper.Create(ctx, creator, nil, nil) require.Error(t, err, "nil WASM code is not allowed") } func TestCreateInvalidWasmCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) - _, err := keepers.ContractKeeper.Create(ctx, creator, []byte("potatoes"), nil) + _, _, err := keepers.ContractKeeper.Create(ctx, creator, []byte("potatoes"), nil) require.Error(t, err, "potatoes are not valid WASM code") } @@ -119,7 +128,7 @@ func TestCreateStoresInstantiatePermission(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper keepers.WasmKeeper.SetParams(ctx, types.Params{ CodeUploadAccess: types.AllowEverybody, @@ -130,7 +139,7 @@ func TestCreateStoresInstantiatePermission(t *testing.T) { }) fundAccounts(t, ctx, accKeeper, bankKeeper, myAddr, deposit) - codeID, err := keeper.Create(ctx, myAddr, hackatomWasm, nil) + codeID, _, err := keeper.Create(ctx, myAddr, hackatomWasm, nil) require.NoError(t, err) codeInfo := keepers.WasmKeeper.GetCodeInfo(ctx, codeID) @@ -141,7 +150,7 @@ func TestCreateStoresInstantiatePermission(t *testing.T) { } func TestCreateWithParamPermissions(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -175,7 +184,7 @@ func TestCreateWithParamPermissions(t *testing.T) { params := types.DefaultParams() params.CodeUploadAccess = spec.srcPermission keepers.WasmKeeper.SetParams(ctx, params) - _, err := keeper.Create(ctx, creator, hackatomWasm, nil) + _, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.True(t, spec.expError.Is(err), err) if spec.expError != nil { return @@ -187,7 +196,7 @@ func TestCreateWithParamPermissions(t *testing.T) { // ensure that the user cannot set the code instantiate permission to something more permissive // than the default func TestEnforceValidPermissionsOnCreate(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper contractKeeper := keepers.ContractKeeper @@ -252,7 +261,7 @@ func TestEnforceValidPermissionsOnCreate(t *testing.T) { params := types.DefaultParams() params.InstantiateDefaultPermission = spec.defaultPermssion keeper.SetParams(ctx, params) - codeID, err := contractKeeper.Create(ctx, creator, hackatomWasm, spec.requestedPermission) + codeID, _, err := contractKeeper.Create(ctx, creator, hackatomWasm, spec.requestedPermission) require.True(t, spec.expError.Is(err), err) if spec.expError == nil { codeInfo := keeper.GetCodeInfo(ctx, codeID) @@ -263,19 +272,19 @@ func TestEnforceValidPermissionsOnCreate(t *testing.T) { } func TestCreateDuplicate(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // create one copy - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) require.Equal(t, uint64(1), contractID) // create second copy - duplicateID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + duplicateID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) require.Equal(t, uint64(2), duplicateID) @@ -289,7 +298,7 @@ func TestCreateDuplicate(t *testing.T) { } func TestCreateWithSimulation(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) ctx = ctx.WithBlockHeader(ocproto.Header{Height: 1}). WithGasMeter(stypes.NewInfiniteGasMeter()) @@ -298,15 +307,15 @@ func TestCreateWithSimulation(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // create this once in simulation mode - contractID, err := keepers.ContractKeeper.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, nil, nil) + ctx, keepers = CreateTestInput(t, false, AvailableCapabilities, nil, nil) ctx = ctx.WithGasMeter(sdk.NewGasMeter(10_000_000)) creator = keepers.Faucet.NewFundedAccount(ctx, deposit...) - contractID, err = keepers.ContractKeeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err = keepers.ContractKeeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) require.Equal(t, uint64(1), contractID) @@ -343,7 +352,7 @@ func TestIsSimulationMode(t *testing.T) { } func TestCreateWithGzippedPayload(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -352,7 +361,7 @@ func TestCreateWithGzippedPayload(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm.gzip") require.NoError(t, err, "reading gzipped WASM code") - contractID, err := keeper.Create(ctx, creator, wasmCode, nil) + contractID, _, err := keeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) require.Equal(t, uint64(1), contractID) // and verify content @@ -361,22 +370,35 @@ func TestCreateWithGzippedPayload(t *testing.T) { require.Equal(t, hackatomWasm, storedCode) } -func TestInstantiate(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) +func TestCreateWithBrokenGzippedPayload(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) - codeID, err := keeper.Create(ctx, creator, hackatomWasm, nil) - require.NoError(t, err) + wasmCode, err := os.ReadFile("./testdata/broken_crc.gzip") + require.NoError(t, err, "reading gzipped WASM code") - _, _, bob := keyPubAddr() - _, _, fred := keyPubAddr() + gm := sdk.NewInfiniteGasMeter() + codeID, checksum, err := keeper.Create(ctx.WithGasMeter(gm), creator, wasmCode, nil) + require.Error(t, err) + assert.Empty(t, codeID) + assert.Empty(t, checksum) + assert.GreaterOrEqual(t, gm.GasConsumed(), sdk.Gas(121384)) // 809232 * 0.15 (default uncompress costs) = 121384 +} + +func TestInstantiate(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + creator := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) + keepers.Faucet.Fund(ctx, creator, deposit...) + example := StoreHackatomExampleContract(t, ctx, keepers) initMsg := HackatomExampleInitMsg{ - Verifier: fred, - Beneficiary: bob, + Verifier: RandomAccountAddress(t), + Beneficiary: RandomAccountAddress(t), } initMsgBz, err := json.Marshal(initMsg) require.NoError(t, err) @@ -385,25 +407,25 @@ func TestInstantiate(t *testing.T) { em := sdk.NewEventManager() // create with no balance is also legal - gotContractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), codeID, creator, nil, initMsgBz, "demo contract 1", nil) + gotContractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), example.CodeID, creator, nil, initMsgBz, "demo contract 1", nil) require.NoError(t, err) require.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", gotContractAddr.String()) gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x18bfc), gasAfter-gasBefore) + require.Equal(t, uint64(0x1964f), gasAfter-gasBefore) } // ensure it is stored properly info := keepers.WasmKeeper.GetContractInfo(ctx, gotContractAddr) require.NotNil(t, info) assert.Equal(t, creator.String(), info.Creator) - assert.Equal(t, codeID, info.CodeID) + assert.Equal(t, example.CodeID, info.CodeID) assert.Equal(t, "demo contract 1", info.Label) exp := []types.ContractCodeHistoryEntry{{ Operation: types.ContractCodeHistoryOperationTypeInit, - CodeID: codeID, + CodeID: example.CodeID, Updated: types.NewAbsoluteTxPosition(ctx), Msg: initMsgBz, }} @@ -425,12 +447,9 @@ func TestInstantiateWithDeposit(t *testing.T) { fred = bytes.Repeat([]byte{2}, types.SDKAddrLen) deposit = sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) - initMsg = HackatomExampleInitMsg{Verifier: fred, Beneficiary: bob} + initMsg = mustMarshal(t, HackatomExampleInitMsg{Verifier: fred, Beneficiary: bob}) ) - initMsgBz, err := json.Marshal(initMsg) - require.NoError(t, err) - specs := map[string]struct { srcActor sdk.AccAddress expError bool @@ -452,17 +471,17 @@ func TestInstantiateWithDeposit(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, bankKeeper, keeper := keepers.AccountKeeper, keepers.BankKeeper, keepers.ContractKeeper if spec.fundAddr { fundAccounts(t, ctx, accKeeper, bankKeeper, spec.srcActor, sdk.NewCoins(sdk.NewInt64Coin("denom", 200))) } - contractID, err := keeper.Create(ctx, spec.srcActor, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, spec.srcActor, hackatomWasm, nil) require.NoError(t, err) // when - addr, _, err := keepers.ContractKeeper.Instantiate(ctx, contractID, spec.srcActor, nil, initMsgBz, "my label", deposit) + addr, _, err := keepers.ContractKeeper.Instantiate(ctx, contractID, spec.srcActor, nil, initMsg, "my label", deposit) // then if spec.expError { require.Error(t, err) @@ -520,11 +539,11 @@ func TestInstantiateWithPermissions(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, bankKeeper, keeper := keepers.AccountKeeper, keepers.BankKeeper, keepers.ContractKeeper fundAccounts(t, ctx, accKeeper, bankKeeper, spec.srcActor, deposit) - contractID, err := keeper.Create(ctx, myAddr, hackatomWasm, &spec.srcPermission) + contractID, _, err := keeper.Create(ctx, myAddr, hackatomWasm, &spec.srcPermission) require.NoError(t, err) _, _, err = keepers.ContractKeeper.Instantiate(ctx, contractID, spec.srcActor, nil, initMsgBz, "demo contract 1", nil) @@ -533,8 +552,144 @@ func TestInstantiateWithPermissions(t *testing.T) { } } +func TestInstantiateWithAccounts(t *testing.T) { + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + example := StoreHackatomExampleContract(t, parentCtx, keepers) + require.Equal(t, uint64(1), example.CodeID) + initMsg := mustMarshal(t, HackatomExampleInitMsg{Verifier: RandomAccountAddress(t), Beneficiary: RandomAccountAddress(t)}) + + senderAddr := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(parentCtx, senderAddr, sdk.NewInt64Coin("denom", 100000000)) + const myLabel = "testing" + mySalt := []byte(`my salt`) + contractAddr := BuildContractAddressPredictable(example.Checksum, senderAddr, mySalt, []byte{}) + + lastAccountNumber := keepers.AccountKeeper.GetAccount(parentCtx, senderAddr).GetAccountNumber() + + specs := map[string]struct { + option Option + account authtypes.AccountI + initBalance sdk.Coin + deposit sdk.Coins + expErr error + expAccount authtypes.AccountI + expBalance sdk.Coins + }{ + "unused BaseAccount exists": { + account: authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + initBalance: sdk.NewInt64Coin("denom", 100000000), + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), // +1 for next seq + expBalance: sdk.NewCoins(sdk.NewInt64Coin("denom", 100000000)), + }, + "BaseAccount with sequence exists": { + account: authtypes.NewBaseAccount(contractAddr, nil, 0, 1), + expErr: types.ErrAccountExists, + }, + "BaseAccount with pubkey exists": { + account: authtypes.NewBaseAccount(contractAddr, &ed25519.PubKey{}, 0, 0), + expErr: types.ErrAccountExists, + }, + "no account existed": { + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), // +1 for next seq, + expBalance: sdk.NewCoins(), + }, + "no account existed before create with deposit": { + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), // +1 for next seq + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), + }, + "prunable DelayedVestingAccount gets overwritten": { + account: vestingtypes.NewDelayedVestingAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), + initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + }, + "prunable ContinuousVestingAccount gets overwritten": { + account: vestingtypes.NewContinuousVestingAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix()), + initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + }, + "prunable account without balance gets overwritten": { + account: vestingtypes.NewContinuousVestingAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(0))), time.Now().Add(time.Hour).Unix(), time.Now().Add(2*time.Hour).Unix()), + expAccount: authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+2, 0), // +1 for next seq, +1 for spec.account created + expBalance: sdk.NewCoins(), + }, + "unknown account type is rejected with error": { + account: authtypes.NewModuleAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + "testing", + ), + initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), + expErr: types.ErrAccountExists, + }, + "with option used to set non default type to accept list": { + option: WithAcceptedAccountTypesOnContractInstantiation(&vestingtypes.DelayedVestingAccount{}), + account: vestingtypes.NewDelayedVestingAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), + initBalance: sdk.NewCoin("denom", sdk.NewInt(1_000)), + deposit: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1))), + expAccount: vestingtypes.NewDelayedVestingAccount(authtypes.NewBaseAccount(contractAddr, nil, lastAccountNumber+1, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), + expBalance: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_001))), + }, + "pruning account fails": { + option: WithAccountPruner(wasmtesting.AccountPrunerMock{CleanupExistingAccountFn: func(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) { + return false, types.ErrUnsupportedForContract.Wrap("testing") + }}), + account: vestingtypes.NewDelayedVestingAccount( + authtypes.NewBaseAccount(contractAddr, nil, 0, 0), + sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))), time.Now().Add(30*time.Hour).Unix()), + expErr: types.ErrUnsupportedForContract, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() + if spec.account != nil { + keepers.AccountKeeper.SetAccount(ctx, keepers.AccountKeeper.NewAccount(ctx, spec.account)) + } + if !spec.initBalance.IsNil() { + keepers.Faucet.Fund(ctx, spec.account.GetAddress(), spec.initBalance) + } + if spec.option != nil { + spec.option.apply(keepers.WasmKeeper) + } + defer func() { + if spec.option != nil { // reset + WithAcceptedAccountTypesOnContractInstantiation(&authtypes.BaseAccount{}).apply(keepers.WasmKeeper) + WithAccountPruner(NewVestingCoinBurner(keepers.BankKeeper)).apply(keepers.WasmKeeper) + } + }() + // when + gotAddr, _, gotErr := keepers.ContractKeeper.Instantiate2(ctx, 1, senderAddr, nil, initMsg, myLabel, spec.deposit, mySalt, false) + if spec.expErr != nil { + assert.ErrorIs(t, gotErr, spec.expErr) + return + } + require.NoError(t, gotErr) + assert.Equal(t, contractAddr, gotAddr) + // and + gotAcc := keepers.AccountKeeper.GetAccount(ctx, contractAddr) + assert.Equal(t, spec.expAccount, gotAcc) + // and + gotBalance := keepers.BankKeeper.GetAllBalances(ctx, contractAddr) + assert.Equal(t, spec.expBalance, gotBalance) + }) + } +} + func TestInstantiateWithNonExistingCodeID(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) @@ -550,7 +705,7 @@ func TestInstantiateWithNonExistingCodeID(t *testing.T) { } func TestInstantiateWithContractDataResponse(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) wasmerMock := &wasmtesting.MockWasmer{ InstantiateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { @@ -566,19 +721,96 @@ func TestInstantiateWithContractDataResponse(t *testing.T) { assert.Equal(t, []byte("my-response-data"), data) } +func TestInstantiateWithContractFactoryChildQueriesParent(t *testing.T) { + // Scenario: + // given a factory contract stored + // when instantiated, the contract creates a new child contract instance + // and the child contracts queries the senders ContractInfo on instantiation + // then the factory contract's ContractInfo should be returned to the child contract + // + // see also: https://github.com/CosmWasm/wasmd/issues/896 + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + keeper := keepers.WasmKeeper + + var instantiationCount int + callbacks := make([]func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error), 2) + wasmerMock := &wasmtesting.MockWasmer{ + // dispatch instantiation calls to callbacks + InstantiateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { + require.Greater(t, len(callbacks), instantiationCount, "unexpected call to instantiation") + do := callbacks[instantiationCount] + instantiationCount++ + return do(codeID, env, info, initMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) + }, + AnalyzeCodeFn: wasmtesting.WithoutIBCAnalyzeFn, + CreateFn: wasmtesting.NoOpCreateFn, + } + + // overwrite wasmvm in router + router := baseapp.NewMsgServiceRouter() + router.SetInterfaceRegistry(keepers.EncodingConfig.InterfaceRegistry) + types.RegisterMsgServer(router, NewMsgServerImpl(NewDefaultPermissionKeeper(keeper))) + keeper.messenger = NewDefaultMessageHandler(router, nil, nil, nil, keepers.EncodingConfig.Marshaler, nil) + // overwrite wasmvm in response handler + keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper)) + + example := StoreRandomContract(t, ctx, keepers, wasmerMock) + // factory contract + callbacks[0] = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { + t.Log("called factory") + return &wasmvmtypes.Response{Data: []byte("parent"), Messages: []wasmvmtypes.SubMsg{ + { + ID: 1, ReplyOn: wasmvmtypes.ReplyNever, + Msg: wasmvmtypes.CosmosMsg{ + Wasm: &wasmvmtypes.WasmMsg{ + Instantiate: &wasmvmtypes.InstantiateMsg{CodeID: example.CodeID, Msg: []byte(`{}`), Label: "child"}, + }, + }, + }, + }}, 0, nil + } + + // child contract + var capturedSenderAddr string + var capturedCodeInfo []byte + callbacks[1] = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { + t.Log("called child") + capturedSenderAddr = info.Sender + var err error + capturedCodeInfo, err = querier.Query(wasmvmtypes.QueryRequest{ + Wasm: &wasmvmtypes.WasmQuery{ + ContractInfo: &wasmvmtypes.ContractInfoQuery{ContractAddr: info.Sender}, + }, + }, gasLimit) + require.NoError(t, err) + return &wasmvmtypes.Response{Data: []byte("child")}, 0, nil + } + + // when + parentAddr, data, err := keepers.ContractKeeper.Instantiate(ctx, example.CodeID, example.CreatorAddr, nil, nil, "test", nil) + + // then + require.NoError(t, err) + assert.Equal(t, []byte("parent"), data) + require.Equal(t, parentAddr.String(), capturedSenderAddr) + expCodeInfo := fmt.Sprintf(`{"code_id":%d,"creator":%q,"pinned":false}`, example.CodeID, example.CreatorAddr.String()) + assert.JSONEq(t, expCodeInfo, string(capturedCodeInfo)) +} + func TestExecute(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) + bob := RandomAccountAddress(t) - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -625,7 +857,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(0x16f9c), gasAfter-gasBefore) + require.Equal(t, uint64(0x17d87), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) @@ -704,7 +936,7 @@ func TestExecuteWithDeposit(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, bankKeeper, keeper := keepers.AccountKeeper, keepers.BankKeeper, keepers.ContractKeeper if spec.newBankParams != nil { bankKeeper.SetParams(ctx, *spec.newBankParams) @@ -712,7 +944,7 @@ func TestExecuteWithDeposit(t *testing.T) { if spec.fundAddr { fundAccounts(t, ctx, accKeeper, bankKeeper, spec.srcActor, sdk.NewCoins(sdk.NewInt64Coin("denom", 200))) } - codeID, err := keeper.Create(ctx, spec.srcActor, hackatomWasm, nil) + codeID, _, err := keeper.Create(ctx, spec.srcActor, hackatomWasm, nil) require.NoError(t, err) initMsg := HackatomExampleInitMsg{Verifier: spec.srcActor, Beneficiary: spec.beneficiary} @@ -738,11 +970,12 @@ func TestExecuteWithDeposit(t *testing.T) { } func TestExecuteWithNonExistingAddress(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) // unauthorized - trialCtx so we don't change state nonExistingAddress := RandomAccountAddress(t) @@ -751,15 +984,16 @@ func TestExecuteWithNonExistingAddress(t *testing.T) { } func TestExecuteWithPanic(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -782,15 +1016,16 @@ func TestExecuteWithPanic(t *testing.T) { } func TestExecuteWithCpuLoop(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -823,15 +1058,16 @@ func TestExecuteWithCpuLoop(t *testing.T) { } func TestExecuteWithStorageLoop(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -864,19 +1100,25 @@ func TestExecuteWithStorageLoop(t *testing.T) { } func TestMigrate(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - 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 - ibcCodeID := StoreIBCReflectContract(t, ctx, keepers).CodeID + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(parentCtx, creator, deposit.Add(deposit...)...) + fred := DeterministicAccountAddress(t, 2) + keepers.Faucet.Fund(parentCtx, fred, topUp...) + + originalCodeID := StoreHackatomExampleContract(t, parentCtx, keepers).CodeID + newCodeID := StoreHackatomExampleContract(t, parentCtx, keepers).CodeID + ibcCodeID := StoreIBCReflectContract(t, parentCtx, keepers).CodeID require.NotEqual(t, originalCodeID, newCodeID) + restrictedCodeExample := StoreHackatomExampleContract(t, parentCtx, keepers) + require.NoError(t, keeper.SetAccessConfig(parentCtx, restrictedCodeExample.CodeID, restrictedCodeExample.CreatorAddr, types.AllowNobody)) + require.NotEqual(t, originalCodeID, restrictedCodeExample.CodeID) + anyAddr := RandomAccountAddress(t) newVerifierAddr := RandomAccountAddress(t) initMsgBz := HackatomExampleInitMsg{ @@ -954,6 +1196,15 @@ func TestMigrate(t *testing.T) { toCodeID: originalCodeID, expErr: sdkerrors.ErrUnauthorized, }, + "prevent migration when new code is restricted": { + admin: creator, + caller: creator, + initMsg: initMsgBz, + fromCodeID: originalCodeID, + toCodeID: restrictedCodeExample.CodeID, + migrateMsg: migMsgBz, + expErr: sdkerrors.ErrUnauthorized, + }, "fail with non existing code id": { admin: creator, caller: creator, @@ -991,7 +1242,7 @@ func TestMigrate(t *testing.T) { "fail when no IBC callbacks": { admin: fred, caller: fred, - initMsg: IBCReflectInitMsg{ReflectCodeID: StoreReflectContract(t, ctx, keepers)}.GetBytes(t), + initMsg: IBCReflectInitMsg{ReflectCodeID: StoreReflectContract(t, parentCtx, keepers).CodeID}.GetBytes(t), fromCodeID: ibcCodeID, toCodeID: newCodeID, migrateMsg: migMsgBz, @@ -999,10 +1250,13 @@ func TestMigrate(t *testing.T) { }, } + blockHeight := parentCtx.BlockHeight() for msg, spec := range specs { t.Run(msg, func(t *testing.T) { // given a contract instance - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + ctx, _ := parentCtx.WithBlockHeight(blockHeight + 1).CacheContext() + blockHeight++ + contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, spec.fromCodeID, creator, spec.admin, spec.initMsg, "demo contract", nil) require.NoError(t, err) if spec.overrideContractAddr != nil { @@ -1045,7 +1299,7 @@ func TestMigrate(t *testing.T) { } func TestMigrateReplacesTheSecondIndex(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) example := InstantiateHackatomExampleContract(t, ctx, keepers) // then assert a second index exists @@ -1079,19 +1333,20 @@ func TestMigrateReplacesTheSecondIndex(t *testing.T) { } func TestMigrateWithDispatchedMessage(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) fred := keepers.Faucet.NewFundedAccount(ctx, sdk.NewInt64Coin("denom", 5000)) burnerCode, err := os.ReadFile("./testdata/burner.wasm") require.NoError(t, err) - originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + originalContractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - burnerContractID, err := keeper.Create(ctx, creator, burnerCode, nil) + burnerContractID, _, err := keeper.Create(ctx, creator, burnerCode, nil) require.NoError(t, err) require.NotEqual(t, originalContractID, burnerContractID) @@ -1164,7 +1419,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { } func TestIterateContractsByCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k, c := keepers.WasmKeeper, keepers.ContractKeeper example1 := InstantiateHackatomExampleContract(t, ctx, keepers) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) @@ -1210,7 +1465,7 @@ func TestIterateContractsByCodeWithMigration(t *testing.T) { return &wasmvmtypes.Response{}, 1, nil }} wasmtesting.MakeInstantiable(&mockWasmVM) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithWasmEngine(&mockWasmVM)) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithWasmEngine(&mockWasmVM)) k, c := keepers.WasmKeeper, keepers.ContractKeeper example1 := InstantiateHackatomExampleContract(t, ctx, keepers) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) @@ -1249,13 +1504,14 @@ type stealFundsMsg struct { } func TestSudo(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.ContractKeeper, keepers.BankKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(ctx, creator, deposit.Add(deposit...)...) - contractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -1332,15 +1588,16 @@ func mustMarshal(t *testing.T, r interface{}) []byte { } func TestUpdateContractAdmin(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) - fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(parentCtx, creator, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(parentCtx, topUp...) - originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + originalContractID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, anyAddr := keyPubAddr() @@ -1383,6 +1640,7 @@ func TestUpdateContractAdmin(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() addr, _, err := keepers.ContractKeeper.Instantiate(ctx, originalContractID, creator, spec.instAdmin, initMsgBz, "demo contract", nil) require.NoError(t, err) if spec.overrideContractAddr != nil { @@ -1400,15 +1658,16 @@ func TestUpdateContractAdmin(t *testing.T) { } func TestClearContractAdmin(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := keepers.Faucet.NewFundedAccount(ctx, deposit.Add(deposit...)...) - fred := keepers.Faucet.NewFundedAccount(ctx, topUp...) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(parentCtx, creator, deposit.Add(deposit...)...) + fred := keepers.Faucet.NewFundedAccount(parentCtx, topUp...) - originalContractID, err := keeper.Create(ctx, creator, hackatomWasm, nil) + originalContractID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) require.NoError(t, err) _, _, anyAddr := keyPubAddr() @@ -1446,6 +1705,7 @@ func TestClearContractAdmin(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() addr, _, err := keepers.ContractKeeper.Instantiate(ctx, originalContractID, creator, spec.instAdmin, initMsgBz, "demo contract", nil) require.NoError(t, err) if spec.overrideContractAddr != nil { @@ -1463,7 +1723,7 @@ func TestClearContractAdmin(t *testing.T) { } func TestExecuteManualInactiveContractFailure(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -1474,7 +1734,7 @@ func TestExecuteManualInactiveContractFailure(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - contractID, err := keeper.Create(ctx, creator, wasmCode, nil) + contractID, _, err := keeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -1491,7 +1751,7 @@ func TestExecuteManualInactiveContractFailure(t *testing.T) { } func TestPinCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum @@ -1518,7 +1778,7 @@ func TestPinCode(t *testing.T) { } func TestUnpinCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum @@ -1552,7 +1812,7 @@ func TestUnpinCode(t *testing.T) { } func TestInitializePinnedCodes(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum @@ -1592,7 +1852,7 @@ 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, nil, nil, WithWasmEngine(&mock)) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithWasmEngine(&mock)) k := keepers.WasmKeeper example := SeedNewContractInstance(t, ctx, keepers, &mock) @@ -1688,9 +1948,7 @@ func TestNewDefaultWasmVMContractResponseHandler(t *testing.T) { } for name, spec := range specs { t.Run(name, func(t *testing.T) { - var ( - msgs []wasmvmtypes.SubMsg - ) + var msgs []wasmvmtypes.SubMsg var mock wasmtesting.MockMsgDispatcher spec.setup(&mock) d := NewDefaultWasmVMContractResponseHandler(&mock) @@ -1710,7 +1968,7 @@ func TestNewDefaultWasmVMContractResponseHandler(t *testing.T) { } func TestReply(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var mock wasmtesting.MockWasmer wasmtesting.MakeInstantiable(&mock) @@ -1779,7 +2037,7 @@ func TestReply(t *testing.T) { } func TestQueryIsolation(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var mock wasmtesting.MockWasmer wasmtesting.MakeInstantiable(&mock) @@ -1809,55 +2067,171 @@ func TestQueryIsolation(t *testing.T) { assert.Nil(t, ctx.KVStore(k.storeKey).Get([]byte(`set_in_query`))) } -func TestBuildContractAddress(t *testing.T) { +func TestSetAccessConfig(t *testing.T) { + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + k := keepers.WasmKeeper + creatorAddr := RandomAccountAddress(t) + nonCreatorAddr := RandomAccountAddress(t) + specs := map[string]struct { - srcCodeID uint64 - srcInstanceID uint64 - expectedAddr string + authz AuthorizationPolicy + chainPermission types.AccessType + newConfig types.AccessConfig + caller sdk.AccAddress + expErr bool }{ - "initial contract": { - srcCodeID: 1, - srcInstanceID: 1, - expectedAddr: "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", - }, - "demo value": { - srcCodeID: 1, - srcInstanceID: 100, - expectedAddr: "link1mujpjkwhut9yjw4xueyugc02evfv46y0dtmnz4lh8xxkkdapym9skz93hr", - }, - "both below max": { - srcCodeID: math.MaxUint32 - 1, - srcInstanceID: math.MaxUint32 - 1, + "user with new permissions == chain permissions": { + authz: DefaultAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowEverybody, + caller: creatorAddr, + }, + "user with new permissions < chain permissions": { + authz: DefaultAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowNobody, + caller: creatorAddr, + }, + "user with new permissions > chain permissions": { + authz: DefaultAuthorizationPolicy{}, + chainPermission: types.AccessTypeNobody, + newConfig: types.AllowEverybody, + caller: creatorAddr, + expErr: true, + }, + "different actor": { + authz: DefaultAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowEverybody, + caller: nonCreatorAddr, + expErr: true, + }, + "gov with new permissions == chain permissions": { + authz: GovAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowEverybody, + caller: creatorAddr, + }, + "gov with new permissions < chain permissions": { + authz: GovAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowNobody, + caller: creatorAddr, + }, + "gov with new permissions > chain permissions": { + authz: GovAuthorizationPolicy{}, + chainPermission: types.AccessTypeNobody, + newConfig: types.AccessTypeOnlyAddress.With(creatorAddr), + caller: creatorAddr, + }, + "gov without actor": { + authz: GovAuthorizationPolicy{}, + chainPermission: types.AccessTypeEverybody, + newConfig: types.AllowEverybody, }, - "both at max": { - srcCodeID: math.MaxUint32, - srcInstanceID: math.MaxUint32, - }, - "codeID > max u32": { - srcCodeID: math.MaxUint32 + 1, - srcInstanceID: 17, - expectedAddr: "link1673hrexz4h6s0ft04l96ygq667djzh2nsr335kstjp49x5dk6rps5267na", + } + const codeID = 1 + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() + newParams := types.DefaultParams() + newParams.InstantiateDefaultPermission = spec.chainPermission + k.SetParams(ctx, newParams) + + k.storeCodeInfo(ctx, codeID, types.NewCodeInfo(nil, creatorAddr, types.AllowNobody)) + // when + gotErr := k.setAccessConfig(ctx, codeID, spec.caller, spec.newConfig, spec.authz) + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + }) + } +} + +func TestAppendToContractHistory(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + var contractAddr sdk.AccAddress = rand.Bytes(types.ContractAddrLen) + var orderedEntries []types.ContractCodeHistoryEntry + + f := fuzz.New().Funcs(ModelFuzzers...) + for i := 0; i < 10; i++ { + var entry types.ContractCodeHistoryEntry + f.Fuzz(&entry) + keepers.WasmKeeper.appendToContractHistory(ctx, contractAddr, entry) + orderedEntries = append(orderedEntries, entry) + } + // when + gotHistory := keepers.WasmKeeper.GetContractHistory(ctx, contractAddr) + assert.Equal(t, orderedEntries, gotHistory) +} + +func TestCoinBurnerPruneBalances(t *testing.T) { + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + amts := sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) + senderAddr := keepers.Faucet.NewFundedAccount(parentCtx, amts...) + + // create vesting account + var vestingAddr sdk.AccAddress = rand.Bytes(types.ContractAddrLen) + msgCreateVestingAccount := vestingtypes.NewMsgCreateVestingAccount(senderAddr, vestingAddr, amts, time.Now().Add(time.Minute).Unix(), false) + _, err := vesting.NewMsgServerImpl(keepers.AccountKeeper, keepers.BankKeeper).CreateVestingAccount(sdk.WrapSDKContext(parentCtx), msgCreateVestingAccount) + require.NoError(t, err) + myVestingAccount := keepers.AccountKeeper.GetAccount(parentCtx, vestingAddr) + require.NotNil(t, myVestingAccount) + + specs := map[string]struct { + setupAcc func(t *testing.T, ctx sdk.Context) authtypes.AccountI + expBalances sdk.Coins + expHandled bool + expErr *sdkerrors.Error + }{ + "vesting account - all removed": { + setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { return myVestingAccount }, + expBalances: sdk.NewCoins(), + expHandled: true, + }, + "vesting account with other tokens - only original denoms removed": { + setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { + keepers.Faucet.Fund(ctx, vestingAddr, sdk.NewCoin("other", sdk.NewInt(2))) + return myVestingAccount + }, + expBalances: sdk.NewCoins(sdk.NewCoin("other", sdk.NewInt(2))), + expHandled: true, }, - "instanceID > max u32": { - srcCodeID: 22, - srcInstanceID: math.MaxUint32 + 1, - expectedAddr: "link10q3pgfvmeyy0veekgtqhxujxkhz0vm9zmalqgc7evrhj68q3l62q7nceel", + "non vesting account - not handled": { + setupAcc: func(t *testing.T, ctx sdk.Context) authtypes.AccountI { + return &authtypes.BaseAccount{Address: myVestingAccount.GetAddress().String()} + }, + expBalances: sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(100))), + expHandled: false, }, } for name, spec := range specs { t.Run(name, func(t *testing.T) { - gotAddr := BuildContractAddress(spec.srcCodeID, spec.srcInstanceID) - require.NotNil(t, gotAddr) - assert.Nil(t, sdk.VerifyAddressFormat(gotAddr)) - if len(spec.expectedAddr) > 0 { - require.Equal(t, spec.expectedAddr, gotAddr.String()) + ctx, _ := parentCtx.CacheContext() + existingAccount := spec.setupAcc(t, ctx) + // overwrite account in store as in keeper before calling prune + keepers.AccountKeeper.SetAccount(ctx, keepers.AccountKeeper.NewAccountWithAddress(ctx, vestingAddr)) + + // when + noGasCtx := ctx.WithGasMeter(sdk.NewGasMeter(0)) // should not use callers gas + gotHandled, gotErr := NewVestingCoinBurner(keepers.BankKeeper).CleanupExistingAccount(noGasCtx, existingAccount) + // then + if spec.expErr != nil { + require.ErrorIs(t, gotErr, spec.expErr) + return } + require.NoError(t, gotErr) + assert.Equal(t, spec.expBalances, keepers.BankKeeper.GetAllBalances(ctx, vestingAddr)) + assert.Equal(t, spec.expHandled, gotHandled) + // and no out of gas panic }) } } func TestActivateContract(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var mock wasmtesting.MockWasmer @@ -1883,7 +2257,7 @@ func TestActivateContract(t *testing.T) { } func TestDeactivateContract(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var mock wasmtesting.MockWasmer @@ -1905,7 +2279,7 @@ func TestDeactivateContract(t *testing.T) { } func TestIterateInactiveContracts(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) k := keepers.WasmKeeper var mock wasmtesting.MockWasmer @@ -1932,14 +2306,14 @@ func TestIterateInactiveContracts(t *testing.T) { func TestKeeper_GetByteCode(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) em := sdk.NewEventManager() - _, err := keeper.Create(ctx.WithEventManager(em), creator, hackatomWasm, nil) + _, _, err := keeper.Create(ctx.WithEventManager(em), creator, hackatomWasm, nil) require.NoError(t, err) tests := []struct { diff --git a/x/wasm/keeper/legacy_querier_test.go b/x/wasm/keeper/legacy_querier_test.go index 76dbbadcab..6882ab826b 100644 --- a/x/wasm/keeper/legacy_querier_test.go +++ b/x/wasm/keeper/legacy_querier_test.go @@ -18,7 +18,7 @@ import ( ) func TestLegacyQueryContractState(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -28,7 +28,7 @@ func TestLegacyQueryContractState(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - contractID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) + contractID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -155,7 +155,7 @@ func TestLegacyQueryContractState(t *testing.T) { } func TestLegacyQueryContractListByCodeOrdering(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) @@ -166,7 +166,7 @@ func TestLegacyQueryContractListByCodeOrdering(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -219,7 +219,7 @@ func TestLegacyQueryContractListByCodeOrdering(t *testing.T) { } func TestLegacyQueryContractHistory(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper var otherAddr sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) @@ -330,7 +330,7 @@ func TestLegacyQueryCodeList(t *testing.T) { for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper for _, codeID := range spec.codeIDs { diff --git a/x/wasm/keeper/msg_dispatcher.go b/x/wasm/keeper/msg_dispatcher.go index 0b56701c18..3db3ea78cf 100644 --- a/x/wasm/keeper/msg_dispatcher.go +++ b/x/wasm/keeper/msg_dispatcher.go @@ -1,7 +1,9 @@ package keeper import ( + "bytes" "fmt" + "sort" sdk "github.com/line/lbm-sdk/types" sdkerrors "github.com/line/lbm-sdk/types/errors" @@ -107,6 +109,16 @@ func (d MessageDispatcher) DispatchSubmessages(ctx sdk.Context, contractAddr sdk commit() filteredEvents = filterEvents(append(em.Events(), events...)) ctx.EventManager().EmitEvents(filteredEvents) + if msg.Msg.Wasm == nil { + filteredEvents = []sdk.Event{} + } else { + for _, e := range filteredEvents { + attributes := e.Attributes + sort.SliceStable(attributes, func(i, j int) bool { + return bytes.Compare(attributes[i].Key, attributes[j].Key) < 0 + }) + } + } } // on failure, revert state from sandbox, and ignore events (just skip doing the above) // we only callback if requested. Short-circuit here the cases we don't want to diff --git a/x/wasm/keeper/msg_dispatcher_test.go b/x/wasm/keeper/msg_dispatcher_test.go index 8c3e4bb115..f37f09bf2c 100644 --- a/x/wasm/keeper/msg_dispatcher_test.go +++ b/x/wasm/keeper/msg_dispatcher_test.go @@ -295,8 +295,9 @@ func TestDispatchSubmessages(t *testing.T) { expCommits: []bool{true}, expEvents: []sdk.Event{sdk.NewEvent("execute", sdk.NewAttribute("foo", "bar"))}, }, - "reply gets proper events": { - msgs: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyAlways}}, + "wasm reply gets proper events": { + // put fake wasmmsg in here to show where it comes from + msgs: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyAlways, Msg: wasmvmtypes.CosmosMsg{Wasm: &wasmvmtypes.WasmMsg{}}}}, replyer: &mockReplyer{ replyFn: func(ctx sdk.Context, contractAddress sdk.AccAddress, reply wasmvmtypes.Reply) ([]byte, error) { if reply.Result.Err != "" { @@ -342,6 +343,48 @@ func TestDispatchSubmessages(t *testing.T) { sdk.NewEvent("wasm-reply"), }, }, + "non-wasm reply events get filtered": { + // show events from a stargate message gets filtered out + msgs: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyAlways, Msg: wasmvmtypes.CosmosMsg{Stargate: &wasmvmtypes.StargateMsg{}}}}, + replyer: &mockReplyer{ + replyFn: func(ctx sdk.Context, contractAddress sdk.AccAddress, reply wasmvmtypes.Reply) ([]byte, error) { + if reply.Result.Err != "" { + return nil, errors.New(reply.Result.Err) + } + res := reply.Result.Ok + + // ensure the input events are what we expect + // I didn't use require.Equal() to act more like a contract... but maybe that would be better + if len(res.Events) != 0 { + return nil, errors.New("events not filtered out") + } + + // let's add a custom event here and see if it makes it out + ctx.EventManager().EmitEvent(sdk.NewEvent("stargate-reply")) + + // update data from what we got in + return res.Data, nil + }, + }, + msgHandler: &wasmtesting.MockMessageHandler{ + DispatchMsgFn: func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) { + events = []sdk.Event{ + // this is filtered out + sdk.NewEvent("message", sdk.NewAttribute("stargate", "something-something")), + // we still emit this to the client, but not the contract + sdk.NewEvent("non-determinstic"), + } + return events, [][]byte{[]byte("subData")}, nil + }, + }, + expData: []byte("subData"), + expCommits: []bool{true}, + expEvents: []sdk.Event{ + sdk.NewEvent("non-determinstic"), + // the event from reply is also exposed + sdk.NewEvent("stargate-reply"), + }, + }, } for name, spec := range specs { t.Run(name, func(t *testing.T) { diff --git a/x/wasm/keeper/msg_server.go b/x/wasm/keeper/msg_server.go index 5cef0f2bfa..4f84b47cf8 100644 --- a/x/wasm/keeper/msg_server.go +++ b/x/wasm/keeper/msg_server.go @@ -21,6 +21,9 @@ func NewMsgServerImpl(k types.ContractOpsKeeper) types.MsgServer { } func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*types.MsgStoreCodeResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -33,17 +36,22 @@ func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*t sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), )) - codeID, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) + codeID, checksum, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) if err != nil { return nil, err } return &types.MsgStoreCodeResponse{ - CodeID: codeID, + CodeID: codeID, + Checksum: checksum, }, nil } +// InstantiateContract instantiate a new contract with classic sequence based address generation func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInstantiateContract) (*types.MsgInstantiateContractResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) @@ -74,6 +82,40 @@ func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInst }, nil } +// InstantiateContract2 instantiate a new contract with predicatable address generated +func (m msgServer) InstantiateContract2(goCtx context.Context, msg *types.MsgInstantiateContract2) (*types.MsgInstantiateContract2Response, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + var adminAddr sdk.AccAddress + if msg.Admin != "" { + if adminAddr, err = sdk.AccAddressFromBech32(msg.Admin); err != nil { + return nil, sdkerrors.Wrap(err, "admin") + } + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + )) + contractAddr, data, err := m.keeper.Instantiate2(ctx, msg.CodeID, senderAddr, adminAddr, msg.Msg, msg.Label, msg.Funds, msg.Salt, msg.FixMsg) + if err != nil { + return nil, err + } + + return &types.MsgInstantiateContract2Response{ + Address: contractAddr.String(), + Data: data, + }, nil +} + func (m msgServer) StoreCodeAndInstantiateContract(goCtx context.Context, msg *lbmtypes.MsgStoreCodeAndInstantiateContract) (*lbmtypes.MsgStoreCodeAndInstantiateContractResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -81,7 +123,7 @@ func (m msgServer) StoreCodeAndInstantiateContract(goCtx context.Context, if err != nil { return nil, sdkerrors.Wrap(err, "sender") } - codeID, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) + codeID, _, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) if err != nil { return nil, err } @@ -114,6 +156,10 @@ func (m msgServer) StoreCodeAndInstantiateContract(goCtx context.Context, } func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteContract) (*types.MsgExecuteContractResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -141,6 +187,10 @@ func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteC } func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateContract) (*types.MsgMigrateContractResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -168,6 +218,10 @@ func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateC } func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) (*types.MsgUpdateAdminResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -196,6 +250,10 @@ func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) } func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) (*types.MsgClearAdminResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { diff --git a/x/wasm/keeper/msg_server_integration_test.go b/x/wasm/keeper/msg_server_integration_test.go new file mode 100644 index 0000000000..c5453903e3 --- /dev/null +++ b/x/wasm/keeper/msg_server_integration_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "crypto/sha256" + _ "embed" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/line/lbm-sdk/testutil/testdata" + ocproto "github.com/line/ostracon/proto/ostracon/types" + + "github.com/line/wasmd/app" + "github.com/line/wasmd/x/wasm/types" +) + +//go:embed testdata/reflect.wasm +var wasmContract []byte + +func TestStoreCode(t *testing.T) { + wasmApp := app.Setup(false) + ctx := wasmApp.BaseApp.NewContext(false, ocproto.Header{}) + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + }) + + // when + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + + // then + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + assert.Equal(t, uint64(1), result.CodeID) + expHash := sha256.Sum256(wasmContract) + assert.Equal(t, expHash[:], result.Checksum) + // and + info := wasmApp.WasmKeeper.GetCodeInfo(ctx, 1) + assert.NotNil(t, info) + assert.Equal(t, expHash[:], info.CodeHash) + assert.Equal(t, sender.String(), info.Creator) + assert.Equal(t, types.DefaultParams().InstantiateDefaultPermission.With(sender), info.InstantiateConfig) +} diff --git a/x/wasm/keeper/options.go b/x/wasm/keeper/options.go index fe0b45672a..9112b8ae33 100644 --- a/x/wasm/keeper/options.go +++ b/x/wasm/keeper/options.go @@ -2,9 +2,12 @@ package keeper import ( "fmt" + "reflect" "github.com/prometheus/client_golang/prometheus" + authtypes "github.com/line/lbm-sdk/x/auth/types" + "github.com/line/wasmd/x/wasm/types" ) @@ -89,11 +92,25 @@ func WithMessageEncoders(x *MessageEncoders) Option { // WithCoinTransferrer is an optional constructor parameter to set a custom coin transferrer func WithCoinTransferrer(x CoinTransferrer) Option { + if x == nil { + panic("must not be nil") + } return optsFn(func(k *Keeper) { k.bank = x }) } +// WithAccountPruner is an optional constructor parameter to set a custom type that handles balances and data cleanup +// for accounts pruned on contract instantiate +func WithAccountPruner(x AccountPruner) Option { + if x == nil { + panic("must not be nil") + } + return optsFn(func(k *Keeper) { + k.accountPruner = x + }) +} + func WithVMCacheMetrics(r prometheus.Registerer) Option { return optsFn(func(k *Keeper) { NewWasmVMCacheMetricsCollector(k.wasmVM).Register(r) @@ -121,3 +138,29 @@ func WithMaxQueryStackSize(m uint32) Option { k.maxQueryStackSize = m }) } + +// WithAcceptedAccountTypesOnContractInstantiation sets the accepted account types. Account types of this list won't be overwritten or cause a failure +// when they exist for an address on contract instantiation. +// +// Values should be references and contain the `*authtypes.BaseAccount` as default bank account type. +func WithAcceptedAccountTypesOnContractInstantiation(accts ...authtypes.AccountI) Option { + m := asTypeMap(accts) + return optsFn(func(k *Keeper) { + k.acceptedAccountTypes = m + }) +} + +func asTypeMap(accts []authtypes.AccountI) map[reflect.Type]struct{} { + m := make(map[reflect.Type]struct{}, len(accts)) + for _, a := range accts { + if a == nil { + panic(types.ErrEmpty.Wrap("address")) + } + at := reflect.TypeOf(a) + if _, exists := m[at]; exists { + panic(types.ErrDuplicate.Wrapf("%T", a)) + } + m[at] = struct{}{} + } + return m +} diff --git a/x/wasm/keeper/options_test.go b/x/wasm/keeper/options_test.go index cf2f29e1d2..727e3c5ca1 100644 --- a/x/wasm/keeper/options_test.go +++ b/x/wasm/keeper/options_test.go @@ -1,12 +1,15 @@ package keeper import ( + "reflect" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" authkeeper "github.com/line/lbm-sdk/x/auth/keeper" + authtypes "github.com/line/lbm-sdk/x/auth/types" + vestingtypes "github.com/line/lbm-sdk/x/auth/vesting/types" bankpluskeeper "github.com/line/lbm-sdk/x/bankplus/keeper" distributionkeeper "github.com/line/lbm-sdk/x/distribution/keeper" paramtypes "github.com/line/lbm-sdk/x/params/types" @@ -69,12 +72,27 @@ func TestConstructorOptions(t *testing.T) { assert.IsType(t, uint32(1), k.maxQueryStackSize) }, }, + "accepted account types": { + srcOpt: WithAcceptedAccountTypesOnContractInstantiation(&authtypes.BaseAccount{}, &vestingtypes.ContinuousVestingAccount{}), + verify: func(t *testing.T, k Keeper) { + exp := map[reflect.Type]struct{}{ + reflect.TypeOf(&authtypes.BaseAccount{}): {}, + reflect.TypeOf(&vestingtypes.ContinuousVestingAccount{}): {}, + } + assert.Equal(t, exp, k.acceptedAccountTypes) + }, + }, + "account pruner": { + srcOpt: WithAccountPruner(VestingCoinBurner{}), + verify: func(t *testing.T, k Keeper) { + assert.Equal(t, VestingCoinBurner{}, k.accountPruner) + }, + }, } for name, spec := range specs { t.Run(name, func(t *testing.T) { - k := NewKeeper(nil, nil, paramtypes.NewSubspace(nil, nil, nil, nil, ""), authkeeper.AccountKeeper{}, bankpluskeeper.BaseKeeper{}, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, "tempDir", types.DefaultWasmConfig(), SupportedFeatures, nil, nil, spec.srcOpt) + k := NewKeeper(nil, nil, paramtypes.NewSubspace(nil, nil, nil, nil, ""), authkeeper.AccountKeeper{}, bankpluskeeper.BaseKeeper{}, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, "tempDir", types.DefaultWasmConfig(), AvailableCapabilities, nil, nil, spec.srcOpt) spec.verify(t, k) }) } - } diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index e86d9e9ad1..a5aa03630a 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -69,10 +69,15 @@ func handleStoreCodeProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types if err != nil { return sdkerrors.Wrap(err, "run as address") } - codeID, err := k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission) + codeID, _, err := k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission) if err != nil { return err } + + // if code should not be pinned return earlier + if p.UnpinCode { + return nil + } return k.PinCode(ctx, codeID) } @@ -112,6 +117,7 @@ func handleMigrateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.M if err != nil { return sdkerrors.Wrap(err, "contract") } + // runAs is not used if this is permissioned, so just put any valid address there (second contractAddr) data, err := k.Migrate(ctx, contractAddr, contractAddr, p.CodeID, p.Msg) if err != nil { @@ -223,7 +229,6 @@ func handleUnpinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type return sdkerrors.Wrapf(err, "code id: %d", v) } } - return nil } @@ -232,8 +237,9 @@ func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsK return err } + var emptyCaller sdk.AccAddress for _, accessConfigUpdate := range p.AccessConfigUpdates { - if err := k.SetAccessConfig(ctx, accessConfigUpdate.CodeID, accessConfigUpdate.InstantiatePermission); err != nil { + if err := k.SetAccessConfig(ctx, accessConfigUpdate.CodeID, emptyCaller, accessConfigUpdate.InstantiatePermission); err != nil { return sdkerrors.Wrapf(err, "code id: %d", accessConfigUpdate.CodeID) } } diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 5c9a58e55a..658bceb1b8 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -23,9 +23,9 @@ import ( ) func TestStoreCodeProposal(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, "staking", nil, nil) + parentCtx, keepers := CreateTestInput(t, false, "staking", nil, nil) govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper - wasmKeeper.SetParams(ctx, types.Params{ + wasmKeeper.SetParams(parentCtx, types.Params{ CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, GasMultiplier: types.DefaultGasMultiplier, @@ -35,31 +35,49 @@ func TestStoreCodeProposal(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - myActorAddress := RandomBech32AccountAddress(t) + specs := map[string]struct { + codeID int64 + unpinCode bool + }{ + "upload with pinning (default)": { + unpinCode: false, + }, + "upload with code unpin": { + unpinCode: true, + }, + } - src := types.StoreCodeProposalFixture(func(p *types.StoreCodeProposal) { - p.RunAs = myActorAddress - p.WASMByteCode = wasmCode - }) + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + ctx, _ := parentCtx.CacheContext() + myActorAddress := RandomBech32AccountAddress(t) - // when stored - storedProposal, err := govKeeper.SubmitProposal(ctx, src) - require.NoError(t, err) + src := types.StoreCodeProposalFixture(func(p *types.StoreCodeProposal) { + p.RunAs = myActorAddress + p.WASMByteCode = wasmCode + p.UnpinCode = spec.unpinCode + }) - // and proposal execute - handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute()) - err = handler(ctx, storedProposal.GetContent()) - require.NoError(t, err) + // when stored + storedProposal, err := govKeeper.SubmitProposal(ctx, src) + require.NoError(t, err) - // then - cInfo := wasmKeeper.GetCodeInfo(ctx, 1) - require.NotNil(t, cInfo) - assert.Equal(t, myActorAddress, cInfo.Creator) - assert.True(t, wasmKeeper.IsPinnedCode(ctx, 1)) + // and proposal execute + handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute()) + err = handler(ctx, storedProposal.GetContent()) + require.NoError(t, err) - storedCode, err := wasmKeeper.GetByteCode(ctx, 1) - require.NoError(t, err) - assert.Equal(t, wasmCode, storedCode) + // then + cInfo := wasmKeeper.GetCodeInfo(ctx, 1) + require.NotNil(t, cInfo) + assert.Equal(t, myActorAddress, cInfo.Creator) + assert.Equal(t, !spec.unpinCode, wasmKeeper.IsPinnedCode(ctx, 1)) + + storedCode, err := wasmKeeper.GetByteCode(ctx, 1) + require.NoError(t, err) + assert.Equal(t, wasmCode, storedCode) + }) + } } func TestInstantiateProposal(t *testing.T) { @@ -224,9 +242,9 @@ func TestMigrateProposal(t *testing.T) { require.NoError(t, wasmKeeper.importCode(ctx, 2, codeInfoFixture, wasmCode)) var ( - anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, types.ContractAddrLen) - otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) - contractAddr = BuildContractAddress(1, 1) + anyAddress = DeterministicAccountAddress(t, 1) + otherAddress = DeterministicAccountAddress(t, 2) + contractAddr = BuildContractAddressClassic(1, 1) ) contractInfoFixture := types.ContractInfoFixture(func(c *types.ContractInfo) { @@ -405,7 +423,7 @@ func TestSudoProposal(t *testing.T) { func TestAdminProposals(t *testing.T) { var ( otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) - contractAddr = BuildContractAddress(1, 1) + contractAddr = BuildContractAddressClassic(1, 1) ) wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index 0728135ac7..98a6290add 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -313,6 +313,13 @@ func (q GrpcQuerier) PinnedCodes(c context.Context, req *types.QueryPinnedCodesR }, nil } +// Params returns params of the module. +func (q GrpcQuerier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + params := q.keeper.GetParams(ctx) + return &types.QueryParamsResponse{Params: params}, nil +} + func (q GrpcQuerier) InactiveContracts(c context.Context, req *lbmtypes.QueryInactiveContractsRequest) (*lbmtypes.QueryInactiveContractsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index 3b84c44ab3..dacf7dc1bb 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -28,7 +28,7 @@ import ( ) func TestQueryAllContractState(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) @@ -115,7 +115,7 @@ func TestQueryAllContractState(t *testing.T) { } func TestQuerySmartContractState(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) @@ -158,8 +158,8 @@ func TestQuerySmartContractState(t *testing.T) { } func TestQuerySmartContractPanics(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) - contractAddr := BuildContractAddress(1, 1) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + contractAddr := BuildContractAddressClassic(1, 1) keepers.WasmKeeper.storeCodeInfo(ctx, 1, types.CodeInfo{}) keepers.WasmKeeper.storeContractInfo(ctx, contractAddr, &types.ContractInfo{ CodeID: 1, @@ -203,7 +203,7 @@ func TestQuerySmartContractPanics(t *testing.T) { } func TestQueryRawContractState(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) @@ -258,7 +258,7 @@ func TestQueryRawContractState(t *testing.T) { } func TestQueryContractListByCodeOrdering(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) @@ -269,7 +269,7 @@ func TestQueryContractListByCodeOrdering(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) _, _, bob := keyPubAddr() @@ -314,7 +314,7 @@ func TestQueryContractListByCodeOrdering(t *testing.T) { } func TestQueryContractHistory(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper var ( @@ -458,7 +458,7 @@ func TestQueryCode(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper codeID := uint64(1) @@ -511,7 +511,7 @@ func TestQueryCodeList(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper specs := map[string]struct { @@ -587,7 +587,7 @@ func TestQueryContractInfo(t *testing.T) { contractAddr = RandomAccountAddress(t) anyDate = time.Now().UTC() ) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) // register an example extension. must be protobuf keepers.EncodingConfig.InterfaceRegistry.RegisterImplementations( (*types.ContractInfoExtension)(nil), @@ -653,7 +653,7 @@ func TestQueryContractInfo(t *testing.T) { } func TestQueryPinnedCodes(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper exampleContract1 := InstantiateHackatomExampleContract(t, ctx, keepers) @@ -665,11 +665,11 @@ func TestQueryPinnedCodes(t *testing.T) { specs := map[string]struct { srcQuery *types.QueryPinnedCodesRequest expCodeIDs []uint64 - expErr bool + expErr *sdkErrors.Error }{ "req nil": { srcQuery: nil, - expErr: true, + expErr: nil, // todo check error and change }, "query all": { srcQuery: &types.QueryPinnedCodesRequest{}, @@ -690,7 +690,7 @@ func TestQueryPinnedCodes(t *testing.T) { Key: []byte("test"), }, }, - expErr: true, + expErr: nil, // todo check error and change }, "with pagination limit": { srcQuery: &types.QueryPinnedCodesRequest{ @@ -712,7 +712,7 @@ func TestQueryPinnedCodes(t *testing.T) { for msg, spec := range specs { t.Run(msg, func(t *testing.T) { got, err := q.PinnedCodes(sdk.WrapSDKContext(ctx), spec.srcQuery) - if spec.expErr { + if spec.expErr != nil { assert.Nil(t, got) assert.NotNil(t, err) @@ -724,11 +724,39 @@ func TestQueryPinnedCodes(t *testing.T) { } } +func TestQueryParams(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) + keeper := keepers.WasmKeeper + + q := Querier(keeper) + + paramsResponse, err := q.Params(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + require.NoError(t, err) + require.NotNil(t, paramsResponse) + + defaultParams := types.DefaultParams() + + require.Equal(t, paramsResponse.Params.CodeUploadAccess, defaultParams.CodeUploadAccess) + require.Equal(t, paramsResponse.Params.InstantiateDefaultPermission, defaultParams.InstantiateDefaultPermission) + + keeper.SetParams(ctx, types.Params{ + CodeUploadAccess: types.AllowNobody, + InstantiateDefaultPermission: types.AccessTypeNobody, + }) + + paramsResponse, err = q.Params(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{}) + require.NoError(t, err) + require.NotNil(t, paramsResponse) + + require.Equal(t, paramsResponse.Params.CodeUploadAccess, types.AllowNobody) + require.Equal(t, paramsResponse.Params.InstantiateDefaultPermission, types.AccessTypeNobody) +} + func TestQueryCodeInfo(t *testing.T) { wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper anyAddress, err := sdk.AccAddressFromBech32("link1qyqszqgpqyqszqgpqyqszqgpqyqszqgp8apuk5") @@ -780,11 +808,10 @@ func TestQueryCodeInfo(t *testing.T) { } func TestQueryCodeInfoList(t *testing.T) { - wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper anyAddress, err := sdk.AccAddressFromBech32("link1qyqszqgpqyqszqgpqyqszqgpqyqszqgp8apuk5") @@ -853,7 +880,7 @@ func fromBase64(s string) []byte { } func TestQueryInactiveContracts(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper var mock wasmtesting.MockWasmer @@ -880,7 +907,7 @@ func TestQueryInactiveContracts(t *testing.T) { } func TestQueryIsInactiveContract(t *testing.T) { - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil) keeper := keepers.WasmKeeper var mock wasmtesting.MockWasmer diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index eaa6295eb7..8975ba23fe 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -188,9 +188,24 @@ func BankQuerier(bankKeeper types.BankViewKeeper) func(ctx sdk.Context, request } return json.Marshal(res) } + if request.Supply != nil { + coin := bankKeeper.GetSupply(ctx, request.Supply.Denom) + res := wasmvmtypes.SupplyResponse{ + Amount: wasmvmtypes.Coin{ + Denom: coin.Denom, + Amount: coin.Amount.String(), + }, + } + return json.Marshal(res) + } return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown BankQuery variant"} } } + +func NoCustomQuerier(sdk.Context, json.RawMessage) ([]byte, error) { + return nil, wasmvmtypes.UnsupportedRequest{Kind: "custom"} +} + func CustomQuerierImpl(queryRouter GRPCQueryRouter) func(ctx sdk.Context, querierJson json.RawMessage) ([]byte, error) { return func(ctx sdk.Context, querierJson json.RawMessage) ([]byte, error) { var linkQueryWrapper types.LinkQueryWrapper diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index 805df3067b..bc23793952 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -509,10 +509,18 @@ func (m mockWasmQueryKeeper) IsPinnedCode(ctx sdk.Context, codeID uint64) bool { } type bankKeeperMock struct { + GetSupplyFn func(ctx sdk.Context, denom string) sdk.Coin GetBalanceFn func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin GetAllBalancesFn func(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins } +func (m bankKeeperMock) GetSupply(ctx sdk.Context, denom string) sdk.Coin { + if m.GetSupplyFn == nil { + panic("not expected to be called") + } + return m.GetSupplyFn(ctx, denom) +} + func (m bankKeeperMock) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { if m.GetBalanceFn == nil { panic("not expected to be called") diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 96ddcf9232..c9441b9be2 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -45,7 +45,7 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc return realWasmQuerier.HandleQuery(ctx, caller, request) }) } - ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithQueryHandlerDecorator(countingQuerierDec)) + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithQueryHandlerDecorator(countingQuerierDec)) keeper = keepers.WasmKeeper exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) return exampleContract.Contract, exampleContract.CreatorAddr, ctx, keeper @@ -91,7 +91,7 @@ func TestGasCostOnQuery(t *testing.T) { Depth: 1, Work: 50, }, - expectedGas: 2*GasWork50 + GasReturnHashed, + expectedGas: 2*GasWork50 + GasReturnHashed + 1, // +1 for rounding }, "recursion 4, some work": { gasLimit: 400_000, @@ -99,7 +99,7 @@ func TestGasCostOnQuery(t *testing.T) { Depth: 4, Work: 50, }, - expectedGas: 5*GasWork50 + 4*GasReturnHashed, + expectedGas: 5*GasWork50 + 4*GasReturnHashed + 1, }, } @@ -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 = 78_193 // = 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 = 21 + GasReturnHashed uint64 = 26 ) cases := map[string]struct { diff --git a/x/wasm/keeper/reflect_test.go b/x/wasm/keeper/reflect_test.go index 57df48cbd9..ed6bd27c6b 100644 --- a/x/wasm/keeper/reflect_test.go +++ b/x/wasm/keeper/reflect_test.go @@ -20,59 +20,13 @@ import ( banktypes "github.com/line/lbm-sdk/x/bank/types" wasmvmtypes "github.com/line/wasmvm/types" + "github.com/line/wasmd/x/wasm/keeper/testdata" "github.com/line/wasmd/x/wasm/types" ) // ReflectInitMsg is {} -// ReflectHandleMsg is used to encode handle messages -type ReflectHandleMsg struct { - Reflect *reflectPayload `json:"reflect_msg,omitempty"` - ReflectSubMsg *reflectSubPayload `json:"reflect_sub_msg,omitempty"` - Change *ownerPayload `json:"change_owner,omitempty"` -} - -type ownerPayload struct { - Owner sdk.Address `json:"owner"` -} - -type reflectPayload struct { - Msgs []wasmvmtypes.CosmosMsg `json:"msgs"` -} - -type reflectSubPayload struct { - Msgs []wasmvmtypes.SubMsg `json:"msgs"` -} - -// ReflectQueryMsg is used to encode query messages -type ReflectQueryMsg struct { - Owner *struct{} `json:"owner,omitempty"` - Capitalized *Text `json:"capitalized,omitempty"` - Chain *ChainQuery `json:"chain,omitempty"` - SubMsgResult *SubCall `json:"sub_msg_result,omitempty"` -} - -type ChainQuery struct { - Request *wasmvmtypes.QueryRequest `json:"request,omitempty"` -} - -type Text struct { - Text string `json:"text"` -} - -type SubCall struct { - ID uint64 `json:"id"` -} - -type OwnerResponse struct { - Owner string `json:"owner,omitempty"` -} - -type ChainResponse struct { - Data []byte `json:"data,omitempty"` -} - -func buildReflectQuery(t *testing.T, query *ReflectQueryMsg) []byte { +func buildReflectQuery(t *testing.T, query *testdata.ReflectQueryMsg) []byte { bz, err := json.Marshal(query) require.NoError(t, err) return bz @@ -83,7 +37,7 @@ func mustParse(t *testing.T, data []byte, res interface{}) { require.NoError(t, err) } -const ReflectFeatures = "staking,mask,stargate" +const ReflectFeatures = "staking,mask,stargate,cosmwasm_1_1" func TestReflectContractSend(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler @@ -95,16 +49,14 @@ func TestReflectContractSend(t *testing.T) { _, _, bob := keyPubAddr() // upload reflect code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - reflectID, err := keeper.Create(ctx, creator, reflectCode, nil) + reflectID, _, err := keeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), reflectID) // upload hackatom escrow code escrowCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - escrowID, err := keeper.Create(ctx, creator, escrowCode, nil) + escrowID, _, err := keeper.Create(ctx, creator, escrowCode, nil) require.NoError(t, err) require.Equal(t, uint64(2), escrowID) @@ -149,8 +101,8 @@ func TestReflectContractSend(t *testing.T) { }, }, }} - reflectSend := ReflectHandleMsg{ - Reflect: &reflectPayload{ + reflectSend := testdata.ReflectHandleMsg{ + Reflect: &testdata.ReflectPayload{ Msgs: msgs, }, } @@ -177,9 +129,7 @@ func TestReflectCustomMsg(t *testing.T) { _, _, fred := keyPubAddr() // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), codeID) @@ -190,8 +140,8 @@ func TestReflectCustomMsg(t *testing.T) { require.NotEmpty(t, contractAddr) // set owner to bob - transfer := ReflectHandleMsg{ - Change: &ownerPayload{ + transfer := testdata.ReflectHandleMsg{ + ChangeOwner: &testdata.OwnerPayload{ Owner: bob, }, } @@ -217,8 +167,8 @@ func TestReflectCustomMsg(t *testing.T) { }, }, }} - reflectSend := ReflectHandleMsg{ - Reflect: &reflectPayload{ + reflectSend := testdata.ReflectHandleMsg{ + Reflect: &testdata.ReflectPayload{ Msgs: msgs, }, } @@ -241,8 +191,8 @@ func TestReflectCustomMsg(t *testing.T) { } opaque, err := toReflectRawMsg(cdc, sdkSendMsg) require.NoError(t, err) - reflectOpaque := ReflectHandleMsg{ - Reflect: &reflectPayload{ + reflectOpaque := testdata.ReflectHandleMsg{ + Reflect: &testdata.ReflectPayload{ Msgs: []wasmvmtypes.CosmosMsg{opaque}, }, } @@ -268,9 +218,7 @@ func TestMaskReflectCustomQuery(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), codeID) @@ -281,21 +229,21 @@ func TestMaskReflectCustomQuery(t *testing.T) { require.NotEmpty(t, contractAddr) // let's perform a normal query of state - ownerQuery := ReflectQueryMsg{ + ownerQuery := testdata.ReflectQueryMsg{ Owner: &struct{}{}, } ownerQueryBz, err := json.Marshal(ownerQuery) require.NoError(t, err) ownerRes, err := keeper.QuerySmart(ctx, contractAddr, ownerQueryBz) require.NoError(t, err) - var res OwnerResponse + var res testdata.OwnerResponse err = json.Unmarshal(ownerRes, &res) require.NoError(t, err) assert.Equal(t, res.Owner, creator.String()) // and now making use of the custom querier callbacks - customQuery := ReflectQueryMsg{ - Capitalized: &Text{ + customQuery := testdata.ReflectQueryMsg{ + Capitalized: &testdata.Text{ Text: "all Caps noW", }, } @@ -320,9 +268,7 @@ func TestReflectStargateQuery(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, funds...) // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), codeID) @@ -339,13 +285,13 @@ func TestReflectStargateQuery(t *testing.T) { }, }, } - simpleQueryBz, err := json.Marshal(ReflectQueryMsg{ - Chain: &ChainQuery{Request: &bankQuery}, + simpleQueryBz, err := json.Marshal(testdata.ReflectQueryMsg{ + Chain: &testdata.ChainQuery{Request: &bankQuery}, }) require.NoError(t, err) simpleRes, err := keeper.QuerySmart(ctx, contractAddr, simpleQueryBz) require.NoError(t, err) - var simpleChain ChainResponse + var simpleChain testdata.ChainResponse mustParse(t, simpleRes, &simpleChain) var simpleBalance wasmvmtypes.AllBalancesResponse mustParse(t, simpleChain.Data, &simpleBalance) @@ -354,6 +300,57 @@ func TestReflectStargateQuery(t *testing.T) { assert.Equal(t, simpleBalance.Amount[0].Denom, expectedBalance[0].Denom) } +func TestReflectTotalSupplyQuery(t *testing.T) { + cdc := MakeEncodingConfig(t).Marshaler + ctx, keepers := CreateTestInput(t, false, ReflectFeatures, nil, nil, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) + keeper := keepers.WasmKeeper + // upload code + codeID := StoreReflectContract(t, ctx, keepers).CodeID + // creator instantiates a contract and gives it tokens + creator := RandomAccountAddress(t) + contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, codeID, creator, nil, []byte("{}"), "testing", nil) + require.NoError(t, err) + + currentStakeSupply := keepers.BankKeeper.GetSupply(ctx, "stake") + require.NotEmpty(t, currentStakeSupply.Amount) // ensure we have real data + specs := map[string]struct { + denom string + expAmount wasmvmtypes.Coin + }{ + "known denom": { + denom: "stake", + expAmount: ConvertSdkCoinToWasmCoin(currentStakeSupply), + }, + "unknown denom": { + denom: "unknown", + expAmount: wasmvmtypes.Coin{Denom: "unknown", Amount: "0"}, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // when + queryBz := mustMarshal(t, testdata.ReflectQueryMsg{ + Chain: &testdata.ChainQuery{ + Request: &wasmvmtypes.QueryRequest{ + Bank: &wasmvmtypes.BankQuery{ + Supply: &wasmvmtypes.SupplyQuery{spec.denom}, + }, + }, + }, + }) + simpleRes, err := keeper.QuerySmart(ctx, contractAddr, queryBz) + + // then + require.NoError(t, err) + var rsp testdata.ChainResponse + mustParse(t, simpleRes, &rsp) + var supplyRsp wasmvmtypes.SupplyResponse + mustParse(t, rsp.Data, &supplyRsp) + assert.Equal(t, spec.expAmount, supplyRsp.Amount, spec.expAmount) + }) + } +} + func TestReflectInvalidStargateQuery(t *testing.T) { cdc := MakeEncodingConfig(t).Marshaler ctx, keepers := CreateTestInput(t, false, ReflectFeatures, nil, nil, WithMessageEncoders(reflectEncoders(cdc)), WithQueryPlugins(reflectPlugins())) @@ -364,9 +361,7 @@ func TestReflectInvalidStargateQuery(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, funds...) // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), codeID) @@ -386,8 +381,8 @@ func TestReflectInvalidStargateQuery(t *testing.T) { Data: protoQueryBin, }, } - protoQueryBz, err := json.Marshal(ReflectQueryMsg{ - Chain: &ChainQuery{Request: &protoRequest}, + protoQueryBz, err := json.Marshal(testdata.ReflectQueryMsg{ + Chain: &testdata.ChainQuery{Request: &protoRequest}, }) require.NoError(t, err) @@ -403,8 +398,8 @@ func TestReflectInvalidStargateQuery(t *testing.T) { Data: []byte{}, }, } - protoQueryBz, err = json.Marshal(ReflectQueryMsg{ - Chain: &ChainQuery{Request: &protoRequest}, + protoQueryBz, err = json.Marshal(testdata.ReflectQueryMsg{ + Chain: &testdata.ChainQuery{Request: &protoRequest}, }) require.NoError(t, err) @@ -420,8 +415,8 @@ func TestReflectInvalidStargateQuery(t *testing.T) { Data: []byte{}, }, } - protoQueryBz, err = json.Marshal(ReflectQueryMsg{ - Chain: &ChainQuery{Request: &protoRequest}, + protoQueryBz, err = json.Marshal(testdata.ReflectQueryMsg{ + Chain: &testdata.ChainQuery{Request: &protoRequest}, }) require.NoError(t, err) @@ -444,9 +439,7 @@ func TestMaskReflectWasmQueries(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload reflect code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - reflectID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + reflectID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), reflectID) @@ -457,10 +450,10 @@ func TestMaskReflectWasmQueries(t *testing.T) { require.NotEmpty(t, reflectAddr) // for control, let's make some queries directly on the reflect - ownerQuery := buildReflectQuery(t, &ReflectQueryMsg{Owner: &struct{}{}}) + ownerQuery := buildReflectQuery(t, &testdata.ReflectQueryMsg{Owner: &struct{}{}}) res, err := keeper.QuerySmart(ctx, reflectAddr, ownerQuery) require.NoError(t, err) - var ownerRes OwnerResponse + var ownerRes testdata.OwnerResponse mustParse(t, res, &ownerRes) require.Equal(t, ownerRes.Owner, creator.String()) @@ -472,7 +465,7 @@ func TestMaskReflectWasmQueries(t *testing.T) { require.Equal(t, stateRes.Owner, creator.String()) // now, let's reflect a smart query into the x/wasm handlers and see if we get the same result - reflectOwnerQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ + reflectOwnerQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ Smart: &wasmvmtypes.SmartQuery{ ContractAddr: reflectAddr.String(), Msg: ownerQuery, @@ -482,14 +475,14 @@ func TestMaskReflectWasmQueries(t *testing.T) { res, err = keeper.QuerySmart(ctx, reflectAddr, reflectOwnerBin) require.NoError(t, err) // first we pull out the data from chain response, before parsing the original response - var reflectRes ChainResponse + var reflectRes testdata.ChainResponse mustParse(t, res, &reflectRes) - var reflectOwnerRes OwnerResponse + var reflectOwnerRes testdata.OwnerResponse mustParse(t, reflectRes.Data, &reflectOwnerRes) require.Equal(t, reflectOwnerRes.Owner, creator.String()) // and with queryRaw - reflectStateQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ + reflectStateQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ Raw: &wasmvmtypes.RawQuery{ ContractAddr: reflectAddr.String(), Key: configKey, @@ -499,7 +492,7 @@ func TestMaskReflectWasmQueries(t *testing.T) { res, err = keeper.QuerySmart(ctx, reflectAddr, reflectStateBin) require.NoError(t, err) // first we pull out the data from chain response, before parsing the original response - var reflectRawRes ChainResponse + var reflectRawRes testdata.ChainResponse mustParse(t, res, &reflectRawRes) // now, with the raw data, we can parse it into state var reflectStateRes reflectState @@ -516,9 +509,7 @@ func TestWasmRawQueryWithNil(t *testing.T) { creator := keepers.Faucet.NewFundedAccount(ctx, deposit...) // upload reflect code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - reflectID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + reflectID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), reflectID) @@ -534,7 +525,7 @@ func TestWasmRawQueryWithNil(t *testing.T) { require.Nil(t, raw) // and with queryRaw - reflectQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ + reflectQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Wasm: &wasmvmtypes.WasmQuery{ Raw: &wasmvmtypes.RawQuery{ ContractAddr: reflectAddr.String(), Key: missingKey, @@ -545,7 +536,7 @@ func TestWasmRawQueryWithNil(t *testing.T) { require.NoError(t, err) // first we pull out the data from chain response, before parsing the original response - var reflectRawRes ChainResponse + var reflectRawRes testdata.ChainResponse mustParse(t, res, &reflectRawRes) // and make sure there is no data require.Empty(t, reflectRawRes.Data) @@ -630,8 +621,8 @@ func fromReflectRawMsg(cdc codec.Codec) CustomEncoder { } type reflectCustomQuery struct { - Ping *struct{} `json:"ping,omitempty"` - Capitalized *Text `json:"capitalized,omitempty"` + Ping *struct{} `json:"ping,omitempty"` + Capitalized *testdata.Text `json:"capitalized,omitempty"` } // this is from the go code back to the contract (capitalized or ping) diff --git a/x/wasm/keeper/relay.go b/x/wasm/keeper/relay.go index 66d4cd6a98..47126c2534 100644 --- a/x/wasm/keeper/relay.go +++ b/x/wasm/keeper/relay.go @@ -35,8 +35,7 @@ func (k Keeper) OnOpenChannel( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCChannelOpen(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCChannelOpen(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { return "", sdkerrors.Wrap(types.ErrExecuteFailed, execErr.Error()) @@ -71,8 +70,7 @@ func (k Keeper) OnConnectChannel( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCChannelConnect(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCChannelConnect(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { @@ -104,8 +102,7 @@ func (k Keeper) OnCloseChannel( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCChannelClose(codeInfo.CodeHash, params, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCChannelClose(codeInfo.CodeHash, params, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { @@ -136,8 +133,7 @@ func (k Keeper) OnRecvPacket( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCPacketReceive(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCPacketReceive(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { @@ -172,8 +168,7 @@ func (k Keeper) OnAckPacket( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCPacketAck(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCPacketAck(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { @@ -201,8 +196,7 @@ func (k Keeper) OnTimeoutPacket( querier := k.newQueryHandler(ctx, contractAddr) gas := k.runtimeGasForContract(ctx) - wasmStore := types.NewWasmStore(prefixStore) - res, gasUsed, execErr := k.wasmVM.IBCPacketTimeout(codeInfo.CodeHash, env, msg, wasmStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) + res, gasUsed, execErr := k.wasmVM.IBCPacketTimeout(codeInfo.CodeHash, env, msg, prefixStore, k.cosmwasmAPI(ctx), querier, ctx.GasMeter(), gas, costJSONDeserialization) k.consumeRuntimeGas(ctx, gasUsed) if execErr != nil { diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index 8ec2a2d0dc..51de44a0ea 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -21,7 +21,7 @@ func TestOnOpenChannel(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 @@ -91,7 +91,7 @@ func TestOnConnectChannel(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 @@ -202,7 +202,7 @@ func TestOnCloseChannel(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 @@ -312,7 +312,7 @@ func TestOnRecvPacket(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 const storageCosts = sdk.Gas(2879) @@ -474,7 +474,7 @@ func TestOnAckPacket(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 @@ -579,7 +579,7 @@ func TestOnTimeoutPacket(t *testing.T) { var m wasmtesting.MockWasmer wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} - parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil, WithMessageHandler(messenger)) + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, nil, nil, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 diff --git a/x/wasm/keeper/snapshotter.go b/x/wasm/keeper/snapshotter.go index b6e7ec8917..b5214d80e6 100644 --- a/x/wasm/keeper/snapshotter.go +++ b/x/wasm/keeper/snapshotter.go @@ -100,6 +100,9 @@ func (ws *WasmSnapshotter) Restore( } func restoreV1(ctx sdk.Context, k *Keeper, compressedCode []byte) error { + if !ioutils.IsGzip(compressedCode) { + return types.ErrInvalid.Wrap("not a gzip") + } wasmCode, err := ioutils.Uncompress(compressedCode, uint64(types.MaxWasmSize)) if err != nil { return sdkerrors.Wrap(types.ErrCreateFailed, err.Error()) diff --git a/x/wasm/keeper/snapshotter_integration_test.go b/x/wasm/keeper/snapshotter_integration_test.go index d5afa072e5..a90c157d37 100644 --- a/x/wasm/keeper/snapshotter_integration_test.go +++ b/x/wasm/keeper/snapshotter_integration_test.go @@ -54,11 +54,10 @@ func TestSnapshotter(t *testing.T) { for i, v := range spec.wasmFiles { wasmCode, err := os.ReadFile(v) require.NoError(t, err) - codeID, err := contractKeeper.Create(ctx, genesisAddr, wasmCode, nil) + codeID, checksum, err := contractKeeper.Create(ctx, genesisAddr, wasmCode, nil) require.NoError(t, err) require.Equal(t, uint64(i+1), codeID) - hash := sha256.Sum256(wasmCode) - srcCodeIDToChecksum[codeID] = hash[:] + srcCodeIDToChecksum[codeID] = checksum } // create snapshot srcWasmApp.Commit() diff --git a/x/wasm/keeper/staking_test.go b/x/wasm/keeper/staking_test.go index 244d550e6a..96bcfd8ec2 100644 --- a/x/wasm/keeper/staking_test.go +++ b/x/wasm/keeper/staking_test.go @@ -21,6 +21,7 @@ import ( stakingtypes "github.com/line/lbm-sdk/x/staking/types" wasmvmtypes "github.com/line/wasmvm/types" + "github.com/line/wasmd/x/wasm/keeper/testdata" wasmtypes "github.com/line/wasmd/x/wasm/types" ) @@ -36,12 +37,12 @@ type StakingInitMsg struct { // StakingHandleMsg is used to encode handle messages type StakingHandleMsg struct { - Transfer *transferPayload `json:"transfer,omitempty"` - Bond *struct{} `json:"bond,omitempty"` - Unbond *unbondPayload `json:"unbond,omitempty"` - Claim *struct{} `json:"claim,omitempty"` - Reinvest *struct{} `json:"reinvest,omitempty"` - Change *ownerPayload `json:"change_owner,omitempty"` + Transfer *transferPayload `json:"transfer,omitempty"` + Bond *struct{} `json:"bond,omitempty"` + Unbond *unbondPayload `json:"unbond,omitempty"` + Claim *struct{} `json:"claim,omitempty"` + Reinvest *struct{} `json:"reinvest,omitempty"` + Change *testdata.OwnerPayload `json:"change_owner,omitempty"` } type transferPayload struct { @@ -93,7 +94,7 @@ type InvestmentResponse struct { } func TestInitializeStaking(t *testing.T) { - ctx, k := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, k := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, stakingKeeper, keeper, bankKeeper := k.AccountKeeper, k.StakingKeeper, k.ContractKeeper, k.BankKeeper valAddr := addValidator(t, ctx, stakingKeeper, k.Faucet, sdk.NewInt64Coin("stake", 1234567)) @@ -108,7 +109,7 @@ func TestInitializeStaking(t *testing.T) { // upload staking derivates code stakingCode, err := os.ReadFile("./testdata/staking.wasm") require.NoError(t, err) - stakingID, err := keeper.Create(ctx, creator, stakingCode, nil) + stakingID, _, err := keeper.Create(ctx, creator, stakingCode, nil) require.NoError(t, err) require.Equal(t, uint64(1), stakingID) @@ -168,7 +169,7 @@ type initInfo struct { } func initializeStaking(t *testing.T) initInfo { - ctx, k := CreateTestInput(t, false, SupportedFeatures, nil, nil) + ctx, k := CreateTestInput(t, false, AvailableCapabilities, nil, nil) accKeeper, stakingKeeper, keeper, bankKeeper := k.AccountKeeper, k.StakingKeeper, k.WasmKeeper, k.BankKeeper valAddr := addValidator(t, ctx, stakingKeeper, k.Faucet, sdk.NewInt64Coin("stake", 1000000)) @@ -191,7 +192,7 @@ func initializeStaking(t *testing.T) initInfo { // upload staking derivates code stakingCode, err := os.ReadFile("./testdata/staking.wasm") require.NoError(t, err) - stakingID, err := k.ContractKeeper.Create(ctx, creator, stakingCode, nil) + stakingID, _, err := k.ContractKeeper.Create(ctx, creator, stakingCode, nil) require.NoError(t, err) require.Equal(t, uint64(1), stakingID) @@ -447,9 +448,7 @@ func TestQueryStakingInfo(t *testing.T) { creator := initInfo.faucet.NewFundedAccount(ctx, deposit...) // upload mask code - maskCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - maskID, err := initInfo.contractKeeper.Create(ctx, creator, maskCode, nil) + maskID, _, err := initInfo.contractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(2), maskID) @@ -460,21 +459,21 @@ func TestQueryStakingInfo(t *testing.T) { // STEP 3: now, let's reflect some queries. // let's get the bonded denom - reflectBondedQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectBondedQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ BondedDenom: &struct{}{}, }}}} reflectBondedBin := buildReflectQuery(t, &reflectBondedQuery) res, err := keeper.QuerySmart(ctx, maskAddr, reflectBondedBin) require.NoError(t, err) // first we pull out the data from chain response, before parsing the original response - var reflectRes ChainResponse + var reflectRes testdata.ChainResponse mustParse(t, res, &reflectRes) var bondedRes wasmvmtypes.BondedDenomResponse mustParse(t, reflectRes.Data, &bondedRes) assert.Equal(t, "stake", bondedRes.Denom) // now, let's reflect a smart query into the x/wasm handlers and see if we get the same result - reflectAllValidatorsQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectAllValidatorsQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ AllValidators: &wasmvmtypes.AllValidatorsQuery{}, }}}} reflectAllValidatorsBin := buildReflectQuery(t, &reflectAllValidatorsQuery) @@ -493,7 +492,7 @@ func TestQueryStakingInfo(t *testing.T) { require.Contains(t, valInfo.MaxChangeRate, "0.010") // find a validator - reflectValidatorQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectValidatorQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ Validator: &wasmvmtypes.ValidatorQuery{ Address: valAddr.String(), }, @@ -515,7 +514,7 @@ func TestQueryStakingInfo(t *testing.T) { // missing validator noVal := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()) - reflectNoValidatorQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectNoValidatorQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ Validator: &wasmvmtypes.ValidatorQuery{ Address: noVal.String(), }, @@ -530,7 +529,7 @@ func TestQueryStakingInfo(t *testing.T) { require.Nil(t, noValidatorRes.Validator) // test to get all my delegations - reflectAllDelegationsQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectAllDelegationsQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ AllDelegations: &wasmvmtypes.AllDelegationsQuery{ Delegator: contractAddr.String(), }, @@ -553,7 +552,7 @@ func TestQueryStakingInfo(t *testing.T) { require.Equal(t, funds[0].Amount.String(), delInfo.Amount.Amount) // test to get one delegations - reflectDelegationQuery := ReflectQueryMsg{Chain: &ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ + reflectDelegationQuery := testdata.ReflectQueryMsg{Chain: &testdata.ChainQuery{Request: &wasmvmtypes.QueryRequest{Staking: &wasmvmtypes.StakingQuery{ Delegation: &wasmvmtypes.DelegationQuery{ Validator: valAddr.String(), Delegator: contractAddr.String(), diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index 856f1b26bb..478319f2aa 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -13,6 +13,7 @@ import ( sdk "github.com/line/lbm-sdk/types" wasmvmtypes "github.com/line/wasmvm/types" + "github.com/line/wasmd/x/wasm/keeper/testdata" "github.com/line/wasmd/x/wasm/types" ) @@ -31,9 +32,7 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { _, _, fred := keyPubAddr() // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) require.Equal(t, uint64(1), codeID) @@ -59,8 +58,8 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { }, }, } - reflectSend := ReflectHandleMsg{ - ReflectSubMsg: &reflectSubPayload{ + reflectSend := testdata.ReflectHandleMsg{ + ReflectSubMsg: &testdata.ReflectSubPayload{ Msgs: []wasmvmtypes.SubMsg{{ ID: 7, Msg: msg, @@ -80,8 +79,8 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { checkAccount(t, ctx, accKeeper, bankKeeper, creator, creatorBalance) // query the reflect state to ensure the result was stored - query := ReflectQueryMsg{ - SubMsgResult: &SubCall{ID: 7}, + query := testdata.ReflectQueryMsg{ + SubMsgResult: &testdata.SubCall{ID: 7}, } queryBz, err := json.Marshal(query) require.NoError(t, err) @@ -96,15 +95,8 @@ 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, 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", - Value: fred.String(), - }, transfer.Attributes[0]) + // as of v0.28.0 we strip out all events that don't come from wasm contracts. can't trust the sdk. + require.Len(t, sub.Events, 0) } func TestDispatchSubMsgErrorHandling(t *testing.T) { @@ -122,15 +114,13 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { uploader := keepers.Faucet.NewFundedAccount(ctx, contractStart.Add(contractStart...)...) // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - reflectID, err := keepers.ContractKeeper.Create(ctx, uploader, reflectCode, nil) + reflectID, _, err := keepers.ContractKeeper.Create(ctx, uploader, testdata.ReflectContractWasm(), nil) require.NoError(t, err) // create hackatom contract for testing (for infinite loop) hackatomCode, err := os.ReadFile("./testdata/hackatom.wasm") require.NoError(t, err) - hackatomID, err := keepers.ContractKeeper.Create(ctx, uploader, hackatomCode, nil) + hackatomID, _, err := keepers.ContractKeeper.Create(ctx, uploader, hackatomCode, nil) require.NoError(t, err) _, _, bob := keyPubAddr() _, _, fred := keyPubAddr() @@ -300,8 +290,8 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { require.NoError(t, err) msg := tc.msg(contractAddr.String(), empty.String()) - reflectSend := ReflectHandleMsg{ - ReflectSubMsg: &reflectSubPayload{ + reflectSend := testdata.ReflectHandleMsg{ + ReflectSubMsg: &testdata.ReflectSubPayload{ Msgs: []wasmvmtypes.SubMsg{{ ID: tc.submsgID, Msg: msg, @@ -331,8 +321,8 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { require.NoError(t, err) // query the reply - query := ReflectQueryMsg{ - SubMsgResult: &SubCall{ID: tc.submsgID}, + query := testdata.ReflectQueryMsg{ + SubMsgResult: &testdata.SubCall{ID: tc.submsgID}, } queryBz, err := json.Marshal(query) require.NoError(t, err) @@ -381,9 +371,7 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { _, _, fred := keyPubAddr() // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) // creator instantiates a contract and gives it tokens @@ -403,8 +391,8 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { }, }, } - reflectSend := ReflectHandleMsg{ - ReflectSubMsg: &reflectSubPayload{ + reflectSend := testdata.ReflectHandleMsg{ + ReflectSubMsg: &testdata.ReflectSubPayload{ Msgs: []wasmvmtypes.SubMsg{{ ID: 7, Msg: msg, @@ -418,8 +406,8 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { require.NoError(t, err) // query the reflect state to ensure the result was stored - query := ReflectQueryMsg{ - SubMsgResult: &SubCall{ID: 7}, + query := testdata.ReflectQueryMsg{ + SubMsgResult: &testdata.SubCall{ID: 7}, } queryBz, err := json.Marshal(query) require.NoError(t, err) @@ -449,9 +437,7 @@ func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { _, _, fred := keyPubAddr() // upload code - reflectCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) require.NoError(t, err) // creator instantiates a contract and gives it tokens @@ -529,8 +515,8 @@ func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { subMsg.ReplyOn = wasmvmtypes.ReplyError } - reflectSend := ReflectHandleMsg{ - ReflectSubMsg: &reflectSubPayload{ + reflectSend := testdata.ReflectHandleMsg{ + ReflectSubMsg: &testdata.ReflectSubPayload{ Msgs: []wasmvmtypes.SubMsg{subMsg}, }, } @@ -545,8 +531,8 @@ func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { } // query the reflect state to check if the result was stored - query := ReflectQueryMsg{ - SubMsgResult: &SubCall{ID: id}, + query := testdata.ReflectQueryMsg{ + SubMsgResult: &testdata.SubCall{ID: id}, } queryBz, err := json.Marshal(query) require.NoError(t, err) diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index f704a34f1a..65c2156c2f 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -1,6 +1,7 @@ package keeper import ( + "bytes" "encoding/binary" "encoding/json" "fmt" @@ -16,11 +17,13 @@ import ( "github.com/line/lbm-sdk/std" "github.com/line/lbm-sdk/store" sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/types/address" sdkerrors "github.com/line/lbm-sdk/types/errors" "github.com/line/lbm-sdk/types/module" "github.com/line/lbm-sdk/x/auth" authkeeper "github.com/line/lbm-sdk/x/auth/keeper" authtypes "github.com/line/lbm-sdk/x/auth/types" + "github.com/line/lbm-sdk/x/auth/vesting" authzkeeper "github.com/line/lbm-sdk/x/authz/keeper" "github.com/line/lbm-sdk/x/bank" bankkeeper "github.com/line/lbm-sdk/x/bank/keeper" @@ -75,7 +78,7 @@ import ( "github.com/line/wasmd/x/wasm/types" ) -var ModuleBasics = module.NewBasicManager( +var moduleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, @@ -92,6 +95,7 @@ var ModuleBasics = module.NewBasicManager( upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, + vesting.AppModuleBasic{}, ) func MakeTestCodec(t testing.TB) codec.Codec { @@ -106,8 +110,8 @@ func MakeEncodingConfig(_ testing.TB) wasmappparams.EncodingConfig { std.RegisterInterfaces(interfaceRegistry) std.RegisterLegacyAminoCodec(amino) - ModuleBasics.RegisterLegacyAminoCodec(amino) - ModuleBasics.RegisterInterfaces(interfaceRegistry) + moduleBasics.RegisterLegacyAminoCodec(amino) + moduleBasics.RegisterInterfaces(interfaceRegistry) // add wasmd types lbmtypes.RegisterInterfaces(interfaceRegistry) lbmtypes.RegisterLegacyAminoCodec(amino) @@ -190,16 +194,16 @@ func CreateDefaultTestInput(t testing.TB) (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, encoders *MessageEncoders, queriers *QueryPlugins, opts ...Option) (sdk.Context, TestKeepers) { +func CreateTestInput(t testing.TB, isCheckTx bool, availableCapabilities string, encoders *MessageEncoders, queriers *QueryPlugins, opts ...Option) (sdk.Context, TestKeepers) { // Load default wasm config - return createTestInput(t, isCheckTx, supportedFeatures, encoders, queriers, types.DefaultWasmConfig(), dbm.NewMemDB(), opts...) + return createTestInput(t, isCheckTx, availableCapabilities, encoders, queriers, 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 testing.TB, isCheckTx bool, - supportedFeatures string, + availableCapabilities string, encoders *MessageEncoders, queriers *QueryPlugins, wasmConfig types.WasmConfig, @@ -389,7 +393,7 @@ func createTestInput( querier, tempDir, wasmConfig, - supportedFeatures, + availableCapabilities, encoders, queriers, opts..., @@ -469,7 +473,7 @@ func handleStoreCode(ctx sdk.Context, k types.ContractOpsKeeper, msg *types.MsgS if err != nil { return nil, sdkerrors.Wrap(err, "sender") } - codeID, err := k.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) + codeID, _, err := k.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) if err != nil { return nil, err } @@ -528,6 +532,11 @@ func RandomAccountAddress(_ testing.TB) sdk.AccAddress { return addr } +// DeterministicAccountAddress creates a test address with v repeated to valid address size +func DeterministicAccountAddress(_ testing.TB, v byte) sdk.AccAddress { + return bytes.Repeat([]byte{v}, address.Len) +} + func RandomBech32AccountAddress(t testing.TB) string { return RandomAccountAddress(t).String() } @@ -537,6 +546,7 @@ type ExampleContract struct { Creator crypto.PrivKey CreatorAddr sdk.AccAddress CodeID uint64 + Checksum []byte } func StoreHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { @@ -551,14 +561,8 @@ func StoreIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) return StoreExampleContract(t, ctx, keepers, "./testdata/ibc_reflect.wasm") } -func StoreReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) uint64 { - wasmCode, err := os.ReadFile("./testdata/reflect.wasm") - require.NoError(t, err) - - _, _, creatorAddr := keyPubAddr() - codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) - require.NoError(t, err) - return codeID +func StoreReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleContract { + return StoreExampleContract(t, ctx, keepers, "./testdata/reflect.wasm") } func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmFile string) ExampleContract { @@ -569,9 +573,10 @@ func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wa wasmCode, err := os.ReadFile(wasmFile) require.NoError(t, err) - codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) + codeID, _, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) require.NoError(t, err) - return ExampleContract{anyAmount, creator, creatorAddr, codeID} + hash := keepers.WasmKeeper.GetCodeInfo(ctx, codeID).CodeHash + return ExampleContract{anyAmount, creator, creatorAddr, codeID, hash} } var wasmIdent = []byte("\x00\x61\x73\x6D") @@ -610,9 +615,9 @@ func StoreRandomContractWithAccessConfig( fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) keepers.WasmKeeper.wasmVM = mock wasmCode := append(wasmIdent, rand.Bytes(10)...) //nolint:gocritic - codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, cfg) + codeID, checksum, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, cfg) require.NoError(t, err) - exampleContract := ExampleContract{InitialAmount: anyAmount, Creator: creator, CreatorAddr: creatorAddr, CodeID: codeID} + exampleContract := ExampleContract{InitialAmount: anyAmount, Creator: creator, CreatorAddr: creatorAddr, CodeID: codeID, Checksum: checksum} return exampleContract } @@ -623,6 +628,8 @@ type HackatomExampleInstance struct { VerifierAddr sdk.AccAddress Beneficiary crypto.PrivKey BeneficiaryAddr sdk.AccAddress + Label string + Deposit sdk.Coins } // InstantiateHackatomExampleContract load and instantiate the "./testdata/hackatom.wasm" contract @@ -640,7 +647,8 @@ func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers T initialAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) adminAddr := contract.CreatorAddr - contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, contract.CodeID, contract.CreatorAddr, adminAddr, initMsgBz, "demo contract to query", initialAmount) + label := "demo contract to query" + contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, contract.CodeID, contract.CreatorAddr, adminAddr, initMsgBz, label, initialAmount) require.NoError(t, err) return HackatomExampleInstance{ ExampleContract: contract, @@ -649,6 +657,31 @@ func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers T VerifierAddr: verifierAddr, Beneficiary: beneficiary, BeneficiaryAddr: beneficiaryAddr, + Label: label, + Deposit: initialAmount, + } +} + +type ExampleInstance struct { + ExampleContract + Contract sdk.AccAddress + Label string + Deposit sdk.Coins +} + +// InstantiateReflectExampleContract load and instantiate the "./testdata/reflect.wasm" contract +func InstantiateReflectExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) ExampleInstance { + example := StoreReflectContract(t, ctx, keepers) + initialAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 100)) + label := "demo contract to query" + contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, example.CodeID, example.CreatorAddr, nil, []byte("{}"), label, initialAmount) + + require.NoError(t, err) + return ExampleInstance{ + ExampleContract: example, + Contract: contractAddr, + Label: label, + Deposit: initialAmount, } } @@ -672,7 +705,7 @@ type IBCReflectExampleInstance struct { // InstantiateIBCReflectContract load and instantiate the "./testdata/ibc_reflect.wasm" contract func InstantiateIBCReflectContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) IBCReflectExampleInstance { - reflectID := StoreReflectContract(t, ctx, keepers) + reflectID := StoreReflectContract(t, ctx, keepers).CodeID ibcReflectID := StoreIBCReflectContract(t, ctx, keepers).CodeID initMsgBz := IBCReflectInitMsg{ diff --git a/x/wasm/keeper/testdata/broken_crc.gzip b/x/wasm/keeper/testdata/broken_crc.gzip new file mode 100644 index 0000000000..378713e2ff Binary files /dev/null and b/x/wasm/keeper/testdata/broken_crc.gzip differ diff --git a/x/wasm/keeper/testdata/reflect.go b/x/wasm/keeper/testdata/reflect.go index ad365ce0c2..0cafa631bb 100644 --- a/x/wasm/keeper/testdata/reflect.go +++ b/x/wasm/keeper/testdata/reflect.go @@ -2,6 +2,9 @@ package testdata import ( _ "embed" + + "github.com/line/lbm-sdk/types" + typwasmvmtypes "github.com/line/wasmvm/types" ) //go:embed reflect.wasm @@ -10,3 +13,50 @@ var reflectContract []byte func ReflectContractWasm() []byte { return reflectContract } + +// ReflectHandleMsg is used to encode handle messages +type ReflectHandleMsg struct { + Reflect *ReflectPayload `json:"reflect_msg,omitempty"` + ReflectSubMsg *ReflectSubPayload `json:"reflect_sub_msg,omitempty"` + ChangeOwner *OwnerPayload `json:"change_owner,omitempty"` +} + +type OwnerPayload struct { + Owner types.Address `json:"owner"` +} + +type ReflectPayload struct { + Msgs []typwasmvmtypes.CosmosMsg `json:"msgs"` +} + +type ReflectSubPayload struct { + Msgs []typwasmvmtypes.SubMsg `json:"msgs"` +} + +// ReflectQueryMsg is used to encode query messages +type ReflectQueryMsg struct { + Owner *struct{} `json:"owner,omitempty"` + Capitalized *Text `json:"capitalized,omitempty"` + Chain *ChainQuery `json:"chain,omitempty"` + SubMsgResult *SubCall `json:"sub_msg_result,omitempty"` +} + +type ChainQuery struct { + Request *typwasmvmtypes.QueryRequest `json:"request,omitempty"` +} + +type Text struct { + Text string `json:"text"` +} + +type SubCall struct { + ID uint64 `json:"id"` +} + +type OwnerResponse struct { + Owner string `json:"owner,omitempty"` +} + +type ChainResponse struct { + Data []byte `json:"data,omitempty"` +} diff --git a/x/wasm/keeper/testdata/reflect.wasm.v1_0 b/x/wasm/keeper/testdata/reflect.wasm.v1_0 new file mode 100644 index 0000000000..312f45768d Binary files /dev/null and b/x/wasm/keeper/testdata/reflect.wasm.v1_0 differ diff --git a/x/wasm/keeper/wasmtesting/coin_transferrer.go b/x/wasm/keeper/wasmtesting/extension_mocks.go similarity index 60% rename from x/wasm/keeper/wasmtesting/coin_transferrer.go rename to x/wasm/keeper/wasmtesting/extension_mocks.go index 4164ee4046..d21323075c 100644 --- a/x/wasm/keeper/wasmtesting/coin_transferrer.go +++ b/x/wasm/keeper/wasmtesting/extension_mocks.go @@ -2,6 +2,7 @@ package wasmtesting import ( sdk "github.com/line/lbm-sdk/types" + authtypes "github.com/line/lbm-sdk/x/auth/types" ) type MockCoinTransferrer struct { @@ -22,3 +23,14 @@ func (m *MockCoinTransferrer) TransferCoins(ctx sdk.Context, fromAddr sdk.AccAdd } return m.TransferCoinsFn(ctx, fromAddr, toAddr, amt) } + +type AccountPrunerMock struct { + CleanupExistingAccountFn func(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) +} + +func (m AccountPrunerMock) CleanupExistingAccount(ctx sdk.Context, existingAccount authtypes.AccountI) (handled bool, err error) { + if m.CleanupExistingAccountFn == nil { + panic("not expected to be called") + } + return m.CleanupExistingAccountFn(ctx, existingAccount) +} diff --git a/x/wasm/module.go b/x/wasm/module.go index 636e9dda8d..29a370ae2f 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -3,7 +3,10 @@ package wasm import ( "context" "encoding/json" + "fmt" "math/rand" + "runtime/debug" + "strings" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cast" @@ -17,8 +20,8 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/module" simtypes "github.com/line/lbm-sdk/types/simulation" - simKeeper "github.com/line/lbm-sdk/x/simulation" abci "github.com/line/ostracon/abci/types" + wasmvm "github.com/line/wasmvm" "github.com/line/wasmd/x/wasm/client/cli" "github.com/line/wasmd/x/wasm/keeper" @@ -100,7 +103,7 @@ type AppModule struct { keeper *Keeper validatorSetSource keeper.ValidatorSetSource accountKeeper types.AccountKeeper // for simulation - bankKeeper simKeeper.BankKeeper + bankKeeper simulation.BankKeeper } // ConsensusVersion is a sequence number for state-breaking change of the @@ -115,7 +118,7 @@ func NewAppModule( keeper *Keeper, validatorSetSource keeper.ValidatorSetSource, ak types.AccountKeeper, - bk simKeeper.BankKeeper, + bk simulation.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, @@ -158,7 +161,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.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genesisState types.GenesisState + var genesisState GenesisState cdc.MustUnmarshalJSON(data, &genesisState) validators, err := InitGenesis(ctx, am.keeper, genesisState, am.validatorSetSource, am.Route().Handler()) if err != nil { @@ -219,6 +222,8 @@ func AddModuleInitFlags(startCmd *cobra.Command) { startCmd.Flags().Uint32(flagWasmMemoryCacheSize, defaults.MemoryCacheSize, "Sets the size in MiB (NOT bytes) of an in-memory cache for Wasm modules. Set to 0 to disable.") startCmd.Flags().Uint64(flagWasmQueryGasLimit, defaults.SmartQueryGasLimit, "Set the max gas that can be spent on executing a query with a Wasm contract") startCmd.Flags().String(flagWasmSimulationGasLimit, "", "Set the max gas that can be spent when executing a simulation TX") + + startCmd.PreRunE = chainPreRuns(checkLibwasmVersion, startCmd.PreRunE) } // ReadWasmConfig reads the wasm specifig configuration @@ -252,3 +257,50 @@ func ReadWasmConfig(opts servertypes.AppOptions) (types.WasmConfig, error) { } return cfg, nil } + +func getExpectedLibwasmVersion() string { + buildInfo, ok := debug.ReadBuildInfo() + if !ok { + panic("can't read build info") + } + for _, d := range buildInfo.Deps { + if d.Path != "github.com/CosmWasm/wasmvm" { + continue + } + if d.Replace != nil { + return d.Replace.Version + } + return d.Version + } + return "" +} + +func checkLibwasmVersion(cmd *cobra.Command, args []string) error { + wasmVersion, err := wasmvm.LibwasmvmVersion() + if err != nil { + return fmt.Errorf("unable to retrieve libwasmversion %w", err) + } + wasmExpectedVersion := getExpectedLibwasmVersion() + if wasmExpectedVersion == "" { + return fmt.Errorf("wasmvm module not exist") + } + if !strings.Contains(wasmExpectedVersion, wasmVersion) { + return fmt.Errorf("libwasmversion mismatch. got: %s; expected: %s", wasmVersion, wasmExpectedVersion) + } + return nil +} + +type preRunFn func(cmd *cobra.Command, args []string) error + +func chainPreRuns(pfns ...preRunFn) preRunFn { + return func(cmd *cobra.Command, args []string) error { + for _, pfn := range pfns { + if pfn != nil { + if err := pfn(cmd, args); err != nil { + return err + } + } + } + return nil + } +} diff --git a/x/wasm/module_integration_test.go b/x/wasm/module_integration_test.go new file mode 100644 index 0000000000..379444bf97 --- /dev/null +++ b/x/wasm/module_integration_test.go @@ -0,0 +1,32 @@ +package wasm_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/types/module" + upgradetypes "github.com/line/lbm-sdk/x/upgrade/types" + ocproto "github.com/line/ostracon/proto/ostracon/types" + + "github.com/line/wasmd/app" + "github.com/line/wasmd/x/wasm" +) + +func TestModuleMigrations(t *testing.T) { + wasmApp := app.Setup(false) + ctx := wasmApp.BaseApp.NewContext(false, ocproto.Header{}) + upgradeHandler := func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return wasmApp.ModuleManager().RunMigrations(ctx, wasmApp.ModuleConfigurator(), fromVM) + } + fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) + fromVM[wasm.ModuleName] = 1 // start with initial version + upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) + // when + gotVM, err := wasmApp.ModuleManager().RunMigrations(ctx, wasmApp.ModuleConfigurator(), fromVM) + // then + require.NoError(t, err) + assert.Equal(t, uint64(1), gotVM[wasm.ModuleName]) +} diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index e7d609da1d..856625670f 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -1,6 +1,7 @@ package wasm import ( + "bytes" "encoding/json" "fmt" "os" @@ -11,6 +12,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/types/address" "github.com/line/lbm-sdk/types/module" authkeeper "github.com/line/lbm-sdk/x/auth/keeper" bankkeeper "github.com/line/lbm-sdk/x/bank/keeper" @@ -20,6 +22,7 @@ import ( "github.com/line/ostracon/crypto/ed25519" "github.com/line/wasmd/x/wasm/keeper" + "github.com/line/wasmd/x/wasm/keeper/testdata" "github.com/line/wasmd/x/wasm/types" ) @@ -34,7 +37,7 @@ type testData struct { } func setupTest(t *testing.T) testData { - ctx, keepers := CreateTestInput(t, false, "iterator,staking,stargate", nil, nil) + ctx, keepers := CreateTestInput(t, false, "iterator,staking,stargate,cosmwasm_1_1", nil, nil) cdc := keeper.MakeTestCodec(t) data := testData{ module: NewAppModule(cdc, keepers.WasmKeeper, keepers.StakingKeeper, keepers.AccountKeeper, keepers.BankKeeper), @@ -67,7 +70,7 @@ var ( _, _, addrAcc1 = keyPubAddr() addr1 = addrAcc1.String() testContract = mustLoad("./keeper/testdata/hackatom.wasm") - maskContract = mustLoad("./keeper/testdata/reflect.wasm") + maskContract = testdata.ReflectContractWasm() oldContract = mustLoad("./testdata/escrow_0.7.wasm") ) @@ -175,18 +178,19 @@ func TestHandleInstantiate(t *testing.T) { CodeID: firstCodeID, Msg: initMsgBz, Funds: nil, + Label: "testing", } res, err = h(data.ctx, &initCmd) require.NoError(t, err) contractBech32Addr := parseInitResponse(t, res.Data) - assert.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", contractBech32Addr) + require.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", contractBech32Addr) // this should be standard x/wasm init event, nothing from contract - assert.Equal(t, 3, len(res.Events), prettyEvents(res.Events)) - assert.Equal(t, "message", res.Events[0].Type) + require.Equal(t, 3, len(res.Events), prettyEvents(res.Events)) + require.Equal(t, "message", res.Events[0].Type) assertAttribute(t, "module", "wasm", res.Events[0].Attributes[0]) - assert.Equal(t, "instantiate", res.Events[1].Type) - assert.Equal(t, "wasm", res.Events[2].Type) + require.Equal(t, "instantiate", res.Events[1].Type) + require.Equal(t, "wasm", res.Events[2].Type) assertAttribute(t, "_contract_address", contractBech32Addr, res.Events[2].Attributes[0]) assertCodeList(t, q, data.ctx, 1) @@ -407,21 +411,22 @@ func TestHandleExecute(t *testing.T) { CodeID: firstCodeID, Msg: initMsgBz, Funds: deposit, + Label: "testing", } res, err = h(data.ctx, &initCmd) require.NoError(t, err) contractBech32Addr := parseInitResponse(t, res.Data) - assert.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", contractBech32Addr) - // this should be standard x/wasm init event, plus a bank send event (2), with no custom contract events - assert.Equal(t, 6, len(res.Events), prettyEvents(res.Events)) - assert.Equal(t, "message", res.Events[0].Type) + require.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", 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, 6, len(res.Events), prettyEvents(res.Events)) + require.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) - assert.Equal(t, "transfer", res.Events[3].Type) - assert.Equal(t, "instantiate", res.Events[4].Type) - assert.Equal(t, "wasm", res.Events[5].Type) + 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 @@ -521,7 +526,8 @@ func TestHandleExecuteEscrow(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) - creator := data.faucet.NewFundedAccount(data.ctx, deposit.Add(deposit...)...) + creator := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) + data.faucet.Fund(data.ctx, creator, sdk.NewInt64Coin("denom", 100000)) fred := data.faucet.NewFundedAccount(data.ctx, topUp...) h := data.module.Route().Handler() @@ -546,6 +552,7 @@ func TestHandleExecuteEscrow(t *testing.T) { CodeID: firstCodeID, Msg: initMsgBz, Funds: deposit, + Label: "testing", } res, err = h(data.ctx, &initCmd) require.NoError(t, err) diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index 4f0191d2c6..60797e420f 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -326,7 +326,7 @@ func (p player) incrementCounter(key []byte, store wasmvm.KVStore) uint64 { } func (p player) QueryState(key []byte) uint64 { - raw := p.chain.GetTestSupport().WasmKeeper().QueryRaw(p.chain.GetContext(), p.contractAddr, key) + raw := p.chain.App.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 eb0d3bcf5d..f918556345 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -196,7 +196,7 @@ func TestContractCanInitiateIBCTransferMsg(t *testing.T) { require.Equal(t, 0, len(chainB.PendingSendPackets)) // and dest chain balance contains voucher - bankKeeperB := chainB.GetTestSupport().BankKeeper() + bankKeeperB := chainB.App.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())) @@ -271,7 +271,7 @@ func TestContractCanEmulateIBCTransferMessage(t *testing.T) { require.Equal(t, 0, len(chainB.PendingSendPackets)) // and dest chain balance contains voucher - bankKeeperB := chainB.GetTestSupport().BankKeeper() + bankKeeperB := chainB.App.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())) @@ -538,7 +538,7 @@ func (c *ackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmv // 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.GetTestSupport().TransferKeeper().OnRecvPacket(ctx, ibcPacket, src) + err := c.chain.App.TransferKeeper.OnRecvPacket(ctx, ibcPacket, src) if err != nil { return nil, 0, sdkerrors.Wrap(err, "within our smart contract") } @@ -563,7 +563,7 @@ func (c *ackReceiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtyp // 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.GetTestSupport().TransferKeeper().OnAcknowledgementPacket(ctx, ibcPacket, data, ack) + err := c.chain.App.TransferKeeper.OnAcknowledgementPacket(ctx, ibcPacket, data, ack) if err != nil { return nil, 0, sdkerrors.Wrap(err, "within our smart contract") } diff --git a/x/wasm/simulation/genesis.go b/x/wasm/simulation/genesis.go index 4981401687..7720dca663 100644 --- a/x/wasm/simulation/genesis.go +++ b/x/wasm/simulation/genesis.go @@ -1,33 +1,28 @@ package simulation import ( - "encoding/json" - "fmt" - "github.com/line/lbm-sdk/types/module" "github.com/line/wasmd/x/wasm/types" ) -// RandomizedGenState RandomizeGenState generates a random GenesisState for wasm -func RandomizedGenState(simState *module.SimulationState) { - params := RandomParams(simState.Rand) +// RandomizedGenState generates a random GenesisState for wasm +func RandomizedGenState(simstate *module.SimulationState) { + params := types.DefaultParams() wasmGenesis := types.GenesisState{ Params: params, Codes: nil, Contracts: nil, Sequences: []types.Sequence{ - {IDKey: types.KeyLastCodeID, Value: simState.Rand.Uint64()}, - {IDKey: types.KeyLastInstanceID, Value: simState.Rand.Uint64()}, + {IDKey: types.KeyLastCodeID, Value: simstate.Rand.Uint64()}, }, GenMsgs: nil, } - bz, err := json.MarshalIndent(&wasmGenesis.Params, "", " ") + _, err := simstate.Cdc.MarshalJSON(&wasmGenesis) if err != nil { panic(err) } - fmt.Printf("Selected randomly generated wasm parameters:\n%s\n", bz) - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&wasmGenesis) + simstate.GenState[types.ModuleName] = simstate.Cdc.MustMarshalJSON(&wasmGenesis) } diff --git a/x/wasm/simulation/operations.go b/x/wasm/simulation/operations.go index 5f2f0eedac..7208037c9c 100644 --- a/x/wasm/simulation/operations.go +++ b/x/wasm/simulation/operations.go @@ -1,72 +1,119 @@ package simulation import ( + "encoding/json" "math/rand" + "os" "github.com/line/lbm-sdk/baseapp" sdk "github.com/line/lbm-sdk/types" + sdkerrors "github.com/line/lbm-sdk/types/errors" "github.com/line/lbm-sdk/types/module" simtypes "github.com/line/lbm-sdk/types/simulation" "github.com/line/lbm-sdk/x/simulation" + wasmvmtypes "github.com/line/wasmvm/types" - wasmappparams "github.com/line/wasmd/app/params" + "github.com/line/wasmd/app/params" + wasmkeeper "github.com/line/wasmd/x/wasm/keeper" "github.com/line/wasmd/x/wasm/keeper/testdata" "github.com/line/wasmd/x/wasm/types" ) // Simulation operation weights constants +// +//nolint:gosec const ( - OpWeightMsgStoreCode = "op_weight_msg_store_code" //nolint:gosec - OpWeightMsgInstantiateContract = "op_weight_msg_instantiate_contract" //nolint:gosec - OpReflectContractPath = "op_reflect_contract_path" //nolint:gosec + OpWeightMsgStoreCode = "op_weight_msg_store_code" + OpWeightMsgInstantiateContract = "op_weight_msg_instantiate_contract" + OpWeightMsgExecuteContract = "op_weight_msg_execute_contract" + OpReflectContractPath = "op_reflect_contract_path" ) // WasmKeeper is a subset of the wasm keeper used by simulations type WasmKeeper interface { GetParams(ctx sdk.Context) types.Params IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo) bool) + IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) + QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + PeekAutoIncrementID(ctx sdk.Context, lastIDKey []byte) uint64 +} +type BankKeeper interface { + simulation.BankKeeper + IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool } // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( simstate *module.SimulationState, ak types.AccountKeeper, - bk simulation.BankKeeper, + bk BankKeeper, wasmKeeper WasmKeeper, ) simulation.WeightedOperations { var ( weightMsgStoreCode int weightMsgInstantiateContract int + weightMsgExecuteContract int + wasmContractPath string ) simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgStoreCode, &weightMsgStoreCode, nil, func(_ *rand.Rand) { - weightMsgStoreCode = wasmappparams.DefaultWeightMsgStoreCode + weightMsgStoreCode = params.DefaultWeightMsgStoreCode }, ) simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgInstantiateContract, &weightMsgInstantiateContract, nil, func(_ *rand.Rand) { - weightMsgInstantiateContract = wasmappparams.DefaultWeightMsgInstantiateContract + weightMsgInstantiateContract = params.DefaultWeightMsgInstantiateContract + }, + ) + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgExecuteContract, &weightMsgInstantiateContract, nil, + func(_ *rand.Rand) { + weightMsgExecuteContract = params.DefaultWeightMsgExecuteContract + }, + ) + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpReflectContractPath, &wasmContractPath, nil, + func(_ *rand.Rand) { + wasmContractPath = "" }, ) - wasmBz := testdata.ReflectContractWasm() + var wasmBz []byte + if wasmContractPath == "" { + wasmBz = testdata.ReflectContractWasm() + } else { + var err error + wasmBz, err = os.ReadFile(wasmContractPath) + if err != nil { + panic(err) + } + } return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgStoreCode, - SimulateMsgStoreCode(ak, bk, wasmKeeper, wasmBz), + SimulateMsgStoreCode(ak, bk, wasmKeeper, wasmBz, 5_000_000), ), simulation.NewWeightedOperation( weightMsgInstantiateContract, - SimulateMsgInstantiateContract(ak, bk, wasmKeeper), + SimulateMsgInstantiateContract(ak, bk, wasmKeeper, DefaultSimulationCodeIDSelector), + ), + simulation.NewWeightedOperation( + weightMsgExecuteContract, + SimulateMsgExecuteContract( + ak, + bk, + wasmKeeper, + DefaultSimulationExecuteContractSelector, + DefaultSimulationExecuteSenderSelector, + DefaultSimulationExecutePayloader, + ), ), } } // SimulateMsgStoreCode generates a MsgStoreCode with random values -func SimulateMsgStoreCode(ak types.AccountKeeper, bk simulation.BankKeeper, wasmKeeper WasmKeeper, wasmBz []byte) simtypes.Operation { +func SimulateMsgStoreCode(ak types.AccountKeeper, bk BankKeeper, wasmKeeper WasmKeeper, wasmBz []byte, gas uint64) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, @@ -78,37 +125,39 @@ func SimulateMsgStoreCode(ak types.AccountKeeper, bk simulation.BankKeeper, wasm return simtypes.NoOpMsg(types.ModuleName, types.MsgStoreCode{}.Type(), "no chain permission"), nil, nil } - config := &types.AccessConfig{ - Permission: types.AccessTypeEverybody, - } - simAccount, _ := simtypes.RandomAcc(r, accs) + + permission := wasmKeeper.GetParams(ctx).InstantiateDefaultPermission + config := permission.With(simAccount.Address) + msg := types.MsgStoreCode{ Sender: simAccount.Address.String(), WASMByteCode: wasmBz, - InstantiatePermission: config, + InstantiatePermission: &config, } + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, nil) + return GenAndDeliverTxWithRandFees(txCtx, gas) + } +} - txCtx := simulation.OperationInput{ - R: r, - App: app, - TxGen: wasmappparams.MakeEncodingConfig().TxConfig, - Cdc: nil, - Msg: &msg, - MsgType: msg.Type(), - Context: ctx, - SimAccount: simAccount, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } +// CodeIDSelector returns code id to be used in simulations +type CodeIDSelector = func(ctx sdk.Context, wasmKeeper WasmKeeper) uint64 - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } +// DefaultSimulationCodeIDSelector picks the first code id +func DefaultSimulationCodeIDSelector(ctx sdk.Context, wasmKeeper WasmKeeper) uint64 { + var codeID uint64 + wasmKeeper.IterateCodeInfos(ctx, func(u uint64, info types.CodeInfo) bool { + if info.InstantiateConfig.Permission != types.AccessTypeEverybody { + return false + } + codeID = u + return true + }) + return codeID } // SimulateMsgInstantiateContract generates a MsgInstantiateContract with random values -func SimulateMsgInstantiateContract(ak types.AccountKeeper, bk simulation.BankKeeper, wasmKeeper WasmKeeper) simtypes.Operation { +func SimulateMsgInstantiateContract(ak types.AccountKeeper, bk BankKeeper, wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, @@ -118,20 +167,17 @@ func SimulateMsgInstantiateContract(ak types.AccountKeeper, bk simulation.BankKe ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) - var codeID uint64 - wasmKeeper.IterateCodeInfos(ctx, func(u uint64, info types.CodeInfo) bool { - if info.InstantiateConfig.Permission != types.AccessTypeEverybody { - return false - } - codeID = u - return true - }) - + codeID := codeSelector(ctx, wasmKeeper) if codeID == 0 { return simtypes.NoOpMsg(types.ModuleName, types.MsgInstantiateContract{}.Type(), "no codes with permission available"), nil, nil } - - spendable := bk.SpendableCoins(ctx, simAccount.Address) + deposit := sdk.Coins{} + spendableCoins := bk.SpendableCoins(ctx, simAccount.Address) + for _, v := range spendableCoins { + if bk.IsSendEnabledCoin(ctx, v) { + deposit = deposit.Add(simtypes.RandSubsetCoins(r, sdk.NewCoins(v))...) + } + } msg := types.MsgInstantiateContract{ Sender: simAccount.Address.String(), @@ -139,23 +185,156 @@ func SimulateMsgInstantiateContract(ak types.AccountKeeper, bk simulation.BankKe CodeID: codeID, Label: simtypes.RandStringOfLength(r, 10), Msg: []byte(`{}`), - Funds: simtypes.RandSubsetCoins(r, spendable), + Funds: deposit, + } + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, deposit) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +// MsgExecuteContractSelector returns contract address to be used in simulations +type MsgExecuteContractSelector = func(ctx sdk.Context, wasmKeeper WasmKeeper) sdk.AccAddress + +// MsgExecutePayloader extension point to modify msg with custom payload +type MsgExecutePayloader func(msg *types.MsgExecuteContract) error + +// MsgExecuteSenderSelector extension point that returns the sender address +type MsgExecuteSenderSelector func(wasmKeeper WasmKeeper, ctx sdk.Context, contractAddr sdk.AccAddress, accs []simtypes.Account) (simtypes.Account, error) + +// SimulateMsgExecuteContract create a execute message a reflect contract instance +func SimulateMsgExecuteContract( + ak types.AccountKeeper, + bk BankKeeper, + wasmKeeper WasmKeeper, + contractSelector MsgExecuteContractSelector, + senderSelector MsgExecuteSenderSelector, + payloader MsgExecutePayloader, +) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + contractAddr := contractSelector(ctx, wasmKeeper) + if contractAddr == nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "no contract instance available"), nil, nil + } + simAccount, err := senderSelector(wasmKeeper, ctx, contractAddr, accs) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "query contract owner"), nil, err } - txCtx := simulation.OperationInput{ - R: r, - App: app, - TxGen: wasmappparams.MakeEncodingConfig().TxConfig, - Cdc: nil, - Msg: &msg, - MsgType: msg.Type(), - Context: ctx, - SimAccount: simAccount, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, + deposit := sdk.Coins{} + spendableCoins := bk.SpendableCoins(ctx, simAccount.Address) + for _, v := range spendableCoins { + if bk.IsSendEnabledCoin(ctx, v) { + deposit = deposit.Add(simtypes.RandSubsetCoins(r, sdk.NewCoins(v))...) + } + } + if deposit.IsZero() { + return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "broke account"), nil, nil + } + msg := types.MsgExecuteContract{ + Sender: simAccount.Address.String(), + Contract: contractAddr.String(), + Funds: deposit, + } + if err := payloader(&msg); err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "contract execute payload"), nil, err } + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, deposit) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } + +// BuildOperationInput helper to build object +func BuildOperationInput( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + msg interface { + sdk.Msg + Type() string + }, + simAccount simtypes.Account, + ak types.AccountKeeper, + bk BankKeeper, + deposit sdk.Coins, +) simulation.OperationInput { + return simulation.OperationInput{ + R: r, + App: app, + TxGen: params.MakeEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + AccountKeeper: ak, + Bankkeeper: bk, + ModuleName: types.ModuleName, + CoinsSpentInMsg: deposit, + } +} + +// DefaultSimulationExecuteContractSelector picks the first contract address +func DefaultSimulationExecuteContractSelector(ctx sdk.Context, wasmKeeper WasmKeeper) sdk.AccAddress { + var r sdk.AccAddress + wasmKeeper.IterateContractInfo(ctx, func(address sdk.AccAddress, info types.ContractInfo) bool { + r = address + return true + }) + return r +} + +// DefaultSimulationExecuteSenderSelector queries reflect contract for owner address and selects accounts +func DefaultSimulationExecuteSenderSelector(wasmKeeper WasmKeeper, ctx sdk.Context, contractAddr sdk.AccAddress, accs []simtypes.Account) (simtypes.Account, error) { + var none simtypes.Account + bz, err := json.Marshal(testdata.ReflectQueryMsg{Owner: &struct{}{}}) + if err != nil { + return none, sdkerrors.Wrap(err, "build smart query") + } + got, err := wasmKeeper.QuerySmart(ctx, contractAddr, bz) + if err != nil { + return none, sdkerrors.Wrap(err, "exec smart query") + } + var ownerRes testdata.OwnerResponse + if err := json.Unmarshal(got, &ownerRes); err != nil || ownerRes.Owner == "" { + return none, sdkerrors.Wrap(err, "parse smart query response") + } + ownerAddr, err := sdk.AccAddressFromBech32(ownerRes.Owner) + if err != nil { + return none, sdkerrors.Wrap(err, "parse contract owner address") + } + simAccount, ok := simtypes.FindAccount(accs, ownerAddr) + if !ok { + return none, sdkerrors.Wrap(err, "unknown contract owner address") + } + return simAccount, nil +} + +// DefaultSimulationExecutePayloader implements a bank msg to send the +// tokens from contract account back to original sender +func DefaultSimulationExecutePayloader(msg *types.MsgExecuteContract) error { + reflectSend := testdata.ReflectHandleMsg{ + Reflect: &testdata.ReflectPayload{ + Msgs: []wasmvmtypes.CosmosMsg{{ + Bank: &wasmvmtypes.BankMsg{ + Send: &wasmvmtypes.SendMsg{ + ToAddress: msg.Sender, // + Amount: wasmkeeper.ConvertSdkCoinsToWasmCoins(msg.Funds), + }, + }, + }}, + }, + } + reflectSendBz, err := json.Marshal(reflectSend) + if err != nil { + return err + } + msg.Msg = reflectSendBz + return nil +} diff --git a/x/wasm/simulation/params.go b/x/wasm/simulation/params.go index dcac18af09..177f23a779 100644 --- a/x/wasm/simulation/params.go +++ b/x/wasm/simulation/params.go @@ -12,7 +12,7 @@ import ( ) func ParamChanges(r *rand.Rand, cdc codec.Codec) []simtypes.ParamChange { - params := RandomParams(r) + params := types.DefaultParams() return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, string(types.ParamStoreKeyUploadAccess), func(r *rand.Rand) string { diff --git a/x/wasm/simulation/sim_utils.go b/x/wasm/simulation/sim_utils.go new file mode 100644 index 0000000000..7f5f9fde82 --- /dev/null +++ b/x/wasm/simulation/sim_utils.go @@ -0,0 +1,53 @@ +package simulation + +import ( + "github.com/line/lbm-sdk/simapp/helpers" + sdk "github.com/line/lbm-sdk/types" + simtypes "github.com/line/lbm-sdk/types/simulation" + "github.com/line/lbm-sdk/x/simulation" +) + +// GenAndDeliverTxWithRandFees generates a transaction with a random fee and delivers it. +func GenAndDeliverTxWithRandFees(txCtx simulation.OperationInput, gas uint64) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) + spendable := txCtx.Bankkeeper.SpendableCoins(txCtx.Context, account.GetAddress()) + + var fees sdk.Coins + var err error + + coins, hasNeg := spendable.SafeSub(txCtx.CoinsSpentInMsg) + if hasNeg { + return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "message doesn't leave room for fees"), nil, err + } + + fees, err = simtypes.RandomFees(txCtx.R, txCtx.Context, coins) + if err != nil { + return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate fees"), nil, err + } + return GenAndDeliverTx(txCtx, fees, gas) +} + +// GenAndDeliverTx generates a transactions and delivers it. +func GenAndDeliverTx(txCtx simulation.OperationInput, fees sdk.Coins, gas uint64) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) + tx, err := helpers.GenTx( + txCtx.TxGen, + []sdk.Msg{txCtx.Msg}, + fees, + gas, + txCtx.Context.ChainID(), + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + txCtx.SimAccount.PrivKey, + ) + if err != nil { + return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate mock tx"), nil, err + } + + _, _, err = txCtx.App.Deliver(txCtx.TxGen.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to deliver tx"), nil, err + } + + return simtypes.NewOperationMsg(txCtx.Msg, true, "", txCtx.Cdc), nil, nil +} diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go index a7012c26c6..a47d5f2741 100644 --- a/x/wasm/types/codec.go +++ b/x/wasm/types/codec.go @@ -16,6 +16,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { //nolint:staticcheck legacy.RegisterAminoMsg(cdc, &MsgStoreCode{}, "wasm/MsgStoreCode") legacy.RegisterAminoMsg(cdc, &MsgInstantiateContract{}, "wasm/MsgInstantiateContract") + legacy.RegisterAminoMsg(cdc, &MsgInstantiateContract2{}, "wasm/MsgInstantiateContract2") legacy.RegisterAminoMsg(cdc, &MsgExecuteContract{}, "wasm/MsgExecuteContract") legacy.RegisterAminoMsg(cdc, &MsgMigrateContract{}, "wasm/MsgMigrateContract") legacy.RegisterAminoMsg(cdc, &MsgUpdateAdmin{}, "wasm/MsgUpdateAdmin") @@ -40,6 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgStoreCode{}, &MsgInstantiateContract{}, + &MsgInstantiateContract2{}, &MsgExecuteContract{}, &MsgMigrateContract{}, &MsgUpdateAdmin{}, @@ -67,7 +69,10 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.NewLegacyAmino() + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/wasm module codec. + ModuleCdc = codec.NewAminoCodec(amino) ) diff --git a/x/wasm/types/errors.go b/x/wasm/types/errors.go index 5eafb527ad..b087d9ae21 100644 --- a/x/wasm/types/errors.go +++ b/x/wasm/types/errors.go @@ -55,7 +55,7 @@ var ( // ErrMaxIBCChannels error for maximum number of ibc channels reached ErrMaxIBCChannels = sdkErrors.Register(DefaultCodespace, 16, "max transfer channels") - // ErrUnsupportedForContract error when a feature is used that is not supported for/ by this contract + // ErrUnsupportedForContract error when a capability is used that is not supported for/ by this contract ErrUnsupportedForContract = sdkErrors.Register(DefaultCodespace, 17, "unsupported for this contract") // ErrPinContractFailed error for pinning contract failures diff --git a/x/wasm/types/events.go b/x/wasm/types/events.go index 5213ed143b..8aafb145a3 100644 --- a/x/wasm/types/events.go +++ b/x/wasm/types/events.go @@ -23,9 +23,11 @@ const ( const ( AttributeReservedPrefix = "_" - AttributeKeyContractAddr = "_contract_address" - AttributeKeyCodeID = "code_id" - AttributeKeyCodeIDs = "code_ids" - AttributeKeyResultDataHex = "result" - AttributeKeyFeature = "feature" + AttributeKeyContractAddr = "_contract_address" + AttributeKeyCodeID = "code_id" + AttributeKeyCodeIDs = "code_ids" + AttributeKeyChecksum = "code_checksum" + AttributeKeyResultDataHex = "result" + AttributeKeyFeature = "feature" + AttributeKeyRequiredCapability = "required_capability" ) diff --git a/x/wasm/types/expected_keepers.go b/x/wasm/types/expected_keepers.go index 20e5f0e13a..0e04ea1ece 100644 --- a/x/wasm/types/expected_keepers.go +++ b/x/wasm/types/expected_keepers.go @@ -17,6 +17,7 @@ import ( type BankViewKeeper interface { GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetSupply(ctx sdk.Context, denom string) sdk.Coin } // Burner is a subset of the sdk bank keeper methods diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index 1a8a0f4328..c2f721ef5e 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -20,6 +20,7 @@ type ViewKeeper interface { IterateCodeInfos(ctx sdk.Context, cb func(uint64, CodeInfo) bool) GetByteCode(ctx sdk.Context, codeID uint64) ([]byte, error) IsPinnedCode(ctx sdk.Context, codeID uint64) bool + GetParams(ctx sdk.Context) Params IterateInactiveContracts(ctx sdk.Context, fn func(contractAddress sdk.AccAddress) bool) IsInactiveContract(ctx sdk.Context, contractAddress sdk.AccAddress) bool } @@ -27,10 +28,29 @@ type ViewKeeper interface { // ContractOpsKeeper contains mutable operations on a contract. type ContractOpsKeeper interface { // Create uploads and compiles a WASM contract, returning a short identifier for the contract - Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *AccessConfig) (codeID uint64, err error) + Create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte, instantiateAccess *AccessConfig) (codeID uint64, checksum []byte, err error) - // Instantiate creates an instance of a WASM contract - Instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins) (sdk.AccAddress, []byte, error) + // Instantiate creates an instance of a WASM contract using the classic sequence based address generator + Instantiate( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, + ) (sdk.AccAddress, []byte, error) + + // Instantiate2 creates an instance of a WASM contract using the predictable address generator + Instantiate2( + ctx sdk.Context, + codeID uint64, + creator, admin sdk.AccAddress, + initMsg []byte, + label string, + deposit sdk.Coins, + salt []byte, + fixMsg bool, + ) (sdk.AccAddress, []byte, error) // Execute executes the contract instance Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) @@ -57,7 +77,7 @@ type ContractOpsKeeper interface { SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra ContractInfoExtension) error // SetAccessConfig updates the access config of a code id. - SetAccessConfig(ctx sdk.Context, codeID uint64, config AccessConfig) error + SetAccessConfig(ctx sdk.Context, codeID uint64, caller sdk.AccAddress, newConfig AccessConfig) error // DeactivateContract add the contract address to inactive contract list. DeactivateContract(ctx sdk.Context, contractAddress sdk.AccAddress) error diff --git a/x/wasm/types/params.go b/x/wasm/types/params.go index 7a7378cdb8..7f3ae6fb91 100644 --- a/x/wasm/types/params.go +++ b/x/wasm/types/params.go @@ -52,20 +52,33 @@ var ParamStoreKeyCompileCost = []byte("compileCost") var AllAccessTypes = []AccessType{ AccessTypeNobody, AccessTypeOnlyAddress, + AccessTypeAnyOfAddresses, AccessTypeEverybody, } -func (a AccessType) With(addr sdk.AccAddress) AccessConfig { +func (a AccessType) With(addrs ...sdk.AccAddress) AccessConfig { switch a { case AccessTypeNobody: return AllowNobody case AccessTypeOnlyAddress: - if err := sdk.VerifyAddressFormat(addr); err != nil { + if n := len(addrs); n != 1 { + panic(fmt.Sprintf("expected exactly 1 address but got %d", n)) + } + if err := sdk.VerifyAddressFormat(addrs[0]); err != nil { panic(err) } - return AccessConfig{Permission: AccessTypeOnlyAddress, Address: addr.String()} + return AccessConfig{Permission: AccessTypeOnlyAddress, Address: addrs[0].String()} case AccessTypeEverybody: return AllowEverybody + case AccessTypeAnyOfAddresses: + bech32Addrs := make([]string, len(addrs)) + for i, v := range addrs { + bech32Addrs[i] = v.String() + } + if err := assertValidAddresses(bech32Addrs); err != nil { + panic(sdkerrors.Wrap(err, "addresses")) + } + return AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: bech32Addrs} } panic("unsupported access type") } @@ -78,6 +91,8 @@ func (a AccessType) String() string { return "OnlyAddress" case AccessTypeEverybody: return "Everybody" + case AccessTypeAnyOfAddresses: + return "AnyOfAddresses" } return "Unspecified" } @@ -185,6 +200,7 @@ func validateAccessType(i interface{}) error { return sdkerrors.Wrapf(ErrInvalid, "unknown type: %q", a) } +// ValidateBasic performs basic validation func (a AccessConfig) ValidateBasic() error { switch a.Permission { case AccessTypeUnspecified: @@ -195,8 +211,16 @@ func (a AccessConfig) ValidateBasic() error { } return nil case AccessTypeOnlyAddress: + if len(a.Addresses) != 0 { + return ErrInvalid.Wrap("addresses field set") + } _, err := sdk.AccAddressFromBech32(a.Address) return err + case AccessTypeAnyOfAddresses: + if a.Address != "" { + return ErrInvalid.Wrap("address field set") + } + return sdkerrors.Wrap(assertValidAddresses(a.Addresses), "addresses") } return sdkerrors.Wrapf(ErrInvalid, "unknown type: %q", a.Permission) } @@ -234,6 +258,25 @@ func validateCompileCost(i interface{}) error { return nil } +func assertValidAddresses(addrs []string) error { + if len(addrs) == 0 { + return ErrEmpty + } + idx := make(map[string]struct{}, len(addrs)) + for _, a := range addrs { + if _, err := sdk.AccAddressFromBech32(a); err != nil { + return sdkerrors.Wrapf(err, "address: %s", a) + } + if _, exists := idx[a]; exists { + return ErrDuplicate.Wrapf("address: %s", a) + } + idx[a] = struct{}{} + } + return nil +} + +// Allowed returns if permission includes the actor. +// Actor address must be valid and not nil func (a AccessConfig) Allowed(actor sdk.AccAddress) bool { switch a.Permission { case AccessTypeNobody: @@ -242,6 +285,13 @@ func (a AccessConfig) Allowed(actor sdk.AccAddress) bool { return true case AccessTypeOnlyAddress: return a.Address == actor.String() + case AccessTypeAnyOfAddresses: + for _, v := range a.Addresses { + if v == actor.String() { + return true + } + } + return false default: panic("unknown type") } diff --git a/x/wasm/types/params_test.go b/x/wasm/types/params_test.go index f5a35f2c65..10c23c9ee0 100644 --- a/x/wasm/types/params_test.go +++ b/x/wasm/types/params_test.go @@ -1,6 +1,7 @@ package types import ( + "bytes" "encoding/json" "testing" @@ -15,6 +16,7 @@ import ( func TestValidateParams(t *testing.T) { var ( anyAddress sdk.AccAddress = make([]byte, ContractAddrLen) + otherAddress sdk.AccAddress = bytes.Repeat([]byte{1}, ContractAddrLen) invalidAddress = "invalid address" ) @@ -52,6 +54,18 @@ func TestValidateParams(t *testing.T) { CompileCost: DefaultCompileCost, }, }, + "all good with anyOf address": { + src: Params{ + CodeUploadAccess: AccessTypeAnyOfAddresses.With(anyAddress), + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + }, + "all good with anyOf addresses": { + src: Params{ + CodeUploadAccess: AccessTypeAnyOfAddresses.With(anyAddress, otherAddress), + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + }, "reject empty type in instantiate permission": { src: Params{ CodeUploadAccess: AllowNobody, @@ -81,6 +95,13 @@ func TestValidateParams(t *testing.T) { }, expErr: true, }, + "reject wrong field addresses in only address": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeOnlyAddress, Address: anyAddress.String(), Addresses: []string{anyAddress.String()}}, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + }, + expErr: true, + }, "reject CodeUploadAccess Everybody with obsolete address": { src: Params{ CodeUploadAccess: AccessConfig{Permission: AccessTypeEverybody, Address: anyAddress.String()}, @@ -120,6 +141,41 @@ func TestValidateParams(t *testing.T) { }, expErr: true, }, + "reject empty addresses in any of addresses": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{}}, + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + expErr: true, + }, + "reject addresses not set in any of addresses": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeAnyOfAddresses}, + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + expErr: true, + }, + "reject invalid address in any of addresses": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{invalidAddress}}, + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + expErr: true, + }, + "reject duplicate address in any of addresses": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{anyAddress.String(), anyAddress.String()}}, + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + expErr: true, + }, + "reject wrong field address in any of addresses": { + src: Params{ + CodeUploadAccess: AccessConfig{Permission: AccessTypeAnyOfAddresses, Address: anyAddress.String(), Addresses: []string{anyAddress.String()}}, + InstantiateDefaultPermission: AccessTypeAnyOfAddresses, + }, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -138,11 +194,12 @@ func TestAccessTypeMarshalJson(t *testing.T) { src AccessType exp string }{ - "Unspecified": {src: AccessTypeUnspecified, exp: `"Unspecified"`}, - "Nobody": {src: AccessTypeNobody, exp: `"Nobody"`}, - "OnlyAddress": {src: AccessTypeOnlyAddress, exp: `"OnlyAddress"`}, - "Everybody": {src: AccessTypeEverybody, exp: `"Everybody"`}, - "unknown": {src: 999, exp: `"Unspecified"`}, + "Unspecified": {src: AccessTypeUnspecified, exp: `"Unspecified"`}, + "Nobody": {src: AccessTypeNobody, exp: `"Nobody"`}, + "OnlyAddress": {src: AccessTypeOnlyAddress, exp: `"OnlyAddress"`}, + "AccessTypeAnyOfAddresses": {src: AccessTypeAnyOfAddresses, exp: `"AnyOfAddresses"`}, + "Everybody": {src: AccessTypeEverybody, exp: `"Everybody"`}, + "unknown": {src: 999, exp: `"Unspecified"`}, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -158,11 +215,12 @@ func TestAccessTypeUnmarshalJson(t *testing.T) { src string exp AccessType }{ - "Unspecified": {src: `"Unspecified"`, exp: AccessTypeUnspecified}, - "Nobody": {src: `"Nobody"`, exp: AccessTypeNobody}, - "OnlyAddress": {src: `"OnlyAddress"`, exp: AccessTypeOnlyAddress}, - "Everybody": {src: `"Everybody"`, exp: AccessTypeEverybody}, - "unknown": {src: `""`, exp: AccessTypeUnspecified}, + "Unspecified": {src: `"Unspecified"`, exp: AccessTypeUnspecified}, + "Nobody": {src: `"Nobody"`, exp: AccessTypeNobody}, + "OnlyAddress": {src: `"OnlyAddress"`, exp: AccessTypeOnlyAddress}, + "AnyOfAddresses": {src: `"AnyOfAddresses"`, exp: AccessTypeAnyOfAddresses}, + "Everybody": {src: `"Everybody"`, exp: AccessTypeEverybody}, + "unknown": {src: `""`, exp: AccessTypeUnspecified}, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -200,3 +258,83 @@ func TestParamsUnmarshalJson(t *testing.T) { }) } } + +func TestAccessTypeWith(t *testing.T) { + myAddress := sdk.AccAddress(randBytes(SDKAddrLen)) + myOtherAddress := sdk.AccAddress(randBytes(SDKAddrLen)) + specs := map[string]struct { + src AccessType + addrs []sdk.AccAddress + exp AccessConfig + expPanic bool + }{ + "nobody": { + src: AccessTypeNobody, + exp: AccessConfig{Permission: AccessTypeNobody}, + }, + "nobody with address": { + src: AccessTypeNobody, + addrs: []sdk.AccAddress{myAddress}, + exp: AccessConfig{Permission: AccessTypeNobody}, + }, + "everybody": { + src: AccessTypeEverybody, + exp: AccessConfig{Permission: AccessTypeEverybody}, + }, + "everybody with address": { + src: AccessTypeEverybody, + addrs: []sdk.AccAddress{myAddress}, + exp: AccessConfig{Permission: AccessTypeEverybody}, + }, + "only address without address": { + src: AccessTypeOnlyAddress, + expPanic: true, + }, + "only address with address": { + src: AccessTypeOnlyAddress, + addrs: []sdk.AccAddress{myAddress}, + exp: AccessConfig{Permission: AccessTypeOnlyAddress, Address: myAddress.String()}, + }, + "only address with invalid address": { + src: AccessTypeOnlyAddress, + addrs: []sdk.AccAddress{nil}, + expPanic: true, + }, + "any of address without address": { + src: AccessTypeAnyOfAddresses, + expPanic: true, + }, + "any of address with single address": { + src: AccessTypeAnyOfAddresses, + addrs: []sdk.AccAddress{myAddress}, + exp: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{myAddress.String()}}, + }, + "any of address with multiple addresses": { + src: AccessTypeAnyOfAddresses, + addrs: []sdk.AccAddress{myAddress, myOtherAddress}, + exp: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{myAddress.String(), myOtherAddress.String()}}, + }, + "any of address with duplicate addresses": { + src: AccessTypeAnyOfAddresses, + addrs: []sdk.AccAddress{myAddress, myAddress}, + expPanic: true, + }, + "any of address with invalid address": { + src: AccessTypeAnyOfAddresses, + addrs: []sdk.AccAddress{nil}, + expPanic: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + if !spec.expPanic { + got := spec.src.With(spec.addrs...) + assert.Equal(t, spec.exp, got) + return + } + assert.Panics(t, func() { + spec.src.With(spec.addrs...) + }) + }) + } +} diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 2c8bdfe7df..0aa92f9163 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -160,7 +160,7 @@ func (p InstantiateContractProposal) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "code id is required") } - if err := validateLabel(p.Label); err != nil { + if err := ValidateLabel(p.Label); err != nil { return err } diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index 21d9bcb216..41c1e40932 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -38,6 +38,8 @@ type StoreCodeProposal struct { WASMByteCode []byte `protobuf:"bytes,4,opt,name=wasm_byte_code,json=wasmByteCode,proto3" json:"wasm_byte_code,omitempty"` // InstantiatePermission to apply on contract creation, optional InstantiatePermission *AccessConfig `protobuf:"bytes,7,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission,omitempty"` + // UnpinCode code on upload, optional + UnpinCode bool `protobuf:"varint,8,opt,name=unpin_code,json=unpinCode,proto3" json:"unpin_code,omitempty"` } func (m *StoreCodeProposal) Reset() { *m = StoreCodeProposal{} } @@ -539,58 +541,60 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 815 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0xce, 0x34, 0x89, 0x93, 0x4e, 0x23, 0x08, 0xde, 0xb4, 0x1b, 0x0a, 0xb2, 0x23, 0x2f, 0x42, - 0x91, 0x10, 0xb6, 0x52, 0x24, 0x04, 0xdc, 0xea, 0x80, 0x44, 0x57, 0xaa, 0x54, 0xb9, 0xaa, 0x90, - 0x00, 0x61, 0x4d, 0xec, 0xa9, 0x77, 0x84, 0x3d, 0x63, 0x79, 0x26, 0xed, 0xf6, 0x3f, 0x70, 0xe0, - 0x80, 0x38, 0xf1, 0x03, 0x10, 0x17, 0xc4, 0x9d, 0x2b, 0x52, 0x8f, 0x7b, 0xdc, 0x93, 0x61, 0xd3, - 0x7f, 0xd0, 0x23, 0x12, 0x12, 0x9a, 0x19, 0xa7, 0xa4, 0x5d, 0x9a, 0x5d, 0xc4, 0x06, 0x89, 0x8b, - 0xe5, 0xf1, 0x7b, 0x6f, 0xbe, 0x6f, 0x3e, 0x7d, 0x6f, 0x9e, 0xa1, 0x1d, 0x31, 0x9e, 0x9d, 0x22, - 0x9e, 0x79, 0xea, 0x71, 0x32, 0xf2, 0xf2, 0x82, 0xe5, 0x8c, 0xa3, 0xd4, 0xcd, 0x0b, 0x26, 0x98, - 0xd9, 0x9d, 0x27, 0xb8, 0xea, 0x71, 0x32, 0xda, 0xee, 0x25, 0x2c, 0x61, 0x2a, 0xe8, 0xc9, 0x37, - 0x9d, 0xb7, 0x6d, 0xc9, 0x3c, 0xc6, 0xbd, 0x09, 0xe2, 0xd8, 0x3b, 0x19, 0x4d, 0xb0, 0x40, 0x23, - 0x2f, 0x62, 0x84, 0x56, 0xf1, 0xd7, 0x9f, 0x02, 0x12, 0x67, 0x39, 0xe6, 0x3a, 0xea, 0xfc, 0x01, - 0xe0, 0x2b, 0x87, 0x82, 0x15, 0x78, 0xcc, 0x62, 0x7c, 0x50, 0x31, 0x30, 0x7b, 0xb0, 0x29, 0x88, - 0x48, 0x71, 0x1f, 0x0c, 0xc0, 0x70, 0x3d, 0xd0, 0x0b, 0x73, 0x00, 0x37, 0x62, 0xcc, 0xa3, 0x82, - 0xe4, 0x82, 0x30, 0xda, 0x5f, 0x53, 0xb1, 0xc5, 0x4f, 0xe6, 0x26, 0x34, 0x8a, 0x29, 0x0d, 0x11, - 0xef, 0xd7, 0x75, 0x61, 0x31, 0xa5, 0xbb, 0xdc, 0x7c, 0x17, 0xbe, 0x24, 0xb1, 0xc3, 0xc9, 0x99, - 0xc0, 0x61, 0xc4, 0x62, 0xdc, 0x6f, 0x0c, 0xc0, 0xb0, 0xe3, 0x77, 0x67, 0xa5, 0xdd, 0xf9, 0x64, - 0xf7, 0x70, 0xdf, 0x3f, 0x13, 0x8a, 0x40, 0xd0, 0x91, 0x79, 0xf3, 0x95, 0x79, 0x04, 0xb7, 0x08, - 0xe5, 0x02, 0x51, 0x41, 0x90, 0xc0, 0x61, 0x8e, 0x8b, 0x8c, 0x70, 0x2e, 0xb1, 0x5b, 0x03, 0x30, - 0xdc, 0xd8, 0xb1, 0xdc, 0x9b, 0x1a, 0xb9, 0xbb, 0x51, 0x84, 0x39, 0x1f, 0x33, 0x7a, 0x4c, 0x92, - 0x60, 0x73, 0xa1, 0xfa, 0xe0, 0xaa, 0xf8, 0x7e, 0xa3, 0xdd, 0xec, 0x1a, 0xf7, 0x1b, 0x6d, 0xa3, - 0xdb, 0x72, 0x7e, 0x59, 0x83, 0xaf, 0xed, 0xfd, 0x95, 0x35, 0x66, 0x54, 0x14, 0x28, 0x12, 0xab, - 0x52, 0xa2, 0x07, 0x9b, 0x28, 0xce, 0x08, 0x55, 0x02, 0xac, 0x07, 0x7a, 0x61, 0xde, 0x83, 0x2d, - 0xa9, 0x4a, 0x48, 0xe2, 0x7e, 0x73, 0x00, 0x86, 0x0d, 0x1f, 0xce, 0x4a, 0xdb, 0x90, 0x12, 0xec, - 0x7d, 0x18, 0x18, 0x32, 0xb4, 0x17, 0xcb, 0xd2, 0x14, 0x4d, 0x70, 0xda, 0x37, 0x74, 0xa9, 0x5a, - 0x98, 0x43, 0x58, 0xcf, 0x78, 0xa2, 0xf4, 0xe8, 0xf8, 0x5b, 0xbf, 0x97, 0xb6, 0x19, 0xa0, 0xd3, - 0xf9, 0x29, 0xf6, 0x31, 0xe7, 0x28, 0xc1, 0x81, 0x4c, 0x31, 0x3f, 0x87, 0xcd, 0xe3, 0x29, 0x8d, - 0x79, 0xbf, 0x3d, 0xa8, 0x0f, 0x37, 0x76, 0x5e, 0x75, 0xb5, 0x6f, 0x5c, 0xe9, 0x1b, 0xb7, 0xf2, - 0x8d, 0x3b, 0x66, 0x84, 0xfa, 0x6f, 0x9d, 0x97, 0x76, 0xed, 0x87, 0x5f, 0xed, 0x7b, 0x09, 0x11, - 0x0f, 0xa6, 0x13, 0x37, 0x62, 0x99, 0x97, 0x12, 0x8a, 0xbd, 0x74, 0x92, 0xbd, 0xcd, 0xe3, 0x2f, - 0x2b, 0x03, 0xc9, 0x5c, 0x1e, 0xe8, 0x4d, 0x9d, 0x9f, 0x01, 0xbc, 0xbb, 0x4f, 0x92, 0xe2, 0x45, - 0x6a, 0xb8, 0x0d, 0xdb, 0x51, 0xb5, 0x57, 0xa5, 0xd7, 0xd5, 0xfa, 0xf9, 0x24, 0xab, 0xc4, 0x31, - 0x9e, 0x29, 0x8e, 0xf3, 0x0d, 0x80, 0xbd, 0xc3, 0x69, 0xcc, 0x56, 0xc2, 0xbd, 0x7e, 0x83, 0x7b, - 0x45, 0xab, 0xf1, 0x6c, 0x5a, 0x5f, 0xad, 0xc1, 0xbb, 0x1f, 0x3d, 0xc4, 0xd1, 0x74, 0xf5, 0xce, - 0x5c, 0x26, 0x76, 0x45, 0xb8, 0xf9, 0x0f, 0x4c, 0x66, 0xac, 0xc2, 0x64, 0xdf, 0x01, 0x78, 0xe7, - 0x28, 0x8f, 0x91, 0xc0, 0xbb, 0xb2, 0x6f, 0xfe, 0xb5, 0x14, 0x23, 0xb8, 0x4e, 0xf1, 0x69, 0xa8, - 0x3b, 0x52, 0xa9, 0xe1, 0xf7, 0x2e, 0x4b, 0xbb, 0x7b, 0x86, 0xb2, 0xf4, 0x03, 0xe7, 0x2a, 0xe4, - 0x04, 0x6d, 0x8a, 0x4f, 0x15, 0xe4, 0x32, 0x99, 0x9c, 0x07, 0xd0, 0x1c, 0xa7, 0x18, 0x15, 0x2f, - 0x86, 0xdc, 0x12, 0x07, 0x39, 0x3f, 0x02, 0xd8, 0x3d, 0x20, 0x54, 0xda, 0x9d, 0x5f, 0x01, 0xbd, - 0x79, 0x0d, 0xc8, 0xef, 0x5e, 0x96, 0x76, 0x47, 0x9f, 0x44, 0x7d, 0x76, 0xe6, 0xd0, 0xef, 0xfd, - 0x0d, 0xb4, 0xbf, 0x75, 0x59, 0xda, 0xa6, 0xce, 0x5e, 0x08, 0x3a, 0xd7, 0x29, 0xbd, 0x2f, 0x29, - 0xa9, 0xa6, 0x93, 0xe6, 0xa9, 0x0f, 0x1b, 0xbe, 0x35, 0x2b, 0xed, 0x96, 0xee, 0x3a, 0x7e, 0x59, - 0xda, 0x2f, 0xeb, 0x1d, 0xe6, 0x49, 0x4e, 0xd0, 0xd2, 0x9d, 0xc8, 0x9d, 0x9f, 0x00, 0x34, 0x8f, - 0x68, 0xfe, 0xbf, 0xe2, 0xfc, 0x2d, 0x80, 0xe6, 0xe2, 0x3c, 0xd1, 0xd6, 0x5b, 0xbc, 0x7a, 0xc0, - 0xad, 0x57, 0xcf, 0x67, 0xb7, 0x8e, 0xae, 0xb5, 0xe7, 0x19, 0x5d, 0x7e, 0x43, 0xb6, 0xc7, 0x2d, - 0x03, 0xcc, 0xb9, 0x00, 0xd0, 0xd6, 0x64, 0xae, 0x8f, 0xae, 0x63, 0x92, 0xfc, 0x87, 0xca, 0x7e, - 0x01, 0x37, 0x91, 0xa2, 0x1c, 0x46, 0x0a, 0x3a, 0x9c, 0x2a, 0x4a, 0x5a, 0xe6, 0x8d, 0x9d, 0x37, - 0x96, 0x9f, 0x50, 0xf3, 0xaf, 0xce, 0x79, 0x07, 0x3d, 0x15, 0xe1, 0xfe, 0xc7, 0xe7, 0x4f, 0xac, - 0xda, 0xe3, 0x27, 0x56, 0xed, 0xfb, 0x99, 0x05, 0xce, 0x67, 0x16, 0x78, 0x34, 0xb3, 0xc0, 0x6f, - 0x33, 0x0b, 0x7c, 0x7d, 0x61, 0xd5, 0x1e, 0x5d, 0x58, 0xb5, 0xc7, 0x17, 0x56, 0xed, 0x53, 0xe7, - 0xe6, 0xfd, 0x21, 0xc1, 0x62, 0xef, 0xa1, 0xfe, 0xdb, 0x51, 0x97, 0xc8, 0xc4, 0x50, 0xff, 0x3a, - 0xef, 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0x64, 0x4e, 0x2a, 0x98, 0x74, 0x09, 0x00, 0x00, + // 833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xce, 0xe4, 0x87, 0x93, 0x4e, 0x23, 0x08, 0xde, 0xb4, 0x1b, 0x0a, 0xd8, 0x91, 0x17, 0xa1, + 0x48, 0x08, 0x5b, 0x29, 0x12, 0x02, 0x6e, 0x75, 0x40, 0xa2, 0x2b, 0x55, 0xaa, 0x5c, 0x55, 0x48, + 0x80, 0x88, 0x26, 0xf6, 0xd4, 0x3b, 0xc2, 0x9e, 0xb1, 0x3c, 0xe3, 0x76, 0xfb, 0x3f, 0x70, 0xe0, + 0x80, 0x38, 0xed, 0x1f, 0x80, 0xb8, 0x20, 0xee, 0x5c, 0x91, 0x7a, 0xdc, 0xe3, 0x9e, 0x0c, 0x9b, + 0xfe, 0x07, 0x3d, 0x72, 0x42, 0x33, 0xe3, 0x94, 0xb4, 0x4b, 0xbb, 0x8b, 0x68, 0x91, 0xf6, 0x12, + 0x65, 0xe6, 0xbd, 0x99, 0xef, 0x9b, 0x4f, 0xdf, 0x7b, 0xcf, 0xd0, 0x0e, 0x19, 0x4f, 0x8f, 0x10, + 0x4f, 0x3d, 0xf5, 0x73, 0x38, 0xf6, 0xb2, 0x9c, 0x65, 0x8c, 0xa3, 0xc4, 0xcd, 0x72, 0x26, 0x98, + 0xd9, 0x5b, 0x24, 0xb8, 0xea, 0xe7, 0x70, 0xbc, 0xd1, 0x8f, 0x59, 0xcc, 0x54, 0xd0, 0x93, 0xff, + 0x74, 0xde, 0x86, 0x25, 0xf3, 0x18, 0xf7, 0x66, 0x88, 0x63, 0xef, 0x70, 0x3c, 0xc3, 0x02, 0x8d, + 0xbd, 0x90, 0x11, 0x5a, 0xc5, 0xdf, 0x7c, 0x06, 0x48, 0x1c, 0x67, 0x98, 0xeb, 0xa8, 0xf3, 0xa8, + 0x0e, 0x5f, 0xdb, 0x13, 0x2c, 0xc7, 0x13, 0x16, 0xe1, 0xdd, 0x8a, 0x81, 0xd9, 0x87, 0x2d, 0x41, + 0x44, 0x82, 0x07, 0x60, 0x08, 0x46, 0x2b, 0x81, 0x5e, 0x98, 0x43, 0xb8, 0x1a, 0x61, 0x1e, 0xe6, + 0x24, 0x13, 0x84, 0xd1, 0x41, 0x5d, 0xc5, 0x96, 0xb7, 0xcc, 0x35, 0x68, 0xe4, 0x05, 0x9d, 0x22, + 0x3e, 0x68, 0xe8, 0x83, 0x79, 0x41, 0xb7, 0xb8, 0xf9, 0x01, 0x7c, 0x45, 0x62, 0x4f, 0x67, 0xc7, + 0x02, 0x4f, 0x43, 0x16, 0xe1, 0x41, 0x73, 0x08, 0x46, 0x5d, 0xbf, 0x37, 0x2f, 0xed, 0xee, 0xe7, + 0x5b, 0x7b, 0x3b, 0xfe, 0xb1, 0x50, 0x04, 0x82, 0xae, 0xcc, 0x5b, 0xac, 0xcc, 0x7d, 0xb8, 0x4e, + 0x28, 0x17, 0x88, 0x0a, 0x82, 0x04, 0x9e, 0x66, 0x38, 0x4f, 0x09, 0xe7, 0x12, 0xbb, 0x3d, 0x04, + 0xa3, 0xd5, 0x4d, 0xcb, 0xbd, 0xac, 0x91, 0xbb, 0x15, 0x86, 0x98, 0xf3, 0x09, 0xa3, 0x07, 0x24, + 0x0e, 0xd6, 0x96, 0x4e, 0xef, 0x9e, 0x1f, 0x36, 0xdf, 0x82, 0xb0, 0xa0, 0x19, 0xa1, 0x9a, 0x4a, + 0x67, 0x08, 0x46, 0x9d, 0x60, 0x45, 0xed, 0x48, 0xd4, 0xfb, 0xcd, 0x4e, 0xab, 0x67, 0xdc, 0x6f, + 0x76, 0x8c, 0x5e, 0xdb, 0xf9, 0xad, 0x0e, 0xdf, 0xd8, 0xfe, 0xfb, 0x92, 0x09, 0xa3, 0x22, 0x47, + 0xa1, 0xb8, 0x2d, 0xa1, 0xfa, 0xb0, 0x85, 0xa2, 0x94, 0x50, 0xa5, 0xcf, 0x4a, 0xa0, 0x17, 0xe6, + 0x3d, 0xd8, 0x96, 0x4c, 0xa7, 0x24, 0x1a, 0xb4, 0x86, 0x60, 0xd4, 0xf4, 0xe1, 0xbc, 0xb4, 0x0d, + 0xc9, 0x75, 0xfb, 0x93, 0xc0, 0x90, 0xa1, 0xed, 0x48, 0x1e, 0x4d, 0xd0, 0x0c, 0x27, 0x03, 0x43, + 0x1f, 0x55, 0x0b, 0x73, 0x04, 0x1b, 0x29, 0x8f, 0x95, 0x5c, 0x5d, 0x7f, 0xfd, 0xcf, 0xd2, 0x36, + 0x03, 0x74, 0xb4, 0x78, 0xc5, 0x0e, 0xe6, 0x1c, 0xc5, 0x38, 0x90, 0x29, 0xe6, 0x57, 0xb0, 0x75, + 0x50, 0xd0, 0x88, 0x0f, 0x3a, 0xc3, 0xc6, 0x68, 0x75, 0xf3, 0x75, 0x57, 0xdb, 0xca, 0x95, 0xb6, + 0x72, 0x2b, 0x5b, 0xb9, 0x13, 0x46, 0xa8, 0xff, 0xee, 0x49, 0x69, 0xd7, 0x7e, 0xfa, 0xdd, 0xbe, + 0x17, 0x13, 0xf1, 0xa0, 0x98, 0xb9, 0x21, 0x4b, 0xbd, 0x84, 0x50, 0xec, 0x25, 0xb3, 0xf4, 0x3d, + 0x1e, 0x7d, 0x53, 0xf9, 0x4b, 0xe6, 0xf2, 0x40, 0x5f, 0xea, 0xfc, 0x0a, 0xe0, 0xdd, 0x1d, 0x12, + 0xe7, 0x37, 0xa9, 0xe1, 0x06, 0xec, 0x84, 0xd5, 0x5d, 0x95, 0x5e, 0xe7, 0xeb, 0x17, 0x93, 0xac, + 0x12, 0xc7, 0x78, 0xae, 0x38, 0xce, 0xf7, 0x00, 0xf6, 0xf7, 0x8a, 0x88, 0xdd, 0x0a, 0xf7, 0xc6, + 0x25, 0xee, 0x15, 0xad, 0xe6, 0xf3, 0x69, 0x7d, 0x5b, 0x87, 0x77, 0x3f, 0x7d, 0x88, 0xc3, 0xe2, + 0xf6, 0x9d, 0x79, 0x9d, 0xd8, 0x15, 0xe1, 0xd6, 0xbf, 0x30, 0x99, 0x71, 0x1b, 0x26, 0x7b, 0x04, + 0xe0, 0x9d, 0xfd, 0x2c, 0x42, 0x02, 0x6f, 0xc9, 0xba, 0xf9, 0xcf, 0x52, 0x8c, 0xe1, 0x0a, 0xc5, + 0x47, 0x53, 0x5d, 0x91, 0x4a, 0x0d, 0xbf, 0x7f, 0x56, 0xda, 0xbd, 0x63, 0x94, 0x26, 0x1f, 0x3b, + 0xe7, 0x21, 0x27, 0xe8, 0x50, 0x7c, 0xa4, 0x20, 0xaf, 0x93, 0xc9, 0x79, 0x00, 0xcd, 0x49, 0x82, + 0x51, 0x7e, 0x33, 0xe4, 0xae, 0x71, 0x90, 0xf3, 0x33, 0x80, 0xbd, 0x5d, 0xdd, 0xcd, 0xf8, 0x39, + 0xd0, 0x3b, 0x17, 0x80, 0xfc, 0xde, 0x59, 0x69, 0x77, 0xf5, 0x4b, 0xd4, 0xb6, 0xb3, 0x80, 0xfe, + 0xf0, 0x1f, 0xa0, 0xfd, 0xf5, 0xb3, 0xd2, 0x36, 0x75, 0xf6, 0x52, 0xd0, 0xb9, 0x48, 0xe9, 0x23, + 0x49, 0x49, 0x15, 0x9d, 0x34, 0x4f, 0x63, 0xd4, 0xf4, 0xad, 0x79, 0x69, 0xb7, 0x75, 0xd5, 0xf1, + 0xb3, 0xd2, 0x7e, 0x55, 0xdf, 0xb0, 0x48, 0x72, 0x82, 0xb6, 0xae, 0x44, 0xee, 0xfc, 0x02, 0xa0, + 0xb9, 0xbf, 0xe8, 0xc0, 0x2f, 0x09, 0xe7, 0x1f, 0x00, 0x34, 0x97, 0xc7, 0x8d, 0xb6, 0xde, 0x72, + 0xeb, 0x01, 0x57, 0xb6, 0x9e, 0x2f, 0xaf, 0x9c, 0x6c, 0xf5, 0x17, 0x99, 0x6c, 0x7e, 0x53, 0x96, + 0xc7, 0x15, 0xf3, 0xcd, 0x39, 0x05, 0xd0, 0xd6, 0x64, 0x2e, 0x8e, 0xae, 0x03, 0x12, 0xff, 0x8f, + 0xca, 0x7e, 0x0d, 0xd7, 0x90, 0xa2, 0x3c, 0x0d, 0x15, 0xf4, 0xb4, 0x50, 0x94, 0xb4, 0xcc, 0xab, + 0x9b, 0x6f, 0x5f, 0xff, 0x42, 0xcd, 0xbf, 0x7a, 0xe7, 0x1d, 0xf4, 0x4c, 0x84, 0xfb, 0x9f, 0x9d, + 0x3c, 0xb5, 0x6a, 0x4f, 0x9e, 0x5a, 0xb5, 0x1f, 0xe7, 0x16, 0x38, 0x99, 0x5b, 0xe0, 0xf1, 0xdc, + 0x02, 0x7f, 0xcc, 0x2d, 0xf0, 0xdd, 0xa9, 0x55, 0x7b, 0x7c, 0x6a, 0xd5, 0x9e, 0x9c, 0x5a, 0xb5, + 0x2f, 0x9c, 0xcb, 0xfd, 0x43, 0x82, 0x45, 0xde, 0x43, 0xfd, 0x31, 0xa4, 0x9a, 0xc8, 0xcc, 0x50, + 0x9f, 0x42, 0xef, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0x84, 0xae, 0x6e, 0x5d, 0x93, 0x09, 0x00, + 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -627,6 +631,9 @@ func (this *StoreCodeProposal) Equal(that interface{}) bool { if !this.InstantiatePermission.Equal(that1.InstantiatePermission) { return false } + if this.UnpinCode != that1.UnpinCode { + return false + } return true } func (this *InstantiateContractProposal) Equal(that interface{}) bool { @@ -1007,6 +1014,16 @@ func (m *StoreCodeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.UnpinCode { + i-- + if m.UnpinCode { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } if m.InstantiatePermission != nil { { size, err := m.InstantiatePermission.MarshalToSizedBuffer(dAtA[:i]) @@ -1644,6 +1661,9 @@ func (m *StoreCodeProposal) Size() (n int) { l = m.InstantiatePermission.Size() n += 1 + l + sovProposal(uint64(l)) } + if m.UnpinCode { + n += 2 + } return n } @@ -2109,6 +2129,26 @@ func (m *StoreCodeProposal) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnpinCode", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnpinCode = bool(v != 0) default: iNdEx = preIndex skippy, err := skipProposal(dAtA[iNdEx:]) diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index ba70d57d94..3300614198 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -803,6 +803,82 @@ func (m *QueryPinnedCodesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPinnedCodesResponse proto.InternalMessageInfo +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9677c207036b9f2b, []int{19} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9677c207036b9f2b, []int{20} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryContractInfoRequest)(nil), "cosmwasm.wasm.v1.QueryContractInfoRequest") proto.RegisterType((*QueryContractInfoResponse)(nil), "cosmwasm.wasm.v1.QueryContractInfoResponse") @@ -823,87 +899,92 @@ func init() { proto.RegisterType((*QueryCodesResponse)(nil), "cosmwasm.wasm.v1.QueryCodesResponse") proto.RegisterType((*QueryPinnedCodesRequest)(nil), "cosmwasm.wasm.v1.QueryPinnedCodesRequest") proto.RegisterType((*QueryPinnedCodesResponse)(nil), "cosmwasm.wasm.v1.QueryPinnedCodesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "cosmwasm.wasm.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmwasm.wasm.v1.QueryParamsResponse") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/query.proto", fileDescriptor_9677c207036b9f2b) } var fileDescriptor_9677c207036b9f2b = []byte{ - // 1188 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x3f, 0x93, 0xfc, 0x54, 0xff, 0x46, 0x90, 0x18, 0x93, 0xee, 0x46, - 0x4b, 0x15, 0xd2, 0x34, 0xec, 0x36, 0x69, 0xa3, 0x0a, 0x24, 0x84, 0xea, 0x04, 0x9a, 0x44, 0x8a, - 0x94, 0x6e, 0x0f, 0x48, 0xf4, 0x10, 0x8d, 0xbd, 0x13, 0x67, 0x25, 0x7b, 0xc7, 0xd9, 0x99, 0x24, - 0xb5, 0xa2, 0x00, 0xaa, 0xc4, 0x01, 0x09, 0x01, 0x12, 0xea, 0x19, 0x0e, 0xa8, 0x70, 0x86, 0x1b, - 0xaf, 0x20, 0xc7, 0x48, 0x5c, 0x38, 0x59, 0xe0, 0x70, 0x40, 0x79, 0x09, 0x3d, 0xa1, 0x99, 0x9d, - 0x75, 0xd6, 0x7f, 0x36, 0x76, 0xaa, 0x88, 0x8b, 0xe5, 0xf5, 0x3c, 0xf3, 0xcc, 0xe7, 0xf9, 0xee, - 0x33, 0xcf, 0xf3, 0x18, 0x4e, 0x95, 0x29, 0xab, 0x1d, 0x60, 0x56, 0xb3, 0xe4, 0xc7, 0xfe, 0x82, - 0xb5, 0xbb, 0x47, 0xfc, 0x86, 0x59, 0xf7, 0x29, 0xa7, 0x28, 0x17, 0xae, 0x9a, 0xf2, 0x63, 0x7f, - 0xa1, 0xf0, 0x5a, 0x85, 0x56, 0xa8, 0x5c, 0xb4, 0xc4, 0xb7, 0xc0, 0xae, 0xd0, 0xeb, 0x85, 0x37, - 0xea, 0x84, 0x85, 0xab, 0x15, 0x4a, 0x2b, 0x55, 0x62, 0xe1, 0xba, 0x6b, 0x61, 0xcf, 0xa3, 0x1c, - 0x73, 0x97, 0x7a, 0xe1, 0xea, 0x9c, 0xd8, 0x4b, 0x99, 0x55, 0xc2, 0x8c, 0x04, 0x87, 0x5b, 0xfb, - 0x0b, 0x25, 0xc2, 0xf1, 0x82, 0x55, 0xc7, 0x15, 0xd7, 0x93, 0xc6, 0x81, 0xad, 0x71, 0x0f, 0xe6, - 0x1f, 0x09, 0x8b, 0x65, 0xea, 0x71, 0x1f, 0x97, 0xf9, 0x9a, 0xb7, 0x4d, 0x6d, 0xb2, 0xbb, 0x47, - 0x18, 0x47, 0x79, 0x98, 0xc6, 0x8e, 0xe3, 0x13, 0xc6, 0xf2, 0x60, 0x1a, 0xcc, 0x66, 0xed, 0xf0, - 0xd1, 0xf8, 0x1a, 0xc0, 0x37, 0xfa, 0x6c, 0x63, 0x75, 0xea, 0x31, 0x12, 0xbf, 0x0f, 0x3d, 0x82, - 0xff, 0x2b, 0xab, 0x1d, 0x5b, 0xae, 0xb7, 0x4d, 0xf3, 0x23, 0xd3, 0x60, 0x76, 0x6c, 0x51, 0x33, - 0xbb, 0x55, 0x31, 0xa3, 0x8e, 0x8b, 0xe3, 0xc7, 0x4d, 0x3d, 0x71, 0xd2, 0xd4, 0xc1, 0x59, 0x53, - 0x4f, 0xd8, 0xe3, 0xe5, 0xc8, 0xda, 0x7b, 0xc9, 0x7f, 0x7e, 0xd0, 0x81, 0xf1, 0x19, 0x7c, 0xb3, - 0x83, 0x67, 0xd5, 0x65, 0x9c, 0xfa, 0x8d, 0x81, 0x91, 0xa0, 0x8f, 0x20, 0x3c, 0xd7, 0x44, 0xe1, - 0xcc, 0x98, 0x81, 0x80, 0xa6, 0x10, 0xd0, 0x0c, 0xde, 0x9e, 0x12, 0xd0, 0xdc, 0xc4, 0x15, 0xa2, - 0xbc, 0xda, 0x91, 0x9d, 0xc6, 0xaf, 0x00, 0x4e, 0xf5, 0x27, 0x50, 0xa2, 0xac, 0xc3, 0x34, 0xf1, - 0xb8, 0xef, 0x12, 0x81, 0x70, 0x6d, 0x76, 0x6c, 0x71, 0x2e, 0x3e, 0xe8, 0x65, 0xea, 0x10, 0xb5, - 0xff, 0x43, 0x8f, 0xfb, 0x8d, 0x62, 0x52, 0x08, 0x60, 0x87, 0x0e, 0xd0, 0xc3, 0x3e, 0xd0, 0x6f, - 0x0f, 0x84, 0x0e, 0x40, 0x3a, 0xa8, 0x3f, 0xed, 0x92, 0x8d, 0x15, 0x1b, 0xe2, 0xec, 0x50, 0xb6, - 0x49, 0x98, 0x2e, 0x53, 0x87, 0x6c, 0xb9, 0x8e, 0x94, 0x2d, 0x69, 0xa7, 0xc4, 0xe3, 0x9a, 0x73, - 0x65, 0xaa, 0x7d, 0xd1, 0xad, 0x5a, 0x1b, 0x40, 0xa9, 0x36, 0x05, 0xb3, 0xe1, 0xdb, 0x0e, 0x74, - 0xcb, 0xda, 0xe7, 0x3f, 0x5c, 0x9d, 0x0e, 0x9f, 0x87, 0x1c, 0x0f, 0xaa, 0xd5, 0x10, 0xe5, 0x31, - 0xc7, 0x9c, 0xfc, 0x77, 0x09, 0xf4, 0x3d, 0x80, 0x37, 0x62, 0x10, 0x94, 0x16, 0x4b, 0x30, 0x55, - 0xa3, 0x0e, 0xa9, 0x86, 0x09, 0x34, 0xd9, 0x9b, 0x40, 0x1b, 0x62, 0x5d, 0x65, 0x8b, 0x32, 0xbe, - 0x3a, 0x91, 0x3e, 0x56, 0x1a, 0xd9, 0xf8, 0xe0, 0x92, 0x1a, 0xdd, 0x80, 0x50, 0x9e, 0xb1, 0xe5, - 0x60, 0x8e, 0x25, 0xc2, 0xb8, 0x9d, 0x95, 0xbf, 0xac, 0x60, 0x8e, 0x8d, 0xbb, 0x2a, 0xf2, 0x5e, - 0xc7, 0x2a, 0x72, 0x04, 0x93, 0x72, 0x27, 0x90, 0x3b, 0xe5, 0x77, 0x63, 0x17, 0x6a, 0x72, 0xd3, - 0xe3, 0x1a, 0xf6, 0xf9, 0x25, 0x79, 0x96, 0x7a, 0x79, 0x8a, 0x13, 0x2f, 0x9b, 0x3a, 0x8a, 0x10, - 0x6c, 0x10, 0xc6, 0x84, 0x12, 0x11, 0xce, 0x0d, 0xa8, 0xc7, 0x1e, 0xa9, 0x48, 0xe7, 0xa2, 0xa4, - 0xb1, 0x3e, 0x83, 0x08, 0x6e, 0xc3, 0x9c, 0xca, 0xfd, 0xc1, 0x37, 0xce, 0x78, 0x3e, 0x02, 0x73, - 0xc2, 0xb0, 0xa3, 0xd0, 0xde, 0xea, 0xb2, 0x2e, 0xe6, 0x5a, 0x4d, 0x3d, 0x25, 0xcd, 0x56, 0xce, - 0x9a, 0xfa, 0x88, 0xeb, 0xb4, 0x6f, 0x6c, 0x1e, 0xa6, 0xcb, 0x3e, 0xc1, 0x9c, 0xfa, 0x32, 0xde, - 0xac, 0x1d, 0x3e, 0xa2, 0x0d, 0x98, 0x15, 0x38, 0x5b, 0x3b, 0x98, 0xed, 0xe4, 0xaf, 0x49, 0xee, - 0x3b, 0x2f, 0x9b, 0xfa, 0x7c, 0xc5, 0xe5, 0x3b, 0x7b, 0x25, 0xb3, 0x4c, 0x6b, 0x56, 0xd5, 0xf5, - 0x88, 0x45, 0x99, 0x88, 0x81, 0x7a, 0x56, 0xd5, 0x2d, 0x31, 0xab, 0xd4, 0xe0, 0x84, 0x99, 0xab, - 0xe4, 0x69, 0x51, 0x7c, 0xb1, 0x33, 0xc2, 0xc5, 0x2a, 0x66, 0x3b, 0xe8, 0x09, 0x9c, 0x70, 0x3d, - 0xc6, 0xb1, 0xc7, 0x5d, 0xcc, 0xc9, 0x56, 0x9d, 0xf8, 0x35, 0x97, 0x31, 0x91, 0x7a, 0xa9, 0xb8, - 0x5a, 0xff, 0xa0, 0x5c, 0x26, 0x8c, 0x2d, 0x53, 0x6f, 0xdb, 0xad, 0xa8, 0xe4, 0x7d, 0x3d, 0xe2, - 0x63, 0xb3, 0xed, 0x22, 0x28, 0xf6, 0xeb, 0xc9, 0x4c, 0x32, 0x37, 0xba, 0x9e, 0xcc, 0x8c, 0xe6, - 0x52, 0xc6, 0x33, 0x00, 0xff, 0x1f, 0x51, 0x51, 0x09, 0xb3, 0x26, 0xca, 0x86, 0x10, 0x46, 0xf4, - 0x18, 0x20, 0xcf, 0x35, 0xfa, 0x95, 0xdb, 0x4e, 0x3d, 0x8b, 0x99, 0x76, 0x8f, 0xc9, 0x94, 0xd5, - 0x1a, 0x9a, 0x52, 0x6f, 0x34, 0xc8, 0x92, 0xcc, 0x59, 0x53, 0x97, 0xcf, 0xc1, 0x3b, 0x54, 0xdd, - 0xe7, 0x49, 0x84, 0x81, 0x85, 0xaf, 0xb2, 0xb3, 0x30, 0x80, 0x57, 0x2e, 0x0c, 0x2f, 0x00, 0x44, - 0x51, 0xef, 0x2a, 0xc4, 0x87, 0x10, 0xb6, 0x43, 0x0c, 0x2b, 0xc2, 0x30, 0x31, 0x06, 0xfa, 0x66, - 0xc3, 0xf8, 0xae, 0xb0, 0x3e, 0x60, 0x38, 0x29, 0x39, 0x37, 0x5d, 0xcf, 0x23, 0xce, 0x05, 0x5a, - 0xbc, 0x7a, 0x91, 0xfc, 0x06, 0xa8, 0x71, 0xa5, 0xe3, 0x8c, 0xf6, 0xdd, 0xcb, 0xa8, 0xdb, 0x10, - 0xe8, 0x91, 0x2c, 0x5e, 0x17, 0xb1, 0xb6, 0x9a, 0x7a, 0x3a, 0xb8, 0x12, 0xcc, 0x4e, 0x07, 0xb7, - 0xe1, 0xea, 0x82, 0x5e, 0xfc, 0x72, 0x0c, 0x8e, 0x4a, 0x22, 0xf4, 0x1c, 0xc0, 0xf1, 0xe8, 0xd4, - 0x82, 0xfa, 0x34, 0xf8, 0xb8, 0x51, 0xab, 0x70, 0x7b, 0x28, 0xdb, 0xe0, 0x7c, 0x63, 0xfe, 0xd9, - 0xef, 0x7f, 0x7f, 0x37, 0x32, 0x83, 0x6e, 0x5a, 0x3d, 0x43, 0x62, 0xd8, 0x1b, 0xad, 0x43, 0x55, - 0xeb, 0x8e, 0xd0, 0x0b, 0x00, 0xaf, 0x77, 0x0d, 0x25, 0xe8, 0x9d, 0x01, 0xc7, 0x75, 0x8e, 0x4f, - 0x05, 0x73, 0x58, 0x73, 0x05, 0x78, 0x4f, 0x02, 0x9a, 0x68, 0x7e, 0x18, 0x40, 0x6b, 0x47, 0x41, - 0xfd, 0x18, 0x01, 0x55, 0x73, 0xc0, 0x40, 0xd0, 0xce, 0x81, 0x65, 0x20, 0x68, 0xd7, 0x78, 0x61, - 0x2c, 0x4a, 0xd0, 0x79, 0x34, 0xd7, 0x0f, 0xd4, 0x21, 0xd6, 0xa1, 0x4a, 0xa8, 0x23, 0xeb, 0x7c, - 0xe8, 0xf8, 0x09, 0xc0, 0x5c, 0x77, 0x8f, 0x46, 0x71, 0x07, 0xc7, 0xcc, 0x13, 0x05, 0x6b, 0x68, - 0xfb, 0x61, 0x48, 0x7b, 0x24, 0x65, 0x12, 0xea, 0x17, 0x00, 0x73, 0xdd, 0x3d, 0x35, 0x96, 0x34, - 0xa6, 0xab, 0xc7, 0x92, 0xc6, 0x35, 0x6b, 0xe3, 0x7d, 0x49, 0x7a, 0x1f, 0x2d, 0x0d, 0x45, 0xea, - 0xe3, 0x03, 0xeb, 0xf0, 0xbc, 0x19, 0x1f, 0xa1, 0xdf, 0x00, 0x44, 0xbd, 0x0d, 0x16, 0xdd, 0x89, - 0xc1, 0x88, 0x6d, 0xff, 0x85, 0x85, 0x4b, 0xec, 0x50, 0xe8, 0x1f, 0x48, 0xf4, 0x77, 0xd1, 0xfd, - 0xe1, 0x44, 0x16, 0x8e, 0x3a, 0xe1, 0x1b, 0x30, 0x29, 0xd3, 0xd6, 0x88, 0xcd, 0xc3, 0xf3, 0x5c, - 0x7d, 0xeb, 0x42, 0x1b, 0x45, 0x34, 0x2b, 0x89, 0x0c, 0x34, 0x3d, 0x28, 0x41, 0x91, 0x0f, 0x47, - 0x65, 0x39, 0x44, 0x17, 0xf9, 0x0d, 0x0b, 0x72, 0xe1, 0xe6, 0xc5, 0x46, 0xea, 0x74, 0x4d, 0x9e, - 0x9e, 0x47, 0x13, 0xfd, 0x4f, 0x47, 0x5f, 0x01, 0x38, 0x16, 0xa9, 0xc4, 0xe8, 0x56, 0x8c, 0xd7, - 0xde, 0x8e, 0x50, 0x98, 0x1b, 0xc6, 0x54, 0x61, 0xcc, 0x48, 0x8c, 0x69, 0xa4, 0xf5, 0xc7, 0x60, - 0x56, 0x5d, 0x6e, 0x2a, 0xae, 0x1c, 0xff, 0xa5, 0x25, 0x7e, 0x6e, 0x69, 0x89, 0xe3, 0x96, 0x06, - 0x4e, 0x5a, 0x1a, 0xf8, 0xb3, 0xa5, 0x81, 0x6f, 0x4f, 0xb5, 0xc4, 0xc9, 0xa9, 0x96, 0xf8, 0xe3, - 0x54, 0x4b, 0x7c, 0x62, 0x74, 0x0f, 0x35, 0xc2, 0x8f, 0x63, 0x3d, 0x0d, 0xfc, 0xc9, 0x7f, 0xd8, - 0xa5, 0x94, 0xfc, 0x63, 0x7c, 0xf7, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x66, 0x16, 0x91, - 0xc8, 0x0f, 0x00, 0x00, + // 1242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x98, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x3f, 0xd3, 0xfc, 0x54, 0xff, 0x86, 0xd2, 0x18, 0x93, 0xae, 0xa3, + 0xa5, 0x84, 0x34, 0x0d, 0xbb, 0x4d, 0xda, 0x50, 0x81, 0x84, 0x50, 0x9d, 0x40, 0x93, 0x48, 0x91, + 0xd2, 0xed, 0x01, 0x89, 0x1e, 0xa2, 0xb1, 0x77, 0xe2, 0xac, 0x64, 0xef, 0x38, 0x3b, 0x93, 0xa4, + 0x56, 0x14, 0x40, 0x95, 0x90, 0x38, 0x20, 0x40, 0x42, 0x3d, 0xc3, 0x01, 0x15, 0xce, 0x70, 0xe3, + 0x15, 0xe4, 0x18, 0x89, 0x0b, 0x27, 0x0b, 0x1c, 0x0e, 0x28, 0x2f, 0xa1, 0x27, 0x34, 0xb3, 0xb3, + 0xce, 0xae, 0xed, 0x8d, 0x9d, 0x2a, 0xe2, 0x62, 0xed, 0xee, 0x3c, 0xf3, 0xcc, 0xe7, 0xf9, 0xce, + 0x33, 0xcf, 0x3c, 0x09, 0x9c, 0xa8, 0x50, 0x56, 0xdf, 0xc3, 0xac, 0x6e, 0xca, 0x9f, 0xdd, 0x39, + 0x73, 0x7b, 0x87, 0x78, 0x4d, 0xa3, 0xe1, 0x51, 0x4e, 0x51, 0x2e, 0x18, 0x35, 0xe4, 0xcf, 0xee, + 0x5c, 0xe1, 0x6a, 0x95, 0x56, 0xa9, 0x1c, 0x34, 0xc5, 0x93, 0x6f, 0x57, 0xe8, 0xf5, 0xc2, 0x9b, + 0x0d, 0xc2, 0x82, 0xd1, 0x2a, 0xa5, 0xd5, 0x1a, 0x31, 0x71, 0xc3, 0x31, 0xb1, 0xeb, 0x52, 0x8e, + 0xb9, 0x43, 0xdd, 0x60, 0x74, 0x46, 0xcc, 0xa5, 0xcc, 0x2c, 0x63, 0x46, 0xfc, 0xc5, 0xcd, 0xdd, + 0xb9, 0x32, 0xe1, 0x78, 0xce, 0x6c, 0xe0, 0xaa, 0xe3, 0x4a, 0x63, 0xdf, 0x56, 0xbf, 0x0b, 0xf3, + 0x0f, 0x85, 0xc5, 0x22, 0x75, 0xb9, 0x87, 0x2b, 0x7c, 0xc5, 0xdd, 0xa4, 0x16, 0xd9, 0xde, 0x21, + 0x8c, 0xa3, 0x3c, 0x4c, 0x63, 0xdb, 0xf6, 0x08, 0x63, 0x79, 0x30, 0x09, 0xa6, 0xb3, 0x56, 0xf0, + 0xaa, 0x7f, 0x0d, 0xe0, 0x6b, 0x7d, 0xa6, 0xb1, 0x06, 0x75, 0x19, 0x89, 0x9f, 0x87, 0x1e, 0xc2, + 0xff, 0x55, 0xd4, 0x8c, 0x0d, 0xc7, 0xdd, 0xa4, 0xf9, 0x91, 0x49, 0x30, 0x7d, 0x79, 0x5e, 0x33, + 0xba, 0x55, 0x31, 0xc2, 0x8e, 0x4b, 0x63, 0x87, 0xad, 0x62, 0xe2, 0xa8, 0x55, 0x04, 0x27, 0xad, + 0x62, 0xc2, 0x1a, 0xab, 0x84, 0xc6, 0xde, 0x4b, 0xfe, 0xf3, 0x43, 0x11, 0xe8, 0x9f, 0xc1, 0xd7, + 0x23, 0x3c, 0xcb, 0x0e, 0xe3, 0xd4, 0x6b, 0x0e, 0x8c, 0x04, 0x7d, 0x04, 0xe1, 0xa9, 0x26, 0x0a, + 0x67, 0xca, 0xf0, 0x05, 0x34, 0x84, 0x80, 0x86, 0xbf, 0x7b, 0x4a, 0x40, 0x63, 0x1d, 0x57, 0x89, + 0xf2, 0x6a, 0x85, 0x66, 0xea, 0xbf, 0x02, 0x38, 0xd1, 0x9f, 0x40, 0x89, 0xb2, 0x0a, 0xd3, 0xc4, + 0xe5, 0x9e, 0x43, 0x04, 0xc2, 0xa5, 0xe9, 0xcb, 0xf3, 0x33, 0xf1, 0x41, 0x2f, 0x52, 0x9b, 0xa8, + 0xf9, 0x1f, 0xba, 0xdc, 0x6b, 0x96, 0x92, 0x42, 0x00, 0x2b, 0x70, 0x80, 0x1e, 0xf4, 0x81, 0x7e, + 0x6b, 0x20, 0xb4, 0x0f, 0x12, 0xa1, 0xfe, 0xb4, 0x4b, 0x36, 0x56, 0x6a, 0x8a, 0xb5, 0x03, 0xd9, + 0xc6, 0x61, 0xba, 0x42, 0x6d, 0xb2, 0xe1, 0xd8, 0x52, 0xb6, 0xa4, 0x95, 0x12, 0xaf, 0x2b, 0xf6, + 0x85, 0xa9, 0xf6, 0x45, 0xb7, 0x6a, 0x1d, 0x00, 0xa5, 0xda, 0x04, 0xcc, 0x06, 0xbb, 0xed, 0xeb, + 0x96, 0xb5, 0x4e, 0x3f, 0x5c, 0x9c, 0x0e, 0x9f, 0x07, 0x1c, 0xf7, 0x6b, 0xb5, 0x00, 0xe5, 0x11, + 0xc7, 0x9c, 0xfc, 0x77, 0x09, 0xf4, 0x3d, 0x80, 0xd7, 0x63, 0x10, 0x94, 0x16, 0x0b, 0x30, 0x55, + 0xa7, 0x36, 0xa9, 0x05, 0x09, 0x34, 0xde, 0x9b, 0x40, 0x6b, 0x62, 0x5c, 0x65, 0x8b, 0x32, 0xbe, + 0x38, 0x91, 0x3e, 0x56, 0x1a, 0x59, 0x78, 0xef, 0x9c, 0x1a, 0x5d, 0x87, 0x50, 0xae, 0xb1, 0x61, + 0x63, 0x8e, 0x25, 0xc2, 0x98, 0x95, 0x95, 0x5f, 0x96, 0x30, 0xc7, 0xfa, 0x1d, 0x15, 0x79, 0xaf, + 0x63, 0x15, 0x39, 0x82, 0x49, 0x39, 0x13, 0xc8, 0x99, 0xf2, 0x59, 0xdf, 0x86, 0x9a, 0x9c, 0xf4, + 0xa8, 0x8e, 0x3d, 0x7e, 0x4e, 0x9e, 0x85, 0x5e, 0x9e, 0xd2, 0xb5, 0x17, 0xad, 0x22, 0x0a, 0x11, + 0xac, 0x11, 0xc6, 0x84, 0x12, 0x21, 0xce, 0x35, 0x58, 0x8c, 0x5d, 0x52, 0x91, 0xce, 0x84, 0x49, + 0x63, 0x7d, 0xfa, 0x11, 0xdc, 0x82, 0x39, 0x95, 0xfb, 0x83, 0x4f, 0x9c, 0xfe, 0x6c, 0x04, 0xe6, + 0x84, 0x61, 0xa4, 0xd0, 0xde, 0xec, 0xb2, 0x2e, 0xe5, 0xda, 0xad, 0x62, 0x4a, 0x9a, 0x2d, 0x9d, + 0xb4, 0x8a, 0x23, 0x8e, 0xdd, 0x39, 0xb1, 0x79, 0x98, 0xae, 0x78, 0x04, 0x73, 0xea, 0xc9, 0x78, + 0xb3, 0x56, 0xf0, 0x8a, 0xd6, 0x60, 0x56, 0xe0, 0x6c, 0x6c, 0x61, 0xb6, 0x95, 0xbf, 0x24, 0xb9, + 0x6f, 0xbf, 0x68, 0x15, 0x67, 0xab, 0x0e, 0xdf, 0xda, 0x29, 0x1b, 0x15, 0x5a, 0x37, 0x6b, 0x8e, + 0x4b, 0x4c, 0xca, 0x44, 0x0c, 0xd4, 0x35, 0x6b, 0x4e, 0x99, 0x99, 0xe5, 0x26, 0x27, 0xcc, 0x58, + 0x26, 0x4f, 0x4a, 0xe2, 0xc1, 0xca, 0x08, 0x17, 0xcb, 0x98, 0x6d, 0xa1, 0xc7, 0xf0, 0x9a, 0xe3, + 0x32, 0x8e, 0x5d, 0xee, 0x60, 0x4e, 0x36, 0x1a, 0xc4, 0xab, 0x3b, 0x8c, 0x89, 0xd4, 0x4b, 0xc5, + 0xd5, 0xfa, 0xfb, 0x95, 0x0a, 0x61, 0x6c, 0x91, 0xba, 0x9b, 0x4e, 0x55, 0x25, 0xef, 0xab, 0x21, + 0x1f, 0xeb, 0x1d, 0x17, 0x7e, 0xb1, 0x5f, 0x4d, 0x66, 0x92, 0xb9, 0xd1, 0xd5, 0x64, 0x66, 0x34, + 0x97, 0xd2, 0x9f, 0x02, 0xf8, 0xff, 0x90, 0x8a, 0x4a, 0x98, 0x15, 0x51, 0x36, 0x84, 0x30, 0xe2, + 0x8e, 0x01, 0x72, 0x5d, 0xbd, 0x5f, 0xb9, 0x8d, 0xea, 0x59, 0xca, 0x74, 0xee, 0x98, 0x4c, 0x45, + 0x8d, 0xa1, 0x09, 0xb5, 0xa3, 0x7e, 0x96, 0x64, 0x4e, 0x5a, 0x45, 0xf9, 0xee, 0xef, 0xa1, 0xba, + 0x7d, 0x1e, 0x87, 0x18, 0x58, 0xb0, 0x95, 0xd1, 0xc2, 0x00, 0x5e, 0xba, 0x30, 0x3c, 0x07, 0x10, + 0x85, 0xbd, 0xab, 0x10, 0x1f, 0x40, 0xd8, 0x09, 0x31, 0xa8, 0x08, 0xc3, 0xc4, 0xe8, 0xeb, 0x9b, + 0x0d, 0xe2, 0xbb, 0xc0, 0xfa, 0x80, 0xe1, 0xb8, 0xe4, 0x5c, 0x77, 0x5c, 0x97, 0xd8, 0x67, 0x68, + 0xf1, 0xf2, 0x45, 0xf2, 0x1b, 0xa0, 0xda, 0x95, 0xc8, 0x1a, 0x9d, 0xb3, 0x97, 0x51, 0xa7, 0xc1, + 0xd7, 0x23, 0x59, 0xba, 0x22, 0x62, 0x6d, 0xb7, 0x8a, 0x69, 0xff, 0x48, 0x30, 0x2b, 0xed, 0x9f, + 0x86, 0x0b, 0x0c, 0xfa, 0xaa, 0xda, 0x9c, 0x75, 0xec, 0xe1, 0x7a, 0x10, 0xaf, 0xbe, 0x06, 0x5f, + 0x89, 0x7c, 0x55, 0x84, 0xef, 0xc0, 0x54, 0x43, 0x7e, 0x51, 0xe9, 0x90, 0xef, 0xdd, 0x2f, 0x7f, + 0x46, 0x50, 0xc2, 0x7d, 0xeb, 0xf9, 0x2f, 0xc7, 0xe0, 0xa8, 0xf4, 0x87, 0x9e, 0x01, 0x38, 0x16, + 0x6e, 0x8d, 0x50, 0x9f, 0x2e, 0x22, 0xae, 0x9f, 0x2b, 0xdc, 0x1a, 0xca, 0xd6, 0x67, 0xd5, 0x67, + 0x9f, 0xfe, 0xfe, 0xf7, 0x77, 0x23, 0x53, 0xe8, 0x86, 0xd9, 0xd3, 0x89, 0x06, 0x17, 0xb0, 0xb9, + 0xaf, 0x0a, 0xea, 0x01, 0x7a, 0x0e, 0xe0, 0x95, 0xae, 0xce, 0x07, 0xbd, 0x3d, 0x60, 0xb9, 0x68, + 0x8f, 0x56, 0x30, 0x86, 0x35, 0x57, 0x80, 0x77, 0x25, 0xa0, 0x81, 0x66, 0x87, 0x01, 0x34, 0xb7, + 0x14, 0xd4, 0x8f, 0x21, 0x50, 0xd5, 0x6c, 0x0c, 0x04, 0x8d, 0x76, 0x45, 0x03, 0x41, 0xbb, 0x7a, + 0x18, 0x7d, 0x5e, 0x82, 0xce, 0xa2, 0x99, 0x7e, 0xa0, 0x36, 0x31, 0xf7, 0x55, 0xd6, 0x1e, 0x98, + 0xa7, 0x9d, 0xcd, 0x4f, 0x00, 0xe6, 0xba, 0x1b, 0x01, 0x14, 0xb7, 0x70, 0x4c, 0xd3, 0x52, 0x30, + 0x87, 0xb6, 0x1f, 0x86, 0xb4, 0x47, 0x52, 0x26, 0xa1, 0x7e, 0x01, 0x30, 0xd7, 0x7d, 0x71, 0xc7, + 0x92, 0xc6, 0xb4, 0x0e, 0xb1, 0xa4, 0x71, 0x1d, 0x81, 0xfe, 0xbe, 0x24, 0xbd, 0x87, 0x16, 0x86, + 0x22, 0xf5, 0xf0, 0x9e, 0xb9, 0x7f, 0x7a, 0xe3, 0x1f, 0xa0, 0xdf, 0x00, 0x44, 0xbd, 0xb7, 0x38, + 0xba, 0x1d, 0x83, 0x11, 0xdb, 0x63, 0x14, 0xe6, 0xce, 0x31, 0x43, 0xa1, 0x7f, 0x20, 0xd1, 0xdf, + 0x45, 0xf7, 0x86, 0x13, 0x59, 0x38, 0x8a, 0xc2, 0x37, 0x61, 0x52, 0xa6, 0xad, 0x1e, 0x9b, 0x87, + 0xa7, 0xb9, 0xfa, 0xc6, 0x99, 0x36, 0x8a, 0x68, 0x5a, 0x12, 0xe9, 0x68, 0x72, 0x50, 0x82, 0x22, + 0x0f, 0x8e, 0xca, 0x9a, 0x8b, 0xce, 0xf2, 0x1b, 0x54, 0xc1, 0xc2, 0x8d, 0xb3, 0x8d, 0xd4, 0xea, + 0x9a, 0x5c, 0x3d, 0x8f, 0xae, 0xf5, 0x5f, 0x1d, 0x7d, 0x05, 0xe0, 0xe5, 0x50, 0xb9, 0x47, 0x37, + 0x63, 0xbc, 0xf6, 0x5e, 0x3b, 0x85, 0x99, 0x61, 0x4c, 0x15, 0xc6, 0x94, 0xc4, 0x98, 0x44, 0x5a, + 0x7f, 0x0c, 0x66, 0x36, 0xe4, 0x24, 0x74, 0x00, 0x53, 0x7e, 0x8d, 0x46, 0x71, 0xe1, 0x45, 0xae, + 0x82, 0xc2, 0x9b, 0x03, 0xac, 0x86, 0x5e, 0xde, 0xbf, 0x18, 0x96, 0x0e, 0xff, 0xd2, 0x12, 0x3f, + 0xb7, 0xb5, 0xc4, 0x61, 0x5b, 0x03, 0x47, 0x6d, 0x0d, 0xfc, 0xd9, 0xd6, 0xc0, 0xb7, 0xc7, 0x5a, + 0xe2, 0xe8, 0x58, 0x4b, 0xfc, 0x71, 0xac, 0x25, 0x3e, 0xd1, 0xbb, 0x1b, 0x37, 0xe1, 0xc7, 0x36, + 0x9f, 0xf8, 0xfe, 0xe4, 0x7f, 0x11, 0xca, 0x29, 0xf9, 0xc7, 0xff, 0x9d, 0x7f, 0x03, 0x00, 0x00, + 0xff, 0xff, 0xf8, 0x94, 0xf6, 0x1f, 0xac, 0x10, 0x00, 0x00, } func (this *QueryContractInfoResponse) Equal(that interface{}) bool { @@ -1024,6 +1105,8 @@ type QueryClient interface { Codes(ctx context.Context, in *QueryCodesRequest, opts ...grpc.CallOption) (*QueryCodesResponse, error) // PinnedCodes gets the pinned code ids PinnedCodes(ctx context.Context, in *QueryPinnedCodesRequest, opts ...grpc.CallOption) (*QueryPinnedCodesResponse, error) + // Params gets the module params + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -1115,6 +1198,15 @@ func (c *queryClient) PinnedCodes(ctx context.Context, in *QueryPinnedCodesReque return out, nil } +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ContractInfo gets the contract meta data @@ -1135,6 +1227,8 @@ type QueryServer interface { Codes(context.Context, *QueryCodesRequest) (*QueryCodesResponse, error) // PinnedCodes gets the pinned code ids PinnedCodes(context.Context, *QueryPinnedCodesRequest) (*QueryPinnedCodesResponse, error) + // Params gets the module params + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1168,6 +1262,9 @@ func (*UnimplementedQueryServer) Codes(ctx context.Context, req *QueryCodesReque func (*UnimplementedQueryServer) PinnedCodes(ctx context.Context, req *QueryPinnedCodesRequest) (*QueryPinnedCodesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PinnedCodes not implemented") } +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1335,6 +1432,24 @@ func _Query_PinnedCodes_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmwasm.wasm.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1375,6 +1490,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PinnedCodes", Handler: _Query_PinnedCodes_Handler, }, + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmwasm/wasm/v1/query.proto", @@ -2144,6 +2263,62 @@ func (m *QueryPinnedCodesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2466,6 +2641,26 @@ func (m *QueryPinnedCodesResponse) Size() (n int) { return n } +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4579,6 +4774,139 @@ func (m *QueryPinnedCodesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/types/query.pb.gw.go b/x/wasm/types/query.pb.gw.go index f91f21ccf6..f5aed81ed2 100644 --- a/x/wasm/types/query.pb.gw.go +++ b/x/wasm/types/query.pb.gw.go @@ -579,6 +579,24 @@ func local_request_Query_PinnedCodes_0(ctx context.Context, marshaler runtime.Ma } +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -765,6 +783,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -986,6 +1024,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1007,6 +1065,8 @@ var ( pattern_Query_Codes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmwasm", "wasm", "v1", "code"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_PinnedCodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmwasm", "wasm", "v1", "codes", "pinned"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmwasm", "wasm", "v1", "codes", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1027,4 +1087,6 @@ var ( forward_Query_Codes_0 = runtime.ForwardResponseMessage forward_Query_PinnedCodes_0 = runtime.ForwardResponseMessage + + forward_Query_Params_0 = runtime.ForwardResponseMessage ) diff --git a/x/wasm/types/store.go b/x/wasm/types/store.go deleted file mode 100644 index 64b0eab4b8..0000000000 --- a/x/wasm/types/store.go +++ /dev/null @@ -1,30 +0,0 @@ -package types - -import ( - storetypes "github.com/line/lbm-sdk/store/types" - wasmvm "github.com/line/wasmvm" -) - -var _ wasmvm.KVStore = (*WasmStore)(nil) - -// WasmStore is a wrapper struct of `KVStore` -// It translates from cosmos KVStore to wasmvm-defined KVStore. -// The spec of interface `Iterator` is a bit different so we cannot use cosmos KVStore directly. -type WasmStore struct { - storetypes.KVStore -} - -// Iterator re-define for wasmvm's `Iterator` -func (s WasmStore) Iterator(start, end []byte) wasmvm.Iterator { - return s.KVStore.Iterator(start, end) -} - -// ReverseIterator re-define for wasmvm's `Iterator` -func (s WasmStore) ReverseIterator(start, end []byte) wasmvm.Iterator { - return s.KVStore.ReverseIterator(start, end) -} - -// NewWasmStore creates a instance of WasmStore -func NewWasmStore(kvStore storetypes.KVStore) WasmStore { - return WasmStore{kvStore} -} diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 818b6e79b2..5082964882 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -95,7 +95,7 @@ func (msg MsgInstantiateContract) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "code id is required") } - if err := validateLabel(msg.Label); err != nil { + if err := ValidateLabel(msg.Label); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "label is required") } @@ -306,3 +306,56 @@ func (msg MsgIBCCloseChannel) GetSignBytes() []byte { func (msg MsgIBCCloseChannel) GetSigners() []sdk.AccAddress { return nil } + +var _ sdk.Msg = &MsgInstantiateContract2{} + +func (msg MsgInstantiateContract2) Route() string { + return RouterKey +} + +func (msg MsgInstantiateContract2) Type() string { + return "instantiate2" +} + +func (msg MsgInstantiateContract2) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { + return sdkerrors.Wrap(err, "sender") + } + + if msg.CodeID == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "code id is required") + } + + if err := ValidateLabel(msg.Label); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "label is required") + } + + if !msg.Funds.IsValid() { + return sdkerrors.ErrInvalidCoins + } + + if len(msg.Admin) != 0 { + if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { + return sdkerrors.Wrap(err, "admin") + } + } + if err := msg.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") + } + if err := ValidateSalt(msg.Salt); err != nil { + return sdkerrors.Wrap(err, "salt") + } + return nil +} + +func (msg MsgInstantiateContract2) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgInstantiateContract2) GetSigners() []sdk.AccAddress { + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{senderAddr} +} diff --git a/x/wasm/types/tx.pb.go b/x/wasm/types/tx.pb.go index c6fbdaf895..2d8db853bd 100644 --- a/x/wasm/types/tx.pb.go +++ b/x/wasm/types/tx.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + github_com_cosmos_cosmos_sdk_types "github.com/line/lbm-sdk/types" github_com_line_lbm_sdk_types "github.com/line/lbm-sdk/types" types "github.com/line/lbm-sdk/types" grpc "google.golang.org/grpc" @@ -78,6 +79,8 @@ var xxx_messageInfo_MsgStoreCode proto.InternalMessageInfo type MsgStoreCodeResponse struct { // CodeID is the reference to the stored WASM code CodeID uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // Checksum is the sha256 hash of the stored code + Checksum []byte `protobuf:"bytes,2,opt,name=checksum,proto3" json:"checksum,omitempty"` } func (m *MsgStoreCodeResponse) Reset() { *m = MsgStoreCodeResponse{} } @@ -163,11 +166,66 @@ func (m *MsgInstantiateContract) XXX_DiscardUnknown() { var xxx_messageInfo_MsgInstantiateContract proto.InternalMessageInfo +// MsgInstantiateContract2 create a new smart contract instance for the given +// code id with a predicable address. +type MsgInstantiateContract2 struct { + // Sender is the that actor that signed the messages + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // Admin is an optional address that can execute migrations + Admin string `protobuf:"bytes,2,opt,name=admin,proto3" json:"admin,omitempty"` + // CodeID is the reference to the stored WASM code + CodeID uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // Label is optional metadata to be stored with a contract instance. + Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"` + // Msg json encoded message to be passed to the contract on instantiation + Msg RawContractMessage `protobuf:"bytes,5,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` + // Funds coins that are transferred to the contract on instantiation + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` + // Salt is an arbitrary value provided by the sender. Size can be 1 to 64. + Salt []byte `protobuf:"bytes,7,opt,name=salt,proto3" json:"salt,omitempty"` + // FixMsg include the msg value into the hash for the predictable address. + // Default is false + FixMsg bool `protobuf:"varint,8,opt,name=fix_msg,json=fixMsg,proto3" json:"fix_msg,omitempty"` +} + +func (m *MsgInstantiateContract2) Reset() { *m = MsgInstantiateContract2{} } +func (m *MsgInstantiateContract2) String() string { return proto.CompactTextString(m) } +func (*MsgInstantiateContract2) ProtoMessage() {} +func (*MsgInstantiateContract2) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{3} +} +func (m *MsgInstantiateContract2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInstantiateContract2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInstantiateContract2.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgInstantiateContract2) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInstantiateContract2.Merge(m, src) +} +func (m *MsgInstantiateContract2) XXX_Size() int { + return m.Size() +} +func (m *MsgInstantiateContract2) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInstantiateContract2.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInstantiateContract2 proto.InternalMessageInfo + // MsgInstantiateContractResponse return instantiation result data type MsgInstantiateContractResponse struct { // Address is the bech32 address of the new contract instance. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // Data contains base64-encoded bytes to returned from the contract + // Data contains bytes to returned from the contract Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } @@ -175,7 +233,7 @@ func (m *MsgInstantiateContractResponse) Reset() { *m = MsgInstantiateCo func (m *MsgInstantiateContractResponse) String() string { return proto.CompactTextString(m) } func (*MsgInstantiateContractResponse) ProtoMessage() {} func (*MsgInstantiateContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{3} + return fileDescriptor_4f74d82755520264, []int{4} } func (m *MsgInstantiateContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -204,6 +262,47 @@ func (m *MsgInstantiateContractResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgInstantiateContractResponse proto.InternalMessageInfo +// MsgInstantiateContract2Response return instantiation result data +type MsgInstantiateContract2Response struct { + // Address is the bech32 address of the new contract instance. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Data contains bytes to returned from the contract + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgInstantiateContract2Response) Reset() { *m = MsgInstantiateContract2Response{} } +func (m *MsgInstantiateContract2Response) String() string { return proto.CompactTextString(m) } +func (*MsgInstantiateContract2Response) ProtoMessage() {} +func (*MsgInstantiateContract2Response) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{5} +} +func (m *MsgInstantiateContract2Response) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInstantiateContract2Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInstantiateContract2Response.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgInstantiateContract2Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInstantiateContract2Response.Merge(m, src) +} +func (m *MsgInstantiateContract2Response) XXX_Size() int { + return m.Size() +} +func (m *MsgInstantiateContract2Response) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInstantiateContract2Response.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInstantiateContract2Response proto.InternalMessageInfo + // MsgExecuteContract submits the given message data to a smart contract type MsgExecuteContract struct { // Sender is the that actor that signed the messages @@ -220,7 +319,7 @@ func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } func (*MsgExecuteContract) ProtoMessage() {} func (*MsgExecuteContract) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{4} + return fileDescriptor_4f74d82755520264, []int{6} } func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -251,7 +350,7 @@ var xxx_messageInfo_MsgExecuteContract proto.InternalMessageInfo // MsgExecuteContractResponse returns execution result data. type MsgExecuteContractResponse struct { - // Data contains base64-encoded bytes to returned from the contract + // Data contains bytes to returned from the contract Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } @@ -259,7 +358,7 @@ func (m *MsgExecuteContractResponse) Reset() { *m = MsgExecuteContractRe func (m *MsgExecuteContractResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecuteContractResponse) ProtoMessage() {} func (*MsgExecuteContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{5} + return fileDescriptor_4f74d82755520264, []int{7} } func (m *MsgExecuteContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -304,7 +403,7 @@ func (m *MsgMigrateContract) Reset() { *m = MsgMigrateContract{} } func (m *MsgMigrateContract) String() string { return proto.CompactTextString(m) } func (*MsgMigrateContract) ProtoMessage() {} func (*MsgMigrateContract) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{6} + return fileDescriptor_4f74d82755520264, []int{8} } func (m *MsgMigrateContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -344,7 +443,7 @@ func (m *MsgMigrateContractResponse) Reset() { *m = MsgMigrateContractRe func (m *MsgMigrateContractResponse) String() string { return proto.CompactTextString(m) } func (*MsgMigrateContractResponse) ProtoMessage() {} func (*MsgMigrateContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{7} + return fileDescriptor_4f74d82755520264, []int{9} } func (m *MsgMigrateContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -387,7 +486,7 @@ func (m *MsgUpdateAdmin) Reset() { *m = MsgUpdateAdmin{} } func (m *MsgUpdateAdmin) String() string { return proto.CompactTextString(m) } func (*MsgUpdateAdmin) ProtoMessage() {} func (*MsgUpdateAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{8} + return fileDescriptor_4f74d82755520264, []int{10} } func (m *MsgUpdateAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -424,7 +523,7 @@ func (m *MsgUpdateAdminResponse) Reset() { *m = MsgUpdateAdminResponse{} func (m *MsgUpdateAdminResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateAdminResponse) ProtoMessage() {} func (*MsgUpdateAdminResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{9} + return fileDescriptor_4f74d82755520264, []int{11} } func (m *MsgUpdateAdminResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -465,7 +564,7 @@ func (m *MsgClearAdmin) Reset() { *m = MsgClearAdmin{} } func (m *MsgClearAdmin) String() string { return proto.CompactTextString(m) } func (*MsgClearAdmin) ProtoMessage() {} func (*MsgClearAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{10} + return fileDescriptor_4f74d82755520264, []int{12} } func (m *MsgClearAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -502,7 +601,7 @@ func (m *MsgClearAdminResponse) Reset() { *m = MsgClearAdminResponse{} } func (m *MsgClearAdminResponse) String() string { return proto.CompactTextString(m) } func (*MsgClearAdminResponse) ProtoMessage() {} func (*MsgClearAdminResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4f74d82755520264, []int{11} + return fileDescriptor_4f74d82755520264, []int{13} } func (m *MsgClearAdminResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -535,7 +634,9 @@ func init() { proto.RegisterType((*MsgStoreCode)(nil), "cosmwasm.wasm.v1.MsgStoreCode") proto.RegisterType((*MsgStoreCodeResponse)(nil), "cosmwasm.wasm.v1.MsgStoreCodeResponse") proto.RegisterType((*MsgInstantiateContract)(nil), "cosmwasm.wasm.v1.MsgInstantiateContract") + proto.RegisterType((*MsgInstantiateContract2)(nil), "cosmwasm.wasm.v1.MsgInstantiateContract2") proto.RegisterType((*MsgInstantiateContractResponse)(nil), "cosmwasm.wasm.v1.MsgInstantiateContractResponse") + proto.RegisterType((*MsgInstantiateContract2Response)(nil), "cosmwasm.wasm.v1.MsgInstantiateContract2Response") proto.RegisterType((*MsgExecuteContract)(nil), "cosmwasm.wasm.v1.MsgExecuteContract") proto.RegisterType((*MsgExecuteContractResponse)(nil), "cosmwasm.wasm.v1.MsgExecuteContractResponse") proto.RegisterType((*MsgMigrateContract)(nil), "cosmwasm.wasm.v1.MsgMigrateContract") @@ -549,55 +650,61 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/tx.proto", fileDescriptor_4f74d82755520264) } var fileDescriptor_4f74d82755520264 = []byte{ - // 756 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x1b, 0x27, 0x4d, 0x6e, 0xf3, 0xf5, 0x8b, 0x4c, 0x1b, 0x52, 0x83, 0x9c, 0xc8, 0x45, - 0x10, 0x09, 0xb0, 0x9b, 0x22, 0xb1, 0x61, 0x43, 0x13, 0x58, 0xb4, 0x92, 0x11, 0x72, 0x55, 0x10, - 0x08, 0x29, 0x9a, 0xd8, 0x53, 0x63, 0x91, 0x78, 0x82, 0x67, 0xda, 0xb4, 0x8f, 0xc0, 0x8e, 0x1d, - 0xef, 0xc0, 0x5b, 0xb0, 0xeb, 0x0a, 0x75, 0xc9, 0x2a, 0x40, 0xfa, 0x16, 0xac, 0x90, 0xff, 0x52, - 0xd7, 0x75, 0xd2, 0x20, 0xc4, 0xc6, 0x9a, 0xeb, 0x39, 0xf7, 0x9e, 0xb9, 0x47, 0x67, 0xee, 0xc0, - 0x9a, 0x41, 0x68, 0x7f, 0x88, 0x68, 0x5f, 0xf5, 0x3f, 0x87, 0x4d, 0x95, 0x1d, 0x29, 0x03, 0x97, - 0x30, 0x22, 0x94, 0xa3, 0x2d, 0xc5, 0xff, 0x1c, 0x36, 0x45, 0xc9, 0xfb, 0x43, 0xa8, 0xda, 0x45, - 0x14, 0xab, 0x87, 0xcd, 0x2e, 0x66, 0xa8, 0xa9, 0x1a, 0xc4, 0x76, 0x82, 0x0c, 0x71, 0xc5, 0x22, - 0x16, 0xf1, 0x97, 0xaa, 0xb7, 0x0a, 0xff, 0xde, 0xbc, 0x4c, 0x71, 0x3c, 0xc0, 0x34, 0xd8, 0x95, - 0xbf, 0x70, 0x50, 0xd2, 0xa8, 0xb5, 0xcb, 0x88, 0x8b, 0xdb, 0xc4, 0xc4, 0x42, 0x05, 0xf2, 0x14, - 0x3b, 0x26, 0x76, 0xab, 0x5c, 0x9d, 0x6b, 0x14, 0xf5, 0x30, 0x12, 0x1e, 0xc2, 0xb2, 0x97, 0xdf, - 0xe9, 0x1e, 0x33, 0xdc, 0x31, 0x88, 0x89, 0xab, 0x0b, 0x75, 0xae, 0x51, 0x6a, 0x95, 0xc7, 0xa3, - 0x5a, 0xe9, 0xe5, 0xd6, 0xae, 0xd6, 0x3a, 0x66, 0x7e, 0x05, 0xbd, 0xe4, 0xe1, 0xa2, 0x48, 0xd8, - 0x83, 0x8a, 0xed, 0x50, 0x86, 0x1c, 0x66, 0x23, 0x86, 0x3b, 0x03, 0xec, 0xf6, 0x6d, 0x4a, 0x6d, - 0xe2, 0x54, 0x73, 0x75, 0xae, 0xb1, 0xb4, 0x29, 0x29, 0xc9, 0x3e, 0x95, 0x2d, 0xc3, 0xc0, 0x94, - 0xb6, 0x89, 0xb3, 0x6f, 0x5b, 0xfa, 0x6a, 0x2c, 0xfb, 0xf9, 0x24, 0x79, 0x87, 0x2f, 0x64, 0xcb, - 0xfc, 0x0e, 0x5f, 0xe0, 0xcb, 0x39, 0xf9, 0x11, 0xac, 0xc4, 0x5b, 0xd0, 0x31, 0x1d, 0x10, 0x87, - 0x62, 0x61, 0x1d, 0x16, 0xbd, 0x83, 0x76, 0x6c, 0xd3, 0xef, 0x85, 0x6f, 0xc1, 0x78, 0x54, 0xcb, - 0x7b, 0x90, 0xed, 0x27, 0x7a, 0xde, 0xdb, 0xda, 0x36, 0xe5, 0x0f, 0x0b, 0x50, 0xd1, 0xa8, 0xb5, - 0x7d, 0xce, 0xd2, 0x26, 0x0e, 0x73, 0x91, 0xc1, 0xa6, 0x4a, 0xb1, 0x02, 0x39, 0x64, 0xf6, 0x6d, - 0xc7, 0x57, 0xa0, 0xa8, 0x07, 0x41, 0x9c, 0x2d, 0x3b, 0x8d, 0xcd, 0x4b, 0xed, 0xa1, 0x2e, 0xee, - 0x55, 0xf9, 0x20, 0xd5, 0x0f, 0x84, 0x06, 0x64, 0xfb, 0xd4, 0xf2, 0x05, 0x29, 0xb5, 0x2a, 0xbf, - 0x46, 0x35, 0x41, 0x47, 0xc3, 0xe8, 0x18, 0x1a, 0xa6, 0x14, 0x59, 0x58, 0xf7, 0x20, 0xc2, 0x1b, - 0xc8, 0xed, 0x1f, 0x38, 0x26, 0xad, 0xe6, 0xeb, 0xd9, 0xc6, 0xd2, 0xe6, 0x9a, 0x12, 0x58, 0x42, - 0xf1, 0x2c, 0xa1, 0x84, 0x96, 0x50, 0xda, 0xc4, 0x76, 0x5a, 0x77, 0x4f, 0x46, 0xb5, 0xcc, 0xe7, - 0xef, 0xb5, 0x75, 0xcb, 0x66, 0x6f, 0x0f, 0xba, 0x8a, 0x41, 0xfa, 0x6a, 0xcf, 0x76, 0xb0, 0xda, - 0xeb, 0xf6, 0xef, 0x53, 0xf3, 0x5d, 0xe8, 0x02, 0x0f, 0x4b, 0xf5, 0xa0, 0xa8, 0xfc, 0x0c, 0xa4, - 0x74, 0x29, 0x26, 0x92, 0x56, 0x61, 0x11, 0x99, 0xa6, 0x8b, 0x29, 0x0d, 0x35, 0x89, 0x42, 0x41, - 0x00, 0xde, 0x44, 0x0c, 0x05, 0xae, 0xd0, 0xfd, 0xb5, 0x7c, 0xca, 0x81, 0xa0, 0x51, 0xeb, 0xe9, - 0x11, 0x36, 0x0e, 0xe6, 0xd0, 0x55, 0x84, 0x82, 0x11, 0x62, 0x42, 0x69, 0x27, 0x71, 0x24, 0x51, - 0xf6, 0x0f, 0x24, 0xca, 0xfd, 0x0b, 0x89, 0x36, 0x40, 0xbc, 0xdc, 0xd1, 0x44, 0x9e, 0x48, 0x04, - 0x2e, 0x26, 0xc2, 0xa7, 0x40, 0x04, 0xcd, 0xb6, 0x5c, 0xf4, 0x97, 0x22, 0xcc, 0x65, 0xb1, 0x50, - 0x29, 0xfe, 0x4a, 0xa5, 0xc2, 0x5e, 0x12, 0x07, 0x9b, 0xd9, 0x0b, 0x82, 0x65, 0x8d, 0x5a, 0x7b, - 0x03, 0x13, 0x31, 0xbc, 0xe5, 0xbb, 0x7e, 0x5a, 0x1b, 0x37, 0xa0, 0xe8, 0xe0, 0x61, 0x27, 0x7e, - 0x4f, 0x0a, 0x0e, 0x1e, 0x06, 0x49, 0xf1, 0x1e, 0xb3, 0x17, 0x7b, 0x94, 0xab, 0xfe, 0x75, 0x8c, - 0x51, 0x44, 0x07, 0x92, 0xdb, 0xf0, 0x9f, 0x46, 0xad, 0x76, 0x0f, 0x23, 0x77, 0x36, 0xf7, 0xac, - 0xf2, 0xd7, 0x61, 0xf5, 0x42, 0x91, 0xa8, 0xfa, 0xe6, 0x57, 0x1e, 0xb2, 0x1a, 0xb5, 0x84, 0x5d, - 0x28, 0x9e, 0x0f, 0xc3, 0x94, 0xe1, 0x14, 0x9f, 0x34, 0xe2, 0xed, 0xd9, 0xfb, 0x13, 0x2d, 0xdf, - 0xc3, 0xb5, 0xb4, 0x01, 0xd3, 0x48, 0x4d, 0x4f, 0x41, 0x8a, 0x1b, 0xf3, 0x22, 0x27, 0x94, 0x18, - 0xfe, 0x4f, 0xde, 0xbb, 0x5b, 0xa9, 0x45, 0x12, 0x28, 0xf1, 0xde, 0x3c, 0xa8, 0x38, 0x4d, 0xd2, - 0xd9, 0xe9, 0x34, 0x09, 0xd4, 0x14, 0x9a, 0x69, 0x66, 0x7c, 0x05, 0x4b, 0x71, 0xd7, 0xd5, 0x53, - 0x93, 0x63, 0x08, 0xb1, 0x71, 0x15, 0x62, 0x52, 0xfa, 0x05, 0x40, 0xcc, 0x53, 0xb5, 0xd4, 0xbc, - 0x73, 0x80, 0x78, 0xe7, 0x0a, 0x40, 0x54, 0xb7, 0xf5, 0xf8, 0xe4, 0xa7, 0x94, 0x39, 0x19, 0x4b, - 0xdc, 0xe9, 0x58, 0xe2, 0x7e, 0x8c, 0x25, 0xee, 0xe3, 0x99, 0x94, 0x39, 0x3d, 0x93, 0x32, 0xdf, - 0xce, 0xa4, 0xcc, 0x6b, 0x39, 0x39, 0x73, 0xbc, 0x62, 0xa6, 0x7a, 0x14, 0x3c, 0xd2, 0xfe, 0xe0, - 0xe9, 0xe6, 0xfd, 0x27, 0xfa, 0xc1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x26, 0x87, 0x1c, 0xe3, - 0x25, 0x08, 0x00, 0x00, + // 855 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x1b, 0x27, 0x4d, 0xde, 0x86, 0x25, 0x32, 0xd9, 0xd4, 0x6b, 0x90, 0x13, 0x79, 0x11, + 0x18, 0x01, 0x76, 0x13, 0x24, 0xce, 0x34, 0x81, 0x43, 0x57, 0x32, 0x20, 0x57, 0xcb, 0x0a, 0x84, + 0x14, 0x4d, 0xec, 0x89, 0xd7, 0xda, 0xd8, 0x13, 0x3c, 0x93, 0x26, 0xfd, 0x09, 0xdc, 0xb8, 0xf1, + 0x1f, 0xf8, 0x0d, 0x5c, 0x90, 0x38, 0xf4, 0xd8, 0x23, 0xa7, 0x00, 0xe9, 0xbf, 0xe0, 0x84, 0xfc, + 0x59, 0x6f, 0xea, 0xa4, 0x01, 0x84, 0xb4, 0x97, 0x64, 0x5e, 0xcf, 0xf3, 0x7e, 0x3d, 0x7e, 0xde, + 0x19, 0xc3, 0x23, 0x8b, 0x50, 0x6f, 0x81, 0xa8, 0xa7, 0x47, 0x3f, 0x17, 0x3d, 0x9d, 0x2d, 0xb5, + 0x59, 0x40, 0x18, 0x11, 0x9a, 0xe9, 0x96, 0x16, 0xfd, 0x5c, 0xf4, 0x24, 0x39, 0x7c, 0x42, 0xa8, + 0x3e, 0x46, 0x14, 0xeb, 0x17, 0xbd, 0x31, 0x66, 0xa8, 0xa7, 0x5b, 0xc4, 0xf5, 0x63, 0x0f, 0xa9, + 0xe5, 0x10, 0x87, 0x44, 0x4b, 0x3d, 0x5c, 0x25, 0x4f, 0xdf, 0xba, 0x9b, 0xe2, 0x72, 0x86, 0x69, + 0xbc, 0xab, 0xfc, 0xc2, 0x41, 0xc3, 0xa0, 0xce, 0x39, 0x23, 0x01, 0x1e, 0x12, 0x1b, 0x0b, 0x6d, + 0xa8, 0x52, 0xec, 0xdb, 0x38, 0x10, 0xb9, 0x2e, 0xa7, 0xd6, 0xcd, 0xc4, 0x12, 0x3e, 0x86, 0x07, + 0xa1, 0xff, 0x68, 0x7c, 0xc9, 0xf0, 0xc8, 0x22, 0x36, 0x16, 0x0f, 0xba, 0x9c, 0xda, 0x18, 0x34, + 0xd7, 0xab, 0x4e, 0xe3, 0xd9, 0xe9, 0xb9, 0x31, 0xb8, 0x64, 0x51, 0x04, 0xb3, 0x11, 0xe2, 0x52, + 0x4b, 0x78, 0x0a, 0x6d, 0xd7, 0xa7, 0x0c, 0xf9, 0xcc, 0x45, 0x0c, 0x8f, 0x66, 0x38, 0xf0, 0x5c, + 0x4a, 0x5d, 0xe2, 0x8b, 0x95, 0x2e, 0xa7, 0x1e, 0xf5, 0x65, 0x6d, 0xb3, 0x4f, 0xed, 0xd4, 0xb2, + 0x30, 0xa5, 0x43, 0xe2, 0x4f, 0x5c, 0xc7, 0x7c, 0x98, 0xf3, 0xfe, 0x32, 0x73, 0x7e, 0xc2, 0xd7, + 0xca, 0x4d, 0xfe, 0x09, 0x5f, 0xe3, 0x9b, 0x15, 0xe5, 0x19, 0xb4, 0xf2, 0x2d, 0x98, 0x98, 0xce, + 0x88, 0x4f, 0xb1, 0xf0, 0x18, 0x0e, 0xc3, 0x42, 0x47, 0xae, 0x1d, 0xf5, 0xc2, 0x0f, 0x60, 0xbd, + 0xea, 0x54, 0x43, 0xc8, 0xd9, 0xa7, 0x66, 0x35, 0xdc, 0x3a, 0xb3, 0x05, 0x09, 0x6a, 0xd6, 0x73, + 0x6c, 0xbd, 0xa0, 0x73, 0x2f, 0xee, 0xc8, 0xcc, 0x6c, 0xe5, 0xfb, 0x03, 0x68, 0x1b, 0xd4, 0x39, + 0xbb, 0xad, 0x60, 0x48, 0x7c, 0x16, 0x20, 0x8b, 0x6d, 0xa5, 0xa9, 0x05, 0x15, 0x64, 0x7b, 0xae, + 0x1f, 0xc5, 0xaa, 0x9b, 0xb1, 0x91, 0xaf, 0xa4, 0xbc, 0xb5, 0x92, 0x16, 0x54, 0xa6, 0x68, 0x8c, + 0xa7, 0x22, 0x1f, 0xbb, 0x46, 0x86, 0xa0, 0x42, 0xd9, 0xa3, 0x4e, 0x44, 0x56, 0x63, 0xd0, 0xfe, + 0x6b, 0xd5, 0x11, 0x4c, 0xb4, 0x48, 0xcb, 0x30, 0x30, 0xa5, 0xc8, 0xc1, 0x66, 0x08, 0x11, 0xbe, + 0x85, 0xca, 0x64, 0xee, 0xdb, 0x54, 0xac, 0x76, 0xcb, 0xea, 0x51, 0xff, 0x91, 0x16, 0xcb, 0x45, + 0x0b, 0xe5, 0xa2, 0x25, 0x72, 0xd1, 0x86, 0xc4, 0xf5, 0x07, 0xef, 0x5f, 0xad, 0x3a, 0xa5, 0x9f, + 0x7e, 0xef, 0x3c, 0x76, 0x5c, 0xf6, 0x7c, 0x3e, 0xd6, 0x2c, 0xe2, 0xe9, 0x53, 0xd7, 0xc7, 0xfa, + 0x74, 0xec, 0x7d, 0x48, 0xed, 0x17, 0x89, 0x42, 0x42, 0x2c, 0x35, 0xe3, 0xa0, 0xca, 0xcf, 0x07, + 0x70, 0x5c, 0xcc, 0x45, 0xff, 0x55, 0x24, 0x03, 0xed, 0x4d, 0xc6, 0x49, 0x42, 0x86, 0x9a, 0x23, + 0x23, 0x19, 0xb4, 0xf8, 0x6f, 0x0b, 0x23, 0x82, 0x00, 0x3c, 0x45, 0x53, 0x26, 0x1e, 0x46, 0xaa, + 0x89, 0xd6, 0xc2, 0x31, 0x1c, 0x4e, 0xdc, 0xe5, 0x28, 0x2c, 0xb2, 0xd6, 0xe5, 0xd4, 0x9a, 0x59, + 0x9d, 0xb8, 0x4b, 0x83, 0x3a, 0xca, 0xe7, 0x20, 0x17, 0xb3, 0x97, 0xa9, 0x55, 0x84, 0x43, 0x64, + 0xdb, 0x01, 0xa6, 0x34, 0x61, 0x31, 0x35, 0xc3, 0x44, 0x36, 0x62, 0x28, 0x91, 0x67, 0xb4, 0x56, + 0xbe, 0x80, 0xce, 0x96, 0xb7, 0xf1, 0x2f, 0x03, 0x5e, 0x73, 0x20, 0x18, 0xd4, 0xf9, 0x6c, 0x89, + 0xad, 0xf9, 0x1e, 0x3a, 0x0f, 0xc7, 0x26, 0xc1, 0x24, 0x6f, 0x37, 0xb3, 0xd3, 0xb7, 0x54, 0xfe, + 0x07, 0x92, 0xad, 0xfc, 0x1f, 0x92, 0x3d, 0x01, 0xe9, 0x6e, 0x47, 0x19, 0x3d, 0x29, 0x09, 0x5c, + 0x8e, 0x84, 0x1f, 0x63, 0x12, 0x0c, 0xd7, 0x09, 0xd0, 0x7f, 0x24, 0x61, 0x2f, 0x95, 0x27, 0x4c, + 0xf1, 0xf7, 0x32, 0x95, 0xf4, 0xb2, 0x51, 0xd8, 0xce, 0x5e, 0x10, 0x3c, 0x30, 0xa8, 0xf3, 0x74, + 0x66, 0x23, 0x86, 0x4f, 0xa3, 0xc1, 0xdb, 0xd6, 0xc6, 0x9b, 0x50, 0xf7, 0xf1, 0x62, 0x94, 0x1f, + 0xd5, 0x9a, 0x8f, 0x17, 0xb1, 0x53, 0xbe, 0xc7, 0xf2, 0xcb, 0x3d, 0x2a, 0x62, 0x74, 0x3c, 0xe6, + 0x52, 0xa4, 0x05, 0x29, 0x43, 0x78, 0xcd, 0xa0, 0xce, 0x70, 0x8a, 0x51, 0xb0, 0x3b, 0xf7, 0xae, + 0xf0, 0xc7, 0xf0, 0xf0, 0xa5, 0x20, 0x69, 0xf4, 0xfe, 0xaf, 0x15, 0x28, 0x1b, 0xd4, 0x11, 0xce, + 0xa1, 0x7e, 0x7b, 0x71, 0x15, 0x5c, 0x24, 0xf9, 0x5b, 0x41, 0x7a, 0x67, 0xf7, 0x7e, 0xc6, 0xe5, + 0x77, 0xf0, 0x46, 0xd1, 0x81, 0xaf, 0x16, 0xba, 0x17, 0x20, 0xa5, 0x93, 0x7d, 0x91, 0x59, 0x4a, + 0x06, 0xad, 0xc2, 0x73, 0xf5, 0xbd, 0x7d, 0x23, 0xf5, 0xa5, 0xde, 0xde, 0xd0, 0x2c, 0x2b, 0x86, + 0xd7, 0x37, 0xa7, 0xfd, 0xed, 0xc2, 0x28, 0x1b, 0x28, 0xe9, 0x83, 0x7d, 0x50, 0xf9, 0x34, 0x9b, + 0xf3, 0x54, 0x9c, 0x66, 0x03, 0xb5, 0x25, 0xcd, 0xb6, 0x11, 0xf8, 0x1a, 0x8e, 0xf2, 0x5a, 0xef, + 0x16, 0x3a, 0xe7, 0x10, 0x92, 0x7a, 0x1f, 0x22, 0x0b, 0xfd, 0x15, 0x40, 0x4e, 0xc9, 0x9d, 0x42, + 0xbf, 0x5b, 0x80, 0xf4, 0xee, 0x3d, 0x80, 0x34, 0xee, 0xe0, 0x93, 0xab, 0x3f, 0xe5, 0xd2, 0xd5, + 0x5a, 0xe6, 0xae, 0xd7, 0x32, 0xf7, 0xc7, 0x5a, 0xe6, 0x7e, 0xb8, 0x91, 0x4b, 0xd7, 0x37, 0x72, + 0xe9, 0xb7, 0x1b, 0xb9, 0xf4, 0x8d, 0xb2, 0x79, 0xd2, 0x85, 0xc1, 0x6c, 0x7d, 0x19, 0x7f, 0xc6, + 0x45, 0xc7, 0xdd, 0xb8, 0x1a, 0x7d, 0xc4, 0x7d, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x77, + 0xb6, 0xf2, 0xa2, 0x47, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -614,8 +721,12 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // StoreCode to submit Wasm code to the system StoreCode(ctx context.Context, in *MsgStoreCode, opts ...grpc.CallOption) (*MsgStoreCodeResponse, error) - // Instantiate creates a new smart contract instance for the given code id. + // InstantiateContract creates a new smart contract instance for the given + // code id. InstantiateContract(ctx context.Context, in *MsgInstantiateContract, opts ...grpc.CallOption) (*MsgInstantiateContractResponse, error) + // InstantiateContract2 creates a new smart contract instance for the given + // code id with a predictable address + InstantiateContract2(ctx context.Context, in *MsgInstantiateContract2, opts ...grpc.CallOption) (*MsgInstantiateContract2Response, error) // Execute submits the given message data to a smart contract ExecuteContract(ctx context.Context, in *MsgExecuteContract, opts ...grpc.CallOption) (*MsgExecuteContractResponse, error) // Migrate runs a code upgrade/ downgrade for a smart contract @@ -652,6 +763,15 @@ func (c *msgClient) InstantiateContract(ctx context.Context, in *MsgInstantiateC return out, nil } +func (c *msgClient) InstantiateContract2(ctx context.Context, in *MsgInstantiateContract2, opts ...grpc.CallOption) (*MsgInstantiateContract2Response, error) { + out := new(MsgInstantiateContract2Response) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/InstantiateContract2", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) ExecuteContract(ctx context.Context, in *MsgExecuteContract, opts ...grpc.CallOption) (*MsgExecuteContractResponse, error) { out := new(MsgExecuteContractResponse) err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/ExecuteContract", in, out, opts...) @@ -692,8 +812,12 @@ func (c *msgClient) ClearAdmin(ctx context.Context, in *MsgClearAdmin, opts ...g type MsgServer interface { // StoreCode to submit Wasm code to the system StoreCode(context.Context, *MsgStoreCode) (*MsgStoreCodeResponse, error) - // Instantiate creates a new smart contract instance for the given code id. + // InstantiateContract creates a new smart contract instance for the given + // code id. InstantiateContract(context.Context, *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) + // InstantiateContract2 creates a new smart contract instance for the given + // code id with a predictable address + InstantiateContract2(context.Context, *MsgInstantiateContract2) (*MsgInstantiateContract2Response, error) // Execute submits the given message data to a smart contract ExecuteContract(context.Context, *MsgExecuteContract) (*MsgExecuteContractResponse, error) // Migrate runs a code upgrade/ downgrade for a smart contract @@ -714,6 +838,9 @@ func (*UnimplementedMsgServer) StoreCode(ctx context.Context, req *MsgStoreCode) func (*UnimplementedMsgServer) InstantiateContract(ctx context.Context, req *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InstantiateContract not implemented") } +func (*UnimplementedMsgServer) InstantiateContract2(ctx context.Context, req *MsgInstantiateContract2) (*MsgInstantiateContract2Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method InstantiateContract2 not implemented") +} func (*UnimplementedMsgServer) ExecuteContract(ctx context.Context, req *MsgExecuteContract) (*MsgExecuteContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ExecuteContract not implemented") } @@ -767,6 +894,24 @@ func _Msg_InstantiateContract_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_InstantiateContract2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgInstantiateContract2) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).InstantiateContract2(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Msg/InstantiateContract2", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).InstantiateContract2(ctx, req.(*MsgInstantiateContract2)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_ExecuteContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgExecuteContract) if err := dec(in); err != nil { @@ -851,6 +996,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "InstantiateContract", Handler: _Msg_InstantiateContract_Handler, }, + { + MethodName: "InstantiateContract2", + Handler: _Msg_InstantiateContract2_Handler, + }, { MethodName: "ExecuteContract", Handler: _Msg_ExecuteContract_Handler, @@ -941,6 +1090,13 @@ func (m *MsgStoreCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Checksum) > 0 { + i -= len(m.Checksum) + copy(dAtA[i:], m.Checksum) + i = encodeVarintTx(dAtA, i, uint64(len(m.Checksum))) + i-- + dAtA[i] = 0x12 + } if m.CodeID != 0 { i = encodeVarintTx(dAtA, i, uint64(m.CodeID)) i-- @@ -1019,6 +1175,93 @@ func (m *MsgInstantiateContract) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgInstantiateContract2) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgInstantiateContract2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInstantiateContract2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FixMsg { + i-- + if m.FixMsg { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if len(m.Salt) > 0 { + i -= len(m.Salt) + copy(dAtA[i:], m.Salt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) + i-- + dAtA[i] = 0x3a + } + if len(m.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintTx(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x2a + } + if len(m.Label) > 0 { + i -= len(m.Label) + copy(dAtA[i:], m.Label) + i = encodeVarintTx(dAtA, i, uint64(len(m.Label))) + i-- + dAtA[i] = 0x22 + } + if m.CodeID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CodeID)) + i-- + dAtA[i] = 0x18 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgInstantiateContractResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1056,6 +1299,43 @@ func (m *MsgInstantiateContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgInstantiateContract2Response) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgInstantiateContract2Response) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInstantiateContract2Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgExecuteContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1391,6 +1671,10 @@ func (m *MsgStoreCodeResponse) Size() (n int) { if m.CodeID != 0 { n += 1 + sovTx(uint64(m.CodeID)) } + l = len(m.Checksum) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1428,34 +1712,24 @@ func (m *MsgInstantiateContract) Size() (n int) { return n } -func (m *MsgInstantiateContractResponse) Size() (n int) { +func (m *MsgInstantiateContract2) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Address) + l = len(m.Sender) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Data) + l = len(m.Admin) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} - -func (m *MsgExecuteContract) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.CodeID != 0 { + n += 1 + sovTx(uint64(m.CodeID)) } - l = len(m.Contract) + l = len(m.Label) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1469,15 +1743,26 @@ func (m *MsgExecuteContract) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } + l = len(m.Salt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FixMsg { + n += 2 + } return n } -func (m *MsgExecuteContractResponse) Size() (n int) { +func (m *MsgInstantiateContractResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Data) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1485,42 +1770,99 @@ func (m *MsgExecuteContractResponse) Size() (n int) { return n } -func (m *MsgMigrateContract) Size() (n int) { +func (m *MsgInstantiateContract2Response) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Contract) + l = len(m.Address) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.CodeID != 0 { - n += 1 + sovTx(uint64(m.CodeID)) - } - l = len(m.Msg) + l = len(m.Data) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgMigrateContractResponse) Size() (n int) { +func (m *MsgExecuteContract) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Data) + l = len(m.Sender) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgExecuteContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMigrateContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.CodeID != 0 { + n += 1 + sovTx(uint64(m.CodeID)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMigrateContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} func (m *MsgUpdateAdmin) Size() (n int) { if m == nil { @@ -1784,6 +2126,40 @@ func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksum = append(m.Checksum[:0], dAtA[iNdEx:postIndex]...) + if m.Checksum == nil { + m.Checksum = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2038,6 +2414,293 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgInstantiateContract2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContract2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) + } + m.CodeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Label", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Label = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) + if m.Msg == nil { + m.Msg = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funds = append(m.Funds, types.Coin{}) + if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) + if m.Salt == nil { + m.Salt = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FixMsg", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.FixMsg = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2154,6 +2817,122 @@ func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgInstantiateContract2Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContract2Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index d6e818306f..5692776d2d 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -84,6 +84,7 @@ func TestInstantiateContractValidation(t *testing.T) { badAddress := bad.String() // proper address size goodAddress := sdk.AccAddress(make([]byte, 20)).String() + sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) cases := map[string]struct { msg MsgInstantiateContract @@ -185,6 +186,142 @@ func TestInstantiateContractValidation(t *testing.T) { } } +func TestInstantiateContract2Validation(t *testing.T) { + bad, err := sdk.AccAddressFromHex("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) + + cases := map[string]struct { + msg MsgInstantiateContract2 + valid bool + }{ + "empty": { + msg: MsgInstantiateContract2{}, + valid: false, + }, + "correct minimal": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte("{}"), + Salt: []byte{0}, + }, + valid: true, + }, + "missing code": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + Label: "foo", + Msg: []byte("{}"), + Salt: []byte{0}, + }, + valid: false, + }, + "missing label": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + Msg: []byte("{}"), + Salt: []byte{0}, + }, + valid: false, + }, + "label too long": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + Label: strings.Repeat("food", 33), + Salt: []byte{0}, + }, + valid: false, + }, + "bad sender minimal": { + msg: MsgInstantiateContract2{ + Sender: badAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte("{}"), + Salt: []byte{0}, + }, + valid: false, + }, + "correct maximal": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: strings.Repeat("a", MaxLabelSize), + Msg: []byte(`{"some": "data"}`), + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + Salt: bytes.Repeat([]byte{0}, MaxSaltSize), + FixMsg: true, + }, + valid: true, + }, + "negative funds": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte(`{"some": "data"}`), + // we cannot use sdk.NewCoin() constructors as they panic on creating invalid data (before we can test) + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-200)}}, + Salt: []byte{0}, + }, + valid: false, + }, + "non json init msg": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte("invalid-json"), + Salt: []byte{0}, + }, + valid: false, + }, + "empty init msg": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Salt: []byte{0}, + }, + valid: false, + }, + "empty salt": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte(`{"some": "data"}`), + }, + valid: false, + }, + "salt too long": { + msg: MsgInstantiateContract2{ + Sender: goodAddress, + CodeID: firstCodeID, + Label: "foo", + Msg: []byte(`{"some": "data"}`), + Salt: bytes.Repeat([]byte{0}, 65), + }, + valid: false, + }, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.valid { + assert.NoError(t, err) + } else { + assert.Error(t, err) + } + }) + } +} + func TestExecuteContractValidation(t *testing.T) { bad, err := sdk.AccAddressFromHex("012345") require.NoError(t, err) diff --git a/x/wasm/types/types.go b/x/wasm/types/types.go index 8b04e0958a..b01fbd95f9 100644 --- a/x/wasm/types/types.go +++ b/x/wasm/types/types.go @@ -89,7 +89,7 @@ func (c *ContractInfo) ValidateBasic() error { return sdkerrors.Wrap(err, "admin") } } - if err := validateLabel(c.Label); err != nil { + if err := ValidateLabel(c.Label); err != nil { return sdkerrors.Wrap(err, "label") } if c.Extension == nil { @@ -335,18 +335,54 @@ func VerifyAddressLen() func(addr []byte) error { // IsSubset will return true if the caller is the same as the superset, // or if the caller is more restrictive than the superset. -func (a AccessConfig) IsSubset(superSet AccessConfig) bool { - switch superSet.Permission { +func (a AccessType) IsSubset(superSet AccessType) bool { + switch superSet { case AccessTypeEverybody: // Everything is a subset of this - return a.Permission != AccessTypeUnspecified + return a != AccessTypeUnspecified case AccessTypeNobody: // Only an exact match is a subset of this - return a.Permission == AccessTypeNobody + return a == AccessTypeNobody + case AccessTypeOnlyAddress, AccessTypeAnyOfAddresses: + // Nobody or address(es) + return a == AccessTypeNobody || a == AccessTypeOnlyAddress || a == AccessTypeAnyOfAddresses + default: + return false + } +} + +// IsSubset will return true if the caller is the same as the superset, +// or if the caller is more restrictive than the superset. +func (a AccessConfig) IsSubset(superSet AccessConfig) bool { + switch superSet.Permission { case AccessTypeOnlyAddress: // An exact match or nobody - return a.Permission == AccessTypeNobody || (a.Permission == AccessTypeOnlyAddress && a.Address == superSet.Address) - default: + return a.Permission == AccessTypeNobody || (a.Permission == AccessTypeOnlyAddress && a.Address == superSet.Address) || + (a.Permission == AccessTypeAnyOfAddresses && isSubset([]string{superSet.Address}, a.Addresses)) + case AccessTypeAnyOfAddresses: + // An exact match or nobody + return a.Permission == AccessTypeNobody || (a.Permission == AccessTypeOnlyAddress && isSubset(superSet.Addresses, []string{a.Address})) || + a.Permission == AccessTypeAnyOfAddresses && isSubset(superSet.Addresses, a.Addresses) + case AccessTypeUnspecified: return false + default: + return a.Permission.IsSubset(superSet.Permission) + } +} + +// return true when all elements in sub are also part of super +func isSubset(super, sub []string) bool { + if len(sub) == 0 { + return true + } + var matches int + for _, o := range sub { + for _, s := range super { + if o == s { + matches++ + break + } + } } + return matches == len(sub) } diff --git a/x/wasm/types/types.pb.go b/x/wasm/types/types.pb.go index f0764b5b23..a21dc8d506 100644 --- a/x/wasm/types/types.pb.go +++ b/x/wasm/types/types.pb.go @@ -35,10 +35,13 @@ const ( AccessTypeUnspecified AccessType = 0 // AccessTypeNobody forbidden AccessTypeNobody AccessType = 1 - // AccessTypeOnlyAddress restricted to an address + // AccessTypeOnlyAddress restricted to a single address + // Deprecated: use AccessTypeAnyOfAddresses instead AccessTypeOnlyAddress AccessType = 2 // AccessTypeEverybody unrestricted AccessTypeEverybody AccessType = 3 + // AccessTypeAnyOfAddresses allow any of the addresses + AccessTypeAnyOfAddresses AccessType = 4 ) var AccessType_name = map[int32]string{ @@ -46,13 +49,15 @@ var AccessType_name = map[int32]string{ 1: "ACCESS_TYPE_NOBODY", 2: "ACCESS_TYPE_ONLY_ADDRESS", 3: "ACCESS_TYPE_EVERYBODY", + 4: "ACCESS_TYPE_ANY_OF_ADDRESSES", } var AccessType_value = map[string]int32{ - "ACCESS_TYPE_UNSPECIFIED": 0, - "ACCESS_TYPE_NOBODY": 1, - "ACCESS_TYPE_ONLY_ADDRESS": 2, - "ACCESS_TYPE_EVERYBODY": 3, + "ACCESS_TYPE_UNSPECIFIED": 0, + "ACCESS_TYPE_NOBODY": 1, + "ACCESS_TYPE_ONLY_ADDRESS": 2, + "ACCESS_TYPE_EVERYBODY": 3, + "ACCESS_TYPE_ANY_OF_ADDRESSES": 4, } func (AccessType) EnumDescriptor() ([]byte, []int) { @@ -136,7 +141,10 @@ var xxx_messageInfo_AccessTypeParam proto.InternalMessageInfo // AccessConfig access control type. type AccessConfig struct { Permission AccessType `protobuf:"varint,1,opt,name=permission,proto3,enum=cosmwasm.wasm.v1.AccessType" json:"permission,omitempty" yaml:"permission"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + // Address + // Deprecated: replaced by addresses + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Addresses []string `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty" yaml:"addresses"` } func (m *AccessConfig) Reset() { *m = AccessConfig{} } @@ -452,83 +460,87 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/types.proto", fileDescriptor_e6155d98fa173e02) } var fileDescriptor_e6155d98fa173e02 = []byte{ - // 1213 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xda, 0xce, 0x87, 0x27, 0x6e, 0x71, 0xa7, 0x09, 0xb5, 0x4d, 0xe5, 0x75, 0x97, 0x22, - 0xd2, 0x36, 0xb5, 0xdb, 0x20, 0x81, 0x14, 0x89, 0x0a, 0xaf, 0xbd, 0x34, 0x5b, 0x11, 0xdb, 0x1a, - 0xbb, 0xa0, 0x20, 0x55, 0xab, 0xf5, 0xee, 0xc4, 0x19, 0x75, 0xbd, 0x63, 0xed, 0x8c, 0x53, 0xfb, - 0x1f, 0xa0, 0x48, 0x48, 0xdc, 0xe0, 0x12, 0x09, 0x01, 0x42, 0xfd, 0x01, 0x5c, 0xb9, 0x57, 0x88, - 0x43, 0x8f, 0x9c, 0x56, 0x90, 0x5e, 0xe0, 0xea, 0x63, 0xb9, 0xa0, 0x9d, 0xb1, 0xb1, 0x69, 0xd3, - 0x26, 0x5c, 0x56, 0xfb, 0x7e, 0x3c, 0xcf, 0xfb, 0x39, 0xb3, 0x0b, 0x2e, 0x3b, 0x94, 0xf5, 0x1e, - 0xd9, 0xac, 0x57, 0x16, 0x8f, 0x83, 0xdb, 0x65, 0x3e, 0xea, 0x63, 0x56, 0xea, 0x07, 0x94, 0x53, - 0x98, 0x99, 0x5a, 0x4b, 0xe2, 0x71, 0x70, 0x3b, 0x9f, 0x8b, 0x34, 0x94, 0x59, 0xc2, 0x5e, 0x96, - 0x82, 0x74, 0xce, 0xaf, 0x76, 0x69, 0x97, 0x4a, 0x7d, 0xf4, 0x36, 0xd1, 0xe6, 0xba, 0x94, 0x76, - 0x3d, 0x5c, 0x16, 0x52, 0x67, 0xb0, 0x57, 0xb6, 0xfd, 0x91, 0x34, 0x69, 0x0f, 0xc0, 0x1b, 0x15, - 0xc7, 0xc1, 0x8c, 0xb5, 0x47, 0x7d, 0xdc, 0xb4, 0x03, 0xbb, 0x07, 0x6b, 0x60, 0xe1, 0xc0, 0xf6, - 0x06, 0x38, 0xab, 0x14, 0x95, 0xf5, 0xf3, 0x9b, 0x97, 0x4b, 0x2f, 0x26, 0x50, 0x9a, 0x21, 0xf4, - 0xcc, 0x38, 0x54, 0xd3, 0x23, 0xbb, 0xe7, 0x6d, 0x69, 0x02, 0xa4, 0x21, 0x09, 0xde, 0x4a, 0x7e, - 0xf3, 0xad, 0xaa, 0x68, 0x5f, 0x2b, 0x20, 0x2d, 0xbd, 0xab, 0xd4, 0xdf, 0x23, 0x5d, 0xd8, 0x02, - 0xa0, 0x8f, 0x83, 0x1e, 0x61, 0x8c, 0x50, 0xff, 0x4c, 0x11, 0xd6, 0xc6, 0xa1, 0x7a, 0x41, 0x46, - 0x98, 0x21, 0x35, 0x34, 0x47, 0x03, 0x37, 0xc0, 0x92, 0xed, 0xba, 0x01, 0x66, 0x2c, 0x1b, 0x2f, - 0x2a, 0xeb, 0x29, 0x1d, 0x8e, 0x43, 0xf5, 0xbc, 0xc4, 0x4c, 0x0c, 0x1a, 0x9a, 0xba, 0x4c, 0x32, - 0xfb, 0x35, 0x01, 0x16, 0x45, 0xbd, 0x0c, 0x52, 0x00, 0x1d, 0xea, 0x62, 0x6b, 0xd0, 0xf7, 0xa8, - 0xed, 0x5a, 0xb6, 0x88, 0x2d, 0x72, 0x5b, 0xd9, 0x2c, 0xbc, 0x2a, 0x37, 0x59, 0x8f, 0x7e, 0xe5, - 0x49, 0xa8, 0xc6, 0xc6, 0xa1, 0x9a, 0x93, 0xd1, 0x5e, 0xe6, 0xd1, 0x50, 0x26, 0x52, 0xde, 0x17, - 0x3a, 0x09, 0x85, 0x5f, 0x2a, 0xa0, 0x40, 0x7c, 0xc6, 0x6d, 0x9f, 0x13, 0x9b, 0x63, 0xcb, 0xc5, - 0x7b, 0xf6, 0xc0, 0xe3, 0xd6, 0x5c, 0x67, 0xe2, 0x67, 0xe8, 0xcc, 0xb5, 0x71, 0xa8, 0xbe, 0x23, - 0xe3, 0xbe, 0x9e, 0x4d, 0x43, 0x97, 0xe7, 0x1c, 0x6a, 0xd2, 0xde, 0x9c, 0xf5, 0xef, 0x23, 0x70, - 0xbe, 0x6b, 0x33, 0xab, 0x37, 0xf0, 0x38, 0xe9, 0x7b, 0x04, 0x07, 0xd9, 0x44, 0x51, 0x59, 0x4f, - 0xea, 0xb9, 0x71, 0xa8, 0xae, 0xc9, 0x00, 0xff, 0xb5, 0x6b, 0xe8, 0x5c, 0xd7, 0x66, 0x3b, 0xff, - 0xca, 0xf0, 0x43, 0x70, 0x4e, 0x46, 0x70, 0xb0, 0xe5, 0x50, 0xc6, 0xb3, 0x49, 0x41, 0x90, 0x1d, - 0x87, 0xea, 0xea, 0x7c, 0x86, 0x13, 0xb3, 0x86, 0xd2, 0x53, 0xb9, 0x4a, 0x19, 0x87, 0x5b, 0x20, - 0xed, 0xd0, 0x5e, 0x9f, 0x78, 0x13, 0xf4, 0x82, 0x40, 0x5f, 0x1a, 0x87, 0xea, 0xc5, 0x69, 0x5f, - 0x67, 0x56, 0x0d, 0xad, 0x4c, 0xc4, 0x08, 0x2b, 0xc6, 0x19, 0xd3, 0xbe, 0x53, 0xc0, 0x72, 0x95, - 0xba, 0xd8, 0xf4, 0xf7, 0x28, 0x7c, 0x0b, 0xa4, 0xc4, 0x20, 0xf6, 0x6d, 0xb6, 0x2f, 0xe6, 0x98, - 0x46, 0xcb, 0x91, 0x62, 0xdb, 0x66, 0xfb, 0x30, 0x0b, 0x96, 0x9c, 0x00, 0xdb, 0x9c, 0x06, 0x72, - 0x59, 0xd0, 0x54, 0x84, 0x2d, 0x00, 0xe7, 0xfb, 0xe8, 0x88, 0x09, 0x8b, 0x5c, 0x4e, 0xdf, 0x83, - 0x64, 0xb4, 0x07, 0xe8, 0xc2, 0x1c, 0x5e, 0x1a, 0xee, 0x25, 0x97, 0x13, 0x99, 0xe4, 0xbd, 0xe4, - 0x72, 0x32, 0xb3, 0xa0, 0xfd, 0x1c, 0x07, 0xe9, 0x2a, 0xf5, 0x79, 0x60, 0x3b, 0x5c, 0x24, 0xfa, - 0x36, 0x58, 0x12, 0x89, 0x12, 0x57, 0xa4, 0x99, 0xd4, 0xc1, 0x71, 0xa8, 0x2e, 0x8a, 0x3a, 0x6a, - 0x68, 0x31, 0x32, 0x99, 0xee, 0x6b, 0x12, 0x5e, 0x05, 0x0b, 0xb6, 0xdb, 0x23, 0xbe, 0x18, 0x57, - 0x0a, 0x49, 0x21, 0xd2, 0x7a, 0x76, 0x07, 0x7b, 0x62, 0x06, 0x29, 0x24, 0x05, 0x78, 0x67, 0xc2, - 0x82, 0xdd, 0x49, 0x45, 0x57, 0x4f, 0xa8, 0xa8, 0xc3, 0xa8, 0x37, 0xe0, 0xb8, 0x3d, 0x6c, 0x52, - 0x46, 0x38, 0xa1, 0x3e, 0x9a, 0x82, 0xe0, 0x4d, 0xb0, 0x42, 0x3a, 0x8e, 0xd5, 0xa7, 0x01, 0x8f, - 0xd2, 0x5d, 0x14, 0xe7, 0xec, 0xdc, 0x71, 0xa8, 0xa6, 0x4c, 0xbd, 0xda, 0xa4, 0x01, 0x37, 0x6b, - 0x28, 0x45, 0x3a, 0x8e, 0x78, 0x75, 0xe1, 0x0e, 0x48, 0xe1, 0x21, 0xc7, 0xbe, 0x58, 0xe6, 0x25, - 0x11, 0x70, 0xb5, 0x24, 0xaf, 0xa1, 0xd2, 0xf4, 0x1a, 0x2a, 0x55, 0xfc, 0x91, 0x9e, 0xfb, 0xe5, - 0xa7, 0x9b, 0x6b, 0xf3, 0x4d, 0x31, 0xa6, 0x30, 0x34, 0x63, 0xd8, 0x4a, 0xfe, 0x19, 0x9d, 0xd9, - 0xbf, 0x15, 0x90, 0x9d, 0xba, 0x46, 0x4d, 0xda, 0x26, 0x8c, 0xd3, 0x60, 0x64, 0xf8, 0x3c, 0x18, - 0xc1, 0x26, 0x48, 0xd1, 0x3e, 0x0e, 0x6c, 0x3e, 0xbb, 0x58, 0x36, 0x5f, 0x2e, 0xf1, 0x04, 0x78, - 0x63, 0x8a, 0x8a, 0x0e, 0x15, 0x9a, 0x91, 0xcc, 0x4f, 0x27, 0xfe, 0xca, 0xe9, 0xdc, 0x01, 0x4b, - 0x83, 0xbe, 0x2b, 0xfa, 0x9a, 0xf8, 0x3f, 0x7d, 0x9d, 0x80, 0xe0, 0x3a, 0x48, 0xf4, 0x58, 0x57, - 0xcc, 0x2a, 0xad, 0xbf, 0xf9, 0x3c, 0x54, 0x21, 0xb2, 0x1f, 0x4d, 0xb3, 0xdc, 0xc1, 0x8c, 0xd9, - 0x5d, 0x8c, 0x22, 0x17, 0x0d, 0x01, 0xf8, 0x32, 0x11, 0xbc, 0x02, 0xd2, 0x1d, 0x8f, 0x3a, 0x0f, - 0xad, 0x7d, 0x4c, 0xba, 0xfb, 0x5c, 0xee, 0x11, 0x5a, 0x11, 0xba, 0x6d, 0xa1, 0x82, 0x39, 0xb0, - 0xcc, 0x87, 0x16, 0xf1, 0x5d, 0x3c, 0x94, 0x85, 0xa0, 0x25, 0x3e, 0x34, 0x23, 0x51, 0xb3, 0xc1, - 0xc2, 0x0e, 0x75, 0xb1, 0x07, 0x75, 0x90, 0x78, 0x88, 0x47, 0xf2, 0xb0, 0xe8, 0xb7, 0x9e, 0x87, - 0xea, 0x46, 0x97, 0xf0, 0xfd, 0x41, 0xa7, 0xe4, 0xd0, 0x5e, 0xd9, 0x23, 0x3e, 0x2e, 0x53, 0x16, - 0xa5, 0x44, 0xfd, 0xb2, 0x47, 0x3a, 0xac, 0xdc, 0x19, 0x71, 0xcc, 0x4a, 0xdb, 0x78, 0xa8, 0x47, - 0x2f, 0x28, 0x02, 0x47, 0x8b, 0x27, 0x3f, 0x1c, 0x71, 0x71, 0xe4, 0xa4, 0x70, 0xfd, 0x2f, 0x05, - 0x80, 0xd9, 0xa5, 0x05, 0xdf, 0x07, 0x97, 0x2a, 0xd5, 0xaa, 0xd1, 0x6a, 0x59, 0xed, 0xdd, 0xa6, - 0x61, 0xdd, 0xaf, 0xb7, 0x9a, 0x46, 0xd5, 0xfc, 0xd8, 0x34, 0x6a, 0x99, 0x58, 0x3e, 0x77, 0x78, - 0x54, 0x5c, 0x9b, 0x39, 0xdf, 0xf7, 0x59, 0x1f, 0x3b, 0x64, 0x8f, 0x60, 0x17, 0x6e, 0x00, 0x38, - 0x8f, 0xab, 0x37, 0xf4, 0x46, 0x6d, 0x37, 0xa3, 0xe4, 0x57, 0x0f, 0x8f, 0x8a, 0x99, 0x19, 0xa4, - 0x4e, 0x3b, 0xd4, 0x1d, 0xc1, 0x0f, 0x40, 0x76, 0xde, 0xbb, 0x51, 0xff, 0x64, 0xd7, 0xaa, 0xd4, - 0x6a, 0xc8, 0x68, 0xb5, 0x32, 0xf1, 0x17, 0xc3, 0x34, 0x7c, 0x6f, 0x54, 0x91, 0x1f, 0x07, 0xb8, - 0x09, 0xd6, 0xe6, 0x81, 0xc6, 0xa7, 0x06, 0xda, 0x15, 0x91, 0x12, 0xf9, 0x4b, 0x87, 0x47, 0xc5, - 0x8b, 0x33, 0x94, 0x71, 0x80, 0x83, 0x51, 0x14, 0x2c, 0xbf, 0xfc, 0xc5, 0xf7, 0x85, 0xd8, 0xe3, - 0x1f, 0x0a, 0xb1, 0xeb, 0x3f, 0x26, 0x40, 0xf1, 0xb4, 0x0d, 0x83, 0x18, 0xdc, 0xaa, 0x36, 0xea, - 0x6d, 0x54, 0xa9, 0xb6, 0xad, 0x6a, 0xa3, 0x66, 0x58, 0xdb, 0x66, 0xab, 0xdd, 0x40, 0xbb, 0x56, - 0xa3, 0x69, 0xa0, 0x4a, 0xdb, 0x6c, 0xd4, 0x4f, 0x6a, 0x4d, 0xf9, 0xf0, 0xa8, 0x78, 0xe3, 0x34, - 0xee, 0xf9, 0x86, 0x7d, 0x06, 0xae, 0x9d, 0x29, 0x8c, 0x59, 0x37, 0xdb, 0x19, 0x25, 0xbf, 0x7e, - 0x78, 0x54, 0xbc, 0x7a, 0x1a, 0xbf, 0xe9, 0x13, 0x0e, 0x1f, 0x80, 0x8d, 0x33, 0x11, 0xef, 0x98, - 0x77, 0x51, 0xa5, 0x6d, 0x64, 0xe2, 0xf9, 0x1b, 0x87, 0x47, 0xc5, 0x77, 0x4f, 0xe3, 0xde, 0x21, - 0xdd, 0xc0, 0xe6, 0xf8, 0xcc, 0xf4, 0x77, 0x8d, 0xba, 0xd1, 0x32, 0x5b, 0x99, 0xc4, 0xd9, 0xe8, - 0xef, 0x62, 0x1f, 0x33, 0xc2, 0xf2, 0xc9, 0x68, 0x58, 0x7a, 0xed, 0xc9, 0x1f, 0x85, 0xd8, 0xe3, - 0xe3, 0x82, 0xf2, 0xe4, 0xb8, 0xa0, 0x3c, 0x3d, 0x2e, 0x28, 0xbf, 0x1f, 0x17, 0x94, 0xaf, 0x9e, - 0x15, 0x62, 0x4f, 0x9f, 0x15, 0x62, 0xbf, 0x3d, 0x2b, 0xc4, 0x3e, 0xd7, 0x5e, 0xdc, 0xff, 0xe8, - 0x30, 0xbb, 0xe5, 0xa1, 0xfc, 0x47, 0x13, 0x3f, 0x68, 0x9d, 0x45, 0x71, 0x93, 0xbd, 0xf7, 0x4f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xc4, 0xff, 0xd0, 0xc1, 0xc1, 0x09, 0x00, 0x00, + // 1267 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcf, 0x6f, 0x1a, 0xc7, + 0x1e, 0x67, 0x01, 0xff, 0x60, 0x4c, 0xf2, 0x36, 0x13, 0xfb, 0x05, 0x78, 0x16, 0x4b, 0xf6, 0xe5, + 0xe9, 0x39, 0x89, 0x03, 0x89, 0x2b, 0xb5, 0x92, 0xa5, 0x46, 0x65, 0x61, 0x13, 0x6f, 0x54, 0x03, + 0x1a, 0x48, 0x2b, 0x57, 0x8a, 0x56, 0xcb, 0xee, 0x18, 0xaf, 0xb2, 0xec, 0xa0, 0x9d, 0xc1, 0x81, + 0xff, 0xa0, 0x42, 0xaa, 0xd4, 0x63, 0x2f, 0x48, 0x55, 0x5b, 0x55, 0xe9, 0xbd, 0xd7, 0xde, 0xa3, + 0xb6, 0x87, 0x1c, 0x7b, 0x5a, 0xb5, 0xce, 0xa5, 0x67, 0x8e, 0xe9, 0xa5, 0xda, 0x19, 0x08, 0xe4, + 0xa7, 0xdd, 0x0b, 0x9a, 0xef, 0x8f, 0xcf, 0xe7, 0xfb, 0x73, 0x66, 0x01, 0x9b, 0x36, 0xa1, 0xdd, + 0x47, 0x16, 0xed, 0x96, 0xf8, 0xcf, 0xf1, 0xad, 0x12, 0x1b, 0xf6, 0x30, 0x2d, 0xf6, 0x02, 0xc2, + 0x08, 0x94, 0x67, 0xd6, 0x22, 0xff, 0x39, 0xbe, 0x95, 0xcb, 0x46, 0x1a, 0x42, 0x4d, 0x6e, 0x2f, + 0x09, 0x41, 0x38, 0xe7, 0xd6, 0x3b, 0xa4, 0x43, 0x84, 0x3e, 0x3a, 0x4d, 0xb5, 0xd9, 0x0e, 0x21, + 0x1d, 0x0f, 0x97, 0xb8, 0xd4, 0xee, 0x1f, 0x96, 0x2c, 0x7f, 0x28, 0x4c, 0xea, 0x03, 0xf0, 0xaf, + 0xb2, 0x6d, 0x63, 0x4a, 0x5b, 0xc3, 0x1e, 0x6e, 0x58, 0x81, 0xd5, 0x85, 0x55, 0xb0, 0x74, 0x6c, + 0x79, 0x7d, 0x9c, 0x91, 0x0a, 0xd2, 0xd6, 0xf9, 0x9d, 0xcd, 0xe2, 0xab, 0x09, 0x14, 0xe7, 0x08, + 0x4d, 0x9e, 0x84, 0x4a, 0x7a, 0x68, 0x75, 0xbd, 0x5d, 0x95, 0x83, 0x54, 0x24, 0xc0, 0xbb, 0xc9, + 0xaf, 0xbe, 0x56, 0x24, 0xf5, 0x17, 0x09, 0xa4, 0x85, 0x77, 0x85, 0xf8, 0x87, 0x6e, 0x07, 0x36, + 0x01, 0xe8, 0xe1, 0xa0, 0xeb, 0x52, 0xea, 0x12, 0xff, 0x4c, 0x11, 0x36, 0x26, 0xa1, 0x72, 0x41, + 0x44, 0x98, 0x23, 0x55, 0xb4, 0x40, 0x03, 0xb7, 0xc1, 0x8a, 0xe5, 0x38, 0x01, 0xa6, 0x34, 0x13, + 0x2f, 0x48, 0x5b, 0x29, 0x0d, 0x4e, 0x42, 0xe5, 0xbc, 0xc0, 0x4c, 0x0d, 0x2a, 0x9a, 0xb9, 0xc0, + 0x1d, 0x90, 0x9a, 0x1e, 0x31, 0xcd, 0x24, 0x0a, 0x89, 0xad, 0x94, 0xb6, 0x3e, 0x09, 0x15, 0xf9, + 0x25, 0x7f, 0x4c, 0x55, 0x34, 0x77, 0x9b, 0x56, 0xf3, 0x6b, 0x02, 0x2c, 0xf3, 0x1e, 0x51, 0x48, + 0x00, 0xb4, 0x89, 0x83, 0xcd, 0x7e, 0xcf, 0x23, 0x96, 0x63, 0x5a, 0x3c, 0x5f, 0x5e, 0xcf, 0xda, + 0x4e, 0xfe, 0x6d, 0xf5, 0x88, 0x1e, 0x68, 0x97, 0x9f, 0x84, 0x4a, 0x6c, 0x12, 0x2a, 0x59, 0x11, + 0xf1, 0x75, 0x1e, 0x15, 0xc9, 0x91, 0xf2, 0x3e, 0xd7, 0x09, 0x28, 0xfc, 0x42, 0x02, 0x79, 0xd7, + 0xa7, 0xcc, 0xf2, 0x99, 0x6b, 0x31, 0x6c, 0x3a, 0xf8, 0xd0, 0xea, 0x7b, 0xcc, 0x5c, 0xe8, 0x66, + 0xfc, 0x0c, 0xdd, 0xbc, 0x3a, 0x09, 0x95, 0xff, 0x89, 0xb8, 0xef, 0x66, 0x53, 0xd1, 0xe6, 0x82, + 0x43, 0x55, 0xd8, 0x1b, 0xf3, 0x9e, 0x7f, 0x04, 0xce, 0x77, 0x2c, 0x6a, 0x76, 0xfb, 0x1e, 0x73, + 0x7b, 0x9e, 0x8b, 0x83, 0x4c, 0xa2, 0x20, 0x6d, 0x25, 0xb5, 0xec, 0x24, 0x54, 0x36, 0x44, 0x80, + 0x97, 0xed, 0x2a, 0x3a, 0xd7, 0xb1, 0xe8, 0xfe, 0x0b, 0x19, 0x7e, 0x08, 0xce, 0x89, 0x08, 0x36, + 0x36, 0x6d, 0x42, 0x59, 0x26, 0xc9, 0x09, 0x32, 0x93, 0x50, 0x59, 0x5f, 0xcc, 0x70, 0x6a, 0x56, + 0x51, 0x7a, 0x26, 0x57, 0x08, 0x65, 0x70, 0x17, 0xa4, 0x6d, 0xd2, 0xed, 0xb9, 0xde, 0x14, 0xbd, + 0xc4, 0xd1, 0x97, 0x26, 0xa1, 0x72, 0x71, 0xd6, 0xd7, 0xb9, 0x55, 0x45, 0x6b, 0x53, 0x31, 0xc2, + 0xf2, 0x71, 0xc6, 0xd4, 0x6f, 0x24, 0xb0, 0x5a, 0x21, 0x0e, 0x36, 0xfc, 0x43, 0x02, 0xff, 0x03, + 0x52, 0x7c, 0x10, 0x47, 0x16, 0x3d, 0xe2, 0x73, 0x4c, 0xa3, 0xd5, 0x48, 0xb1, 0x67, 0xd1, 0x23, + 0x98, 0x01, 0x2b, 0x76, 0x80, 0x2d, 0x46, 0x02, 0xb1, 0x60, 0x68, 0x26, 0xc2, 0x26, 0x80, 0x8b, + 0x7d, 0xb4, 0xf9, 0x84, 0x79, 0x2e, 0xa7, 0xef, 0x41, 0x32, 0xda, 0x03, 0x74, 0x61, 0x01, 0x2f, + 0x0c, 0xf7, 0x92, 0xab, 0x09, 0x39, 0x79, 0x2f, 0xb9, 0x9a, 0x94, 0x97, 0xd4, 0x9f, 0xe2, 0x20, + 0x5d, 0x21, 0x3e, 0x0b, 0x2c, 0x9b, 0xf1, 0x44, 0xff, 0x0b, 0x56, 0x78, 0xa2, 0xae, 0xc3, 0xd3, + 0x4c, 0x6a, 0xe0, 0x24, 0x54, 0x96, 0x79, 0x1d, 0x55, 0xb4, 0x1c, 0x99, 0x0c, 0xe7, 0x1d, 0x09, + 0xaf, 0x83, 0x25, 0xcb, 0xe9, 0xba, 0x3e, 0x1f, 0x57, 0x0a, 0x09, 0x21, 0xd2, 0x7a, 0x56, 0x1b, + 0x7b, 0x7c, 0x06, 0x29, 0x24, 0x04, 0x78, 0x7b, 0xca, 0x82, 0x9d, 0x69, 0x45, 0x57, 0xde, 0x50, + 0x51, 0x9b, 0x12, 0xaf, 0xcf, 0x70, 0x6b, 0xd0, 0x20, 0xd4, 0x65, 0x2e, 0xf1, 0xd1, 0x0c, 0x04, + 0x6f, 0x80, 0x35, 0xb7, 0x6d, 0x9b, 0x3d, 0x12, 0xb0, 0x28, 0xdd, 0x65, 0x7e, 0x37, 0xcf, 0x9d, + 0x84, 0x4a, 0xca, 0xd0, 0x2a, 0x0d, 0x12, 0x30, 0xa3, 0x8a, 0x52, 0x6e, 0xdb, 0xe6, 0x47, 0x07, + 0xee, 0x83, 0x14, 0x1e, 0x30, 0xec, 0xf3, 0x65, 0x5e, 0xe1, 0x01, 0xd7, 0x8b, 0xe2, 0xe9, 0x2a, + 0xce, 0x9e, 0xae, 0x62, 0xd9, 0x1f, 0x6a, 0xd9, 0x9f, 0x7f, 0xbc, 0xb1, 0xb1, 0xd8, 0x14, 0x7d, + 0x06, 0x43, 0x73, 0x86, 0xdd, 0xe4, 0x9f, 0xd1, 0x9d, 0xfd, 0x4b, 0x02, 0x99, 0x99, 0x6b, 0xd4, + 0xa4, 0x3d, 0x97, 0x32, 0x12, 0x0c, 0x75, 0x9f, 0x05, 0x43, 0xd8, 0x00, 0x29, 0xd2, 0xc3, 0x81, + 0xc5, 0xe6, 0x8f, 0xd1, 0xce, 0xeb, 0x25, 0xbe, 0x01, 0x5e, 0x9f, 0xa1, 0xa2, 0x4b, 0x85, 0xe6, + 0x24, 0x8b, 0xd3, 0x89, 0xbf, 0x75, 0x3a, 0xb7, 0xc1, 0x4a, 0xbf, 0xe7, 0xf0, 0xbe, 0x26, 0xfe, + 0x49, 0x5f, 0xa7, 0x20, 0xb8, 0x05, 0x12, 0x5d, 0xda, 0xe1, 0xb3, 0x4a, 0x6b, 0xff, 0x7e, 0x1e, + 0x2a, 0x10, 0x59, 0x8f, 0x66, 0x59, 0xee, 0x63, 0x4a, 0xad, 0x0e, 0x46, 0x91, 0x8b, 0x8a, 0x00, + 0x7c, 0x9d, 0x08, 0x5e, 0x06, 0xe9, 0xb6, 0x47, 0xec, 0x87, 0xe6, 0x11, 0x76, 0x3b, 0x47, 0x4c, + 0xec, 0x11, 0x5a, 0xe3, 0xba, 0x3d, 0xae, 0x82, 0x59, 0xb0, 0xca, 0x06, 0xa6, 0xeb, 0x3b, 0x78, + 0x20, 0x0a, 0x41, 0x2b, 0x6c, 0x60, 0x44, 0xa2, 0x6a, 0x81, 0xa5, 0x7d, 0xe2, 0x60, 0x0f, 0x6a, + 0x20, 0xf1, 0x10, 0x0f, 0xc5, 0x65, 0xd1, 0x6e, 0x3e, 0x0f, 0x95, 0xed, 0x8e, 0xcb, 0x8e, 0xfa, + 0xed, 0xa2, 0x4d, 0xba, 0x25, 0xcf, 0xf5, 0x71, 0x89, 0xd0, 0x28, 0x25, 0xe2, 0x97, 0x3c, 0xb7, + 0x4d, 0x4b, 0xed, 0x21, 0xc3, 0xb4, 0xb8, 0x87, 0x07, 0x5a, 0x74, 0x40, 0x11, 0x38, 0x5a, 0x3c, + 0xf1, 0xb1, 0x89, 0xf3, 0x2b, 0x27, 0x84, 0x6b, 0x3f, 0xc4, 0x01, 0x98, 0x3f, 0x5a, 0xf0, 0x7d, + 0x70, 0xa9, 0x5c, 0xa9, 0xe8, 0xcd, 0xa6, 0xd9, 0x3a, 0x68, 0xe8, 0xe6, 0xfd, 0x5a, 0xb3, 0xa1, + 0x57, 0x8c, 0x3b, 0x86, 0x5e, 0x95, 0x63, 0xb9, 0xec, 0x68, 0x5c, 0xd8, 0x98, 0x3b, 0xdf, 0xf7, + 0x69, 0x0f, 0xdb, 0xee, 0xa1, 0x8b, 0x1d, 0xb8, 0x0d, 0xe0, 0x22, 0xae, 0x56, 0xd7, 0xea, 0xd5, + 0x03, 0x59, 0xca, 0xad, 0x8f, 0xc6, 0x05, 0x79, 0x0e, 0xa9, 0x91, 0x36, 0x71, 0x86, 0xf0, 0x03, + 0x90, 0x59, 0xf4, 0xae, 0xd7, 0x3e, 0x3e, 0x30, 0xcb, 0xd5, 0x2a, 0xd2, 0x9b, 0x4d, 0x39, 0xfe, + 0x6a, 0x98, 0xba, 0xef, 0x0d, 0xcb, 0x2f, 0x3e, 0x28, 0x1b, 0x8b, 0x40, 0xfd, 0x13, 0x1d, 0x1d, + 0xf0, 0x48, 0x89, 0xdc, 0xa5, 0xd1, 0xb8, 0x70, 0x71, 0x8e, 0xd2, 0x8f, 0x71, 0x30, 0xe4, 0xc1, + 0x6e, 0x83, 0xcd, 0x45, 0x4c, 0xb9, 0x76, 0x60, 0xd6, 0xef, 0xcc, 0xc2, 0xe9, 0x4d, 0x39, 0x99, + 0xdb, 0x1c, 0x8d, 0x0b, 0x99, 0x39, 0xb4, 0xec, 0x0f, 0xeb, 0x87, 0xe5, 0xd9, 0x07, 0x29, 0xb7, + 0xfa, 0xf9, 0xb7, 0xf9, 0xd8, 0xe3, 0xef, 0xf2, 0xb1, 0x6b, 0xdf, 0x27, 0x40, 0xe1, 0xb4, 0x0d, + 0x85, 0x18, 0xdc, 0xac, 0xd4, 0x6b, 0x2d, 0x54, 0xae, 0xb4, 0xcc, 0x4a, 0xbd, 0xaa, 0x9b, 0x7b, + 0x46, 0xb3, 0x55, 0x47, 0x07, 0x66, 0xbd, 0xa1, 0xa3, 0x72, 0xcb, 0xa8, 0xd7, 0xde, 0xd4, 0xda, + 0xd2, 0x68, 0x5c, 0xb8, 0x7e, 0x1a, 0xf7, 0x62, 0xc3, 0x3f, 0x05, 0x57, 0xcf, 0x14, 0xc6, 0xa8, + 0x19, 0x2d, 0x59, 0xca, 0x6d, 0x8d, 0xc6, 0x85, 0x2b, 0xa7, 0xf1, 0x1b, 0xbe, 0xcb, 0xe0, 0x03, + 0xb0, 0x7d, 0x26, 0xe2, 0x7d, 0xe3, 0x2e, 0x2a, 0xb7, 0x74, 0x39, 0x9e, 0xbb, 0x3e, 0x1a, 0x17, + 0xfe, 0x7f, 0x1a, 0xf7, 0xbe, 0xdb, 0x09, 0x2c, 0x86, 0xcf, 0x4c, 0x7f, 0x57, 0xaf, 0xe9, 0x4d, + 0xa3, 0x29, 0x27, 0xce, 0x46, 0x7f, 0x17, 0xfb, 0x98, 0xba, 0x34, 0x97, 0x8c, 0x86, 0xa5, 0x55, + 0x9f, 0xfc, 0x91, 0x8f, 0x3d, 0x3e, 0xc9, 0x4b, 0x4f, 0x4e, 0xf2, 0xd2, 0xd3, 0x93, 0xbc, 0xf4, + 0xfb, 0x49, 0x5e, 0xfa, 0xf2, 0x59, 0x3e, 0xf6, 0xf4, 0x59, 0x3e, 0xf6, 0xdb, 0xb3, 0x7c, 0xec, + 0x33, 0xf5, 0xd5, 0xfb, 0x13, 0x3d, 0x06, 0x4e, 0x69, 0x20, 0xfe, 0x17, 0xf2, 0x3f, 0x85, 0xed, + 0x65, 0xfe, 0x12, 0xbe, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x79, 0x87, 0xaf, 0x6f, 0x35, + 0x0a, 0x00, 0x00, } func (this *AccessTypeParam) Equal(that interface{}) bool { @@ -580,6 +592,14 @@ func (this *AccessConfig) Equal(that interface{}) bool { if this.Address != that1.Address { return false } + if len(this.Addresses) != len(that1.Addresses) { + return false + } + for i := range this.Addresses { + if this.Addresses[i] != that1.Addresses[i] { + return false + } + } return true } func (this *Params) Equal(that interface{}) bool { @@ -825,6 +845,15 @@ func (m *AccessConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Addresses[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -1178,6 +1207,12 @@ func (m *AccessConfig) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } return n } @@ -1469,6 +1504,38 @@ func (m *AccessConfig) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/x/wasm/types/types_test.go b/x/wasm/types/types_test.go index 4add3c670d..e04d6fcc41 100644 --- a/x/wasm/types/types_test.go +++ b/x/wasm/types/types_test.go @@ -374,79 +374,332 @@ func TestVerifyAddressLen(t *testing.T) { } } -func TestAccesConfigSubset(t *testing.T) { +func TestAccessConfigSubset(t *testing.T) { + // read + // <, <= is subset of + // !< is not subset of specs := map[string]struct { check AccessConfig superSet AccessConfig isSubSet bool }{ + // nobody "nobody <= nobody": { superSet: AccessConfig{Permission: AccessTypeNobody}, check: AccessConfig{Permission: AccessTypeNobody}, isSubSet: true, }, - "only > nobody": { + "only !< nobody": { superSet: AccessConfig{Permission: AccessTypeNobody}, check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "foobar"}, isSubSet: false, }, - "everybody > nobody": { + "anyOf !< nobody": { + superSet: AccessConfig{Permission: AccessTypeNobody}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"foobar"}}, + isSubSet: false, + }, + "everybody !< nobody ": { superSet: AccessConfig{Permission: AccessTypeNobody}, check: AccessConfig{Permission: AccessTypeEverybody}, isSubSet: false, }, - "unspecified > nobody": { + "unspecified !< nobody": { superSet: AccessConfig{Permission: AccessTypeNobody}, check: AccessConfig{Permission: AccessTypeUnspecified}, isSubSet: false, }, - "nobody <= everybody": { + // only + "nobody < only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeNobody}, + isSubSet: true, + }, + "only <= only(same)": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + isSubSet: true, + }, + "only !< only(other)": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "other"}, + isSubSet: false, + }, + "anyOf(same) <= only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + isSubSet: true, + }, + "anyOf(other) !< only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"foobar"}}, + isSubSet: false, + }, + "anyOf(same, other) !< only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "foobar"}}, + isSubSet: false, + }, + "everybody !< only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeEverybody}, + isSubSet: false, + }, + "unspecified !<= only": { + superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + check: AccessConfig{Permission: AccessTypeUnspecified}, + isSubSet: false, + }, + + // any of + "nobody < anyOf": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeNobody}, + isSubSet: true, + }, + "only(same) < anyOf(same)": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + isSubSet: true, + }, + "only(same) < anyOf(same, other)": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other"}}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + isSubSet: true, + }, + "only(other) !< anyOf": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "other"}, + isSubSet: false, + }, + "anyOf < anyOf": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + isSubSet: true, + }, + "anyOf(multiple) < anyOf(multiple)": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other"}}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other"}}, + isSubSet: true, + }, + "anyOf(multiple, other) !< anyOf(multiple)": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other", "foo"}}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other", "bar"}}, + isSubSet: false, + }, + "anyOf(multiple) !< anyOf": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner", "other"}}, + isSubSet: false, + }, + "everybody !< anyOf": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeEverybody}, + isSubSet: false, + }, + "unspecified !< anyOf ": { + superSet: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"owner"}}, + check: AccessConfig{Permission: AccessTypeUnspecified}, + isSubSet: false, + }, + // everybody + "nobody < everybody": { superSet: AccessConfig{Permission: AccessTypeEverybody}, check: AccessConfig{Permission: AccessTypeNobody}, isSubSet: true, }, - "only <= everybody": { + "only < everybody": { superSet: AccessConfig{Permission: AccessTypeEverybody}, check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "foobar"}, isSubSet: true, }, + "anyOf < everybody": { + superSet: AccessConfig{Permission: AccessTypeEverybody}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"foobar"}}, + isSubSet: true, + }, "everybody <= everybody": { superSet: AccessConfig{Permission: AccessTypeEverybody}, check: AccessConfig{Permission: AccessTypeEverybody}, isSubSet: true, }, - "unspecified > everybody": { + "unspecified !< everybody ": { superSet: AccessConfig{Permission: AccessTypeEverybody}, check: AccessConfig{Permission: AccessTypeUnspecified}, isSubSet: false, }, - "nobody <= only": { - superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + // unspecified + "nobody !< unspecified": { + superSet: AccessConfig{Permission: AccessTypeUnspecified}, check: AccessConfig{Permission: AccessTypeNobody}, - isSubSet: true, + isSubSet: false, }, - "only <= only(same)": { - superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, - check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, - isSubSet: true, + "only !< unspecified": { + superSet: AccessConfig{Permission: AccessTypeUnspecified}, + check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "foobar"}, + isSubSet: false, }, - "only > only(other)": { - superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, - check: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "other"}, + "anyOf !< unspecified": { + superSet: AccessConfig{Permission: AccessTypeUnspecified}, + check: AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{"foobar"}}, isSubSet: false, }, - "everybody > only": { - superSet: AccessConfig{Permission: AccessTypeOnlyAddress, Address: "owner"}, + "everybody !< unspecified": { + superSet: AccessConfig{Permission: AccessTypeUnspecified}, check: AccessConfig{Permission: AccessTypeEverybody}, isSubSet: false, }, - "nobody > unspecified": { + "unspecified !< unspecified ": { superSet: AccessConfig{Permission: AccessTypeUnspecified}, - check: AccessConfig{Permission: AccessTypeNobody}, + check: AccessConfig{Permission: AccessTypeUnspecified}, isSubSet: false, }, } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + subset := spec.check.IsSubset(spec.superSet) + require.Equal(t, spec.isSubSet, subset) + }) + } +} +func TestAccessTypeSubset(t *testing.T) { + specs := map[string]struct { + check AccessType + superSet AccessType + isSubSet bool + }{ + // nobody + "nobody <= nobody": { + superSet: AccessTypeNobody, + check: AccessTypeNobody, + isSubSet: true, + }, + "only !< nobody": { + superSet: AccessTypeNobody, + check: AccessTypeOnlyAddress, + isSubSet: false, + }, + "any !< nobody": { + superSet: AccessTypeNobody, + check: AccessTypeAnyOfAddresses, + isSubSet: false, + }, + "everybody !< nobody": { + superSet: AccessTypeNobody, + check: AccessTypeEverybody, + isSubSet: false, + }, + "unspecified !< nobody": { + superSet: AccessTypeNobody, + check: AccessTypeUnspecified, + isSubSet: false, + }, + // only + "nobody < only": { + superSet: AccessTypeOnlyAddress, + check: AccessTypeNobody, + isSubSet: true, + }, + "only <= only": { + superSet: AccessTypeOnlyAddress, + check: AccessTypeOnlyAddress, + isSubSet: true, + }, + "anyOf !< only": { + superSet: AccessTypeOnlyAddress, + check: AccessTypeAnyOfAddresses, + isSubSet: true, + }, + "everybody !< only": { + superSet: AccessTypeOnlyAddress, + check: AccessTypeEverybody, + isSubSet: false, + }, + "unspecified !< only": { + superSet: AccessTypeOnlyAddress, + check: AccessTypeUnspecified, + isSubSet: false, + }, + // any of + "nobody < anyOf": { + superSet: AccessTypeAnyOfAddresses, + check: AccessTypeNobody, + isSubSet: true, + }, + "only <= anyOf": { + superSet: AccessTypeAnyOfAddresses, + check: AccessTypeOnlyAddress, + isSubSet: true, + }, + "anyOf <= anyOf": { + superSet: AccessTypeAnyOfAddresses, + check: AccessTypeAnyOfAddresses, + isSubSet: true, + }, + "everybody !< anyOf": { + superSet: AccessTypeAnyOfAddresses, + check: AccessTypeEverybody, + isSubSet: false, + }, + "unspecified !< anyOf": { + superSet: AccessTypeAnyOfAddresses, + check: AccessTypeUnspecified, + isSubSet: false, + }, + // everybody + "nobody < everybody": { + superSet: AccessTypeEverybody, + check: AccessTypeNobody, + isSubSet: true, + }, + "only < everybody": { + superSet: AccessTypeEverybody, + check: AccessTypeOnlyAddress, + isSubSet: true, + }, + "anyOf < everybody": { + superSet: AccessTypeEverybody, + check: AccessTypeAnyOfAddresses, + isSubSet: true, + }, + "everybody <= everybody": { + superSet: AccessTypeEverybody, + check: AccessTypeEverybody, + isSubSet: true, + }, + "unspecified !< everybody": { + superSet: AccessTypeEverybody, + check: AccessTypeUnspecified, + isSubSet: false, + }, + // unspecified + "nobody !< unspecified": { + superSet: AccessTypeUnspecified, + check: AccessTypeNobody, + isSubSet: false, + }, + "only !< unspecified": { + superSet: AccessTypeUnspecified, + check: AccessTypeOnlyAddress, + isSubSet: false, + }, + "anyOf !< unspecified": { + superSet: AccessTypeUnspecified, + check: AccessTypeAnyOfAddresses, + isSubSet: false, + }, + "everybody !< unspecified": { + superSet: AccessTypeUnspecified, + check: AccessTypeEverybody, + isSubSet: false, + }, + "unspecified !< unspecified": { + superSet: AccessTypeUnspecified, + check: AccessTypeUnspecified, + isSubSet: false, + }, + } for name, spec := range specs { t.Run(name, func(t *testing.T) { subset := spec.check.IsSubset(spec.superSet) diff --git a/x/wasm/types/validation.go b/x/wasm/types/validation.go index 539c8d8a3b..8759aa06b8 100644 --- a/x/wasm/types/validation.go +++ b/x/wasm/types/validation.go @@ -4,8 +4,11 @@ import ( sdkerrors "github.com/line/lbm-sdk/types/errors" ) +// MaxSaltSize is the longest salt that can be used when instantiating a contract +const MaxSaltSize = 64 + var ( - // MaxLabelSize is the longest label that can be used when Instantiating a contract + // MaxLabelSize is the longest label that can be used when instantiating a contract MaxLabelSize = 128 // extension point for chains to customize via compile flag. // MaxWasmSize is the largest a compiled contract code can be when storing code on chain @@ -22,12 +25,24 @@ func validateWasmCode(s []byte) error { return nil } -func validateLabel(label string) error { +// ValidateLabel ensure label constraints +func ValidateLabel(label string) error { if label == "" { return sdkerrors.Wrap(ErrEmpty, "is required") } if len(label) > MaxLabelSize { - return sdkerrors.Wrap(ErrLimit, "cannot be longer than 128 characters") + return ErrLimit.Wrapf("cannot be longer than %d characters", MaxLabelSize) + } + return nil +} + +// ValidateSalt ensure salt constraints +func ValidateSalt(salt []byte) error { + switch n := len(salt); { + case n == 0: + return sdkerrors.Wrap(ErrEmpty, "is required") + case n > MaxSaltSize: + return ErrLimit.Wrapf("cannot be longer than %d characters", MaxSaltSize) } return nil }