diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 206bf076..f55a90ad 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,15 +1,3 @@ # https://help.github.com/articles/about-codeowners -* @johnletey @mbreithecker - -# CODEOWNERS for x/bundles - -/x/bundles @johnletey @troykessler @mbreithecker - -# CODEOWNERS for x/pool - -/x/pool @johnletey @troykessler @mbreithecker - -# CODEOWNERS for x/team - -/x/team @johnletey @troykessler @mbreithecker +* @johnletey @mbreithecker @troykessler diff --git a/.github/README.md b/.github/README.md index 20dadbee..bd63dfcf 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,6 +1,6 @@ # The KYVE Network -###### v1.2.1 +###### v1.4.0 The KYVE consensus layer is the backbone of the KYVE ecosystem. This layer is a sovereign Delegated Proof of Stake network built using the @@ -18,7 +18,7 @@ You can find the `kyved` binary in the `./build` directory. If you need binaries for alternative architectures than your host: ```shell -make release +make release ENV=mainnet ``` The different binaries can be found in the `./release` directory. diff --git a/.github/mergify.yml b/.github/mergify.yml index 8d0dd702..807ba194 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -38,3 +38,11 @@ pull_request_rules: backport: branches: - release/v1.3.x + - name: backport patches to v1.4.x branch + conditions: + - base=main + - label=backport/v1.4.x + actions: + backport: + branches: + - release/v1.4.x diff --git a/CHANGELOG.md b/CHANGELOG.md index d19514d1..bf73da6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,30 +12,59 @@ # CHANGELOG -## [Unreleased] +An '!' indicates a state machine breaking change. -### Features +## [v1.4.0](https://github.com/KYVENetwork/chain/releases/tag/v1.4.0) - 2023-09-04 - [#33](https://github.com/KYVENetwork/chain/pull/33) Upgrade Cosmos SDK to [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) ([`v0.47.3-kyve`](https://github.com/KYVENetwork/cosmos-sdk/releases/tag/v0.47.3-kyve)). -- (ibc) [#30](https://github.com/KYVENetwork/chain/pull/30) Integrate [Packet Forward Middleware](https://github.com/strangelove-ventures/packet-forward-middleware). + +## [v1.3.1](https://github.com/KYVENetwork/chain/releases/tag/v1.3.1) - 2023-08-02 + +### Bug Fixes + +- [#122](https://github.com/KYVENetwork/chain/pull/122) Fix makefile go version parse cmd. + +## [v1.3.0](https://github.com/KYVENetwork/chain/releases/tag/v1.3.0) - 2023-07-15 + +### Features + +- ! (ibc) [#30](https://github.com/KYVENetwork/chain/pull/30) Integrate [Packet Forward Middleware](https://github.com/strangelove-ventures/packet-forward-middleware). +- ! (`x/bundles`) [#98](https://github.com/KYVENetwork/chain/pull/98) Split inflation rewards between chain and protocol layer. +- ! (`x/bundles`) [#99](https://github.com/KYVENetwork/chain/pull/99) Use weighted round-robin approach for uploader selection. +- ! (`x/bundles`) [#108](https://github.com/KYVENetwork/chain/pull/108) Store stake security for finalized bundles. ### Improvements -- (`x/bundles`) [#62](https://github.com/KYVENetwork/chain/pull/62) Payout storage cost directly to the bundle uploader. -- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Allow protocol validator commission rewards to be claimed. +- ! (`x/bundles`) [#62](https://github.com/KYVENetwork/chain/pull/62) Payout storage cost directly to the bundle uploader. +- ! (`x/pool`) [#74](https://github.com/KYVENetwork/chain/pull/74) Improve parameter validation in pool proposals. +- ! (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Allow protocol validator commission rewards to be claimed. ### Bug Fixes -- (deps) [#82](https://github.com/KYVENetwork/chain/pull/82) Bump Cosmos SDK to [v0.46.13](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.13) ([`v0.46.13-kyve`](https://github.com/KYVENetwork/cosmos-sdk/releases/tag/v0.46.13-kyve)) to adhere to the [Cosmos SDK Barberry Security Advisory](https://forum.cosmos.network/t/cosmos-sdk-security-advisory-barberry). +- [#96](https://github.com/KYVENetwork/chain/pull/96) Track investor delegation inside auth module. ### Client Breaking -- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Include `MsgClaimCommissionRewards` for claiming commission rewards. +- ! (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Include `MsgClaimCommissionRewards` for claiming commission rewards. ### API Breaking - -- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Emit an [event](https://github.com/KYVENetwork/chain/blob/main/x/stakers/spec/05_events.md#eventclaimcommissionrewards) when claiming protocol validator commission rewards. +- (`x/query`) [#87](https://github.com/KYVENetwork/chain/pull/87) Correctly return pools that an account has funded. +- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Emit an [event](https://github.com/KYVENetwork/chain/blob/v1.3.0/x/stakers/spec/05_events.md#eventclaimcommissionrewards) when claiming protocol validator commission rewards. +- (`x/bundles`) [#104](https://github.com/KYVENetwork/chain/pull/104) Improve schema for finalized bundles query. + +## [v1.2.3](https://github.com/KYVENetwork/chain/releases/tag/v1.2.3) - 2023-07-15 + +### API Breaking + +- (`x/query`) [#87](https://github.com/KYVENetwork/chain/pull/87) Correctly return pools that an account has funded. +- (`x/bundles`) [#104](https://github.com/KYVENetwork/chain/pull/104) Improve schema for finalized bundles query. + +## [v1.2.2](https://github.com/KYVENetwork/chain/releases/tag/v1.2.2) - 2023-06-08 + +### Bug Fixes + +- (deps) [#82](https://github.com/KYVENetwork/chain/pull/82) Bump Cosmos SDK to [v0.46.13](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.13) ([`v0.46.13-kyve`](https://github.com/KYVENetwork/cosmos-sdk/releases/tag/v0.46.13-kyve)) to adhere to the [Cosmos SDK Barberry Security Advisory](https://forum.cosmos.network/t/cosmos-sdk-security-advisory-barberry). ## [v1.2.1](https://github.com/KYVENetwork/chain/releases/tag/v1.2.1) - 2023-05-25 diff --git a/Makefile b/Makefile index 3e7f76ff..a2e77161 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ COMMIT := $(shell git log -1 --format='%H') -GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1 -f2) -VERSION := v1.2.1 # $(shell echo $(shell git describe --tags) | sed 's/^v//') +GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2) +VERSION := v1.3.1 # $(shell echo $(shell git describe --tags) | sed 's/^v//') TEAM_ALLOCATION := 165000000000000 ifeq ($(ENV),kaon) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..b0f5d66b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,17 @@ +# KYVE Security Policy + +## Supported Versions + +| Version | Supported | +|---------|--------------------| +| main | :white_check_mark: | +| v1.2.x | :white_check_mark: | +| < v1.2 | :x: | + +## Reporting a Vulnerability + +Two main ways of reporting a vulnerability to the KYVE Core Team exist. + +You can contact us at security@kyve.network, which all code owners can access and check regularly. Tied to this email, you can find our [public key](https://keys.openpgp.org/search?q=security@kyve.network) that you can use to send us encrypted emails. + +Additionally, you can go through GitHub's [private vulnerability reporting system](https://github.com/KYVENetwork/chain/security/advisories/new). diff --git a/app/app.go b/app/app.go index 10215fbf..2e9027f5 100644 --- a/app/app.go +++ b/app/app.go @@ -7,11 +7,12 @@ import ( "os" "path/filepath" - v1p3 "github.com/KYVENetwork/chain/app/upgrades/v1_3" + v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" cmtOs "github.com/cometbft/cometbft/libs/os" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -457,7 +458,7 @@ func NewKYVEApp( // ... other modules keepers app.GlobalKeeper = *globalKeeper.NewKeeper(appCodec, keys[globalTypes.StoreKey], authTypes.NewModuleAddress(govTypes.ModuleName).String()) - app.TeamKeeper = *teamKeeper.NewKeeper(appCodec, keys[teamTypes.StoreKey], app.AccountKeeper, app.BankKeeper) + app.TeamKeeper = *teamKeeper.NewKeeper(appCodec, keys[teamTypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.MintKeeper, *app.UpgradeKeeper) app.PoolKeeper = *poolKeeper.NewKeeper( appCodec, @@ -469,7 +470,9 @@ func NewKYVEApp( app.AccountKeeper, app.BankKeeper, app.DistributionKeeper, + app.MintKeeper, app.UpgradeKeeper, + app.TeamKeeper, ) app.StakersKeeper = *stakersKeeper.NewKeeper( @@ -699,10 +702,10 @@ func NewKYVEApp( ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), // KYVE - bundles.NewAppModule(appCodec, app.BundlesKeeper, app.AccountKeeper, app.BankKeeper), + bundles.NewAppModule(appCodec, app.BundlesKeeper, app.AccountKeeper, app.BankKeeper, app.DistributionKeeper, app.MintKeeper, *app.UpgradeKeeper, app.PoolKeeper, app.TeamKeeper), delegation.NewAppModule(appCodec, app.DelegationKeeper, app.AccountKeeper, app.BankKeeper), global.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.GlobalKeeper, *app.UpgradeKeeper), - pool.NewAppModule(appCodec, app.PoolKeeper, app.AccountKeeper, app.BankKeeper), + pool.NewAppModule(appCodec, app.PoolKeeper, app.AccountKeeper, app.BankKeeper, *app.UpgradeKeeper), query.NewAppModule(appCodec, app.QueryKeeper, app.AccountKeeper, app.BankKeeper), stakers.NewAppModule(appCodec, app.StakersKeeper, app.AccountKeeper, app.BankKeeper), team.NewAppModule(appCodec, app.BankKeeper, app.MintKeeper, app.TeamKeeper, *app.UpgradeKeeper), @@ -719,6 +722,8 @@ func NewKYVEApp( mintTypes.ModuleName, // NOTE: x/team must be run before x/distribution and after x/mint. teamTypes.ModuleName, + // NOTE: x/bundles must be run before x/distribution and after x/team. + bundlesTypes.ModuleName, distributionTypes.ModuleName, slashingTypes.ModuleName, evidenceTypes.ModuleName, @@ -743,7 +748,6 @@ func NewKYVEApp( poolTypes.ModuleName, stakersTypes.ModuleName, delegationTypes.ModuleName, - bundlesTypes.ModuleName, queryTypes.ModuleName, globalTypes.ModuleName, ) @@ -866,8 +870,8 @@ func NewKYVEApp( app.SetEndBlocker(app.EndBlocker) app.UpgradeKeeper.SetUpgradeHandler( - v1p3.UpgradeName, - v1p3.CreateUpgradeHandler( + v1p4.UpgradeName, + v1p4.CreateUpgradeHandler( app.mm, app.configurator, appCodec, @@ -884,8 +888,8 @@ func NewKYVEApp( panic(err) } - if upgradeInfo.Name == v1p3.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - app.SetStoreLoader(v1p3.CreateStoreLoader(upgradeInfo.Height)) + if upgradeInfo.Name == v1p4.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + app.SetStoreLoader(v1p4.CreateStoreLoader(upgradeInfo.Height)) } if loadLatest { diff --git a/app/upgrades/v1_3/constants.go b/app/upgrades/v1_4/constants.go similarity index 95% rename from app/upgrades/v1_3/constants.go rename to app/upgrades/v1_4/constants.go index b059366d..a5a0e6e8 100644 --- a/app/upgrades/v1_3/constants.go +++ b/app/upgrades/v1_4/constants.go @@ -1,7 +1,7 @@ -package v1_3 +package v1_4 // UpgradeName is the name of this specific software upgrade used on-chain. -const UpgradeName = "v1.3.0" +const UpgradeName = "v1.4.0" // TestnetChainID is the Chain ID of the KYVE testnet (Kaon). const TestnetChainID = "kaon-1" diff --git a/app/upgrades/v1_3/store.go b/app/upgrades/v1_4/store.go similarity index 98% rename from app/upgrades/v1_3/store.go rename to app/upgrades/v1_4/store.go index 08d60729..aba15aec 100644 --- a/app/upgrades/v1_3/store.go +++ b/app/upgrades/v1_4/store.go @@ -1,4 +1,4 @@ -package v1_3 +package v1_4 import ( "github.com/cosmos/cosmos-sdk/baseapp" diff --git a/app/upgrades/v1_3/upgrade.go b/app/upgrades/v1_4/upgrade.go similarity index 95% rename from app/upgrades/v1_3/upgrade.go rename to app/upgrades/v1_4/upgrade.go index 3ab7488c..b037723d 100644 --- a/app/upgrades/v1_3/upgrade.go +++ b/app/upgrades/v1_4/upgrade.go @@ -1,4 +1,4 @@ -package v1_3 +package v1_4 import ( "github.com/cosmos/cosmos-sdk/baseapp" @@ -34,6 +34,9 @@ func CreateUpgradeHandler( paramsKeeper paramsKeeper.Keeper, ) upgradeTypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + logger := ctx.Logger().With("upgrade", UpgradeName) + logger.Info("Run v1.4 upgrade") + var err error // Migrate consensus parameters from x/params to dedicated x/consensus module. diff --git a/app/upgrades/v1_3/upgrade_test.go b/app/upgrades/v1_4/upgrade_test.go similarity index 92% rename from app/upgrades/v1_3/upgrade_test.go rename to app/upgrades/v1_4/upgrade_test.go index fe5f34c0..546289de 100644 --- a/app/upgrades/v1_3/upgrade_test.go +++ b/app/upgrades/v1_4/upgrade_test.go @@ -1,4 +1,4 @@ -package v1_3_test +package v1_4_test import ( "context" @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/KYVENetwork/chain/app/upgrades/v1_3" + "github.com/KYVENetwork/chain/app/upgrades/v1_4" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" @@ -21,10 +21,10 @@ var UpgradeContainerVersion = "local" func TestV1P2Upgrade(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, fmt.Sprintf("%s Upgrade Test Suite", v1_3.UpgradeName)) + RunSpecs(t, fmt.Sprintf("%s Upgrade Test Suite", v1_4.UpgradeName)) } -var _ = Describe(fmt.Sprintf("%s Upgrade Tests", v1_3.UpgradeName), Ordered, func() { +var _ = Describe(fmt.Sprintf("%s Upgrade Tests", v1_4.UpgradeName), Ordered, func() { var kaon *cosmos.CosmosChain var kyve *cosmos.CosmosChain @@ -108,8 +108,8 @@ func PerformUpgrade( proposal := cosmos.SoftwareUpgradeProposal{ Deposit: "1" + chain.Config().Denom, - Title: fmt.Sprintf("%s Software Upgrade", v1_3.UpgradeName), - Name: v1_3.UpgradeName, + Title: fmt.Sprintf("%s Software Upgrade", v1_4.UpgradeName), + Name: v1_4.UpgradeName, Description: "description", Height: haltHeight, } diff --git a/app/upgrades/v1_3/upgrade_utils_test.go b/app/upgrades/v1_4/upgrade_utils_test.go similarity index 99% rename from app/upgrades/v1_3/upgrade_utils_test.go rename to app/upgrades/v1_4/upgrade_utils_test.go index 815bb136..7cf2de0c 100644 --- a/app/upgrades/v1_3/upgrade_utils_test.go +++ b/app/upgrades/v1_4/upgrade_utils_test.go @@ -1,4 +1,4 @@ -package v1_3_test +package v1_4_test import ( "encoding/json" diff --git a/config.yml b/config.yml index 35b2c1ee..a2ef69a8 100644 --- a/config.yml +++ b/config.yml @@ -128,9 +128,11 @@ genesis: clawback: "1804978800" commencement: "1647212400" pool: - pool_count: "2" + params: + protocol_inflation_share: "0.04" + pool_count: "1" pool_list: - - config: "ar://tMTrJ8E3QgBNLz0-lyn6QrxasEIX46d14QFVmBWshSI" + - config: "{\"network\":\"kyve-1\",\"rpc\":\"https://rpc-eu-1.kyve.network\"}" current_compression_id: "1" current_index: "0" current_key: "" @@ -138,20 +140,20 @@ genesis: current_summary: "" funders: [] id: "0" - logo: "ar://E3jXAOeJ3El7HQgOf_NtSOwVE7Sd0M4g4bYqjCBH9CU" + logo: "" max_bundle_size: "100" min_delegation: "100000000000" - name: "Avalanche // C-Chain" + name: "KYVE // Mainnet" operating_cost: "2500000000" disabled: false - runtime: '@kyvejs/evm' - start_key: "0" + runtime: '@kyvejs/tendermint-bsync' + start_key: "1" total_bundles: "0" total_funds: "0" upload_interval: "60" protocol: - version: "1.0.0-beta.5" - binaries: "{\"kyve-macos-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Fevm%401.0.0-beta.5/kyve-macos-x64.zip\"}" + version: "1.0.0" + binaries: "{\"kyve-linux-arm64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-arm64.zip\",\"kyve-linux-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-x64.zip\",\"kyve-macos-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-macos-x64.zip\"}" last_upgrade: "0" upgrade_plan: version: "" diff --git a/docs/swagger.yml b/docs/swagger.yml index 40a5d7f3..ad6f0ddf 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -578,6 +578,12 @@ paths: commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE + earned through commission title: >- StakerMetadata contains static information for a staker @@ -2458,101 +2464,143 @@ paths: format: uint64 tags: - QueryBundles - /kyve/query/v1beta1/finalized_bundle/{pool_id}/{id}: + /kyve/v1/bundles/{pool_id}: get: - summary: FinalizedBundle ... - operationId: FinalizedBundle + summary: FinalizedBundles ... + operationId: FinalizedBundlesQuery responses: '200': description: A successful response. schema: type: object properties: - finalized_bundle: - description: finalized_bundle ... + finalized_bundles: + type: array + items: + type: object + properties: + pool_id: + type: string + format: uint64 + title: pool_id in which the bundle was created + id: + type: string + format: uint64 + description: id is is integrated with each valid bundle produced. + storage_id: + type: string + title: >- + storage_id is the id with which the data can be + retrieved from the configured data provider + uploader: + type: string + title: >- + uploader is the address of the staker who submitted this + bundle + from_index: + type: string + format: uint64 + title: >- + from_index is the index from where the bundle starts + (inclusive) + to_index: + type: string + format: uint64 + title: >- + to_index is the index to which the bundle goes + (exclusive) + from_key: + type: string + title: >- + from_key is the key of the first data item in the bundle + proposal + to_key: + type: string + title: to_key the key of the last data item in the bundle + bundle_summary: + type: string + description: bundle_summary is a summary of the bundle. + data_hash: + type: string + description: data_hash is a sha256 hash of the uploaded data. + finalized_at: + description: >- + finalized_at contains details of the block that + finalized this bundle. + type: object + properties: + height: + type: string + description: >- + height is the block height in which the bundle got + finalized. + timestamp: + type: string + description: >- + timestamp is the UNIX timestamp of the block in + which the bundle got finalized. + storage_provider_id: + type: string + format: uint64 + title: >- + storage_provider_id the id of the storage provider where + the bundle is stored + compression_id: + type: string + format: uint64 + title: >- + compression_id the id of the compression type with which + the data was compressed + stake_security: + description: >- + stake_security defines the amount of stake which was + present in the pool during the finalization of the + bundle. + + This field was added in schema version 2. Bundles + finalized before that return `null`. + type: object + properties: + valid_vote_power: + type: string + description: >- + valid_vote_power gives the amount of $KYVE stake + that voted `valid`. + total_vote_power: + type: string + description: >- + total_vote_power gives the amount of total $KYVE + stake that was present in the pool + + during finalization. + title: >- + StakeSecurity represents the relative security of a + finalized bundle + title: >- + FinalizedBundle represents the latest version of a valid + bundle of a pool + description: finalized_bundles ... + pagination: + description: pagination defines the pagination in the response. type: object properties: - pool_id: - type: string - format: uint64 - title: >- - pool_id is the id of the pool for which this proposal is - for - id: - type: string - format: uint64 - title: >- - id is a unique identifier for each finalized bundle in a - pool - storage_id: - type: string - title: >- - storage_id is the id with which the data can be retrieved - from - uploader: - type: string - title: >- - uploader is the address of the staker who submitted this - bundle - from_index: + next_key: type: string - format: uint64 - title: >- - from_index is the index from where the bundle starts - (inclusive) - to_index: + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 - title: to_index is the index to which the bundle goes (exclusive) - to_key: - type: string - title: >- - to_key the key of the last data item in the bundle - proposal - bundle_summary: - type: string - title: bundle_summary a string summary of the current proposal - data_hash: - type: string - title: data_hash a sha256 hash of the raw compressed data - finalized_at: - description: >- - finalized_at contains details of the block that finalized - this bundle. - type: object - properties: - height: - type: string - format: uint64 - description: height ... - timestamp: - type: string - format: uint64 - description: timestamp ... - from_key: - type: string - title: >- - from_key the key of the first data item in the bundle - proposal - storage_provider_id: - type: integer - format: int64 - title: >- - storage_provider_id the id of the storage provider where - the bundle is stored - compression_id: - type: integer - format: int64 title: >- - compression_id the id of the compression type with which - the data was compressed - title: >- - FinalizedBundle represents a bundle proposal where the - majority + total is total number of results available if + PageRequest.count_total - agreed on its validity + was set, its value is undefined otherwise description: >- - QueryFinalizedBundleResponse is the response type for the + QueryStakersByPoolResponse is the response type for the Query/Staker RPC method. default: description: An unexpected error response. @@ -2755,438 +2803,180 @@ paths: required: true type: string format: uint64 - - name: id - description: id ... - in: path - required: true + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false type: string - format: uint64 - tags: - - QueryBundles - /kyve/query/v1beta1/finalized_bundle_by_height/{pool_id}/{height}: - get: - summary: Queries the bundle which contains the data given height - operationId: FinalizedBundlesByHeight - responses: - '200': - description: A successful response. - schema: - type: object - properties: - finalized_bundle: - description: finalized_bundle ... - type: object - properties: - pool_id: - type: string - format: uint64 - title: >- - pool_id is the id of the pool for which this proposal is - for - id: - type: string - format: uint64 - title: >- - id is a unique identifier for each finalized bundle in a - pool - storage_id: - type: string - title: >- - storage_id is the id with which the data can be retrieved - from - uploader: - type: string - title: >- - uploader is the address of the staker who submitted this - bundle - from_index: - type: string - format: uint64 - title: >- - from_index is the index from where the bundle starts - (inclusive) - to_index: - type: string - format: uint64 - title: to_index is the index to which the bundle goes (exclusive) - to_key: - type: string - title: >- - to_key the key of the last data item in the bundle - proposal - bundle_summary: - type: string - title: bundle_summary a string summary of the current proposal - data_hash: - type: string - title: data_hash a sha256 hash of the raw compressed data - finalized_at: - description: >- - finalized_at contains details of the block that finalized - this bundle. - type: object - properties: - height: - type: string - format: uint64 - description: height ... - timestamp: - type: string - format: uint64 - description: timestamp ... - from_key: - type: string - title: >- - from_key the key of the first data item in the bundle - proposal - storage_provider_id: - type: integer - format: int64 - title: >- - storage_provider_id the id of the storage provider where - the bundle is stored - compression_id: - type: integer - format: int64 - title: >- - compression_id the id of the compression type with which - the data was compressed - title: >- - FinalizedBundle represents a bundle proposal where the - majority - - agreed on its validity - description: >- - QueryFinalizedBundleResponse is the response type for the - Query/Staker RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - 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. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `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); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - 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 := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(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 + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. - representation of the deserialized, embedded message, with - an + It is less efficient than using key. Only one of offset or key + should - additional field `@type` which contains the type URL. - Example: + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + a count of the total number of items available for pagination in + UIs. - If the embedded message type is well-known and has a custom - JSON + count_total is only respected when offset is used. It is ignored + when key - representation, that representation will be embedded adding - a field + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. - `value` which holds the custom JSON in addition to the - `@type` - field. Example (for message [google.protobuf.Duration][]): + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + - name: index + description: >- + index is an optional parameter which tells the server to only show - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: pool_id - description: pool_id ... - in: path - required: true - type: string - format: uint64 - - name: height - description: id ... - in: path - required: true + the bundle with the given index. This can not be combined with + pagination. + in: query + required: false type: string - format: uint64 tags: - QueryBundles - /kyve/query/v1beta1/finalized_bundles/{pool_id}: + /kyve/v1/bundles/{pool_id}/{id}: get: - summary: FinalizedBundles ... - operationId: FinalizedBundles + summary: FinalizedBundle ... + operationId: FinalizedBundleQuery responses: '200': description: A successful response. schema: type: object properties: - finalized_bundles: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - title: >- - pool_id is the id of the pool for which this proposal is - for - id: - type: string - format: uint64 - title: >- - id is a unique identifier for each finalized bundle in a - pool - storage_id: - type: string - title: >- - storage_id is the id with which the data can be - retrieved from - uploader: - type: string - title: >- - uploader is the address of the staker who submitted this - bundle - from_index: - type: string - format: uint64 - title: >- - from_index is the index from where the bundle starts - (inclusive) - to_index: - type: string - format: uint64 - title: >- - to_index is the index to which the bundle goes - (exclusive) - to_key: - type: string - title: >- - to_key the key of the last data item in the bundle - proposal - bundle_summary: - type: string - title: bundle_summary a string summary of the current proposal - data_hash: - type: string - title: data_hash a sha256 hash of the raw compressed data - finalized_at: - description: >- - finalized_at contains details of the block that - finalized this bundle. - type: object - properties: - height: - type: string - format: uint64 - description: height ... - timestamp: - type: string - format: uint64 - description: timestamp ... - from_key: - type: string - title: >- - from_key the key of the first data item in the bundle - proposal - storage_provider_id: - type: integer - format: int64 - title: >- - storage_provider_id the id of the storage provider where - the bundle is stored - compression_id: - type: integer - format: int64 - title: >- - compression_id the id of the compression type with which - the data was compressed - title: >- - FinalizedBundle represents a bundle proposal where the - majority - - agreed on its validity - description: finalized_bundles ... - pagination: - description: pagination defines the pagination in the response. + pool_id: + type: string + format: uint64 + title: pool_id in which the bundle was created + id: + type: string + format: uint64 + description: id is is integrated with each valid bundle produced. + storage_id: + type: string + title: >- + storage_id is the id with which the data can be retrieved from + the configured data provider + uploader: + type: string + title: >- + uploader is the address of the staker who submitted this + bundle + from_index: + type: string + format: uint64 + title: >- + from_index is the index from where the bundle starts + (inclusive) + to_index: + type: string + format: uint64 + title: to_index is the index to which the bundle goes (exclusive) + from_key: + type: string + title: >- + from_key is the key of the first data item in the bundle + proposal + to_key: + type: string + title: to_key the key of the last data item in the bundle + bundle_summary: + type: string + description: bundle_summary is a summary of the bundle. + data_hash: + type: string + description: data_hash is a sha256 hash of the uploaded data. + finalized_at: + description: >- + finalized_at contains details of the block that finalized this + bundle. type: object properties: - next_key: + height: type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + description: >- + height is the block height in which the bundle got + finalized. + timestamp: type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total + description: >- + timestamp is the UNIX timestamp of the block in which the + bundle got finalized. + storage_provider_id: + type: string + format: uint64 + title: >- + storage_provider_id the id of the storage provider where the + bundle is stored + compression_id: + type: string + format: uint64 + title: >- + compression_id the id of the compression type with which the + data was compressed + stake_security: + description: >- + stake_security defines the amount of stake which was present + in the pool during the finalization of the bundle. + + This field was added in schema version 2. Bundles finalized + before that return `null`. + type: object + properties: + valid_vote_power: + type: string + description: >- + valid_vote_power gives the amount of $KYVE stake that + voted `valid`. + total_vote_power: + type: string + description: >- + total_vote_power gives the amount of total $KYVE stake + that was present in the pool - was set, its value is undefined otherwise - description: >- - QueryStakersByPoolResponse is the response type for the - Query/Staker RPC method. + during finalization. + title: >- + StakeSecurity represents the relative security of a finalized + bundle + title: >- + FinalizedBundle represents the latest version of a valid bundle of + a pool default: description: An unexpected error response. schema: @@ -3388,62 +3178,12 @@ paths: required: true type: string format: uint64 - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false + - name: id + description: id ... + in: path + required: true type: string format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean tags: - QueryBundles /kyve/query/v1beta1/delegator/{staker}/{delegator}: @@ -4104,6 +3844,12 @@ paths: commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE + earned through commission title: >- StakerMetadata contains static information for a staker @@ -4750,6 +4496,16 @@ paths: type: string format: uint64 description: commission_change_time ... + pool_params: + description: pool_params ... + type: object + properties: + protocol_inflation_share: + type: string + description: protocol_inflation_share ... + pool_inflation_payout_rate: + type: string + description: pool_inflation_payout_rate ... description: QueryParamsResponse ... default: description: An unexpected error response. @@ -5244,6 +5000,13 @@ paths: - POOL_STATUS_NOT_ENOUGH_DELEGATION - POOL_STATUS_UPGRADING default: POOL_STATUS_UNSPECIFIED + account: + type: string + description: account ... + account_balance: + type: string + format: uint64 + description: account_balance ... description: >- QueryPoolResponse is the response type for the Query/Pool RPC method. @@ -5753,6 +5516,13 @@ paths: - POOL_STATUS_NOT_ENOUGH_DELEGATION - POOL_STATUS_UPGRADING default: POOL_STATUS_UNSPECIFIED + account: + type: string + description: account ... + account_balance: + type: string + format: uint64 + description: account_balance ... description: PoolResponse ... description: pools ... pagination: @@ -6124,6 +5894,12 @@ paths: title: |- CommissionChangeEntry shows when the old commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE earned + through commission title: StakerMetadata contains static information for a staker self_delegation: type: string @@ -6547,6 +6323,12 @@ paths: title: |- CommissionChangeEntry shows when the old commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE earned + through commission title: StakerMetadata contains static information for a staker self_delegation: type: string @@ -7075,6 +6857,12 @@ paths: commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE + earned through commission title: >- StakerMetadata contains static information for a staker @@ -7548,6 +7336,12 @@ paths: title: |- CommissionChangeEntry shows when the old commission of a staker will change to the new commission + commission_rewards: + type: string + format: uint64 + title: >- + commission_rewards are the rewards in $KYVE earned + through commission title: StakerMetadata contains static information for a staker self_delegation: type: string diff --git a/proto/kyve/bundles/v1beta1/bundles.proto b/proto/kyve/bundles/v1beta1/bundles.proto index cefd8b25..8c50f54a 100644 --- a/proto/kyve/bundles/v1beta1/bundles.proto +++ b/proto/kyve/bundles/v1beta1/bundles.proto @@ -91,6 +91,8 @@ message FinalizedBundle { uint32 storage_provider_id = 12; // compression_id the id of the compression type with which the data was compressed uint32 compression_id = 13; + // stake_security + StakeSecurity stake_security = 14; } // FinalizedAt ... @@ -100,3 +102,41 @@ message FinalizedAt { // timestamp ... uint64 timestamp = 2; } + +// StakeSecurity stores information about total stake and valid votes with which the bundle got finalized. +message StakeSecurity { + // valid_vote_power is the total amount of stake of all pool stakers which voted valid for the given bundle. + uint64 valid_vote_power = 1; + // total_vote_power is the total amount of stake that was present during the finalization of the bundle + uint64 total_vote_power = 2; +} + +// BundleVersionEntry ... +message BundleVersionEntry { + // height ... + uint64 height = 1; + // version ... + int32 version = 2; +} + +// BundleVersionMap ... +message BundleVersionMap { + // versions ... + repeated BundleVersionEntry versions = 1; +} + +// RoundRobinSingleValidatorProgress ... +message RoundRobinSingleValidatorProgress { + // address ... + string address = 1; + // progress ... + int64 progress = 2; +} + +// RoundRobinProgress ... +message RoundRobinProgress { + // pool_id ... + uint64 pool_id = 1; + // progress_list ... + repeated RoundRobinSingleValidatorProgress progress_list = 2; +} diff --git a/proto/kyve/bundles/v1beta1/events.proto b/proto/kyve/bundles/v1beta1/events.proto index f82143f0..749c9e97 100644 --- a/proto/kyve/bundles/v1beta1/events.proto +++ b/proto/kyve/bundles/v1beta1/events.proto @@ -87,20 +87,24 @@ message EventBundleFinalized { uint64 total = 6; // status of the finalized bundle BundleStatus status = 7; + // amount which funders provided to the total bundle reward (in ukyve) + uint64 funders_payout = 8; + // amount which the inflation pool provided to the total reward (in ukyve) + uint64 inflation_payout = 9; // rewards transferred to treasury (in ukyve) - uint64 reward_treasury = 8; + uint64 reward_treasury = 10; // rewardUploader rewards directly transferred to uploader (in ukyve) - uint64 reward_uploader = 9; + uint64 reward_uploader = 11; // rewardDelegation rewards distributed among all delegators (in ukyve) - uint64 reward_delegation = 10; + uint64 reward_delegation = 12; // rewardTotal the total bundle reward - uint64 reward_total = 11; + uint64 reward_total = 13; // finalized_at the block height where the bundle got finalized - uint64 finalized_at = 12; + uint64 finalized_at = 14; // uploader the address of the uploader of this bundle - string uploader = 13; + string uploader = 15; // next_uploader the address of the next uploader after this bundle - string next_uploader = 14; + string next_uploader = 16; } // EventClaimedUploaderRole is an event emitted when an uploader claims the uploader role diff --git a/proto/kyve/bundles/v1beta1/genesis.proto b/proto/kyve/bundles/v1beta1/genesis.proto index 620274cb..1c31792a 100644 --- a/proto/kyve/bundles/v1beta1/genesis.proto +++ b/proto/kyve/bundles/v1beta1/genesis.proto @@ -16,4 +16,6 @@ message GenesisState { repeated BundleProposal bundle_proposal_list = 2 [(gogoproto.nullable) = false]; // finalized_bundle_list ... repeated FinalizedBundle finalized_bundle_list = 3 [(gogoproto.nullable) = false]; + // round_robin_progress_list ... + repeated RoundRobinProgress round_robin_progress_list = 4 [(gogoproto.nullable) = false]; } diff --git a/proto/kyve/pool/v1beta1/events.proto b/proto/kyve/pool/v1beta1/events.proto index 47c59386..2e23ad92 100644 --- a/proto/kyve/pool/v1beta1/events.proto +++ b/proto/kyve/pool/v1beta1/events.proto @@ -2,8 +2,22 @@ syntax = "proto3"; package kyve.pool.v1beta1; +import "gogoproto/gogo.proto"; +import "kyve/pool/v1beta1/params.proto"; + option go_package = "github.com/KYVENetwork/chain/x/pool/types"; +// EventUpdateParams is an event emitted when the module parameters are updated. +// emitted_by: MsgUpdateParams +message EventUpdateParams { + // old_params is the module's old parameters. + kyve.pool.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.pool.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} + // EventCreatePool ... // emitted_by: EndBlock(gov) message EventCreatePool { diff --git a/proto/kyve/pool/v1beta1/genesis.proto b/proto/kyve/pool/v1beta1/genesis.proto index 0051e4ac..ca5286ab 100644 --- a/proto/kyve/pool/v1beta1/genesis.proto +++ b/proto/kyve/pool/v1beta1/genesis.proto @@ -3,15 +3,15 @@ syntax = "proto3"; package kyve.pool.v1beta1; import "gogoproto/gogo.proto"; +import "kyve/pool/v1beta1/params.proto"; import "kyve/pool/v1beta1/pool.proto"; option go_package = "github.com/KYVENetwork/chain/x/pool/types"; // GenesisState defines the pool module's genesis state. message GenesisState { - reserved 1; - reserved "params"; - + // params ... + Params params = 1 [(gogoproto.nullable) = false]; // pool_list ... repeated kyve.pool.v1beta1.Pool pool_list = 2 [(gogoproto.nullable) = false]; // pool_count ... diff --git a/proto/kyve/pool/v1beta1/params.proto b/proto/kyve/pool/v1beta1/params.proto new file mode 100644 index 00000000..331307a5 --- /dev/null +++ b/proto/kyve/pool/v1beta1/params.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package kyve.pool.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/pool/types"; + +// Params defines the pool module parameters. +message Params { + // protocol_inflation_share ... + string protocol_inflation_share = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // pool_inflation_payout_rate ... + string pool_inflation_payout_rate = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/kyve/pool/v1beta1/query.proto b/proto/kyve/pool/v1beta1/query.proto new file mode 100644 index 00000000..8589b372 --- /dev/null +++ b/proto/kyve/pool/v1beta1/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package kyve.pool.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "kyve/pool/v1beta1/params.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/pool/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/kyve/pool/v1beta1/params"; + } +} + +// 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/proto/kyve/pool/v1beta1/tx.proto b/proto/kyve/pool/v1beta1/tx.proto index 4ca6223d..c7efa075 100644 --- a/proto/kyve/pool/v1beta1/tx.proto +++ b/proto/kyve/pool/v1beta1/tx.proto @@ -31,6 +31,9 @@ service Msg { // CancelRuntimeUpgrade defines a governance operation for cancelling a runtime upgrade. // The authority is hard-coded to the x/gov module account. rpc CancelRuntimeUpgrade(MsgCancelRuntimeUpgrade) returns (MsgCancelRuntimeUpgradeResponse); + // UpdateParams defines a governance operation for updating the x/pool module + // parameters. The authority is hard-coded to the x/gov module account. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } // MsgFundPool defines a SDK message for funding a pool. @@ -158,3 +161,15 @@ message MsgCancelRuntimeUpgrade { // MsgCancelRuntimeUpgradeResponse defines the Msg/CancelRuntimeUpgrade response type. message MsgCancelRuntimeUpgradeResponse {} + +// MsgUpdateParams defines a SDK message for updating the module parameters. +message MsgUpdateParams { + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // payload defines the x/stakers parameters to update. + string payload = 2; +} + +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. +message MsgUpdateParamsResponse {} diff --git a/proto/kyve/query/v1beta1/bundles.proto b/proto/kyve/query/v1beta1/bundles.proto index 60b731f3..56f5f900 100644 --- a/proto/kyve/query/v1beta1/bundles.proto +++ b/proto/kyve/query/v1beta1/bundles.proto @@ -5,25 +5,19 @@ package kyve.query.v1beta1; import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "kyve/bundles/v1beta1/bundles.proto"; option go_package = "github.com/KYVENetwork/chain/x/query/types"; // QueryDelegation contains all rpc requests related to direct delegation data service QueryBundles { // FinalizedBundles ... - rpc FinalizedBundles(QueryFinalizedBundlesRequest) returns (QueryFinalizedBundlesResponse) { - option (google.api.http).get = "/kyve/query/v1beta1/finalized_bundles/{pool_id}"; + rpc FinalizedBundlesQuery(QueryFinalizedBundlesRequest) returns (QueryFinalizedBundlesResponse) { + option (google.api.http).get = "/kyve/v1/bundles/{pool_id}"; } // FinalizedBundle ... - rpc FinalizedBundle(QueryFinalizedBundleRequest) returns (QueryFinalizedBundleResponse) { - option (google.api.http).get = "/kyve/query/v1beta1/finalized_bundle/{pool_id}/{id}"; - } - - // Queries the bundle which contains the data given height - rpc FinalizedBundlesByHeight(QueryFinalizedBundlesByHeightRequest) returns (QueryFinalizedBundlesByHeightResponse) { - option (google.api.http).get = "/kyve/query/v1beta1/finalized_bundle_by_height/{pool_id}/{height}"; + rpc FinalizedBundleQuery(QueryFinalizedBundleRequest) returns (FinalizedBundle) { + option (google.api.http).get = "/kyve/v1/bundles/{pool_id}/{id}"; } // CurrentVoteStatus ... @@ -47,6 +41,56 @@ service QueryBundles { } } +// FinalizedBundle represents the latest version of a valid bundle of a pool +message FinalizedBundle { + // pool_id in which the bundle was created + uint64 pool_id = 1; + // id is is integrated with each valid bundle produced. + uint64 id = 2; + // storage_id is the id with which the data can be retrieved from the configured data provider + string storage_id = 3; + // uploader is the address of the staker who submitted this bundle + string uploader = 4; + // from_index is the index from where the bundle starts (inclusive) + uint64 from_index = 5; + // to_index is the index to which the bundle goes (exclusive) + uint64 to_index = 6; + // from_key is the key of the first data item in the bundle proposal + string from_key = 11; + // to_key the key of the last data item in the bundle + string to_key = 7; + // bundle_summary is a summary of the bundle. + string bundle_summary = 8; + // data_hash is a sha256 hash of the uploaded data. + string data_hash = 9; + // finalized_at contains details of the block that finalized this bundle. + FinalizedAt finalized_at = 10; + // storage_provider_id the id of the storage provider where the bundle is stored + uint64 storage_provider_id = 12; + // compression_id the id of the compression type with which the data was compressed + uint64 compression_id = 13; + // stake_security defines the amount of stake which was present in the pool during the finalization of the bundle. + // This field was added in schema version 2. Bundles finalized before that return `null`. + StakeSecurity stake_security = 14; +} + +// FinalizedAt stores information about finalization block and time. +message FinalizedAt { + // height is the block height in which the bundle got finalized. + string height = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; + // timestamp is the UNIX timestamp of the block in which the bundle got finalized. + string timestamp = 2; +} + +// StakeSecurity represents the relative security of a finalized bundle +message StakeSecurity { + // valid_vote_power gives the amount of $KYVE stake that voted `valid`. + string valid_vote_power = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; + // total_vote_power gives the amount of total $KYVE stake that was present in the pool + // during finalization. + string total_vote_power = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Int"]; +} + // =========================== // finalized_bundles/{pool_id} // =========================== @@ -57,12 +101,15 @@ message QueryFinalizedBundlesRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; // pool_id ... uint64 pool_id = 2; + // index is an optional parameter which tells the server to only show + // the bundle with the given index. This can not be combined with pagination. + string index = 3; } // QueryStakersByPoolResponse is the response type for the Query/Staker RPC method. message QueryFinalizedBundlesResponse { // finalized_bundles ... - repeated kyve.bundles.v1beta1.FinalizedBundle finalized_bundles = 1 [(gogoproto.nullable) = false]; + repeated FinalizedBundle finalized_bundles = 1 [(gogoproto.nullable) = false]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -81,26 +128,8 @@ message QueryFinalizedBundleRequest { // QueryFinalizedBundleResponse is the response type for the Query/Staker RPC method. message QueryFinalizedBundleResponse { - // finalized_bundle ... - kyve.bundles.v1beta1.FinalizedBundle finalized_bundle = 1 [(gogoproto.nullable) = false]; -} - -// =================================== -// finalized_bundle_by_height/{height} -// =================================== - -// QueryFinalizedBundleRequest is the request type for the Query/Staker RPC method. -message QueryFinalizedBundlesByHeightRequest { - // pool_id ... - uint64 pool_id = 1; - // id ... - uint64 height = 2; -} - -// QueryFinalizedBundleResponse is the response type for the Query/Staker RPC method. -message QueryFinalizedBundlesByHeightResponse { - // finalized_bundle ... - kyve.bundles.v1beta1.FinalizedBundle finalized_bundle = 1 [(gogoproto.nullable) = false]; + // finalized_bundles ... + FinalizedBundle finalized_bundles = 1 [(gogoproto.nullable) = false]; } // =============================== diff --git a/proto/kyve/query/v1beta1/params.proto b/proto/kyve/query/v1beta1/params.proto index 83bdd7b7..7d9381fe 100644 --- a/proto/kyve/query/v1beta1/params.proto +++ b/proto/kyve/query/v1beta1/params.proto @@ -7,6 +7,7 @@ import "google/api/annotations.proto"; import "kyve/bundles/v1beta1/params.proto"; import "kyve/delegation/v1beta1/params.proto"; import "kyve/global/v1beta1/global.proto"; +import "kyve/pool/v1beta1/params.proto"; import "kyve/stakers/v1beta1/params.proto"; option go_package = "github.com/KYVENetwork/chain/x/query/types"; @@ -38,4 +39,6 @@ message QueryParamsResponse { cosmos.gov.v1.Params gov_params = 4; // stakers_params ... kyve.stakers.v1beta1.Params stakers_params = 5; + // pool_params ... + kyve.pool.v1beta1.Params pool_params = 6; } diff --git a/proto/kyve/query/v1beta1/pools.proto b/proto/kyve/query/v1beta1/pools.proto index 1bee7e2d..a1ef4b0c 100644 --- a/proto/kyve/query/v1beta1/pools.proto +++ b/proto/kyve/query/v1beta1/pools.proto @@ -65,6 +65,10 @@ message PoolResponse { uint64 total_delegation = 6; // status ... kyve.pool.v1beta1.PoolStatus status = 7; + // account ... + string account = 8; + // account_balance ... + uint64 account_balance = 9; } // ========= diff --git a/proto/kyve/query/v1beta1/query.proto b/proto/kyve/query/v1beta1/query.proto index 87ddc414..b8033a71 100644 --- a/proto/kyve/query/v1beta1/query.proto +++ b/proto/kyve/query/v1beta1/query.proto @@ -122,6 +122,9 @@ message StakerMetadata { // the commission is applied. Users have time to redelegate // if they not agree with the new commission. CommissionChangeEntry pending_commission_change = 7; + + // commission_rewards are the rewards in $KYVE earned through commission + uint64 commission_rewards = 8; } // CommissionChangeEntry shows when the old commission diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index 3f6c55ba..e84c8c36 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -1,7 +1,10 @@ package integration import ( + "time" + "github.com/KYVENetwork/chain/x/bundles" + bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types" "github.com/KYVENetwork/chain/x/delegation" delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" globalTypes "github.com/KYVENetwork/chain/x/global/types" @@ -262,12 +265,33 @@ func (suite *KeeperTestSuite) VerifyStakersGenesisImportExport() { // bundles module checks // ===================== +func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bundlesTypes.FinalizedBundle) { + Expect(queryBundle.Id).To(Equal(rawBundle.Id)) + Expect(queryBundle.PoolId).To(Equal(rawBundle.PoolId)) + Expect(queryBundle.StorageId).To(Equal(rawBundle.StorageId)) + Expect(queryBundle.Uploader).To(Equal(rawBundle.Uploader)) + Expect(queryBundle.FromIndex).To(Equal(rawBundle.FromIndex)) + Expect(queryBundle.ToIndex).To(Equal(rawBundle.ToIndex)) + Expect(queryBundle.ToKey).To(Equal(rawBundle.ToKey)) + Expect(queryBundle.BundleSummary).To(Equal(rawBundle.BundleSummary)) + Expect(queryBundle.DataHash).To(Equal(rawBundle.DataHash)) + Expect(queryBundle.FinalizedAt.Height.Uint64()).To(Equal(rawBundle.FinalizedAt.Height)) + date, dateErr := time.Parse(time.RFC3339, queryBundle.FinalizedAt.Timestamp) + Expect(dateErr).To(BeNil()) + Expect(uint64(date.Unix())).To(Equal(rawBundle.FinalizedAt.Timestamp)) + Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey)) + Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId))) + Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId))) + Expect(queryBundle.StakeSecurity.ValidVotePower.Uint64()).To(Equal(rawBundle.StakeSecurity.ValidVotePower)) + Expect(queryBundle.StakeSecurity.TotalVotePower.Uint64()).To(Equal(rawBundle.StakeSecurity.TotalVotePower)) +} + func (suite *KeeperTestSuite) VerifyBundlesQueries() { pools := suite.App().PoolKeeper.GetAllPools(suite.Ctx()) for _, pool := range pools { finalizedBundlesState := suite.App().BundlesKeeper.GetFinalizedBundlesByPool(suite.Ctx(), pool.Id) - finalizedBundlesQuery, finalizedBundlesQueryErr := suite.App().QueryKeeper.FinalizedBundles(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundlesRequest{ + finalizedBundlesQuery, finalizedBundlesQueryErr := suite.App().QueryKeeper.FinalizedBundlesQuery(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundlesRequest{ PoolId: pool.Id, }) @@ -275,15 +299,15 @@ func (suite *KeeperTestSuite) VerifyBundlesQueries() { Expect(finalizedBundlesQuery.FinalizedBundles).To(HaveLen(len(finalizedBundlesState))) for i := range finalizedBundlesState { - Expect(finalizedBundlesQuery.FinalizedBundles[i]).To(Equal(finalizedBundlesState[i])) - finalizedBundleQuery, finalizedBundleQueryErr := suite.App().QueryKeeper.FinalizedBundle(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundleRequest{ + finalizedBundle, finalizedBundleQueryErr := suite.App().QueryKeeper.FinalizedBundleQuery(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundleRequest{ PoolId: pool.Id, Id: finalizedBundlesState[i].Id, }) Expect(finalizedBundleQueryErr).To(BeNil()) - Expect(finalizedBundleQuery.FinalizedBundle).To(Equal(finalizedBundlesState[i])) + + checkFinalizedBundle(*finalizedBundle, finalizedBundlesState[i]) } } } diff --git a/testutil/integration/helpers.go b/testutil/integration/helpers.go index d202237a..8c691815 100644 --- a/testutil/integration/helpers.go +++ b/testutil/integration/helpers.go @@ -16,6 +16,15 @@ func (suite *KeeperTestSuite) GetBalanceFromAddress(address string) uint64 { return uint64(balance.Amount.Int64()) } +func (suite *KeeperTestSuite) GetBalanceFromPool(poolId uint64) uint64 { + pool, found := suite.App().PoolKeeper.GetPool(suite.Ctx(), poolId) + if !found { + return 0 + } + + return uint64(suite.App().BankKeeper.GetBalance(suite.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) +} + func (suite *KeeperTestSuite) GetBalanceFromModule(moduleName string) uint64 { moduleAcc := suite.App().AccountKeeper.GetModuleAccount(suite.Ctx(), moduleName).GetAddress() return suite.App().BankKeeper.GetBalance(suite.Ctx(), moduleAcc, globalTypes.Denom).Amount.Uint64() diff --git a/testutil/integration/integration.go b/testutil/integration/integration.go index 5656dbee..2464188d 100644 --- a/testutil/integration/integration.go +++ b/testutil/integration/integration.go @@ -81,15 +81,13 @@ func (suite *KeeperTestSuite) initDummyAccounts() { _ = suite.Mint(STAKER_2, 1000*KYVE) _ = suite.Mint(VALADDRESS_2, 1000*KYVE) - mrand.New(mrand.NewSource(1)) - DUMMY = make([]string, 50) for i := 0; i < 50; i++ { byteAddr := make([]byte, 20) for k := 0; k < 20; k++ { - mrand.New(mrand.NewSource(int64(i + k))) - byteAddr[k] = byte(mrand.Int()) + randomSource := mrand.New(mrand.NewSource(int64(i + k))) + byteAddr[k] = byte(randomSource.Int()) } dummy, _ := sdk.Bech32ifyAddressBytes("kyve", byteAddr) DUMMY[i] = dummy @@ -100,8 +98,8 @@ func (suite *KeeperTestSuite) initDummyAccounts() { for i := 0; i < 50; i++ { byteAddr := make([]byte, 20) for k := 0; k < 20; k++ { - mrand.New(mrand.NewSource(int64(i + k + 100))) - byteAddr[k] = byte(mrand.Int()) + randomSource := mrand.New(mrand.NewSource(int64(i + k + 100))) + byteAddr[k] = byte(randomSource.Int()) } dummy, _ := sdk.Bech32ifyAddressBytes("kyve", byteAddr) VALDUMMY[i] = dummy diff --git a/x/bundles/abci.go b/x/bundles/abci.go new file mode 100644 index 00000000..245607a1 --- /dev/null +++ b/x/bundles/abci.go @@ -0,0 +1,90 @@ +package bundles + +import ( + "github.com/KYVENetwork/chain/util" + bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + + // Auth + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + // Bank + bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + // Mint + mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + // Pool + "github.com/KYVENetwork/chain/x/pool/keeper" + // Team + teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" + // Upgrade + upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" +) + +func SplitInflation(ctx sdk.Context, k bundlesKeeper.Keeper, bk bankKeeper.Keeper, mk mintKeeper.Keeper, pk keeper.Keeper, tk teamKeeper.Keeper, uk upgradeKeeper.Keeper) { + minter := mk.GetMinter(ctx) + params := mk.GetParams(ctx) + + // get total inflation rewards for current block + blockProvision := minter.BlockProvision(params).Amount.Int64() + + // calculate the remaining block provision for chain and protocol after x/team took its share + remainingBlockProvision := blockProvision - tk.GetTeamBlockProvision(ctx) + + // calculate block provision for protocol based on protocol inflation share + protocolBlockProvision := sdk.NewDec(remainingBlockProvision).Mul(pk.GetProtocolInflationShare(ctx)).TruncateInt64() + + if protocolBlockProvision == 0 { + return + } + + // track actual distributed block provision for protocol + distributed := uint64(0) + + // calculate total operating cost of pools to get each pool's reward share + totalOperatingCost := uint64(0) + + for _, pool := range pk.GetAllPools(ctx) { + // only include active pools + if err := k.AssertPoolCanRun(ctx, pool.Id); err == nil { + totalOperatingCost += pool.OperatingCost + } + } + + // if the total operating cost is zero all rewards go the chain + if totalOperatingCost == 0 { + return + } + + for _, pool := range pk.GetAllPools(ctx) { + // only include active pools + if err := k.AssertPoolCanRun(ctx, pool.Id); err == nil { + // calculate pool share based of operating cost + amount := uint64(sdk.NewDec(int64(pool.OperatingCost)).Quo(sdk.NewDec(int64(totalOperatingCost))).Mul(sdk.NewDec(protocolBlockProvision)).TruncateInt64()) + + // transfer funds to pool account + if err := util.TransferFromModuleToAddress(bk, ctx, authTypes.FeeCollectorName, pool.GetPoolAccount().String(), amount); err != nil { + util.PanicHalt(uk, ctx, err.Error()) + } + + // track transferred $KYVE to protocol + distributed += amount + } + } + + // calculate if a remainder is left + remainder := uint64(protocolBlockProvision) - distributed + + if remainder > 0 { + // find an active pool + for _, pool := range pk.GetAllPools(ctx) { + if err := k.AssertPoolCanRun(ctx, pool.Id); err != nil { + // add remainder to first active pool we find + if err := util.TransferFromModuleToAddress(bk, ctx, authTypes.FeeCollectorName, pool.GetPoolAccount().String(), remainder); err != nil { + util.PanicHalt(uk, ctx, err.Error()) + } + } + } + } + + // rest gets transferred to chain + pk.Logger(ctx).Info("split portion of minted coins to protocol", "amount", protocolBlockProvision) +} diff --git a/x/bundles/genesis.go b/x/bundles/genesis.go index fbe90d98..bbc38d06 100644 --- a/x/bundles/genesis.go +++ b/x/bundles/genesis.go @@ -19,6 +19,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, entry := range genState.FinalizedBundleList { k.SetFinalizedBundle(ctx, entry) } + + for _, entry := range genState.RoundRobinProgressList { + k.SetRoundRobinProgress(ctx, entry) + } } // ExportGenesis returns the capability module's exported genesis. @@ -30,5 +34,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.FinalizedBundleList = k.GetAllFinalizedBundles(ctx) + genesis.RoundRobinProgressList = k.GetAllRoundRobinProgress(ctx) + return genesis } diff --git a/x/bundles/keeper/abci_protocol_split_test.go b/x/bundles/keeper/abci_protocol_split_test.go new file mode 100644 index 00000000..bfcf0ad1 --- /dev/null +++ b/x/bundles/keeper/abci_protocol_split_test.go @@ -0,0 +1,238 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + globalTypes "github.com/KYVENetwork/chain/x/global/types" + poolTypes "github.com/KYVENetwork/chain/x/pool/types" + stakertypes "github.com/KYVENetwork/chain/x/stakers/types" + sdk "github.com/cosmos/cosmos-sdk/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - abci.go + +* inactive pool should not receive inflation funds +* active pool should receive inflation funds +* pool should split inflation funds depending on operating cost +* pools with zero operating cost should receive nothing +* every pool has zero operating cost + +*/ + +var _ = Describe("abci.go", Ordered, func() { + s := i.NewCleanChain() + + BeforeEach(func() { + s = i.NewCleanChain() + + s.App().PoolKeeper.SetParams(s.Ctx(), poolTypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ + Name: "PoolTest", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + MinDelegation: 100 * i.KYVE, + OperatingCost: 1_000_000, + Protocol: &poolTypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &poolTypes.UpgradePlan{}, + }) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("inactive pool should not receive inflation funds", func() { + // ARRANGE + b1, b2 := uint64(0), uint64(0) + + for t := 0; t < 100; t++ { + // ACT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + b1 = uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + s.Commit() + b2 = uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + // ASSERT + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + } + }) + + It("active pool should receive inflation funds", func() { + // ARRANGE + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.STAKER_0, + PoolId: 0, + Valaddress: i.VALADDRESS_0, + }) + + b1, b2 := uint64(0), uint64(0) + + for t := 0; t < 100; t++ { + // ACT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + b1 = uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + s.Commit() + b2 = uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + // ASSERT + Expect(b1).To(BeNumerically("<", b2)) + } + }) + + It("pool should split inflation funds depending on operating cost", func() { + // ARRANGE + s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ + Name: "PoolTest2", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + MinDelegation: 100 * i.KYVE, + OperatingCost: 2_000_000, + Protocol: &poolTypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &poolTypes.UpgradePlan{}, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.STAKER_0, + PoolId: 0, + Valaddress: i.VALADDRESS_0, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.STAKER_1, + Amount: 100 * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.STAKER_1, + PoolId: 1, + Valaddress: i.VALADDRESS_1, + }) + + // ACT + s.Commit() + + pool1, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + b1 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool1.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + pool2, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + b2 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool2.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + // ASSERT + Expect(b1 * 2).To(BeNumerically("~", b2, 1)) + }) + + It("pools with zero operating cost should receive nothing", func() { + // ARRANGE + s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ + Name: "PoolTest2", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + MinDelegation: 100 * i.KYVE, + OperatingCost: 0, + Protocol: &poolTypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &poolTypes.UpgradePlan{}, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.STAKER_0, + PoolId: 0, + Valaddress: i.VALADDRESS_0, + }) + + // ACT + s.Commit() + + pool1, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + b1 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool1.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + pool2, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + b2 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool2.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + // ASSERT + Expect(b1).To(BeNumerically(">", b2)) + Expect(b2).To(BeZero()) + }) + + It("every pool has zero operating cost", func() { + // ARRANGE + s.App().PoolKeeper.SetPool(s.Ctx(), poolTypes.Pool{ + Id: 0, + Name: "PoolTest", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + OperatingCost: 0, + Protocol: &poolTypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &poolTypes.UpgradePlan{}, + }) + + s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ + Name: "PoolTest2", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + OperatingCost: 0, + Protocol: &poolTypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &poolTypes.UpgradePlan{}, + }) + + // ACT + s.Commit() + + pool1, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + b1 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool1.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + pool2, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + b2 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool2.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) + + // ASSERT + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + }) +}) diff --git a/x/bundles/keeper/getters_bundles.go b/x/bundles/keeper/getters_bundles.go index 060bdb4f..95c8a63d 100644 --- a/x/bundles/keeper/getters_bundles.go +++ b/x/bundles/keeper/getters_bundles.go @@ -2,14 +2,19 @@ package keeper import ( "encoding/binary" + "fmt" + "time" + + cosmossdk_io_math "cosmossdk.io/math" + + queryTypes "github.com/KYVENetwork/chain/x/query/types" + storeTypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/KYVENetwork/chain/util" "github.com/KYVENetwork/chain/x/bundles/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) // SetBundleProposal stores a current bundle proposal in the KV-Store. @@ -69,9 +74,9 @@ func (k Keeper) SetFinalizedBundle(ctx sdk.Context, finalizedBundle types.Finali // SetFinalizedBundleIndexes sets an in-memory reference for every bundle sorted by pool/fromIndex // to allow querying for specific bundle ranges. func (k Keeper) SetFinalizedBundleIndexes(ctx sdk.Context, finalizedBundle types.FinalizedBundle) { - indexByStorageHeight := prefix.NewStore(ctx.KVStore(k.memKey), types.FinalizedBundleByHeightPrefix) - indexByStorageHeight.Set( - types.FinalizedBundleByHeightKey(finalizedBundle.PoolId, finalizedBundle.FromIndex), + indexByStorageIndex := prefix.NewStore(ctx.KVStore(k.memKey), types.FinalizedBundleByIndexPrefix) + indexByStorageIndex.Set( + types.FinalizedBundleByIndexKey(finalizedBundle.PoolId, finalizedBundle.FromIndex), util.GetByteKey(finalizedBundle.Id)) } @@ -114,34 +119,130 @@ func (k Keeper) GetFinalizedBundle(ctx sdk.Context, poolId, id uint64) (val type return val, true } -// TODO(postAudit,@max) consider performance improvement -func (k Keeper) GetPaginatedFinalizedBundleQuery(ctx sdk.Context, pagination *query.PageRequest, poolId uint64) ([]types.FinalizedBundle, *query.PageResponse, error) { - var data []types.FinalizedBundle +func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap map[int32]uint64) (queryBundle queryTypes.FinalizedBundle) { + finalizedHeight := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.FinalizedAt.Height)) + + finalizedBundle := queryTypes.FinalizedBundle{ + PoolId: rawFinalizedBundle.PoolId, + Id: rawFinalizedBundle.Id, + StorageId: rawFinalizedBundle.StorageId, + Uploader: rawFinalizedBundle.Uploader, + FromIndex: rawFinalizedBundle.FromIndex, + ToIndex: rawFinalizedBundle.ToIndex, + ToKey: rawFinalizedBundle.ToKey, + BundleSummary: rawFinalizedBundle.BundleSummary, + DataHash: rawFinalizedBundle.DataHash, + FinalizedAt: &queryTypes.FinalizedAt{ + Height: &finalizedHeight, + Timestamp: time.Unix(int64(rawFinalizedBundle.FinalizedAt.Timestamp), 0).Format(time.RFC3339), + }, + FromKey: rawFinalizedBundle.FromKey, + StorageProviderId: uint64(rawFinalizedBundle.StorageProviderId), + CompressionId: uint64(rawFinalizedBundle.CompressionId), + StakeSecurity: &queryTypes.StakeSecurity{ + ValidVotePower: nil, + TotalVotePower: nil, + }, + } + + // Check for version 2 + if rawFinalizedBundle.FinalizedAt.Height >= versionMap[2] { + validPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.ValidVotePower)) + totalPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.TotalVotePower)) + finalizedBundle.StakeSecurity.ValidVotePower = &validPower + finalizedBundle.StakeSecurity.TotalVotePower = &totalPower + } + + return finalizedBundle +} + +// GetPaginatedFinalizedBundleQuery parses a paginated request and builds a valid response out of the +// raw finalized bundles. It uses the fact that the ID of a bundle increases incrementally (starting with 0) +// and allows therefore for efficient queries using `offset`. +func (k Keeper) GetPaginatedFinalizedBundleQuery(ctx sdk.Context, pagination *query.PageRequest, poolId uint64) ([]queryTypes.FinalizedBundle, *query.PageResponse, error) { + // Parse basic pagination + if pagination == nil { + pagination = &query.PageRequest{CountTotal: true} + } + + offset := pagination.Offset + key := pagination.Key + limit := pagination.Limit + reverse := pagination.Reverse + + if limit == 0 { + limit = query.DefaultLimit + } + + pageResponse := query.PageResponse{} + // user has to use either offset or key, not both + if offset > 0 && key != nil { + return nil, nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + } + + // Init Bundles Store store := prefix.NewStore(ctx.KVStore(k.storeKey), util.GetByteKey(types.FinalizedBundlePrefix, poolId)) - pageRes, err := query.FilteredPaginate(store, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - if accumulate { - var finalizedBundle types.FinalizedBundle - if err := k.cdc.Unmarshal(value, &finalizedBundle); err != nil { - return false, err - } + // Get latest bundle id by obtaining last item from the iterator + reverseIterator := store.ReverseIterator(nil, nil) + if reverseIterator.Valid() { + // Current bundle_id equals the total amount of bundles - 1 + bundleId := binary.BigEndian.Uint64(reverseIterator.Key()) + pageResponse.Total = bundleId + 1 + } + _ = reverseIterator.Close() - data = append(data, finalizedBundle) + // Translate offset to next page keys + if len(key) == 0 { + if reverse { + pagination.Key = util.GetByteKey(pageResponse.Total - offset) + } else { + pagination.Key = util.GetByteKey(offset) } + } - return true, nil - }) - if err != nil { - return nil, nil, status.Error(codes.Internal, err.Error()) + var iterator storeTypes.Iterator + // Use correct iterator depending on the request + if reverse { + iterator = store.ReverseIterator(nil, pagination.Key) + } else { + iterator = store.Iterator(pagination.Key, nil) } - return data, pageRes, nil + var data []queryTypes.FinalizedBundle + versionMap := k.GetBundleVersionMap(ctx).GetMap() + + // Iterate bundle store and build actual response + for i := uint64(0); i < limit; i++ { + if iterator.Valid() { + var rawFinalizedBundle types.FinalizedBundle + if err := k.cdc.Unmarshal(iterator.Value(), &rawFinalizedBundle); err != nil { + return nil, nil, err + } + data = append(data, RawBundleToQueryBundle(rawFinalizedBundle, versionMap)) + pageResponse.NextKey = iterator.Key() + iterator.Next() + } else { + break + } + } + // Fetch next key (if there is one) + if iterator.Valid() { + if !reverse { + pageResponse.NextKey = iterator.Key() + } + } else { + pageResponse.NextKey = nil + } + _ = iterator.Close() + + return data, &pageResponse, nil } -func (k Keeper) GetFinalizedBundleByHeight(ctx sdk.Context, poolId, height uint64) (val types.FinalizedBundle, found bool) { - proposalIndexStore := prefix.NewStore(ctx.KVStore(k.memKey), util.GetByteKey(types.FinalizedBundleByHeightPrefix, poolId)) - proposalIndexIterator := proposalIndexStore.ReverseIterator(nil, util.GetByteKey(height+1)) +func (k Keeper) GetFinalizedBundleByIndex(ctx sdk.Context, poolId, index uint64) (val queryTypes.FinalizedBundle, found bool) { + proposalIndexStore := prefix.NewStore(ctx.KVStore(k.memKey), util.GetByteKey(types.FinalizedBundleByIndexPrefix, poolId)) + proposalIndexIterator := proposalIndexStore.ReverseIterator(nil, util.GetByteKey(index+1)) defer proposalIndexIterator.Close() if proposalIndexIterator.Valid() { @@ -149,10 +250,33 @@ func (k Keeper) GetFinalizedBundleByHeight(ctx sdk.Context, poolId, height uint6 bundle, bundleFound := k.GetFinalizedBundle(ctx, poolId, bundleId) if bundleFound { - if bundle.FromIndex <= height && bundle.ToIndex > height { - return bundle, true + if bundle.FromIndex <= index && bundle.ToIndex > index { + versionMap := k.GetBundleVersionMap(ctx).GetMap() + return RawBundleToQueryBundle(bundle, versionMap), true } } } return } + +// Finalized Bundle Version Map + +// SetBundleVersionMap stores the bundle version map +func (k Keeper) SetBundleVersionMap(ctx sdk.Context, bundleVersionMap types.BundleVersionMap) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&bundleVersionMap) + store.Set(types.FinalizedBundleVersionMapKey, b) +} + +// GetBundleVersionMap returns the bundle version map +func (k Keeper) GetBundleVersionMap(ctx sdk.Context) (val types.BundleVersionMap) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.FinalizedBundleVersionMapKey) + if b == nil { + val.Versions = make([]*types.BundleVersionEntry, 0) + return val + } + + k.cdc.MustUnmarshal(b, &val) + return val +} diff --git a/x/bundles/keeper/getters_round_robin.go b/x/bundles/keeper/getters_round_robin.go new file mode 100644 index 00000000..a53e247b --- /dev/null +++ b/x/bundles/keeper/getters_round_robin.go @@ -0,0 +1,41 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/bundles/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetRoundRobinProgress stores the round-robin progress for a pool +func (k Keeper) SetRoundRobinProgress(ctx sdk.Context, roundRobinProgress types.RoundRobinProgress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RoundRobinProgressPrefix) + b := k.cdc.MustMarshal(&roundRobinProgress) + store.Set(types.RoundRobinProgressKey(roundRobinProgress.PoolId), b) +} + +// GetRoundRobinProgress returns the round-robin progress for a pool +func (k Keeper) GetRoundRobinProgress(ctx sdk.Context, poolId uint64) (val types.RoundRobinProgress, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RoundRobinProgressPrefix) + + b := store.Get(types.RoundRobinProgressKey(poolId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetAllRoundRobinProgress returns the round-robin progress of all pools +func (k Keeper) GetAllRoundRobinProgress(ctx sdk.Context) (list []types.RoundRobinProgress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RoundRobinProgressPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + for ; iterator.Valid(); iterator.Next() { + var val types.RoundRobinProgress + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/bundles/keeper/keeper_suite_dropped_bundles_test.go b/x/bundles/keeper/keeper_suite_dropped_bundles_test.go index 63c34752..f59064dd 100644 --- a/x/bundles/keeper/keeper_suite_dropped_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_dropped_bundles_test.go @@ -138,7 +138,7 @@ var _ = Describe("dropped bundles", Ordered, func() { Expect(bundleProposal.PoolId).To(Equal(uint64(0))) Expect(bundleProposal.StorageId).To(BeEmpty()) Expect(bundleProposal.Uploader).To(BeEmpty()) - Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_1)) + Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) Expect(bundleProposal.DataSize).To(BeZero()) Expect(bundleProposal.DataHash).To(BeEmpty()) Expect(bundleProposal.BundleSize).To(BeZero()) diff --git a/x/bundles/keeper/keeper_suite_funding_bundles_test.go b/x/bundles/keeper/keeper_suite_funding_bundles_test.go index dbf2a30e..36f10c8a 100644 --- a/x/bundles/keeper/keeper_suite_funding_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_funding_bundles_test.go @@ -18,9 +18,10 @@ TEST CASES - funding bundles * Produce a valid bundle with multiple funders and same funding amounts * Produce a valid bundle with multiple funders and different funding amounts * Produce a valid bundle with multiple funders and different funding amounts where not everyone can afford the funds -* Produce a dropped bundle because the only funder can not pay for the bundle reward -* Produce a dropped bundle because multiple funders with same amount can not pay for the bundle reward -* Produce a dropped bundle because multiple funders with different amount can not pay for the bundle reward +* Produce a valid bundle although the only funder can not pay for the bundle reward +* Produce a valid bundle although multiple funders with same amount can not pay for the bundle reward +* Produce a valid bundle although multiple funders with different amount can not pay for the bundle reward +* Produce a valid bundle although there are no funders at all */ @@ -115,9 +116,11 @@ var _ = Describe("funding bundles", Ordered, func() { // ASSERT pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + totalReward := pool.OperatingCost // assert total pool funds Expect(pool.TotalFunds).To(Equal(100*i.KYVE - totalReward)) @@ -187,9 +190,11 @@ var _ = Describe("funding bundles", Ordered, func() { // ASSERT pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + totalReward := pool.OperatingCost // assert total pool funds Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalReward)) @@ -266,9 +271,11 @@ var _ = Describe("funding bundles", Ordered, func() { // ASSERT pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + totalReward := pool.OperatingCost // assert total pool funds Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalReward)) @@ -345,18 +352,17 @@ var _ = Describe("funding bundles", Ordered, func() { // ASSERT pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + totalReward := pool.OperatingCost // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - totalReward)) + Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (totalReward / 2))) Expect(pool.Funders).To(HaveLen(1)) - // assert individual funds - fundersCharge := uint64(sdk.NewDec(int64(totalReward)).TruncateInt64()) - - Expect(pool.GetFunderAmount(i.BOB)).To(Equal(100*i.KYVE - fundersCharge)) + Expect(pool.GetFunderAmount(i.BOB)).To(Equal(100*i.KYVE - (totalReward / 2))) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) @@ -366,7 +372,7 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(balanceBob).To(Equal(initialBalanceBob - 100*i.KYVE)) }) - It("Produce a dropped bundle because the only funder can not pay for the bundle reward", func() { + It("Produce a valid bundle although the only funder can not pay for the bundle reward", func() { // ARRANGE s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ Creator: i.ALICE, @@ -414,44 +420,11 @@ var _ = Describe("funding bundles", Ordered, func() { }) // ASSERT - // check if bundle got not finalized on pool - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - - Expect(pool.CurrentKey).To(Equal("")) - Expect(pool.CurrentSummary).To(BeEmpty()) - Expect(pool.CurrentIndex).To(BeZero()) - Expect(pool.TotalBundles).To(BeZero()) - - // check if finalized bundle exists - _, finalizedBundleFound := s.App().BundlesKeeper.GetFinalizedBundle(s.Ctx(), 0, 0) - Expect(finalizedBundleFound).To(BeFalse()) - - // check if bundle proposal got dropped - bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - Expect(bundleProposalFound).To(BeTrue()) - - Expect(bundleProposal.PoolId).To(Equal(uint64(0))) - Expect(bundleProposal.StorageId).To(Equal("y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI")) - Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.DataSize).To(Equal(uint64(100))) - Expect(bundleProposal.DataHash).To(Equal("test_hash")) - Expect(bundleProposal.BundleSize).To(Equal(uint64(100))) - Expect(bundleProposal.FromKey).To(Equal("0")) - Expect(bundleProposal.ToKey).To(Equal("99")) - Expect(bundleProposal.BundleSummary).To(Equal("test_value")) - Expect(bundleProposal.UpdatedAt).NotTo(BeZero()) - Expect(bundleProposal.VotersValid).To(ContainElement(i.STAKER_0)) - Expect(bundleProposal.VotersInvalid).To(BeEmpty()) - Expect(bundleProposal.VotersAbstain).To(BeEmpty()) - - // check uploader status - valaccountUploader, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_0) - Expect(valaccountUploader.Points).To(BeZero()) - - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) // assert total pool funds Expect(pool.TotalFunds).To(BeZero()) @@ -462,7 +435,7 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(balanceAlice).To(Equal(initialBalanceAlice - 10)) }) - It("Produce a dropped bundle because multiple funders with same amount can not pay for the bundle reward", func() { + It("Produce a valid bundle although multiple funders with same amount can not pay for the bundle reward", func() { // ARRANGE s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ Creator: i.ALICE, @@ -516,44 +489,11 @@ var _ = Describe("funding bundles", Ordered, func() { }) // ASSERT - // check if bundle got not finalized on pool - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - - Expect(pool.CurrentKey).To(Equal("")) - Expect(pool.CurrentSummary).To(BeEmpty()) - Expect(pool.CurrentIndex).To(BeZero()) - Expect(pool.TotalBundles).To(BeZero()) - - // check if finalized bundle exists - _, finalizedBundleFound := s.App().BundlesKeeper.GetFinalizedBundle(s.Ctx(), 0, 0) - Expect(finalizedBundleFound).To(BeFalse()) - - // check if bundle proposal got dropped - bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - Expect(bundleProposalFound).To(BeTrue()) - - Expect(bundleProposal.PoolId).To(Equal(uint64(0))) - Expect(bundleProposal.StorageId).To(Equal("y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI")) - Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.DataSize).To(Equal(uint64(100))) - Expect(bundleProposal.DataHash).To(Equal("test_hash")) - Expect(bundleProposal.BundleSize).To(Equal(uint64(100))) - Expect(bundleProposal.FromKey).To(Equal("0")) - Expect(bundleProposal.ToKey).To(Equal("99")) - Expect(bundleProposal.BundleSummary).To(Equal("test_value")) - Expect(bundleProposal.UpdatedAt).NotTo(BeZero()) - Expect(bundleProposal.VotersValid).To(ContainElement(i.STAKER_0)) - Expect(bundleProposal.VotersInvalid).To(BeEmpty()) - Expect(bundleProposal.VotersAbstain).To(BeEmpty()) - - // check uploader status - valaccountUploader, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_0) - Expect(valaccountUploader.Points).To(BeZero()) - - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) // assert total pool funds Expect(pool.TotalFunds).To(BeZero()) @@ -621,44 +561,11 @@ var _ = Describe("funding bundles", Ordered, func() { }) // ASSERT - // check if bundle got not finalized on pool - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - - Expect(pool.CurrentKey).To(Equal("")) - Expect(pool.CurrentSummary).To(BeEmpty()) - Expect(pool.CurrentIndex).To(BeZero()) - Expect(pool.TotalBundles).To(BeZero()) - - // check if finalized bundle exists - _, finalizedBundleFound := s.App().BundlesKeeper.GetFinalizedBundle(s.Ctx(), 0, 0) - Expect(finalizedBundleFound).To(BeFalse()) - - // check if bundle proposal got dropped - bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - Expect(bundleProposalFound).To(BeTrue()) - - Expect(bundleProposal.PoolId).To(Equal(uint64(0))) - Expect(bundleProposal.StorageId).To(Equal("y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI")) - Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) - Expect(bundleProposal.DataSize).To(Equal(uint64(100))) - Expect(bundleProposal.DataHash).To(Equal("test_hash")) - Expect(bundleProposal.BundleSize).To(Equal(uint64(100))) - Expect(bundleProposal.FromKey).To(Equal("0")) - Expect(bundleProposal.ToKey).To(Equal("99")) - Expect(bundleProposal.BundleSummary).To(Equal("test_value")) - Expect(bundleProposal.UpdatedAt).NotTo(BeZero()) - Expect(bundleProposal.VotersValid).To(ContainElement(i.STAKER_0)) - Expect(bundleProposal.VotersInvalid).To(BeEmpty()) - Expect(bundleProposal.VotersAbstain).To(BeEmpty()) - - // check uploader status - valaccountUploader, _ := s.App().StakersKeeper.GetValaccount(s.Ctx(), 0, i.STAKER_0) - Expect(valaccountUploader.Points).To(BeZero()) - - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) // assert total pool funds Expect(pool.TotalFunds).To(BeZero()) @@ -671,4 +578,63 @@ var _ = Describe("funding bundles", Ordered, func() { balanceBob := s.GetBalanceFromAddress(i.BOB) Expect(balanceBob).To(Equal(initialBalanceBob - 20)) }) + + It("Produce a valid bundle although there are no funders at all", func() { + // ARRANGE + s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + }) + + s.CommitAfterSeconds(60) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + + s.CommitAfterSeconds(60) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) }) diff --git a/x/bundles/keeper/keeper_suite_inflation_splitting_test.go b/x/bundles/keeper/keeper_suite_inflation_splitting_test.go new file mode 100644 index 00000000..500aa90a --- /dev/null +++ b/x/bundles/keeper/keeper_suite_inflation_splitting_test.go @@ -0,0 +1,1166 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + stakertypes "github.com/KYVENetwork/chain/x/stakers/types" + sdk "github.com/cosmos/cosmos-sdk/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - inflation splitting + +* Produce a valid bundle with no funders and 0% inflation splitting +* Produce a valid bundle with no funders and 10% inflation splitting +* Produce a valid bundle with no funders and 100% inflation splitting + +* Produce a valid bundle with sufficient funders and 0% inflation splitting +* Produce a valid bundle with sufficient funders and 10% inflation splitting +* Produce a valid bundle with sufficient funders and 100% inflation splitting + +* Produce a valid bundle with insufficient funders and 0% inflation splitting +* Produce a valid bundle with insufficient funders and 10% inflation splitting +* Produce a valid bundle with insufficient funders and 100% inflation splitting + +* Produce a valid bundle with some insufficient funders and 0% inflation splitting +* Produce a valid bundle with some insufficient funders and 10% inflation splitting +* Produce a valid bundle with some insufficient funders and 100% inflation splitting + +*/ + +var _ = Describe("inflation splitting", Ordered, func() { + s := i.NewCleanChain() + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + + // create clean pool for every test case + s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ + Name: "PoolTest", + MaxBundleSize: 100, + StartKey: "0", + UploadInterval: 60, + OperatingCost: 10_000, + Protocol: &pooltypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &pooltypes.UpgradePlan{}, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.STAKER_0, + PoolId: 0, + Valaddress: i.VALADDRESS_0, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + }) + + s.CommitAfterSeconds(60) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Produce a valid bundle with no funders and 0% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // assert commission rewards + Expect(uploader.CommissionRewards).To(BeZero()) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with no funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is here just the inflation payout + totalPayout := payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with no funders and 100% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.2"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is here just the inflation payout + totalPayout := payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with sufficient funders and 0% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost because the funding is sufficient + // and there is no additional inflation + totalPayout := pool.OperatingCost + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalPayout)) + Expect(pool.Funders).To(HaveLen(2)) + }) + + It("Produce a valid bundle with sufficient funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.3"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := pool.OperatingCost + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(200*i.KYVE - pool.OperatingCost)) + Expect(pool.Funders).To(HaveLen(2)) + }) + + It("Produce a valid bundle with sufficient funders and 100% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := pool.OperatingCost + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(200*i.KYVE - pool.OperatingCost)) + Expect(pool.Funders).To(HaveLen(2)) + }) + + It("Produce a valid bundle with insufficient funders and 0% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the total funds + totalPayout := uint64(300) + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with insufficient funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.3"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := 300 + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with insufficient funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := 300 + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(BeZero()) + Expect(pool.Funders).To(BeEmpty()) + }) + + It("Produce a valid bundle with some insufficient funders and 0% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeZero()) + Expect(b2).To(BeZero()) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the total funds + totalPayout := (pool.OperatingCost / 2) + 200 + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) + Expect(pool.Funders).To(HaveLen(1)) + }) + + It("Produce a valid bundle with some insufficient funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.3"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := (pool.OperatingCost / 2) + 200 + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) + Expect(pool.Funders).To(HaveLen(1)) + }) + + It("Produce a valid bundle with some insufficient funders and 10% inflation splitting", func() { + // ARRANGE + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), + }) + + // mine some blocks + for i := 1; i < 100; i++ { + s.Commit() + } + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.BOB, + Id: 0, + Amount: 200, + }) + + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "y62A3tfbSNcNYDGoL-eXwzyV-Zc9Q0OVtDvR1biJmNI", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 0, + BundleSize: 100, + FromKey: "0", + ToKey: "99", + BundleSummary: "test_value", + }) + + s.CommitAfterSeconds(60) + + b1 := s.GetBalanceFromPool(0) + + // ACT + s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + StorageId: "P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg", + DataSize: 100, + DataHash: "test_hash2", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value2", + }) + + // ASSERT + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + // assert if bundle go finalized + Expect(pool.TotalBundles).To(Equal(uint64(1))) + Expect(pool.CurrentKey).To(Equal("99")) + + // assert pool balance + b2 := s.GetBalanceFromPool(0) + Expect(b1).To(BeNumerically(">", b2)) + + payout := uint64(sdk.NewDec(int64(b1)).Mul(s.App().PoolKeeper.GetPoolInflationPayoutRate(s.Ctx())).TruncateInt64()) + Expect(b1 - b2).To(Equal(payout)) + + // assert bundle reward + uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) + + // the total payout is the operating cost plus the inflation payout + totalPayout := (pool.OperatingCost / 2) + 200 + payout + + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := totalPayout - treasuryReward - storageReward + + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + + // assert commission rewards + Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) + // assert uploader self delegation rewards + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + + // assert total pool funds + Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) + Expect(pool.Funders).To(HaveLen(1)) + }) +}) diff --git a/x/bundles/keeper/keeper_suite_stakers_leave_test.go b/x/bundles/keeper/keeper_suite_stakers_leave_test.go index 5791f928..6250d77f 100644 --- a/x/bundles/keeper/keeper_suite_stakers_leave_test.go +++ b/x/bundles/keeper/keeper_suite_stakers_leave_test.go @@ -217,12 +217,11 @@ var _ = Describe("stakers leave", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) balanceUploader := s.GetBalanceFromAddress(i.STAKER_0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward diff --git a/x/bundles/keeper/keeper_suite_valid_bundles_test.go b/x/bundles/keeper/keeper_suite_valid_bundles_test.go index 72683919..007f40ca 100644 --- a/x/bundles/keeper/keeper_suite_valid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_valid_bundles_test.go @@ -147,6 +147,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(100 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(100 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -178,12 +180,10 @@ var _ = Describe("valid bundles", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), valaccountUploader.Staker) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -199,7 +199,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with one validator and foreign delegations", func() { @@ -265,6 +265,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(400 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -296,12 +298,10 @@ var _ = Describe("valid bundles", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), valaccountUploader.Staker) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -323,7 +323,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with multiple validators and no foreign delegations", func() { @@ -405,6 +405,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(200 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(200 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -413,7 +415,6 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(bundleProposal.PoolId).To(Equal(uint64(0))) Expect(bundleProposal.StorageId).To(Equal("P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg")) Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - // TODO(postAudit,@troy): how to get next uploader deterministically? Expect(bundleProposal.NextUploader).NotTo(BeEmpty()) Expect(bundleProposal.DataSize).To(Equal(uint64(100))) Expect(bundleProposal.DataHash).To(Equal("test_hash2")) @@ -447,12 +448,11 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -468,7 +468,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with one validator and foreign delegations", func() { @@ -562,6 +562,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(700 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -570,7 +572,6 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(bundleProposal.PoolId).To(Equal(uint64(0))) Expect(bundleProposal.StorageId).To(Equal("P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg")) Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - // TODO(postAudit,@troy): how to get next uploader deterministically? Expect(bundleProposal.NextUploader).NotTo(BeEmpty()) Expect(bundleProposal.DataSize).To(Equal(uint64(100))) Expect(bundleProposal.DataHash).To(Equal("test_hash2")) @@ -604,12 +605,10 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -641,7 +640,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some did not vote at all", func() { @@ -727,6 +726,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -768,12 +769,11 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -798,7 +798,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some voted abstain", func() { @@ -892,6 +892,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -933,12 +935,11 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -963,7 +964,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some voted invalid", func() { @@ -1057,6 +1058,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -1108,12 +1111,11 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -1138,6 +1140,6 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) }) diff --git a/x/bundles/keeper/keeper_suite_zero_delegation_test.go b/x/bundles/keeper/keeper_suite_zero_delegation_test.go index e2a60931..79504765 100644 --- a/x/bundles/keeper/keeper_suite_zero_delegation_test.go +++ b/x/bundles/keeper/keeper_suite_zero_delegation_test.go @@ -23,7 +23,7 @@ TEST CASES - zero delegation */ -var _ = Describe("valid bundles", Ordered, func() { +var _ = Describe("zero delegation", Ordered, func() { s := i.NewCleanChain() initialBalanceStaker0 := s.GetBalanceFromAddress(i.STAKER_0) @@ -384,18 +384,17 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) // calculate uploader rewards - totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := totalReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) // assert payout transfer Expect(balanceUploader).To(Equal(initialBalanceStaker0)) // assert commission rewards - Expect(uploader.CommissionRewards).To(Equal(totalUploaderReward)) + Expect(uploader.CommissionRewards).To(Equal(totalUploaderReward + storageReward)) // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) @@ -403,7 +402,7 @@ var _ = Describe("valid bundles", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - totalReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Staker receives upload slash with zero delegation", func() { diff --git a/x/bundles/keeper/logic_bundles.go b/x/bundles/keeper/logic_bundles.go index f513408f..f29812c4 100644 --- a/x/bundles/keeper/logic_bundles.go +++ b/x/bundles/keeper/logic_bundles.go @@ -1,9 +1,6 @@ package keeper import ( - "math/rand" - "sort" - "cosmossdk.io/errors" delegationTypes "github.com/KYVENetwork/chain/x/delegation/types" @@ -31,11 +28,6 @@ func (k Keeper) AssertPoolCanRun(ctx sdk.Context, poolId uint64) error { return types.ErrPoolDisabled } - // Error if the pool has no funds. - if len(pool.Funders) == 0 { - return types.ErrPoolOutOfFunds - } - // Error if min delegation is not reached if k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id) < pool.MinDelegation { return types.ErrMinDelegationNotReached @@ -220,46 +212,54 @@ func (k Keeper) handleNonVoters(ctx sdk.Context, poolId uint64) { } } -// calculatePayouts deducts the network fee from the rewards and splits the remaining amount -// between the staker and its delegators. If there are no delegators, the entire amount is -// awarded to the staker. -func (k Keeper) calculatePayouts(ctx sdk.Context, poolId uint64) (bundleReward types.BundleReward) { - pool, _ := k.poolKeeper.GetPoolWithError(ctx, poolId) +// calculatePayouts calculates the different payouts to treasury, uploader and delegators from the total payout +// the pool module provides for this bundle round +func (k Keeper) calculatePayouts(ctx sdk.Context, poolId uint64, totalPayout uint64) (bundleReward types.BundleReward) { + // This method first subtracts the network fee from it + // After that the uploader receives the storage rewards. If the total payout does not cover the + // storage rewards we pay out the remains, the commission and delegation rewards will be empty + // in this case. After the payout of the storage rewards the remains are divided between uploader + // and its delegators based on the commission. bundleProposal, _ := k.GetBundleProposal(ctx, poolId) - // Should not happen, if so move everything to the treasury + // Should not happen, if so make no payouts if !k.stakerKeeper.DoesStakerExist(ctx, bundleProposal.Uploader) { - bundleReward.Treasury = bundleReward.Total - return } - operatingReward := pool.OperatingCost - storageReward := uint64(k.GetStorageCost(ctx).MulInt64(int64(bundleProposal.DataSize)).TruncateInt64()) + bundleReward.Total = totalPayout - // formula for calculating the rewards - bundleReward.Total = operatingReward + storageReward + // calculate share of treasury from total payout + bundleReward.Treasury = uint64(sdk.NewDec(int64(totalPayout)).Mul(k.GetNetworkFee(ctx)).TruncateInt64()) + + // calculate wanted storage reward the uploader should receive + storageReward := uint64(k.GetStorageCost(ctx).MulInt64(int64(bundleProposal.DataSize)).TruncateInt64()) - // Add fee to treasury - bundleReward.Treasury = uint64(sdk.NewDec(int64(operatingReward)).Mul(k.GetNetworkFee(ctx)).TruncateInt64()) + // if not even the full storage reward can not be paid out we pay out the remains. + // in this case the uploader will not earn the commission rewards and delegators not + // their delegation rewards because total payout is not high enough + if totalPayout-bundleReward.Treasury < storageReward { + bundleReward.Uploader = totalPayout - bundleReward.Treasury + return + } else { + bundleReward.Uploader = storageReward + } - // Remaining rewards to be split between staker and its delegators - totalNodeReward := operatingReward - bundleReward.Treasury + // remaining rewards to be split between uploader and its delegators + totalNodeReward := totalPayout - bundleReward.Treasury - bundleReward.Uploader - // Payout delegators + // payout delegators if k.delegationKeeper.GetDelegationAmount(ctx, bundleProposal.Uploader) > 0 { commission := k.stakerKeeper.GetCommission(ctx, bundleProposal.Uploader) + commissionRewards := uint64(sdk.NewDec(int64(totalNodeReward)).Mul(commission).TruncateInt64()) - bundleReward.Uploader = uint64(sdk.NewDec(int64(totalNodeReward)).Mul(commission).TruncateInt64()) - bundleReward.Delegation = totalNodeReward - bundleReward.Uploader + bundleReward.Uploader += commissionRewards + bundleReward.Delegation = totalNodeReward - commissionRewards } else { - bundleReward.Uploader = totalNodeReward + bundleReward.Uploader += totalNodeReward bundleReward.Delegation = 0 } - // the uploader always receives the full storage reward since the uploader paid for storage - bundleReward.Uploader += storageReward - return } @@ -317,7 +317,7 @@ func (k Keeper) registerBundleProposalFromUploader(ctx sdk.Context, msg *types.M // finalizeCurrentBundleProposal takes the data of the current evaluated proposal // and stores it as a finalized proposal. This only happens if the network // reached quorum on the proposal's validity. -func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, voteDistribution types.VoteDistribution, bundleReward types.BundleReward, nextUploader string) { +func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, voteDistribution types.VoteDistribution, fundersPayout uint64, inflationPayout uint64, bundleReward types.BundleReward, nextUploader string) { pool, _ := k.poolKeeper.GetPool(ctx, poolId) bundleProposal, _ := k.GetBundleProposal(ctx, poolId) @@ -340,6 +340,10 @@ func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, vo DataHash: bundleProposal.DataHash, StorageProviderId: bundleProposal.StorageProviderId, CompressionId: bundleProposal.CompressionId, + StakeSecurity: &types.StakeSecurity{ + ValidVotePower: voteDistribution.Valid, + TotalVotePower: voteDistribution.Total, + }, } k.SetFinalizedBundle(ctx, finalizedBundle) @@ -352,6 +356,8 @@ func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, vo Abstain: voteDistribution.Abstain, Total: voteDistribution.Total, Status: voteDistribution.Status, + FundersPayout: fundersPayout, + InflationPayout: inflationPayout, RewardTreasury: bundleReward.Treasury, RewardUploader: bundleReward.Uploader, RewardDelegation: bundleReward.Delegation, @@ -369,12 +375,7 @@ func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, vo // a required quorum on the validity of the data. When the proposal is dropped // the same next uploader as before can submit his proposal since it is not his // fault, that the last one did not reach any quorum. -func (k Keeper) dropCurrentBundleProposal( - ctx sdk.Context, - poolId uint64, - voteDistribution types.VoteDistribution, - nextUploader string, -) { +func (k Keeper) dropCurrentBundleProposal(ctx sdk.Context, poolId uint64, voteDistribution types.VoteDistribution, nextUploader string) { pool, _ := k.poolKeeper.GetPool(ctx, poolId) bundleProposal, _ := k.GetBundleProposal(ctx, poolId) @@ -412,82 +413,35 @@ func (k Keeper) calculateVotingPower(delegation uint64) (votingPower uint64) { return } -// RandomChoiceCandidate holds the voting power of a candidate for the -// next uploader selection -type RandomChoiceCandidate struct { - Account string - VotingPower uint64 -} - -// getWeightedRandomChoice is an internal function that returns a weighted random -// selection out of a list of candidates based on their voting power. -func (k Keeper) getWeightedRandomChoice(candidates []RandomChoiceCandidate, seed int64) string { - type WeightedRandomChoice struct { - Elements []string - Weights []uint64 - TotalWeight uint64 - } - - wrc := WeightedRandomChoice{} - - for _, candidate := range candidates { - i := sort.Search(len(wrc.Weights), func(i int) bool { return wrc.Weights[i] > candidate.VotingPower }) - wrc.Weights = append(wrc.Weights, 0) - wrc.Elements = append(wrc.Elements, "") - copy(wrc.Weights[i+1:], wrc.Weights[i:]) - copy(wrc.Elements[i+1:], wrc.Elements[i:]) - wrc.Weights[i] = candidate.VotingPower - wrc.Elements[i] = candidate.Account - wrc.TotalWeight += candidate.VotingPower - } - - if wrc.TotalWeight == 0 { - return "" - } - - value := rand.New(rand.NewSource(seed)).Uint64() % wrc.TotalWeight - - for key, weight := range wrc.Weights { - if weight > value { - return wrc.Elements[key] - } - - value -= weight - } - - return "" +// chooseNextUploader selects the next uploader based on a fixed set of stakers in a pool. +// It is guaranteed that someone is chosen deterministically if the round-robin set itself is not empty. +func (k Keeper) chooseNextUploader(ctx sdk.Context, poolId uint64, excluded ...string) (nextUploader string) { + vs := k.LoadRoundRobinValidatorSet(ctx, poolId) + nextUploader = vs.NextProposer(excluded...) + k.SaveRoundRobinValidatorSet(ctx, vs) + return } -// chooseNextUploaderFromSelectedStakers selects the next uploader based on a -// fixed set of stakers in a pool. It is guaranteed that someone is chosen -// deterministically -func (k Keeper) chooseNextUploaderFromSelectedStakers(ctx sdk.Context, poolId uint64, addresses []string) (nextUploader string) { - var _candidates []RandomChoiceCandidate +// chooseNextUploader selects the next uploader based on a fixed set of stakers in a pool. +// It is guaranteed that someone is chosen deterministically if the round-robin set itself is not empty. +func (k Keeper) chooseNextUploaderFromList(ctx sdk.Context, poolId uint64, included []string) (nextUploader string) { + vs := k.LoadRoundRobinValidatorSet(ctx, poolId) - if len(addresses) == 0 { - return "" + // Calculate set difference to obtain excluded + includedMap := make(map[string]bool) + for _, entry := range included { + includedMap[entry] = true } - - for _, s := range addresses { - if k.stakerKeeper.DoesValaccountExist(ctx, poolId, s) { - delegation := k.delegationKeeper.GetDelegationAmount(ctx, s) - - _candidates = append(_candidates, RandomChoiceCandidate{ - Account: s, - VotingPower: k.calculateVotingPower(delegation), - }) + excluded := make([]string, 0) + for _, entry := range vs.Validators { + if !includedMap[entry.Address] { + excluded = append(excluded, entry.Address) } } - return k.getWeightedRandomChoice(_candidates, ctx.BlockHeader().Height) -} - -// chooseNextUploaderFromAllStakers selects the next uploader based on all -// stakers in a pool. It is guaranteed that someone is chosen -// deterministically -func (k Keeper) chooseNextUploaderFromAllStakers(ctx sdk.Context, poolId uint64) (nextUploader string) { - stakers := k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, poolId) - return k.chooseNextUploaderFromSelectedStakers(ctx, poolId, stakers) + nextUploader = vs.NextProposer(excluded...) + k.SaveRoundRobinValidatorSet(ctx, vs) + return } // GetVoteDistribution is an internal function evaluates the quorum status diff --git a/x/bundles/keeper/logic_bundles_test.go b/x/bundles/keeper/logic_bundles_test.go index 5cfa9b49..a4c4a98a 100644 --- a/x/bundles/keeper/logic_bundles_test.go +++ b/x/bundles/keeper/logic_bundles_test.go @@ -15,9 +15,9 @@ TEST CASES - logic_bundles.go * Assert pool can run while pool is upgrading * Assert pool can run while pool is disabled -* Assert pool can run while pool has no funds * Assert pool can run while min delegation is not reached * Assert pool can run +* Assert pool can run while pool has no funds * Assert can vote if sender is no staker * Assert can vote if bundle is dropped @@ -129,7 +129,7 @@ var _ = Describe("logic_bundles.go", Ordered, func() { Expect(err).To(HaveOccurred()) }) - It("Assert pool can run while pool has no funds", func() { + It("Assert pool can run while min delegation is not reached", func() { // ASSERT s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ Name: "PoolTest", @@ -145,9 +145,15 @@ var _ = Describe("logic_bundles.go", Ordered, func() { UpgradePlan: &pooltypes.UpgradePlan{}, }) + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, - Amount: 100 * i.KYVE, + Amount: 99 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ @@ -164,7 +170,7 @@ var _ = Describe("logic_bundles.go", Ordered, func() { Expect(err).To(HaveOccurred()) }) - It("Assert pool can run while min delegation is not reached", func() { + It("Assert pool can run", func() { // ASSERT s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ Name: "PoolTest", @@ -188,7 +194,7 @@ var _ = Describe("logic_bundles.go", Ordered, func() { s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, - Amount: 99 * i.KYVE, + Amount: 100 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ @@ -202,10 +208,10 @@ var _ = Describe("logic_bundles.go", Ordered, func() { err := s.App().BundlesKeeper.AssertPoolCanRun(s.Ctx(), 0) // ASSERT - Expect(err).To(HaveOccurred()) + Expect(err).NotTo(HaveOccurred()) }) - It("Assert pool can run", func() { + It("Assert pool can run while pool has no funds", func() { // ASSERT s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ Name: "PoolTest", @@ -221,12 +227,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { UpgradePlan: &pooltypes.UpgradePlan{}, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, diff --git a/x/bundles/keeper/logic_end_block_handle_upload_timeout.go b/x/bundles/keeper/logic_end_block_handle_upload_timeout.go index ca5d1e3c..fe668431 100644 --- a/x/bundles/keeper/logic_end_block_handle_upload_timeout.go +++ b/x/bundles/keeper/logic_end_block_handle_upload_timeout.go @@ -54,7 +54,7 @@ func (k Keeper) HandleUploadTimeout(goCtx context.Context) { k.handleNonVoters(ctx, pool.Id) // Get next uploader from all pool stakers - nextUploader := k.chooseNextUploaderFromAllStakers(ctx, pool.Id) + nextUploader := k.chooseNextUploader(ctx, pool.Id) // If consensus wasn't reached, we drop the bundle and emit an event. k.dropCurrentBundleProposal(ctx, pool.Id, voteDistribution, nextUploader) @@ -76,7 +76,7 @@ func (k Keeper) HandleUploadTimeout(goCtx context.Context) { } // Update bundle proposal and choose next uploader - bundleProposal.NextUploader = k.chooseNextUploaderFromAllStakers(ctx, pool.Id) + bundleProposal.NextUploader = k.chooseNextUploader(ctx, pool.Id) bundleProposal.UpdatedAt = uint64(ctx.BlockTime().Unix()) k.SetBundleProposal(ctx, bundleProposal) diff --git a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go index db7104eb..d78ce528 100644 --- a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go +++ b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go @@ -15,10 +15,10 @@ import ( TEST CASES - logic_end_block_handle_upload_timeout.go +* Next uploader can stay although pool ran out of funds * First staker who joins gets automatically chosen as next uploader * Next uploader gets removed due to pool upgrading * Next uploader gets removed due to pool being disabled -* Next uploader gets removed due to pool having no funds * Next uploader gets removed due to pool not reaching min stake * Staker is next uploader of genesis bundle and upload interval and timeout does not pass * Staker is next uploader of genesis bundle and upload timeout does not pass but upload interval passes @@ -81,7 +81,20 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { s.PerformValidityChecks() }) - It("First staker who joins gets automatically chosen as next uploader", func() { + It("Next uploader can stay although pool ran out of funds", func() { + // ARRANGE + s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, + PoolId: 0, + }) + + s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + // ACT s.CommitAfterSeconds(1) @@ -98,31 +111,13 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.STAKER_0)).To(Equal(100 * i.KYVE)) }) - It("Next uploader gets removed due to pool upgrading", func() { - // ARRANGE - s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ - Creator: i.VALADDRESS_0, - Staker: i.STAKER_0, - PoolId: 0, - }) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - pool.UpgradePlan = &pooltypes.UpgradePlan{ - Version: "1.0.0", - Binaries: "{}", - ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), - Duration: 3600, - } - - s.App().PoolKeeper.SetPool(s.Ctx(), pool) - + It("First staker who joins gets automatically chosen as next uploader", func() { // ACT s.CommitAfterSeconds(1) // ASSERT bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - Expect(bundleProposal.NextUploader).To(BeEmpty()) + Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) Expect(bundleProposal.StorageId).To(BeEmpty()) poolStakers := s.App().StakersKeeper.GetAllStakerAddressesOfPool(s.Ctx(), 0) @@ -133,7 +128,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.STAKER_0)).To(Equal(100 * i.KYVE)) }) - It("Next uploader gets removed due to pool being disabled", func() { + It("Next uploader gets removed due to pool upgrading", func() { // ARRANGE s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ Creator: i.VALADDRESS_0, @@ -143,7 +138,12 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - pool.Disabled = true + pool.UpgradePlan = &pooltypes.UpgradePlan{ + Version: "1.0.0", + Binaries: "{}", + ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), + Duration: 3600, + } s.App().PoolKeeper.SetPool(s.Ctx(), pool) @@ -163,7 +163,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.STAKER_0)).To(Equal(100 * i.KYVE)) }) - It("Next uploader gets removed due to pool having no funds", func() { + It("Next uploader gets removed due to pool being disabled", func() { // ARRANGE s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ Creator: i.VALADDRESS_0, @@ -171,11 +171,11 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { PoolId: 0, }) - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + pool.Disabled = true + + s.App().PoolKeeper.SetPool(s.Ctx(), pool) // ACT s.CommitAfterSeconds(1) diff --git a/x/bundles/keeper/logic_round_robin.go b/x/bundles/keeper/logic_round_robin.go new file mode 100644 index 00000000..fa2c4601 --- /dev/null +++ b/x/bundles/keeper/logic_round_robin.go @@ -0,0 +1,259 @@ +package keeper + +import ( + "sort" + + "github.com/KYVENetwork/chain/x/bundles/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +/* + +Weighted Round Robin Uploader Selection + +This file implements all necessary logic for a weighted round-robin algorithm. An example introduction can be found +[here](https://learnblockchain.cn/docs/tendermint/spec/reactors/consensus/proposer-selection.html). + +Our implementation additionally has the option of temporarily skipping participants for single rounds. +They do not advance in the round-robin progress and can not be selected as an uploader. +The frequencies of uploader selection with respect to the excluded ones can be described as follows. + +Let $R$ denote the number of total rounds and $r$ the index of the current round. +Let $N$ denote the number of total validators and $n$ the index of the n-th validator. + +The stake (+ delegation) of each validator for each round is given by + $s(n, r)$ + +Then the total stake for round r is given by + $S(r) = \sum_{i=1}^N s(i, r)$ + +Ignoring the existing progress, the likeliness of being selected in the next round is given by + $p(n, r) = s(n, r) / S(r)$ + +Using this value one can obtain the frequencies for uploader selection over all rounds, which is + $P(n) = 1/R * \sum_{r=1}^R p(n, r)$ + +Except for rounding errors $P(n)$ is independent from $R$ if $p(n, r)$ is constant. +If validator $i$ is excluded for round $k$, this is denoted by $s(i, k) = 0$. So in general $S(r)$ is +dependent on validator exclusions and validators set changes. + +*/ + +// RoundRobinValidatorPower contains the total delegation of a protocol validator. It is used as a cache +// because the calculation of the total delegation needs to access the KV-Store and therefore +// consumes gas everytime it is called. +// This value is only stored for the current round and only lives inside the memory. +type RoundRobinValidatorPower struct { + Address string + Power int64 +} + +// RoundRobinValidatorSet is the in memory-object for working with the round-robin state +// It can not be stored to the KV-Store as the Go map iterator is non-deterministic. +// To obtain a deterministic state of the current state call GetRoundRobinProgress(). +type RoundRobinValidatorSet struct { + PoolId uint64 + Validators []RoundRobinValidatorPower + Progress map[string]int64 +} + +// LoadRoundRobinValidatorSet initialises a validator set for the given pool id. +// If available it fetches the current round-robin state. Then it iterates all current pool +// validators and initialises the set accordingly. +// If a validator left the pool, the progress will be ignored. +// If new validators joined the pool, their progress will -1.125 * total_pool_delegation. +// The -1 is necessary to put them at the end of the queue (as the queue is centered around zero). +// The additional -0.125 are added as a penalty factor. +func (k Keeper) LoadRoundRobinValidatorSet(ctx sdk.Context, poolId uint64) RoundRobinValidatorSet { + vs := RoundRobinValidatorSet{} + vs.PoolId = poolId + vs.Progress = make(map[string]int64, 0) + totalDelegation := int64(0) + // Used for calculating the set difference of active validators and existing round-robin set + newValidators := make(map[string]bool, 0) + // Add all current pool validators to the round-robin set + for _, address := range k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, poolId) { + delegation := k.delegationKeeper.GetDelegationAmount(ctx, address) + if delegation > 0 { + // If a validator has no delegation do not add to the round-robin set. Validator is basically non-existent. + vs.Validators = append(vs.Validators, RoundRobinValidatorPower{ + Address: address, + Power: int64(delegation), + }) + vs.Progress[address] = 0 + totalDelegation += int64(delegation) + newValidators[address] = true + } + } + + // Fetch stored progress + roundRobinProgress, _ := k.GetRoundRobinProgress(ctx, poolId) + for _, progress := range roundRobinProgress.ProgressList { + _, ok := vs.Progress[progress.Address] + // If the address is not found it means that the validator left the pool. + // Therefore, this entry can be ignored. + if ok { + vs.Progress[progress.Address] += progress.Progress + } + + // Progress already exists, validator can not be new. + newValidators[progress.Address] = false + } + + for newAddress, isNew := range newValidators { + if isNew { + // Put new validators at the end of the queue with an additional penalty factor. + vs.Progress[newAddress] = sdk.MustNewDecFromStr("-1.125").MulInt64(totalDelegation).TruncateInt64() + } + } + + vs.normalize() + return vs +} + +// SaveRoundRobinValidatorSet saves the current round-robin progress for the given poolId to the KV-Store +func (k Keeper) SaveRoundRobinValidatorSet(ctx sdk.Context, vs RoundRobinValidatorSet) { + roundRobinProgress := types.RoundRobinProgress{ + PoolId: vs.PoolId, + ProgressList: vs.GetRoundRobinProgress(), + } + k.SetRoundRobinProgress(ctx, roundRobinProgress) +} + +// GetRoundRobinProgress returns a deterministic (sorted) list of the current round-robin progress. +// Due to the fact that maps have no order in Go, we must introduce one by ourselves. +// This is done by sorting all entries by their addresses alphabetically. +func (vs *RoundRobinValidatorSet) GetRoundRobinProgress() []*types.RoundRobinSingleValidatorProgress { + // Convert map to list + result := make([]*types.RoundRobinSingleValidatorProgress, 0) + for address, progress := range vs.Progress { + singleProgress := types.RoundRobinSingleValidatorProgress{ + Address: address, + Progress: progress, + } + result = append(result, &singleProgress) + } + // Sort addresses alphabetically + sort.Slice( + result, func(i, j int) bool { + return result[i].Address < result[j].Address + }, + ) + return result +} + +// getTotalDelegation returns the total delegation power of the current set. +func (vs *RoundRobinValidatorSet) getTotalDelegation() (total int64) { + for _, vp := range vs.Validators { + total += vp.Power + } + return +} + +// getTotalDelegation returns the sum of all progresses of each validator. +// This value is supposed to always be zero. However, if new validators join or leave this +// value might no longer be 0. Have a look at normalize(). +func (vs *RoundRobinValidatorSet) getTotalProgress() (total int64) { + for _, vp := range vs.Progress { + total += vp + } + return +} + +// getMinMaxDifference returns the difference of progresses of the two validators with the +// most and least progress. +func (vs *RoundRobinValidatorSet) getMinMaxDifference() int64 { + if len(vs.Validators) == 0 { + return 0 + } + max := vs.Progress[vs.Validators[0].Address] + min := max + for _, p := range vs.Progress { + if p > max { + max = p + } + if p < min { + min = p + } + } + return max - min +} + +// size returns the number of participants in the current round-robin set. +func (vs *RoundRobinValidatorSet) size() int64 { + return int64(len(vs.Validators)) +} + +// normalize scales down the progress set to a maximum difference of 2 * total_delegation. +// This is necessary if validator join or leave the set, to adjust the existing progress. +// It then centers the entire progress around 0. +func (vs *RoundRobinValidatorSet) normalize() { + if vs.size() == 0 { + return + } + + diff := vs.getMinMaxDifference() + + totalProgress := vs.getTotalProgress() + threshold := 2 * vs.getTotalDelegation() + if diff > threshold { + + totalProgress = 0 + for _, val := range vs.Validators { + decProgress := sdk.NewDec(vs.Progress[val.Address]) + vs.Progress[val.Address] = decProgress.MulInt64(threshold).QuoInt64(diff).TruncateInt64() + totalProgress += vs.Progress[val.Address] + } + } + + // center priorities around zero and update + avg := sdk.NewDec(totalProgress).QuoInt64(vs.size()).TruncateInt64() + for key := range vs.Progress { + vs.Progress[key] -= avg + } +} + +// NextProposer advances the current round-robin state by one round, i.e. adjusting the progress +// of all (non-excluded) validators of the set. It then picks the top validator (if not excluded) +// and puts it to the end of the queue. This validator is the then returned as the "nextProposer". +// If the entire set is excluded then the algorithm proceeds as if nobody were excluded. +func (vs *RoundRobinValidatorSet) NextProposer(excludedAddresses ...string) string { + if vs.size() == 0 { + return "" + } + + vs.normalize() + + // If all addresses are excluded, then no address should be excluded + if len(excludedAddresses) == len(vs.Validators) { + excludedAddresses = make([]string, 0) + } + + mapExcludedAddresses := make(map[string]bool) + for _, excluded := range excludedAddresses { + mapExcludedAddresses[excluded] = true + } + + // update + excludedPower := int64(0) + for _, validator := range vs.Validators { + if !mapExcludedAddresses[validator.Address] { + vs.Progress[validator.Address] += validator.Power + } else { + excludedPower += validator.Power + } + } + + currentMaxValidator := vs.Validators[0].Address + for _, validator := range vs.Validators { + if !mapExcludedAddresses[validator.Address] { + if vs.Progress[validator.Address] > vs.Progress[currentMaxValidator] { + currentMaxValidator = validator.Address + } + } + } + + vs.Progress[currentMaxValidator] -= vs.getTotalDelegation() - excludedPower + + return currentMaxValidator +} diff --git a/x/bundles/keeper/logic_round_robin_test.go b/x/bundles/keeper/logic_round_robin_test.go new file mode 100644 index 00000000..8e9f95a6 --- /dev/null +++ b/x/bundles/keeper/logic_round_robin_test.go @@ -0,0 +1,396 @@ +package keeper_test + +import ( + "sort" + + i "github.com/KYVENetwork/chain/testutil/integration" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + stakertypes "github.com/KYVENetwork/chain/x/stakers/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - logic_bundles.go + +* Correctly load round-robin state +* Correctly save and load round-robin state +* Empty round-robin set +* Partially filled round-robin set (one staker with 0 delegation) +* Frequency analysis +* Frequency analysis (rounding) +* Frequency analysis (excluded) +* Exclude everybody +* Exclude all but one +* Leave set +* Join set + +*/ + +func joinDummy(s *i.KeeperTestSuite, index, kyveAmount uint64) { + s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ + Creator: i.DUMMY[index], + Amount: kyveAmount * i.KYVE, + }) + + s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ + Creator: i.DUMMY[index], + PoolId: 0, + Valaddress: i.VALDUMMY[index], + Amount: 0, + }) +} + +func leaveDummy(s *i.KeeperTestSuite, index uint64) { + s.RunTxStakersSuccess(&stakertypes.MsgLeavePool{ + Creator: i.DUMMY[index], + PoolId: 0, + }) + s.CommitAfterSeconds(s.App().StakersKeeper.GetLeavePoolTime(s.Ctx())) + s.CommitAfterSeconds(1) +} + +var _ = Describe("logic_round_robin.go", Ordered, func() { + s := i.NewCleanChain() + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + + // sort dummy accounts alphabetically + sort.Slice(i.DUMMY, func(k, j int) bool { + return i.DUMMY[k] < i.DUMMY[j] + }) + + s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ + Name: "PoolTest", + UploadInterval: 60, + OperatingCost: 2 * i.KYVE, + MinDelegation: 1_000_000 * i.KYVE, + MaxBundleSize: 100, + Protocol: &pooltypes.Protocol{ + Version: "0.0.0", + Binaries: "{}", + LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), + }, + UpgradePlan: &pooltypes.UpgradePlan{ + Version: "1.0.0", + Binaries: "{}", + ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), + Duration: 60, + }, + }) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Correctly load round-robin state", func() { + // ARRANGE + joinDummy(s, 0, 100) + joinDummy(s, 1, 200) + joinDummy(s, 2, 300) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + + // ASSERT + Expect(rrvs.Validators).To(HaveLen(3)) + Expect(rrvs.Validators[0].Address).To(Equal(i.DUMMY[0])) + Expect(rrvs.Validators[0].Power).To(Equal(100 * int64(i.KYVE))) + Expect(rrvs.Validators[1].Address).To(Equal(i.DUMMY[1])) + Expect(rrvs.Validators[1].Power).To(Equal(200 * int64(i.KYVE))) + Expect(rrvs.Validators[2].Address).To(Equal(i.DUMMY[2])) + Expect(rrvs.Validators[2].Power).To(Equal(300 * int64(i.KYVE))) + + Expect(rrvs.Progress).To(HaveLen(3)) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(int64(0))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(int64(0))) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(int64(0))) + }) + + It("Correctly save and load round-robin state", func() { + // ARRANGE + joinDummy(s, 0, 100) + joinDummy(s, 1, 200) + joinDummy(s, 2, 300) + + // ACT + rrvs1 := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + rrvs1.Progress[i.DUMMY[0]] = 1 + rrvs1.Progress[i.DUMMY[1]] = 2 + rrvs1.Progress[i.DUMMY[2]] = 3 + s.App().BundlesKeeper.SaveRoundRobinValidatorSet(s.Ctx(), rrvs1) + + state := rrvs1.GetRoundRobinProgress() + // loading round-robin performs normalising, which shifts values from 1,2,3 to -1,0,1 + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + + // ASSERT + Expect(state[0].Address).To(Equal(i.DUMMY[0])) + Expect(state[0].Progress).To(Equal(int64(1))) + Expect(state[1].Address).To(Equal(i.DUMMY[1])) + Expect(state[1].Progress).To(Equal(int64(2))) + Expect(state[2].Address).To(Equal(i.DUMMY[2])) + Expect(state[2].Progress).To(Equal(int64(3))) + + Expect(rrvs.Validators).To(HaveLen(3)) + Expect(rrvs.Validators[0].Address).To(Equal(i.DUMMY[0])) + Expect(rrvs.Validators[1].Address).To(Equal(i.DUMMY[1])) + Expect(rrvs.Validators[2].Address).To(Equal(i.DUMMY[2])) + + Expect(rrvs.Progress).To(HaveLen(3)) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(int64(-1))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(int64(0))) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(int64(1))) + }) + + It("Empty round-robin set", func() { + // ARRANGE + joinDummy(s, 0, 0) + joinDummy(s, 1, 0) + joinDummy(s, 2, 0) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + state := rrvs.GetRoundRobinProgress() + + nextProposer := rrvs.NextProposer() + + // ASSERT + Expect(rrvs.Validators).To(HaveLen(0)) + Expect(rrvs.Progress).To(HaveLen(0)) + + Expect(state).To(HaveLen(0)) + + Expect(nextProposer).To(BeEmpty()) + }) + + It("Partially filled round-robin set (one staker with 0 delegation)", func() { + // ARRANGE + joinDummy(s, 0, 0) + joinDummy(s, 1, 10) + joinDummy(s, 2, 5) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + state := rrvs.GetRoundRobinProgress() + + nextProposer := rrvs.NextProposer() + + // ASSERT + Expect(rrvs.Validators).To(HaveLen(2)) + Expect(rrvs.Progress).To(HaveLen(2)) + + Expect(state).To(HaveLen(2)) + + Expect(nextProposer).To(Equal(i.DUMMY[1])) + }) + + It("Frequency analysis", func() { + // ARRANGE + joinDummy(s, 0, 2) + joinDummy(s, 1, 31) + joinDummy(s, 2, 67) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + + frequency1 := make(map[string]int, 0) + for i := 0; i < 10; i++ { + frequency1[rrvs.NextProposer()] += 1 + } + + frequency2 := make(map[string]int, 0) + for i := 0; i < 100; i++ { + frequency2[rrvs.NextProposer()] += 1 + } + + frequency3 := make(map[string]int, 0) + for i := 0; i < 100000; i++ { + frequency3[rrvs.NextProposer()] += 1 + } + + // ASSERT + + Expect(frequency1[i.DUMMY[0]]).To(Equal(0)) + Expect(frequency1[i.DUMMY[1]]).To(Equal(3)) + Expect(frequency1[i.DUMMY[2]]).To(Equal(7)) + + Expect(frequency2[i.DUMMY[0]]).To(Equal(2)) + Expect(frequency2[i.DUMMY[1]]).To(Equal(31)) + Expect(frequency2[i.DUMMY[2]]).To(Equal(67)) + + Expect(frequency3[i.DUMMY[0]]).To(Equal(2000)) + Expect(frequency3[i.DUMMY[1]]).To(Equal(31000)) + Expect(frequency3[i.DUMMY[2]]).To(Equal(67000)) + }) + + It("Frequency analysis (rounding)", func() { + // ARRANGE + joinDummy(s, 0, 1) + joinDummy(s, 1, 1) + joinDummy(s, 2, 1) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + + frequency1 := make(map[string]int, 0) + for i := 0; i < 10; i++ { + frequency1[rrvs.NextProposer()] += 1 + } + + frequency2 := make(map[string]int, 0) + for i := 0; i < 100; i++ { + frequency2[rrvs.NextProposer()] += 1 + } + + frequency3 := make(map[string]int, 0) + for i := 0; i < 100000; i++ { + frequency3[rrvs.NextProposer()] += 1 + } + + // ASSERT + + // First one is selected one more time, because of alphabetical order + Expect(frequency1[i.DUMMY[0]]).To(Equal(4)) + Expect(frequency1[i.DUMMY[1]]).To(Equal(3)) + Expect(frequency1[i.DUMMY[2]]).To(Equal(3)) + + Expect(frequency2[i.DUMMY[0]]).To(Equal(33)) + // The state is not reset between rounds, the first one already got selected one more time in + // the previous round, hence its progress is already reset. Therefore, the second one is slected + // one more than the others. + Expect(frequency2[i.DUMMY[1]]).To(Equal(34)) + Expect(frequency2[i.DUMMY[2]]).To(Equal(33)) + + Expect(frequency3[i.DUMMY[0]]).To(Equal(33333)) + Expect(frequency3[i.DUMMY[1]]).To(Equal(33333)) + // Same argument as above + Expect(frequency3[i.DUMMY[2]]).To(Equal(33334)) + }) + + It("Frequency analysis (excluded)", func() { + // ARRANGE + joinDummy(s, 0, 5) + joinDummy(s, 1, 10) + joinDummy(s, 2, 15) + // total stake = 30 + // Do 1000 rounds, in the first 500 exclude Dummy0, in the second 500 exclude Dummy1 + // Frequencies for all three validators: + // P(0) = 1/1000 * (0 + 500 * 5/(5+15)) = 0.125 + // P(1) = 1/1000 * (500 * 10/(10+15) + 0) = 0.2 + // P(2) = 1/1000 * (500 * 15/(10+15) + 500 * 15/(5+15)) = 0.675 + // P(1) + P(2) + P(3) = 1 + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + + frequency := make(map[string]int, 0) + for j := 0; j < 500; j++ { + frequency[rrvs.NextProposer(i.DUMMY[0])] += 1 + } + for j := 0; j < 500; j++ { + frequency[rrvs.NextProposer(i.DUMMY[1])] += 1 + } + + // ASSERT + Expect(frequency[i.DUMMY[0]]).To(Equal(125)) + Expect(frequency[i.DUMMY[1]]).To(Equal(200)) + Expect(frequency[i.DUMMY[2]]).To(Equal(675)) + }) + + It("Exclude everybody", func() { + // ARRANGE + joinDummy(s, 0, 5) + joinDummy(s, 1, 10) + joinDummy(s, 2, 15) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + nextProposer := rrvs.NextProposer(i.DUMMY[0], i.DUMMY[1], i.DUMMY[2]) + + // ASSERT + Expect(nextProposer).To(Equal(i.DUMMY[2])) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(5 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(10 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(-15 * int64(i.KYVE))) + }) + + It("Exclude all but one", func() { + // ARRANGE + joinDummy(s, 0, 5) + joinDummy(s, 1, 10) + joinDummy(s, 2, 15) + + // ACT + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + nextProposer := rrvs.NextProposer(i.DUMMY[1], i.DUMMY[2]) + + // ASSERT + Expect(nextProposer).To(Equal(i.DUMMY[0])) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(0 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(0 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(0 * int64(i.KYVE))) + }) + + It("Leave set", func() { + // ARRANGE + joinDummy(s, 0, 1000) + joinDummy(s, 1, 1000) + joinDummy(s, 2, 1000) + joinDummy(s, 3, 1000) + joinDummy(s, 4, 1000) + + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + nextProposer := rrvs.NextProposer() + s.App().BundlesKeeper.SaveRoundRobinValidatorSet(s.Ctx(), rrvs) + Expect(nextProposer).To(Equal(i.DUMMY[0])) + leaveDummy(s, 2) + leaveDummy(s, 3) + leaveDummy(s, 4) + + // ACT, ASSERT + rrvs = s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(-2000 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(2000 * int64(i.KYVE))) + + nextProposer = rrvs.NextProposer() + Expect(nextProposer).To(Equal(i.DUMMY[1])) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(-1000 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(1000 * int64(i.KYVE))) + + nextProposer = rrvs.NextProposer() + Expect(nextProposer).To(Equal(i.DUMMY[1])) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(0 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(0 * int64(i.KYVE))) + }) + + It("Join set", func() { + // ARRANGE + joinDummy(s, 0, 100) + joinDummy(s, 1, 200) + joinDummy(s, 2, 300) + + rrvs := s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + nextProposer := rrvs.NextProposer() + Expect(nextProposer).To(Equal(i.DUMMY[2])) + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(100 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(200 * int64(i.KYVE))) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(-300 * int64(i.KYVE))) + s.App().BundlesKeeper.SaveRoundRobinValidatorSet(s.Ctx(), rrvs) + + // ACT + joinDummy(s, 3, 400) + rrvs = s.App().BundlesKeeper.LoadRoundRobinValidatorSet(s.Ctx(), 0) + shift := int64(1125_000_000_000 / 4) + + // Assert + Expect(rrvs.Progress[i.DUMMY[0]]).To(Equal(100*int64(i.KYVE) + shift)) + Expect(rrvs.Progress[i.DUMMY[1]]).To(Equal(200*int64(i.KYVE) + shift)) + Expect(rrvs.Progress[i.DUMMY[2]]).To(Equal(-300*int64(i.KYVE) + shift)) + Expect(rrvs.Progress[i.DUMMY[3]]).To(Equal(-1125*int64(i.KYVE) + shift)) + }) +}) diff --git a/x/bundles/keeper/msg_server_claim_uploader_role_test.go b/x/bundles/keeper/msg_server_claim_uploader_role_test.go index a2c96a92..eec9c553 100644 --- a/x/bundles/keeper/msg_server_claim_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_claim_uploader_role_test.go @@ -59,7 +59,7 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { }) // ACT - s.RunTxBundlesError(&bundletypes.MsgClaimUploaderRole{ + s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ Creator: i.VALADDRESS_0, Staker: i.STAKER_0, PoolId: 0, @@ -67,7 +67,7 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { // ASSERT _, found := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - Expect(found).To(BeFalse()) + Expect(found).To(BeTrue()) }) It("Try to claim uploader role without being a staker", func() { diff --git a/x/bundles/keeper/msg_server_skip_uploader_role.go b/x/bundles/keeper/msg_server_skip_uploader_role.go index de9a0db4..34bff46f 100644 --- a/x/bundles/keeper/msg_server_skip_uploader_role.go +++ b/x/bundles/keeper/msg_server_skip_uploader_role.go @@ -8,9 +8,7 @@ import ( ) // SkipUploaderRole handles the logic of an SDK message that allows protocol nodes to skip an upload. -func (k msgServer) SkipUploaderRole( - goCtx context.Context, msg *types.MsgSkipUploaderRole, -) (*types.MsgSkipUploaderRoleResponse, error) { +func (k msgServer) SkipUploaderRole(goCtx context.Context, msg *types.MsgSkipUploaderRole) (*types.MsgSkipUploaderRoleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.AssertCanPropose(ctx, msg.PoolId, msg.Staker, msg.Creator, msg.FromIndex); err != nil { @@ -23,22 +21,8 @@ func (k msgServer) SkipUploaderRole( // reset points of uploader as node has proven to be active k.resetPoints(ctx, msg.PoolId, msg.Staker) - // Get next uploader from stakers voted - stakers := make([]string, 0) - nextUploader := "" - - // exclude the staker who skips the uploader role - for _, staker := range k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, msg.PoolId) { - if staker != msg.Staker { - stakers = append(stakers, staker) - } - } - - if len(stakers) > 0 { - nextUploader = k.chooseNextUploaderFromSelectedStakers(ctx, msg.PoolId, stakers) - } else { - nextUploader = k.chooseNextUploaderFromAllStakers(ctx, msg.PoolId) - } + // Get next uploader, except the one who skipped + nextUploader := k.chooseNextUploader(ctx, msg.PoolId, msg.Staker) bundleProposal.NextUploader = nextUploader bundleProposal.UpdatedAt = uint64(ctx.BlockTime().Unix()) diff --git a/x/bundles/keeper/msg_server_skip_uploader_role_test.go b/x/bundles/keeper/msg_server_skip_uploader_role_test.go index d86e01c2..d06df361 100644 --- a/x/bundles/keeper/msg_server_skip_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_skip_uploader_role_test.go @@ -239,8 +239,8 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { // ACT s.RunTxBundlesSuccess(&bundletypes.MsgSkipUploaderRole{ - Creator: i.VALADDRESS_1, - Staker: i.STAKER_1, + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, PoolId: 0, FromIndex: 0, }) @@ -264,6 +264,6 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(bundleProposal.VotersAbstain).To(BeEmpty()) // here the next uploader should be always be different after skipping - Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) + Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_1)) }) }) diff --git a/x/bundles/keeper/msg_server_submit_bundle_proposal.go b/x/bundles/keeper/msg_server_submit_bundle_proposal.go index 5307fa36..4d95de09 100644 --- a/x/bundles/keeper/msg_server_submit_bundle_proposal.go +++ b/x/bundles/keeper/msg_server_submit_bundle_proposal.go @@ -11,14 +11,10 @@ import ( delegationTypes "github.com/KYVENetwork/chain/x/delegation/types" // Pool poolTypes "github.com/KYVENetwork/chain/x/pool/types" - // Stakers - stakersTypes "github.com/KYVENetwork/chain/x/stakers/types" ) // SubmitBundleProposal handles the logic of an SDK message that allows protocol nodes to submit a new bundle proposal. -func (k msgServer) SubmitBundleProposal( - goCtx context.Context, msg *types.MsgSubmitBundleProposal, -) (*types.MsgSubmitBundleProposalResponse, error) { +func (k msgServer) SubmitBundleProposal(goCtx context.Context, msg *types.MsgSubmitBundleProposal) (*types.MsgSubmitBundleProposalResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.AssertCanPropose(ctx, msg.PoolId, msg.Staker, msg.Creator, msg.FromIndex); err != nil { @@ -38,7 +34,7 @@ func (k msgServer) SubmitBundleProposal( // If previous bundle was dropped just register the new bundle. // No previous round needs to be evaluated if bundleProposal.StorageId == "" { - nextUploader := k.chooseNextUploaderFromAllStakers(ctx, msg.PoolId) + nextUploader := k.chooseNextUploader(ctx, msg.PoolId) k.registerBundleProposalFromUploader(ctx, msg, nextUploader) @@ -59,7 +55,8 @@ func (k msgServer) SubmitBundleProposal( case types.BUNDLE_STATUS_VALID: // If a bundle is valid the following things happen: - // 1. A reward is paid out to the uploader, its delegators and the treasury + // 1. Funders and Inflation Pool are charged. The total payout is divided + // between the uploader, its delegators and the treasury. // The appropriate funds are deducted from the total pool funds // 2. The next uploader is randomly selected based on everybody who // voted valid on this bundle. @@ -67,44 +64,35 @@ func (k msgServer) SubmitBundleProposal( // 4. The sender immediately starts the next round by registering // his new bundle proposal. - // Calculate the total reward for the bundle, and individual payouts. - bundleReward := k.calculatePayouts(ctx, msg.PoolId) - - if err := k.poolKeeper.ChargeFundersOfPool(ctx, msg.PoolId, bundleReward.Total); err != nil { - // update the latest time on bundle to indicate that the bundle is still active - // protocol nodes use this to determine the upload timeout - bundleProposal.UpdatedAt = uint64(ctx.BlockTime().Unix()) - k.SetBundleProposal(ctx, bundleProposal) - - // emit event which indicates that pool has run out of funds - _ = ctx.EventManager().EmitTypedEvent(&poolTypes.EventPoolOutOfFunds{ - PoolId: msg.PoolId, - }) + pool, _ := k.poolKeeper.GetPool(ctx, msg.PoolId) - return &types.MsgSubmitBundleProposalResponse{}, nil + // charge the operating cost from funders + fundersPayout, err := k.poolKeeper.ChargeFundersOfPool(ctx, msg.PoolId, pool.OperatingCost) + if err != nil { + return &types.MsgSubmitBundleProposalResponse{}, err } - pool, _ := k.poolKeeper.GetPool(ctx, msg.PoolId) - bundleProposal, _ := k.GetBundleProposal(ctx, msg.PoolId) + // charge the inflation pool + inflationPayout, err := k.poolKeeper.ChargeInflationPool(ctx, msg.PoolId) + if err != nil { + return &types.MsgSubmitBundleProposalResponse{}, err + } - uploaderPayout := bundleReward.Uploader + // calculate payouts to the different stakeholders like treasury, uploader and delegators + bundleReward := k.calculatePayouts(ctx, msg.PoolId, fundersPayout+inflationPayout) - delegationPayoutSuccessful := k.delegationKeeper.PayoutRewards(ctx, bundleProposal.Uploader, bundleReward.Delegation, poolTypes.ModuleName) - // If staker has no delegators add all delegation rewards to the staker rewards - if !delegationPayoutSuccessful { - uploaderPayout += bundleReward.Delegation + // payout rewards to treasury + if err := util.TransferFromModuleToTreasury(k.accountKeeper, k.distrkeeper, ctx, poolTypes.ModuleName, bundleReward.Treasury); err != nil { + return nil, err } - // transfer funds from pool to stakers module - if err := util.TransferFromModuleToModule(k.bankKeeper, ctx, poolTypes.ModuleName, stakersTypes.ModuleName, uploaderPayout); err != nil { + // payout rewards to uploader through commission rewards + if err := k.stakerKeeper.IncreaseStakerCommissionRewards(ctx, bundleProposal.Uploader, bundleReward.Uploader); err != nil { return nil, err } - // increase commission rewards of uploader - k.stakerKeeper.IncreaseStakerCommissionRewards(ctx, bundleProposal.Uploader, uploaderPayout) - - // send network fee to treasury - if err := util.TransferFromModuleToTreasury(k.accountKeeper, k.distrkeeper, ctx, poolTypes.ModuleName, bundleReward.Treasury); err != nil { + // payout rewards to delegators through delegation rewards + if err := k.delegationKeeper.PayoutRewards(ctx, bundleProposal.Uploader, bundleReward.Delegation, poolTypes.ModuleName); err != nil { return nil, err } @@ -115,28 +103,15 @@ func (k msgServer) SubmitBundleProposal( // Determine next uploader and register next bundle - // Get next uploader from stakers who voted `valid` and are still active - activeVoters := make([]string, 0) - nextUploader := "" - for _, voter := range bundleProposal.VotersValid { - if k.stakerKeeper.DoesValaccountExist(ctx, msg.PoolId, voter) { - activeVoters = append(activeVoters, voter) - } - } + // Get next uploader from stakers who voted `valid` + nextUploader := k.chooseNextUploaderFromList(ctx, msg.PoolId, bundleProposal.VotersValid) - if len(activeVoters) > 0 { - nextUploader = k.chooseNextUploaderFromSelectedStakers(ctx, msg.PoolId, activeVoters) - } else { - nextUploader = k.chooseNextUploaderFromAllStakers(ctx, msg.PoolId) - } - - k.finalizeCurrentBundleProposal(ctx, pool.Id, voteDistribution, bundleReward, nextUploader) + k.finalizeCurrentBundleProposal(ctx, pool.Id, voteDistribution, fundersPayout, inflationPayout, bundleReward, nextUploader) // Register the provided bundle as a new proposal for the next round k.registerBundleProposalFromUploader(ctx, msg, nextUploader) return &types.MsgSubmitBundleProposalResponse{}, nil - case types.BUNDLE_STATUS_INVALID: // If the bundles is invalid, everybody who voted incorrectly gets slashed. // The bundle provided by the message-sender is of no mean, because the previous bundle diff --git a/x/bundles/module.go b/x/bundles/module.go index 44ad2893..451a8dde 100644 --- a/x/bundles/module.go +++ b/x/bundles/module.go @@ -4,6 +4,14 @@ import ( "context" "encoding/json" "fmt" + + poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper" + teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" + bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + distributionKeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + // this line is used by starport scaffolding # 1 "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -91,22 +99,37 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper bankKeeper.Keeper + distributionKeeper distributionKeeper.Keeper + mintKeeper mintKeeper.Keeper + upgradeKeeper upgradeKeeper.Keeper + poolKeeper poolKeeper.Keeper + teamKeeper teamKeeper.Keeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, + bankKeeper bankKeeper.Keeper, + distributionKeeper distributionKeeper.Keeper, + mintKeeper mintKeeper.Keeper, + upgradeKeeper upgradeKeeper.Keeper, + poolKeeper poolKeeper.Keeper, + teamKeeper teamKeeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + distributionKeeper: distributionKeeper, + mintKeeper: mintKeeper, + upgradeKeeper: upgradeKeeper, + poolKeeper: poolKeeper, + teamKeeper: teamKeeper, } } @@ -145,6 +168,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { am.keeper.InitMemStore(ctx) + SplitInflation(ctx, am.keeper, am.bankKeeper, am.mintKeeper, am.poolKeeper, am.teamKeeper, am.upgradeKeeper) } // EndBlock contains the logic that is automatically triggered at the end of each block diff --git a/x/bundles/spec/02_state.md b/x/bundles/spec/02_state.md index 2bebce16..ed36278a 100644 --- a/x/bundles/spec/02_state.md +++ b/x/bundles/spec/02_state.md @@ -59,9 +59,57 @@ type FinalizedBundle struct { ToKey string BundleSummary string DataHash string - FinalizedAt uint64 + FinalizedAt { + Height uint64 + Timestamp uint64 + } FromKey string StorageProviderId uint32 CompressionId uint32 + StakeSecurity { + ValidVotePower uint64 + TotalVotePower uint64 + } } ``` + +### BundleVersionMap + +The version map keeps track of which protocol version was present at given +block heights. It is only updated during chain upgrades. It helps the query +handler to probably decode a finalized bundle. Later it might also be important +for on chain computations. + +- BundleVersionMap `0x03 -> ProtocolBuffer(BundleVersionMap)` + + +## Round-Robin +For correctly determining the next uploader the current round-robin +progress needs to be saved in the KV-Store. Every pool keeps track of its +own round-robin state. + +### RoundRobinSingleValidatorProgress +This struct is not stored directly in the KV-Store but used by the +RoundRobinProgress struct. + +```go +type RoundRobinSingleValidatorProgress struct { + // address of the validator + Address string + // progress within the current round-robin set + Progress int64 +} +``` + +### RoundRobinProgress +RoundRobinProgress stores the current state of the round-robin selection for a +given pool. + +- RoundRobinProgress `0x04 | PoolId -> ProtocolBuffer(roundRobinProgress)` + +```go +message RoundRobinProgress { + PoolId uint64 + ProgressList []RoundRobinSingleValidatorProgress +} +``` \ No newline at end of file diff --git a/x/bundles/spec/04_begin_block.md b/x/bundles/spec/04_begin_block.md new file mode 100644 index 00000000..cb7d4c17 --- /dev/null +++ b/x/bundles/spec/04_begin_block.md @@ -0,0 +1,9 @@ + + +# BeginBlock + +BeginBlock is used to distribute the inflation split to the pools. +All active pools are eligible for the inflation split. The distribution +between the pools are determined by the operating cost of each pool. diff --git a/x/bundles/spec/04_end_block.md b/x/bundles/spec/05_end_block.md similarity index 98% rename from x/bundles/spec/04_end_block.md rename to x/bundles/spec/05_end_block.md index aedb2a34..3ef944bf 100644 --- a/x/bundles/spec/04_end_block.md +++ b/x/bundles/spec/05_end_block.md @@ -1,5 +1,5 @@ # EndBlock diff --git a/x/bundles/spec/06_events.md b/x/bundles/spec/06_events.md index a79557d4..fbf6b526 100644 --- a/x/bundles/spec/06_events.md +++ b/x/bundles/spec/06_events.md @@ -92,22 +92,26 @@ message EventBundleFinalized { uint64 abstain = 5; // total voting power of the pool uint64 total = 6; - // vestingStatus of the finalized bundle - BundleStatus vestingStatus = 7; + // status of the finalized bundle + BundleStatus status = 7; + // amount which funders provided to the total bundle reward (in ukyve) + uint64 funders_payout = 8; + // amount which the inflation pool provided to the total reward (in ukyve) + uint64 inflation_payout = 9; // rewards transferred to treasury (in ukyve) - uint64 reward_treasury = 8; + uint64 reward_treasury = 10; // rewardUploader rewards directly transferred to uploader (in ukyve) - uint64 reward_uploader = 9; + uint64 reward_uploader = 11; // rewardDelegation rewards distributed among all delegators (in ukyve) - uint64 reward_delegation = 10; + uint64 reward_delegation = 12; // rewardTotal the total bundle reward - uint64 reward_total = 11; + uint64 reward_total = 13; // finalized_at the block height where the bundle got finalized - uint64 finalized_at = 12; + uint64 finalized_at = 14; // uploader the address of the uploader of this bundle - string uploader = 13; + string uploader = 15; // next_uploader the address of the next uploader after this bundle - string next_uploader = 14; + string next_uploader = 16; } ``` diff --git a/x/bundles/spec/05_params.md b/x/bundles/spec/08_params.md similarity index 97% rename from x/bundles/spec/05_params.md rename to x/bundles/spec/08_params.md index 00257271..c14aa4ce 100644 --- a/x/bundles/spec/05_params.md +++ b/x/bundles/spec/08_params.md @@ -1,5 +1,5 @@ # Parameters diff --git a/x/bundles/types/bundles.pb.go b/x/bundles/types/bundles.pb.go index 92d1628d..1557b5ff 100644 --- a/x/bundles/types/bundles.pb.go +++ b/x/bundles/types/bundles.pb.go @@ -279,6 +279,8 @@ type FinalizedBundle struct { StorageProviderId uint32 `protobuf:"varint,12,opt,name=storage_provider_id,json=storageProviderId,proto3" json:"storage_provider_id,omitempty"` // compression_id the id of the compression type with which the data was compressed CompressionId uint32 `protobuf:"varint,13,opt,name=compression_id,json=compressionId,proto3" json:"compression_id,omitempty"` + // stake_security + StakeSecurity *StakeSecurity `protobuf:"bytes,14,opt,name=stake_security,json=stakeSecurity,proto3" json:"stake_security,omitempty"` } func (m *FinalizedBundle) Reset() { *m = FinalizedBundle{} } @@ -405,6 +407,13 @@ func (m *FinalizedBundle) GetCompressionId() uint32 { return 0 } +func (m *FinalizedBundle) GetStakeSecurity() *StakeSecurity { + if m != nil { + return m.StakeSecurity + } + return nil +} + // FinalizedAt ... type FinalizedAt struct { // height ... @@ -460,11 +469,282 @@ func (m *FinalizedAt) GetTimestamp() uint64 { return 0 } +// StakeSecurity stores information about total stake and valid votes with which the bundle got finalized. +type StakeSecurity struct { + // valid_vote_power is the total amount of stake of all pool stakers which voted valid for the given bundle. + ValidVotePower uint64 `protobuf:"varint,1,opt,name=valid_vote_power,json=validVotePower,proto3" json:"valid_vote_power,omitempty"` + // total_vote_power is the total amount of stake that was present during the finalization of the bundle + TotalVotePower uint64 `protobuf:"varint,2,opt,name=total_vote_power,json=totalVotePower,proto3" json:"total_vote_power,omitempty"` +} + +func (m *StakeSecurity) Reset() { *m = StakeSecurity{} } +func (m *StakeSecurity) String() string { return proto.CompactTextString(m) } +func (*StakeSecurity) ProtoMessage() {} +func (*StakeSecurity) Descriptor() ([]byte, []int) { + return fileDescriptor_889cf76d77a4de2b, []int{3} +} +func (m *StakeSecurity) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakeSecurity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakeSecurity.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 *StakeSecurity) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakeSecurity.Merge(m, src) +} +func (m *StakeSecurity) XXX_Size() int { + return m.Size() +} +func (m *StakeSecurity) XXX_DiscardUnknown() { + xxx_messageInfo_StakeSecurity.DiscardUnknown(m) +} + +var xxx_messageInfo_StakeSecurity proto.InternalMessageInfo + +func (m *StakeSecurity) GetValidVotePower() uint64 { + if m != nil { + return m.ValidVotePower + } + return 0 +} + +func (m *StakeSecurity) GetTotalVotePower() uint64 { + if m != nil { + return m.TotalVotePower + } + return 0 +} + +// BundleVersionEntry ... +type BundleVersionEntry struct { + // height ... + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // version ... + Version int32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *BundleVersionEntry) Reset() { *m = BundleVersionEntry{} } +func (m *BundleVersionEntry) String() string { return proto.CompactTextString(m) } +func (*BundleVersionEntry) ProtoMessage() {} +func (*BundleVersionEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_889cf76d77a4de2b, []int{4} +} +func (m *BundleVersionEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BundleVersionEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BundleVersionEntry.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 *BundleVersionEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_BundleVersionEntry.Merge(m, src) +} +func (m *BundleVersionEntry) XXX_Size() int { + return m.Size() +} +func (m *BundleVersionEntry) XXX_DiscardUnknown() { + xxx_messageInfo_BundleVersionEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_BundleVersionEntry proto.InternalMessageInfo + +func (m *BundleVersionEntry) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *BundleVersionEntry) GetVersion() int32 { + if m != nil { + return m.Version + } + return 0 +} + +// BundleVersionMap ... +type BundleVersionMap struct { + // versions ... + Versions []*BundleVersionEntry `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions,omitempty"` +} + +func (m *BundleVersionMap) Reset() { *m = BundleVersionMap{} } +func (m *BundleVersionMap) String() string { return proto.CompactTextString(m) } +func (*BundleVersionMap) ProtoMessage() {} +func (*BundleVersionMap) Descriptor() ([]byte, []int) { + return fileDescriptor_889cf76d77a4de2b, []int{5} +} +func (m *BundleVersionMap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BundleVersionMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BundleVersionMap.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 *BundleVersionMap) XXX_Merge(src proto.Message) { + xxx_messageInfo_BundleVersionMap.Merge(m, src) +} +func (m *BundleVersionMap) XXX_Size() int { + return m.Size() +} +func (m *BundleVersionMap) XXX_DiscardUnknown() { + xxx_messageInfo_BundleVersionMap.DiscardUnknown(m) +} + +var xxx_messageInfo_BundleVersionMap proto.InternalMessageInfo + +func (m *BundleVersionMap) GetVersions() []*BundleVersionEntry { + if m != nil { + return m.Versions + } + return nil +} + +// RoundRobinSingleValidatorProgress ... +type RoundRobinSingleValidatorProgress struct { + // address ... + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // progress ... + Progress int64 `protobuf:"varint,2,opt,name=progress,proto3" json:"progress,omitempty"` +} + +func (m *RoundRobinSingleValidatorProgress) Reset() { *m = RoundRobinSingleValidatorProgress{} } +func (m *RoundRobinSingleValidatorProgress) String() string { return proto.CompactTextString(m) } +func (*RoundRobinSingleValidatorProgress) ProtoMessage() {} +func (*RoundRobinSingleValidatorProgress) Descriptor() ([]byte, []int) { + return fileDescriptor_889cf76d77a4de2b, []int{6} +} +func (m *RoundRobinSingleValidatorProgress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RoundRobinSingleValidatorProgress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RoundRobinSingleValidatorProgress.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 *RoundRobinSingleValidatorProgress) XXX_Merge(src proto.Message) { + xxx_messageInfo_RoundRobinSingleValidatorProgress.Merge(m, src) +} +func (m *RoundRobinSingleValidatorProgress) XXX_Size() int { + return m.Size() +} +func (m *RoundRobinSingleValidatorProgress) XXX_DiscardUnknown() { + xxx_messageInfo_RoundRobinSingleValidatorProgress.DiscardUnknown(m) +} + +var xxx_messageInfo_RoundRobinSingleValidatorProgress proto.InternalMessageInfo + +func (m *RoundRobinSingleValidatorProgress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *RoundRobinSingleValidatorProgress) GetProgress() int64 { + if m != nil { + return m.Progress + } + return 0 +} + +// RoundRobinProgress ... +type RoundRobinProgress struct { + // pool_id ... + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // progress_list ... + ProgressList []*RoundRobinSingleValidatorProgress `protobuf:"bytes,2,rep,name=progress_list,json=progressList,proto3" json:"progress_list,omitempty"` +} + +func (m *RoundRobinProgress) Reset() { *m = RoundRobinProgress{} } +func (m *RoundRobinProgress) String() string { return proto.CompactTextString(m) } +func (*RoundRobinProgress) ProtoMessage() {} +func (*RoundRobinProgress) Descriptor() ([]byte, []int) { + return fileDescriptor_889cf76d77a4de2b, []int{7} +} +func (m *RoundRobinProgress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RoundRobinProgress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RoundRobinProgress.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 *RoundRobinProgress) XXX_Merge(src proto.Message) { + xxx_messageInfo_RoundRobinProgress.Merge(m, src) +} +func (m *RoundRobinProgress) XXX_Size() int { + return m.Size() +} +func (m *RoundRobinProgress) XXX_DiscardUnknown() { + xxx_messageInfo_RoundRobinProgress.DiscardUnknown(m) +} + +var xxx_messageInfo_RoundRobinProgress proto.InternalMessageInfo + +func (m *RoundRobinProgress) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *RoundRobinProgress) GetProgressList() []*RoundRobinSingleValidatorProgress { + if m != nil { + return m.ProgressList + } + return nil +} + func init() { proto.RegisterEnum("kyve.bundles.v1beta1.BundleStatus", BundleStatus_name, BundleStatus_value) proto.RegisterType((*BundleProposal)(nil), "kyve.bundles.v1beta1.BundleProposal") proto.RegisterType((*FinalizedBundle)(nil), "kyve.bundles.v1beta1.FinalizedBundle") proto.RegisterType((*FinalizedAt)(nil), "kyve.bundles.v1beta1.FinalizedAt") + proto.RegisterType((*StakeSecurity)(nil), "kyve.bundles.v1beta1.StakeSecurity") + proto.RegisterType((*BundleVersionEntry)(nil), "kyve.bundles.v1beta1.BundleVersionEntry") + proto.RegisterType((*BundleVersionMap)(nil), "kyve.bundles.v1beta1.BundleVersionMap") + proto.RegisterType((*RoundRobinSingleValidatorProgress)(nil), "kyve.bundles.v1beta1.RoundRobinSingleValidatorProgress") + proto.RegisterType((*RoundRobinProgress)(nil), "kyve.bundles.v1beta1.RoundRobinProgress") } func init() { @@ -472,52 +752,65 @@ func init() { } var fileDescriptor_889cf76d77a4de2b = []byte{ - // 710 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xcd, 0x6e, 0x1a, 0x49, - 0x14, 0x85, 0x69, 0xc0, 0x40, 0x5f, 0x7e, 0xcc, 0x94, 0xff, 0xda, 0x78, 0xcc, 0x60, 0x8f, 0x46, - 0x42, 0xa3, 0x11, 0xc8, 0x33, 0x4f, 0x00, 0x06, 0x34, 0x2d, 0x7b, 0xb0, 0x07, 0x8c, 0xa5, 0x64, - 0xd3, 0x2a, 0xdc, 0x65, 0x28, 0x19, 0xba, 0x5a, 0xdd, 0x05, 0x31, 0x7e, 0x82, 0x2c, 0xf3, 0x0e, - 0xc9, 0x63, 0x64, 0x95, 0x55, 0x96, 0x5e, 0x66, 0x19, 0xd9, 0x2f, 0x12, 0x55, 0x55, 0x37, 0x06, - 0xdb, 0x89, 0xbc, 0xc9, 0x8e, 0xfb, 0x9d, 0x53, 0x54, 0xdd, 0xba, 0xa7, 0x0b, 0xf6, 0xaf, 0x66, - 0x53, 0x52, 0xed, 0x4f, 0x1c, 0x7b, 0x44, 0xfc, 0xea, 0xf4, 0xa0, 0x4f, 0x38, 0x3e, 0x08, 0xeb, - 0x8a, 0xeb, 0x31, 0xce, 0xd0, 0xba, 0xf0, 0x54, 0x42, 0x16, 0x78, 0x0a, 0xeb, 0x03, 0x36, 0x60, - 0xd2, 0x50, 0x15, 0xbf, 0x94, 0x77, 0xff, 0x43, 0x1c, 0x72, 0x75, 0xe9, 0x3c, 0xf5, 0x98, 0xcb, - 0x7c, 0x3c, 0x42, 0x5b, 0x90, 0x74, 0x19, 0x1b, 0x59, 0xd4, 0x36, 0xb4, 0x92, 0x56, 0x8e, 0x77, - 0x12, 0xa2,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 0x00, + // 918 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6e, 0x1a, 0x47, + 0x14, 0x66, 0x01, 0xf3, 0x73, 0x60, 0x09, 0x9d, 0xfc, 0x78, 0xed, 0xd4, 0x14, 0x13, 0x55, 0x42, + 0x55, 0x05, 0x8a, 0x7b, 0xd1, 0x6b, 0x1c, 0x40, 0xdd, 0xc6, 0x21, 0x74, 0x37, 0xa0, 0xa6, 0xaa, + 0xb4, 0x1a, 0xd8, 0x31, 0x8c, 0x0c, 0x3b, 0xab, 0xdd, 0x81, 0x18, 0x3f, 0x41, 0xa5, 0x4a, 0x55, + 0xdf, 0xa1, 0x7d, 0x8c, 0x3e, 0x40, 0x2f, 0x73, 0xd9, 0xcb, 0xca, 0x7e, 0x91, 0x6a, 0x66, 0x76, + 0x31, 0xc4, 0xb8, 0xcd, 0x4d, 0xef, 0x38, 0xdf, 0xf7, 0xcd, 0x99, 0xf3, 0xf3, 0x0d, 0x0b, 0xb5, + 0x8b, 0xd5, 0x92, 0x34, 0x47, 0x0b, 0xcf, 0x9d, 0x91, 0xb0, 0xb9, 0x7c, 0x3e, 0x22, 0x1c, 0x3f, + 0x8f, 0xe3, 0x86, 0x1f, 0x30, 0xce, 0xd0, 0x23, 0xa1, 0x69, 0xc4, 0x58, 0xa4, 0x39, 0x7c, 0x34, + 0x61, 0x13, 0x26, 0x05, 0x4d, 0xf1, 0x4b, 0x69, 0x6b, 0xbf, 0xa7, 0xa1, 0x74, 0x2a, 0x95, 0xfd, + 0x80, 0xf9, 0x2c, 0xc4, 0x33, 0xb4, 0x0f, 0x59, 0x9f, 0xb1, 0x99, 0x43, 0x5d, 0x43, 0xab, 0x6a, + 0xf5, 0xb4, 0x95, 0x11, 0xa1, 0xe9, 0xa2, 0x23, 0x80, 0x90, 0xb3, 0x00, 0x4f, 0x88, 0xe0, 0x92, + 0x55, 0xad, 0x9e, 0xb7, 0xf2, 0x11, 0x62, 0xba, 0xe8, 0x10, 0x72, 0x0b, 0x7f, 0xc6, 0xb0, 0x4b, + 0x02, 0x23, 0x25, 0xc9, 0x75, 0x8c, 0x9e, 0x81, 0xee, 0x91, 0x4b, 0xee, 0xac, 0x05, 0x69, 0x29, + 0x28, 0x0a, 0x70, 0x10, 0x8b, 0x9e, 0x42, 0xde, 0xc5, 0x1c, 0x3b, 0x21, 0xbd, 0x22, 0xc6, 0x9e, + 0xbc, 0x3a, 0x27, 0x00, 0x9b, 0x5e, 0x11, 0xf4, 0x19, 0x14, 0x54, 0x47, 0x8a, 0xce, 0x48, 0x1a, + 0x14, 0x24, 0x05, 0x8f, 0x21, 0xc3, 0x99, 0x73, 0x41, 0x56, 0x46, 0x56, 0xe6, 0xde, 0xe3, 0xec, + 0x25, 0x59, 0xa1, 0xcf, 0xa1, 0x14, 0x9f, 0x5b, 0xcc, 0xe7, 0x38, 0x58, 0x19, 0x39, 0x49, 0xeb, + 0xd1, 0x51, 0x05, 0xae, 0xef, 0x9e, 0xe2, 0x70, 0x6a, 0xe4, 0x55, 0xf5, 0x02, 0xf8, 0x06, 0x87, + 0x53, 0xd1, 0xf8, 0xc2, 0x77, 0x31, 0x27, 0xae, 0x83, 0xb9, 0x01, 0xf2, 0xea, 0x7c, 0x84, 0xb4, + 0x38, 0x3a, 0x86, 0xe2, 0x92, 0x71, 0x12, 0x84, 0xce, 0x12, 0xcf, 0xa8, 0x6b, 0x14, 0xaa, 0xa9, + 0x7a, 0xde, 0x2a, 0x28, 0x6c, 0x28, 0x20, 0x51, 0x45, 0x24, 0xa1, 0x9e, 0x12, 0x15, 0xa5, 0x48, + 0x57, 0xa8, 0xa9, 0xc0, 0x0d, 0x19, 0x1e, 0x85, 0x1c, 0x53, 0xcf, 0xd0, 0x37, 0x65, 0x2d, 0x05, + 0xa2, 0x03, 0xc8, 0x9d, 0x07, 0x6c, 0x2e, 0x9b, 0x2d, 0xc9, 0x5a, 0xb3, 0x22, 0x16, 0xed, 0x36, + 0xe0, 0x61, 0xbc, 0x23, 0x3f, 0x60, 0x4b, 0xea, 0x92, 0x40, 0x2c, 0xeb, 0x41, 0x55, 0xab, 0xeb, + 0xd6, 0x27, 0x11, 0xd5, 0x8f, 0x18, 0x53, 0xde, 0x38, 0x66, 0x73, 0x3f, 0x20, 0x61, 0x48, 0x99, + 0x27, 0xa4, 0x65, 0x29, 0xd5, 0x37, 0x50, 0xd3, 0xad, 0xfd, 0x92, 0x86, 0x07, 0x5d, 0xea, 0xe1, + 0x19, 0xbd, 0x22, 0xae, 0xf2, 0xcb, 0xfd, 0x3e, 0x29, 0x41, 0x32, 0xf2, 0x47, 0xda, 0x4a, 0xd2, + 0x0f, 0x7d, 0x93, 0xfa, 0x37, 0xdf, 0xa4, 0x3f, 0xf0, 0xcd, 0x11, 0x80, 0xec, 0x94, 0x7a, 0x2e, + 0xb9, 0x8c, 0x3c, 0x91, 0x17, 0x88, 0x29, 0x00, 0x31, 0x08, 0xce, 0x22, 0x52, 0x39, 0x22, 0xcb, + 0x99, 0xa2, 0xfe, 0x47, 0x3b, 0xb4, 0xa1, 0x78, 0x1e, 0xcf, 0x22, 0x36, 0x44, 0xe1, 0xe4, 0xb8, + 0xb1, 0xeb, 0xd9, 0x35, 0xd6, 0x53, 0x6b, 0x71, 0xab, 0x70, 0x7e, 0x1b, 0x6c, 0x2d, 0xb1, 0xf0, + 0x51, 0x4b, 0x2c, 0x7e, 0xfc, 0x12, 0xf5, 0x1d, 0x4b, 0x44, 0xdf, 0x42, 0x29, 0xe4, 0xf8, 0x82, + 0x38, 0x21, 0x19, 0x2f, 0x02, 0xca, 0x95, 0x79, 0x0a, 0x27, 0xcf, 0x76, 0x57, 0x6e, 0x0b, 0xad, + 0x1d, 0x49, 0x2d, 0x3d, 0xdc, 0x0c, 0x6b, 0x2f, 0xa0, 0xb0, 0xd1, 0x19, 0x7a, 0x02, 0x99, 0x29, + 0xa1, 0x93, 0x29, 0x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, 0xff, 0x45, 0x66, + 0x7a, 0xef, 0xcc, 0x07, 0x00, 0x00, } func (m *BundleProposal) Marshal() (dAtA []byte, err error) { @@ -671,6 +964,18 @@ func (m *FinalizedBundle) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.StakeSecurity != nil { + { + size, err := m.StakeSecurity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 + } if m.CompressionId != 0 { i = encodeVarintBundles(dAtA, i, uint64(m.CompressionId)) i-- @@ -791,51 +1096,231 @@ func (m *FinalizedAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintBundles(dAtA []byte, offset int, v uint64) int { - offset -= sovBundles(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *StakeSecurity) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *BundleProposal) Size() (n int) { - if m == nil { - return 0 - } + +func (m *StakeSecurity) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakeSecurity) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.PoolId != 0 { - n += 1 + sovBundles(uint64(m.PoolId)) - } - l = len(m.StorageId) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) - } - l = len(m.Uploader) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) + if m.TotalVotePower != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.TotalVotePower)) + i-- + dAtA[i] = 0x10 } - l = len(m.NextUploader) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) + if m.ValidVotePower != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.ValidVotePower)) + i-- + dAtA[i] = 0x8 } - if m.DataSize != 0 { - n += 1 + sovBundles(uint64(m.DataSize)) + return len(dAtA) - i, nil +} + +func (m *BundleVersionEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - if m.BundleSize != 0 { - n += 1 + sovBundles(uint64(m.BundleSize)) + return dAtA[:n], nil +} + +func (m *BundleVersionEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BundleVersionEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Version != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x10 } - l = len(m.ToKey) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) + if m.Height != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - l = len(m.BundleSummary) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) + return len(dAtA) - i, nil +} + +func (m *BundleVersionMap) 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 *BundleVersionMap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BundleVersionMap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Versions) > 0 { + for iNdEx := len(m.Versions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Versions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RoundRobinSingleValidatorProgress) 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 *RoundRobinSingleValidatorProgress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RoundRobinSingleValidatorProgress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Progress != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.Progress)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintBundles(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RoundRobinProgress) 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 *RoundRobinProgress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RoundRobinProgress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ProgressList) > 0 { + for iNdEx := len(m.ProgressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ProgressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.PoolId != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintBundles(dAtA []byte, offset int, v uint64) int { + offset -= sovBundles(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BundleProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovBundles(uint64(m.PoolId)) + } + l = len(m.StorageId) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.Uploader) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.NextUploader) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + if m.DataSize != 0 { + n += 1 + sovBundles(uint64(m.DataSize)) + } + if m.BundleSize != 0 { + n += 1 + sovBundles(uint64(m.BundleSize)) + } + l = len(m.ToKey) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.BundleSummary) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) } l = len(m.DataHash) if l > 0 { @@ -927,6 +1412,10 @@ func (m *FinalizedBundle) Size() (n int) { if m.CompressionId != 0 { n += 1 + sovBundles(uint64(m.CompressionId)) } + if m.StakeSecurity != nil { + l = m.StakeSecurity.Size() + n += 1 + l + sovBundles(uint64(l)) + } return n } @@ -945,6 +1434,85 @@ func (m *FinalizedAt) Size() (n int) { return n } +func (m *StakeSecurity) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ValidVotePower != 0 { + n += 1 + sovBundles(uint64(m.ValidVotePower)) + } + if m.TotalVotePower != 0 { + n += 1 + sovBundles(uint64(m.TotalVotePower)) + } + return n +} + +func (m *BundleVersionEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovBundles(uint64(m.Height)) + } + if m.Version != 0 { + n += 1 + sovBundles(uint64(m.Version)) + } + return n +} + +func (m *BundleVersionMap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Versions) > 0 { + for _, e := range m.Versions { + l = e.Size() + n += 1 + l + sovBundles(uint64(l)) + } + } + return n +} + +func (m *RoundRobinSingleValidatorProgress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + if m.Progress != 0 { + n += 1 + sovBundles(uint64(m.Progress)) + } + return n +} + +func (m *RoundRobinProgress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovBundles(uint64(m.PoolId)) + } + if len(m.ProgressList) > 0 { + for _, e := range m.ProgressList { + l = e.Size() + n += 1 + l + sovBundles(uint64(l)) + } + } + return n +} + func sovBundles(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1806,6 +2374,42 @@ func (m *FinalizedBundle) Unmarshal(dAtA []byte) error { break } } + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakeSecurity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StakeSecurity == nil { + m.StakeSecurity = &StakeSecurity{} + } + if err := m.StakeSecurity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBundles(dAtA[iNdEx:]) @@ -1915,6 +2519,470 @@ func (m *FinalizedAt) Unmarshal(dAtA []byte) error { } return nil } +func (m *StakeSecurity) 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 ErrIntOverflowBundles + } + 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: StakeSecurity: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakeSecurity: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidVotePower", wireType) + } + m.ValidVotePower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidVotePower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalVotePower", wireType) + } + m.TotalVotePower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalVotePower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BundleVersionEntry) 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 ErrIntOverflowBundles + } + 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: BundleVersionEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BundleVersionEntry: 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 ErrIntOverflowBundles + } + 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 Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BundleVersionMap) 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 ErrIntOverflowBundles + } + 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: BundleVersionMap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BundleVersionMap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Versions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Versions = append(m.Versions, &BundleVersionEntry{}) + if err := m.Versions[len(m.Versions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RoundRobinSingleValidatorProgress) 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 ErrIntOverflowBundles + } + 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: RoundRobinSingleValidatorProgress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RoundRobinSingleValidatorProgress: 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 ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Progress", wireType) + } + m.Progress = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Progress |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RoundRobinProgress) 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 ErrIntOverflowBundles + } + 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: RoundRobinProgress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RoundRobinProgress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProgressList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProgressList = append(m.ProgressList, &RoundRobinSingleValidatorProgress{}) + if err := m.ProgressList[len(m.ProgressList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBundles(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bundles/types/events.pb.go b/x/bundles/types/events.pb.go index fe617c53..ffbbf676 100644 --- a/x/bundles/types/events.pb.go +++ b/x/bundles/types/events.pb.go @@ -347,20 +347,24 @@ type EventBundleFinalized struct { Total uint64 `protobuf:"varint,6,opt,name=total,proto3" json:"total,omitempty"` // status of the finalized bundle Status BundleStatus `protobuf:"varint,7,opt,name=status,proto3,enum=kyve.bundles.v1beta1.BundleStatus" json:"status,omitempty"` + // amount which funders provided to the total bundle reward (in ukyve) + FundersPayout uint64 `protobuf:"varint,8,opt,name=funders_payout,json=fundersPayout,proto3" json:"funders_payout,omitempty"` + // amount which the inflation pool provided to the total reward (in ukyve) + InflationPayout uint64 `protobuf:"varint,9,opt,name=inflation_payout,json=inflationPayout,proto3" json:"inflation_payout,omitempty"` // rewards transferred to treasury (in ukyve) - RewardTreasury uint64 `protobuf:"varint,8,opt,name=reward_treasury,json=rewardTreasury,proto3" json:"reward_treasury,omitempty"` + RewardTreasury uint64 `protobuf:"varint,10,opt,name=reward_treasury,json=rewardTreasury,proto3" json:"reward_treasury,omitempty"` // rewardUploader rewards directly transferred to uploader (in ukyve) - RewardUploader uint64 `protobuf:"varint,9,opt,name=reward_uploader,json=rewardUploader,proto3" json:"reward_uploader,omitempty"` + RewardUploader uint64 `protobuf:"varint,11,opt,name=reward_uploader,json=rewardUploader,proto3" json:"reward_uploader,omitempty"` // rewardDelegation rewards distributed among all delegators (in ukyve) - RewardDelegation uint64 `protobuf:"varint,10,opt,name=reward_delegation,json=rewardDelegation,proto3" json:"reward_delegation,omitempty"` + RewardDelegation uint64 `protobuf:"varint,12,opt,name=reward_delegation,json=rewardDelegation,proto3" json:"reward_delegation,omitempty"` // rewardTotal the total bundle reward - RewardTotal uint64 `protobuf:"varint,11,opt,name=reward_total,json=rewardTotal,proto3" json:"reward_total,omitempty"` + RewardTotal uint64 `protobuf:"varint,13,opt,name=reward_total,json=rewardTotal,proto3" json:"reward_total,omitempty"` // finalized_at the block height where the bundle got finalized - FinalizedAt uint64 `protobuf:"varint,12,opt,name=finalized_at,json=finalizedAt,proto3" json:"finalized_at,omitempty"` + FinalizedAt uint64 `protobuf:"varint,14,opt,name=finalized_at,json=finalizedAt,proto3" json:"finalized_at,omitempty"` // uploader the address of the uploader of this bundle - Uploader string `protobuf:"bytes,13,opt,name=uploader,proto3" json:"uploader,omitempty"` + Uploader string `protobuf:"bytes,15,opt,name=uploader,proto3" json:"uploader,omitempty"` // next_uploader the address of the next uploader after this bundle - NextUploader string `protobuf:"bytes,14,opt,name=next_uploader,json=nextUploader,proto3" json:"next_uploader,omitempty"` + NextUploader string `protobuf:"bytes,16,opt,name=next_uploader,json=nextUploader,proto3" json:"next_uploader,omitempty"` } func (m *EventBundleFinalized) Reset() { *m = EventBundleFinalized{} } @@ -445,6 +449,20 @@ func (m *EventBundleFinalized) GetStatus() BundleStatus { return BUNDLE_STATUS_UNSPECIFIED } +func (m *EventBundleFinalized) GetFundersPayout() uint64 { + if m != nil { + return m.FundersPayout + } + return 0 +} + +func (m *EventBundleFinalized) GetInflationPayout() uint64 { + if m != nil { + return m.InflationPayout + } + return 0 +} + func (m *EventBundleFinalized) GetRewardTreasury() uint64 { if m != nil { return m.RewardTreasury @@ -769,61 +787,63 @@ func init() { func init() { proto.RegisterFile("kyve/bundles/v1beta1/events.proto", fileDescriptor_a02f505e55d81e92) } var fileDescriptor_a02f505e55d81e92 = []byte{ - // 858 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xce, 0x26, 0x1b, 0x27, 0x7b, 0xfc, 0xd3, 0x64, 0x1b, 0x60, 0x09, 0xd4, 0x4d, 0x8c, 0x10, - 0x91, 0x8a, 0x6c, 0x35, 0xdc, 0x71, 0x97, 0x94, 0x56, 0x58, 0x95, 0x50, 0xb4, 0x69, 0x2b, 0xc1, - 0x8d, 0x35, 0xce, 0x9c, 0xd8, 0x23, 0xaf, 0x77, 0x46, 0x33, 0x63, 0x3b, 0xce, 0x53, 0x20, 0x21, - 0x9e, 0x84, 0x57, 0xe0, 0xa2, 0x97, 0xbd, 0xe4, 0x0a, 0x41, 0xf2, 0x22, 0x68, 0x7e, 0x76, 0x6d, - 0x82, 0x0b, 0x2d, 0x77, 0x3e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0x7e, 0xfb, 0x82, 0x8f, 0x3b, - 0xcf, 0xbf, 0x7f, 0xf5, 0xf4, 0x3b, 0xd4, 0x33, 0x2e, 0x47, 0x9d, 0x8b, 0x21, 0x61, 0x79, 0xe7, - 0xaa, 0xfc, 0xf7, 0xd3, 0x73, 0x81, 0xaa, 0x5f, 0xb1, 0xff, 0x7c, 0x5f, 0xfd, 0x15, 0x00, 0x00, - 0xff, 0xff, 0x37, 0x28, 0x51, 0xd0, 0xb0, 0x07, 0x00, 0x00, + // 895 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdf, 0x6e, 0x1b, 0xc5, + 0x17, 0xce, 0xa6, 0x1b, 0x27, 0x7b, 0xfc, 0x27, 0xce, 0x36, 0xbf, 0x1f, 0x4b, 0xa0, 0x6e, 0x62, + 0x84, 0x08, 0x2a, 0xb2, 0xd5, 0x70, 0xc7, 0x5d, 0x52, 0x5a, 0x61, 0x55, 0x42, 0xd6, 0xa6, 0xad, + 0x04, 0x37, 0xd6, 0x38, 0x73, 0x6c, 0x8f, 0xbc, 0xde, 0x59, 0xcd, 0xcc, 0xda, 0x71, 0x9e, 0x02, + 0x09, 0xf1, 0x24, 0x7d, 0x05, 0x2e, 0x7a, 0xd9, 0x4b, 0xae, 0x10, 0x4a, 0x5e, 0x04, 0xcd, 0x9f, + 0xdd, 0x98, 0xe0, 0x42, 0xcb, 0x9d, 0xcf, 0x77, 0xbe, 0xf9, 0xce, 0xb7, 0xe7, 0x9c, 0x19, 0xc3, + 0xd1, 0x74, 0x39, 0xc7, 0xee, 0x30, 0x4f, 0x69, 0x82, 0xb2, 0x3b, 0x7f, 0x3c, 0x44, 0x45, 0x1e, + 0x77, 0x71, 0x8e, 0xa9, 0x92, 0x9d, 0x4c, 0x70, 0xc5, 0xc3, 0x7d, 0x4d, 0xe9, 0x38, 0x4a, 0xc7, + 0x51, 0x0e, 0xf6,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x54, 0x0b, 0x2e, 0xa6, 0xdd, + 0x8b, 0x09, 0x61, 0x69, 0xf7, 0xb2, 0xfc, 0x3f, 0x55, 0xcb, 0x0c, 0xe5, 0xb0, 0x62, 0xfe, 0x4b, + 0xbf, 0xfe, 0x33, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xeb, 0x71, 0xdc, 0x02, 0x08, 0x00, 0x00, } func (m *EventUpdateParams) Marshal() (dAtA []byte, err error) { @@ -1053,38 +1073,50 @@ func (m *EventBundleFinalized) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.NextUploader) i = encodeVarintEvents(dAtA, i, uint64(len(m.NextUploader))) i-- - dAtA[i] = 0x72 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } if len(m.Uploader) > 0 { i -= len(m.Uploader) copy(dAtA[i:], m.Uploader) i = encodeVarintEvents(dAtA, i, uint64(len(m.Uploader))) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x7a } if m.FinalizedAt != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.FinalizedAt)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x70 } if m.RewardTotal != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.RewardTotal)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x68 } if m.RewardDelegation != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.RewardDelegation)) i-- - dAtA[i] = 0x50 + dAtA[i] = 0x60 } if m.RewardUploader != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.RewardUploader)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x58 } if m.RewardTreasury != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.RewardTreasury)) i-- + dAtA[i] = 0x50 + } + if m.InflationPayout != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.InflationPayout)) + i-- + dAtA[i] = 0x48 + } + if m.FundersPayout != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.FundersPayout)) + i-- dAtA[i] = 0x40 } if m.Status != 0 { @@ -1422,6 +1454,12 @@ func (m *EventBundleFinalized) Size() (n int) { if m.Status != 0 { n += 1 + sovEvents(uint64(m.Status)) } + if m.FundersPayout != 0 { + n += 1 + sovEvents(uint64(m.FundersPayout)) + } + if m.InflationPayout != 0 { + n += 1 + sovEvents(uint64(m.InflationPayout)) + } if m.RewardTreasury != 0 { n += 1 + sovEvents(uint64(m.RewardTreasury)) } @@ -1443,7 +1481,7 @@ func (m *EventBundleFinalized) Size() (n int) { } l = len(m.NextUploader) if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + n += 2 + l + sovEvents(uint64(l)) } return n } @@ -2388,6 +2426,44 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { } } case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FundersPayout", wireType) + } + m.FundersPayout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FundersPayout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationPayout", wireType) + } + m.InflationPayout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InflationPayout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RewardTreasury", wireType) } @@ -2406,7 +2482,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { break } } - case 9: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RewardUploader", wireType) } @@ -2425,7 +2501,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { break } } - case 10: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RewardDelegation", wireType) } @@ -2444,7 +2520,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { break } } - case 11: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RewardTotal", wireType) } @@ -2463,7 +2539,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { break } } - case 12: + case 14: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field FinalizedAt", wireType) } @@ -2482,7 +2558,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { break } } - case 13: + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Uploader", wireType) } @@ -2514,7 +2590,7 @@ func (m *EventBundleFinalized) Unmarshal(dAtA []byte) error { } m.Uploader = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 14: + case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NextUploader", wireType) } diff --git a/x/bundles/types/expected_keepers.go b/x/bundles/types/expected_keepers.go index b30db737..cec3a1c1 100644 --- a/x/bundles/types/expected_keepers.go +++ b/x/bundles/types/expected_keepers.go @@ -36,13 +36,14 @@ type PoolKeeper interface { IncrementBundleInformation(ctx sdk.Context, poolId uint64, currentHeight uint64, currentKey string, currentValue string) GetAllPools(ctx sdk.Context) (list []pooltypes.Pool) - ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) error + ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) + ChargeInflationPool(ctx sdk.Context, poolId uint64) (payout uint64, err error) } type StakerKeeper interface { GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (stakers []string) GetCommission(ctx sdk.Context, stakerAddress string) sdk.Dec - IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) + IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) error AssertValaccountAuthorized(ctx sdk.Context, poolId uint64, stakerAddress string, valaddress string) error DoesStakerExist(ctx sdk.Context, staker string) bool @@ -57,6 +58,6 @@ type StakerKeeper interface { type DelegationKeeper interface { GetDelegationAmount(ctx sdk.Context, staker string) uint64 GetDelegationOfPool(ctx sdk.Context, poolId uint64) uint64 - PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) (success bool) + PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) error SlashDelegators(ctx sdk.Context, poolId uint64, staker string, slashType delegationTypes.SlashType) } diff --git a/x/bundles/types/genesis.pb.go b/x/bundles/types/genesis.pb.go index a65bb607..6695dcb2 100644 --- a/x/bundles/types/genesis.pb.go +++ b/x/bundles/types/genesis.pb.go @@ -31,6 +31,8 @@ type GenesisState struct { BundleProposalList []BundleProposal `protobuf:"bytes,2,rep,name=bundle_proposal_list,json=bundleProposalList,proto3" json:"bundle_proposal_list"` // finalized_bundle_list ... FinalizedBundleList []FinalizedBundle `protobuf:"bytes,3,rep,name=finalized_bundle_list,json=finalizedBundleList,proto3" json:"finalized_bundle_list"` + // round_robin_progress_list ... + RoundRobinProgressList []RoundRobinProgress `protobuf:"bytes,4,rep,name=round_robin_progress_list,json=roundRobinProgressList,proto3" json:"round_robin_progress_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -87,6 +89,13 @@ func (m *GenesisState) GetFinalizedBundleList() []FinalizedBundle { return nil } +func (m *GenesisState) GetRoundRobinProgressList() []RoundRobinProgress { + if m != nil { + return m.RoundRobinProgressList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "kyve.bundles.v1beta1.GenesisState") } @@ -96,26 +105,29 @@ func init() { } var fileDescriptor_21c07b409d3bb015 = []byte{ - // 301 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xae, 0x2c, 0x4b, - 0xd5, 0x4f, 0x2a, 0xcd, 0x4b, 0xc9, 0x49, 0x2d, 0xd6, 0x2f, 0x33, 0x4c,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8, 0xc2, 0x20, 0x0b, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, - 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, - 0x58, 0x8e, 0x21, 0x4a, 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, - 0x3b, 0x32, 0xcc, 0xd5, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x3f, 0x39, 0x23, 0x31, 0x33, - 0x4f, 0xbf, 0x02, 0x1e, 0xc4, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0xa0, 0x35, 0x06, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xed, 0x45, 0xe0, 0xf3, 0x01, 0x00, 0x00, + // 342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x4b, 0x02, 0x41, + 0x18, 0xc6, 0x77, 0x55, 0x3c, 0xac, 0x9d, 0x36, 0x0b, 0x93, 0xd8, 0x4c, 0x0a, 0x3c, 0xc4, 0x0e, + 0xda, 0xad, 0xa3, 0x90, 0x1d, 0x8a, 0x10, 0x83, 0xa0, 0x08, 0x96, 0x59, 0x1d, 0xd7, 0xc1, 0x75, + 0x66, 0x99, 0x19, 0x2d, 0xfb, 0x14, 0x7d, 0x2c, 0x8f, 0x1e, 0x3b, 0x45, 0xb8, 0x5f, 0xa1, 0x0f, + 0x10, 0xf3, 0xc7, 0x40, 0x9a, 0xdb, 0xee, 0xbb, 0xbf, 0xe7, 0xf9, 0xbd, 0xcb, 0xeb, 0x35, 0xa7, + 0xcb, 0x05, 0x02, 0xf1, 0x9c, 0x8c, 0x52, 0xc4, 0xc1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f6, 0x56, 0x9b, 0xc0, 0x5d, 0x6f, 0x02, 0xf7, 0x7b, 0x13, 0xb8, 0x1f, 0x79, 0xe0, 0xac, 0xf3, + 0xc0, 0xf9, 0xcc, 0x03, 0xe7, 0xf9, 0x22, 0xc1, 0x62, 0x32, 0x8f, 0xc3, 0x21, 0x9d, 0x81, 0xdb, + 0xa7, 0xc7, 0xeb, 0x7b, 0x24, 0x5e, 0x29, 0x9b, 0x82, 0xe1, 0x04, 0x62, 0x02, 0xde, 0xfe, 0xae, + 0x29, 0x96, 0x19, 0xe2, 0x71, 0x59, 0x5d, 0xf1, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xc8, + 0xa7, 0xad, 0x5e, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -138,6 +150,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.RoundRobinProgressList) > 0 { + for iNdEx := len(m.RoundRobinProgressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RoundRobinProgressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.FinalizedBundleList) > 0 { for iNdEx := len(m.FinalizedBundleList) - 1; iNdEx >= 0; iNdEx-- { { @@ -210,6 +236,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.RoundRobinProgressList) > 0 { + for _, e := range m.RoundRobinProgressList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -349,6 +381,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RoundRobinProgressList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RoundRobinProgressList = append(m.RoundRobinProgressList, RoundRobinProgress{}) + if err := m.RoundRobinProgressList[len(m.RoundRobinProgressList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/bundles/types/keys.go b/x/bundles/types/keys.go index 0c5597bf..073aa04f 100644 --- a/x/bundles/types/keys.go +++ b/x/bundles/types/keys.go @@ -25,8 +25,12 @@ var ( BundleKeyPrefix = []byte{1} // FinalizedBundlePrefix ... FinalizedBundlePrefix = []byte{2} + // FinalizedBundleVersionMapKey ... + FinalizedBundleVersionMapKey = []byte{3} + // RoundRobinProgressPrefix ... + RoundRobinProgressPrefix = []byte{4} - FinalizedBundleByHeightPrefix = []byte{11} + FinalizedBundleByIndexPrefix = []byte{11} ) // BundleProposalKey ... @@ -39,7 +43,12 @@ func FinalizedBundleKey(poolId uint64, id uint64) []byte { return util.GetByteKey(poolId, id) } -// FinalizedBundleByHeightKey ... -func FinalizedBundleByHeightKey(poolId uint64, height uint64) []byte { +// RoundRobinProgressKey ... +func RoundRobinProgressKey(poolId uint64) []byte { + return util.GetByteKey(poolId) +} + +// FinalizedBundleByIndexKey ... +func FinalizedBundleByIndexKey(poolId uint64, height uint64) []byte { return util.GetByteKey(poolId, height) } diff --git a/x/bundles/types/types.go b/x/bundles/types/types.go index d26d4556..64ed1d6b 100644 --- a/x/bundles/types/types.go +++ b/x/bundles/types/types.go @@ -23,3 +23,15 @@ type BundleReward struct { // total ... Total uint64 } + +// GetMap converts to array to a go map which return the upgrade-height for each version. +// e.g. the schema changed from v1 to v2 at block 1,000. +// then: GetMap()[2] = 1000 +// Version 1 start at 0 and is not encoded in the map +func (bundleVersionMap BundleVersionMap) GetMap() (versionMap map[int32]uint64) { + versionMap = make(map[int32]uint64, 0) + for _, entry := range bundleVersionMap.Versions { + versionMap[entry.Version] = entry.Height + } + return +} diff --git a/x/delegation/keeper/exported_functions.go b/x/delegation/keeper/exported_functions.go index a43e304d..aa87037a 100644 --- a/x/delegation/keeper/exported_functions.go +++ b/x/delegation/keeper/exported_functions.go @@ -1,9 +1,11 @@ package keeper import ( + "cosmossdk.io/errors" "github.com/KYVENetwork/chain/util" "github.com/KYVENetwork/chain/x/delegation/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" ) // These functions are meant to be called from external modules @@ -43,24 +45,28 @@ func (k Keeper) GetDelegationOfPool(ctx sdk.Context, poolId uint64) uint64 { // PayoutRewards transfers `amount` $nKYVE from the `payerModuleName`-module to the delegation module. // It then awards these tokens internally to all delegators of staker `staker`. // Delegators can then receive these rewards if they call the `withdraw`-transaction. -// This method returns false if the payout fails. This happens usually if there are no -// delegators for that staker. If this happens one should do something else with the rewards. -func (k Keeper) PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) (success bool) { +// If the staker has no delegators or the module to module transfer fails the method fails and +// returns the error. +func (k Keeper) PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) error { + // Assert there is an amount + if amount == 0 { + return nil + } + // Assert there are delegators - if k.DoesDelegationDataExist(ctx, staker) { + if !k.DoesDelegationDataExist(ctx, staker) { + return errors.Wrapf(sdkErrors.ErrLogic, "Staker has no delegators which can be paid out.") + } - // Add amount to the rewards pool - k.AddAmountToDelegationRewards(ctx, staker, amount) + // Add amount to the rewards pool + k.AddAmountToDelegationRewards(ctx, staker, amount) - // Transfer tokens to the delegation module - err := util.TransferFromModuleToModule(k.bankKeeper, ctx, payerModuleName, types.ModuleName, amount) - if err != nil { - util.PanicHalt(k.upgradeKeeper, ctx, "Not enough tokens in module") - return false - } - return true + // Transfer tokens to the delegation module + if err := util.TransferFromModuleToModule(k.bankKeeper, ctx, payerModuleName, types.ModuleName, amount); err != nil { + return err } - return false + + return nil } // SlashDelegators reduces the delegation of all delegators of `staker` by fraction diff --git a/x/delegation/keeper/keeper_suite_test.go b/x/delegation/keeper/keeper_suite_test.go index 37185cbb..160587f1 100644 --- a/x/delegation/keeper/keeper_suite_test.go +++ b/x/delegation/keeper/keeper_suite_test.go @@ -18,15 +18,16 @@ func TestDelegationKeeper(t *testing.T) { } func PayoutRewards(s *i.KeeperTestSuite, staker string, amount uint64) { - err := s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) + payout, err := s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) Expect(err).To(BeNil()) - success := s.App().DelegationKeeper.PayoutRewards(s.Ctx(), staker, amount, pooltypes.ModuleName) - Expect(success).To(BeTrue()) + err = s.App().DelegationKeeper.PayoutRewards(s.Ctx(), staker, amount, pooltypes.ModuleName) + Expect(err).NotTo(HaveOccurred()) + Expect(amount).To(Equal(payout)) } func CreateFundedPool(s *i.KeeperTestSuite) { s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/delegation/keeper/msg_server_redelegate_test.go b/x/delegation/keeper/msg_server_redelegate_test.go index b56b7f0c..43dc8361 100644 --- a/x/delegation/keeper/msg_server_redelegate_test.go +++ b/x/delegation/keeper/msg_server_redelegate_test.go @@ -35,7 +35,8 @@ var _ = Describe("Delegation - Redelegation", Ordered, func() { CreateFundedPool(s) s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "EnabledPool", + Name: "EnabledPool", + MinDelegation: 1_000 * i.KYVE, Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/delegation/keeper/msg_server_withdraw_rewards_test.go b/x/delegation/keeper/msg_server_withdraw_rewards_test.go index fc062d4a..331eaadb 100644 --- a/x/delegation/keeper/msg_server_withdraw_rewards_test.go +++ b/x/delegation/keeper/msg_server_withdraw_rewards_test.go @@ -153,14 +153,22 @@ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { It("Test invalid payouts to delegators", func() { // ARRANGE - forkedCtx, _ := s.Ctx().CacheContext() + + // fund pool module + s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) // ACT - success1 := s.App().DelegationKeeper.PayoutRewards(forkedCtx, i.ALICE, 20000*i.KYVE, pooltypes.ModuleName) - success2 := s.App().DelegationKeeper.PayoutRewards(s.Ctx(), i.DUMMY[20], 0*i.KYVE, pooltypes.ModuleName) + // not enough balance in pool module + err1 := s.App().DelegationKeeper.PayoutRewards(s.Ctx(), i.ALICE, 20000*i.KYVE, pooltypes.ModuleName) + // staker does not exist + err2 := s.App().DelegationKeeper.PayoutRewards(s.Ctx(), i.DUMMY[20], 1*i.KYVE, pooltypes.ModuleName) // ASSERT - Expect(success1).To(BeFalse()) - Expect(success2).To(BeFalse()) + Expect(err1).To(HaveOccurred()) + Expect(err2).To(HaveOccurred()) }) }) diff --git a/x/delegation/spec/07_exported.md b/x/delegation/spec/07_exported.md index 9772bfc9..7ae0aa21 100644 --- a/x/delegation/spec/07_exported.md +++ b/x/delegation/spec/07_exported.md @@ -25,9 +25,9 @@ type DelegationKeeper interface { // PayoutRewards transfers `amount` $nKYVE from the `payerModuleName`-module to the delegation module. // It then awards these tokens internally to all delegators of staker `staker`. // Delegators can then receive these rewards if they call the `withdraw`-transaction. - // This method returns false if the payout fails. This happens usually if there are no - // delegators for that staker. If this happens one should do something else with the rewards. - PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) (success bool) + // If the staker has no delegators or the module to module transfer fails the method fails and + // returns the error. + PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) error // SlashDelegators reduces the delegation of all delegators of `staker` by fraction // and transfers the amount to the Treasury. diff --git a/x/pool/client/cli/query.go b/x/pool/client/cli/query.go new file mode 100644 index 00000000..37080a34 --- /dev/null +++ b/x/pool/client/cli/query.go @@ -0,0 +1,23 @@ +package cli + +import ( + "fmt" + + "github.com/KYVENetwork/chain/x/pool/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" +) + +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + + return cmd +} diff --git a/x/pool/client/cli/query_params.go b/x/pool/client/cli/query_params.go new file mode 100644 index 00000000..26f58d78 --- /dev/null +++ b/x/pool/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/KYVENetwork/chain/x/pool/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/pool/genesis.go b/x/pool/genesis.go index 33d12006..23b30394 100644 --- a/x/pool/genesis.go +++ b/x/pool/genesis.go @@ -8,6 +8,8 @@ import ( // InitGenesis initializes the pool module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + k.SetParams(ctx, genState.Params) + for _, elem := range genState.PoolList { k.SetPool(ctx, elem) } @@ -19,6 +21,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) genesis.PoolList = k.GetAllPools(ctx) genesis.PoolCount = k.GetPoolCount(ctx) diff --git a/x/pool/keeper/getters_params.go b/x/pool/keeper/getters_params.go new file mode 100644 index 00000000..bf311ec9 --- /dev/null +++ b/x/pool/keeper/getters_params.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/pool/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams returns the x/pool params from state. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + bz := ctx.KVStore(k.storeKey).Get(types.ParamsKey) + if bz != nil { + k.cdc.MustUnmarshal(bz, ¶ms) + } + + return +} + +// GetProtocolInflationShare returns the ProtocolInflationShare param. +func (k Keeper) GetProtocolInflationShare(ctx sdk.Context) (res sdk.Dec) { + return k.GetParams(ctx).ProtocolInflationShare +} + +// GetPoolInflationPayoutRate returns the GetPoolInflationPayoutRate param +func (k Keeper) GetPoolInflationPayoutRate(ctx sdk.Context) (res sdk.Dec) { + return k.GetParams(ctx).PoolInflationPayoutRate +} + +// SetParams stores the x/pool params in state. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + bz := k.cdc.MustMarshal(¶ms) + ctx.KVStore(k.storeKey).Set(types.ParamsKey, bz) +} diff --git a/x/pool/keeper/grpc_query.go b/x/pool/keeper/grpc_query.go new file mode 100644 index 00000000..2b92ddf8 --- /dev/null +++ b/x/pool/keeper/grpc_query.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "context" + + "github.com/KYVENetwork/chain/x/pool/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/pool/keeper/keeper.go b/x/pool/keeper/keeper.go index a3a4200b..bf73b53f 100644 --- a/x/pool/keeper/keeper.go +++ b/x/pool/keeper/keeper.go @@ -3,45 +3,57 @@ package keeper import ( "fmt" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - "github.com/cometbft/cometbft/libs/log" - - "github.com/KYVENetwork/chain/x/pool/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storeTypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + + // Auth + authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + // Bank + bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + // Distribution + distributionKeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + // Mint + mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + // Pool + "github.com/KYVENetwork/chain/x/pool/types" + // Team + teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" ) type ( Keeper struct { cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey + storeKey storeTypes.StoreKey + memKey storeTypes.StoreKey authority string stakersKeeper types.StakersKeeper - accountKeeper authkeeper.AccountKeeper - bankKeeper bankkeeper.Keeper - distrkeeper distrkeeper.Keeper + accountKeeper authKeeper.AccountKeeper + bankKeeper bankKeeper.Keeper + distrkeeper distributionKeeper.Keeper + mintKeeper mintKeeper.Keeper upgradeKeeper types.UpgradeKeeper + teamKeeper teamKeeper.Keeper } ) func NewKeeper( cdc codec.BinaryCodec, - storeKey storetypes.StoreKey, - memKey storetypes.StoreKey, + storeKey storeTypes.StoreKey, + memKey storeTypes.StoreKey, authority string, - accountKeeper authkeeper.AccountKeeper, - bankKeeper bankkeeper.Keeper, - distrKeeper distrkeeper.Keeper, + accountKeeper authKeeper.AccountKeeper, + bankKeeper bankKeeper.Keeper, + distrKeeper distributionKeeper.Keeper, + mintKeeper mintKeeper.Keeper, upgradeKeeper types.UpgradeKeeper, + teamKeeper teamKeeper.Keeper, ) *Keeper { return &Keeper{ cdc: cdc, @@ -53,8 +65,29 @@ func NewKeeper( accountKeeper: accountKeeper, bankKeeper: bankKeeper, distrkeeper: distrKeeper, + mintKeeper: mintKeeper, upgradeKeeper: upgradeKeeper, + teamKeeper: teamKeeper, + } +} + +func (k Keeper) EnsurePoolAccount(ctx sdk.Context, id uint64) { + name := fmt.Sprintf("%s/%d", types.ModuleName, id) + + address := authTypes.NewModuleAddress(name) + account := k.accountKeeper.GetAccount(ctx, address) + + if account == nil { + // account doesn't exist, initialise a new module account. + account = authTypes.NewEmptyModuleAccount(name) + } else { + // account exists, adjust it to a module account. + baseAccount := authTypes.NewBaseAccount(address, nil, account.GetAccountNumber(), 0) + + account = authTypes.NewModuleAccount(baseAccount, name) } + + k.accountKeeper.SetAccount(ctx, account) } func SetStakersKeeper(k *Keeper, stakersKeeper types.StakersKeeper) { @@ -65,6 +98,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) StoreKey() storetypes.StoreKey { +func (k Keeper) StoreKey() storeTypes.StoreKey { return k.storeKey } diff --git a/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go b/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go index e0e0d633..416361ce 100644 --- a/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go +++ b/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go @@ -29,7 +29,7 @@ var _ = Describe("logic_end_block_handle_pool_upgrades.go", Ordered, func() { // create clean pool for every test case s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", MaxBundleSize: 100, StartKey: "0", MinDelegation: 100 * i.KYVE, diff --git a/x/pool/keeper/logic_funders.go b/x/pool/keeper/logic_funders.go index f72c2972..d5ad55d1 100644 --- a/x/pool/keeper/logic_funders.go +++ b/x/pool/keeper/logic_funders.go @@ -1,8 +1,7 @@ package keeper import ( - "github.com/KYVENetwork/chain/util" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" + poolTypes "github.com/KYVENetwork/chain/x/pool/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -10,69 +9,56 @@ import ( // the appropriate amount from each funder. // All funders who can't afford the amount, are kicked out. // Their remaining amount is transferred to the Treasury. -// The function throws an error if pool ran out of funds. // This method does not transfer any funds. The bundles-module // is responsible for transferring the rewards out of the module. -func (k Keeper) ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) error { +func (k Keeper) ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) { pool, poolErr := k.GetPoolWithError(ctx, poolId) if poolErr != nil { - return poolErr + return 0, poolErr + } + + // if pool has no funders we immediately return + if len(pool.Funders) == 0 { + return payout, err } // This is the amount every funder will be charged - var amountPerFunder uint64 + amountPerFunder := amount / uint64(len(pool.Funders)) // Due to discrete division there will be a reminder which can not be split // equally among all funders. This amount is charged to the lowest funder - var amountRemainder uint64 - - // When a funder is not able to pay, all the remaining funds will be moved - // to the treasury. - var slashedFunds uint64 - - // Remove all funders who can not afford amountPerFunder - for len(pool.Funders) > 0 { - amountPerFunder = amount / uint64(len(pool.Funders)) - amountRemainder = amount - amountPerFunder*uint64(len(pool.Funders)) + amountRemainder := amount - amountPerFunder*uint64(len(pool.Funders)) - lowestFunder := pool.GetLowestFunder() + funders := pool.Funders - if amountRemainder+amountPerFunder > lowestFunder.Amount { - pool.RemoveFunder(lowestFunder.Address) - - _ = ctx.EventManager().EmitTypedEvent(&pooltypes.EventPoolFundsSlashed{ - PoolId: poolId, - Address: lowestFunder.Address, - Amount: lowestFunder.Amount, - }) - - slashedFunds += lowestFunder.Amount + for _, funder := range funders { + if funder.Amount < amountPerFunder { + pool.RemoveFunder(funder.Address) + payout += funder.Amount } else { - break + pool.SubtractAmountFromFunder(funder.Address, amountPerFunder) + payout += amountPerFunder } } - if slashedFunds > 0 { - // send slash to treasury - if err := util.TransferFromModuleToTreasury(k.accountKeeper, k.distrkeeper, ctx, pooltypes.ModuleName, slashedFunds); err != nil { - util.PanicHalt(k.upgradeKeeper, ctx, "pool module out of funds") + lowestFunder := pool.GetLowestFunder() + + if lowestFunder.Address != "" { + if lowestFunder.Amount < amountRemainder { + pool.RemoveFunder(lowestFunder.Address) + payout += lowestFunder.Amount + } else { + pool.SubtractAmountFromFunder(lowestFunder.Address, amountRemainder) + payout += amountRemainder } } if len(pool.Funders) == 0 { - k.SetPool(ctx, pool) - return pooltypes.ErrFundsTooLow - } - - // Remove amount from funders - for _, funder := range pool.Funders { - pool.SubtractAmountFromFunder(funder.Address, amountPerFunder) + _ = ctx.EventManager().EmitTypedEvent(&poolTypes.EventPoolOutOfFunds{ + PoolId: pool.Id, + }) } - lowestFunder := pool.GetLowestFunder() - pool.SubtractAmountFromFunder(lowestFunder.Address, amountRemainder) - k.SetPool(ctx, pool) - - return nil + return payout, nil } diff --git a/x/pool/keeper/logic_funders_test.go b/x/pool/keeper/logic_funders_test.go index ecff4204..ebb83291 100644 --- a/x/pool/keeper/logic_funders_test.go +++ b/x/pool/keeper/logic_funders_test.go @@ -10,7 +10,7 @@ import ( /* -TEST CASES - logic_funders_test.go +TEST CASES - logic_funders.go * Add funders; check total sum * Add multiple funders; check total sum @@ -20,16 +20,22 @@ TEST CASES - logic_funders_test.go * Charge Funders test remainder * Charge exactly the lowest funder amount * Kick out multiple lowest funders -* Kick out all funders +* Charge more than pool has funds +* Charge pool which has no funds at all */ -func chargeFunders(s *i.KeeperTestSuite, amount uint64) error { - err := s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) - if err == nil { - return util.TransferFromModuleToAddress(s.App().BankKeeper, s.Ctx(), pooltypes.ModuleName, i.BURNER, amount) +func chargeFunders(s *i.KeeperTestSuite, amount uint64) (payout uint64, err error) { + payout, err = s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) + if err != nil { + return 0, err } - return err + + if err := util.TransferFromModuleToAddress(s.App().BankKeeper, s.Ctx(), pooltypes.ModuleName, i.BURNER, payout); err != nil { + return 0, err + } + + return payout, err } func fundersCheck(pool *pooltypes.Pool) { @@ -43,14 +49,14 @@ func fundersCheck(pool *pooltypes.Pool) { Expect(pool.TotalFunds).To(Equal(poolFunds)) } -var _ = Describe("logic_funders_test.go", Ordered, func() { +var _ = Describe("logic_funders.go", Ordered, func() { s := i.NewCleanChain() var pool *pooltypes.Pool BeforeEach(func() { s = i.NewCleanChain() pool = &pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", MaxBundleSize: 100, StartKey: "0", MinDelegation: 100 * i.KYVE, @@ -147,10 +153,11 @@ var _ = Describe("logic_funders_test.go", Ordered, func() { Expect(pool.TotalFunds).To(Equal(50 * 100 * i.KYVE)) // ACT - err := chargeFunders(s, 50*10*i.KYVE) + payout, err := chargeFunders(s, 50*10*i.KYVE) // ASSERT Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(50 * 10 * i.KYVE)) pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.TotalFunds).To(Equal(50 * 90 * i.KYVE)) @@ -176,10 +183,11 @@ var _ = Describe("logic_funders_test.go", Ordered, func() { // ACT // Charge 10 $KYVE + 49tkyve // the 49 tkyve will be charged to the lowest funder - err := chargeFunders(s, 50*10*i.KYVE+49) + payout, err := chargeFunders(s, 50*10*i.KYVE+49) // ASSERT Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(50*10*i.KYVE + 49)) pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) @@ -213,10 +221,11 @@ var _ = Describe("logic_funders_test.go", Ordered, func() { Expect(pool.TotalFunds).To(Equal((100*40 + 200*10) * i.KYVE)) // ACT - err := chargeFunders(s, 50*100*i.KYVE) + payout, err := chargeFunders(s, 50*100*i.KYVE) // ASSERT Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(50 * 100 * i.KYVE)) pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(10)) @@ -247,16 +256,17 @@ var _ = Describe("logic_funders_test.go", Ordered, func() { // Charge 5000 // Act - err := chargeFunders(s, 5000*i.KYVE) + payout, err := chargeFunders(s, 5000*i.KYVE) // Assert Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(3000 * i.KYVE)) pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(10)) for _, funder := range pool.Funders { - Expect(funder.Amount).To(Equal(500 * i.KYVE)) + Expect(funder.Amount).To(Equal(900 * i.KYVE)) } }) @@ -274,12 +284,31 @@ var _ = Describe("logic_funders_test.go", Ordered, func() { Expect(pool.TotalFunds).To(Equal((50 * 50) * i.KYVE)) // ACT - err := chargeFunders(s, 5000*i.KYVE) + payout, err := chargeFunders(s, 5000*i.KYVE) // ASSERT - Expect(err).To(HaveOccurred()) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(2500 * i.KYVE)) + + pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + Expect(pool.Funders).To(HaveLen(0)) + }) + + It("Charge pool which has no funds at all", func() { + // ARRANGE + pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + Expect(poolFound).To(BeTrue()) + Expect(pool.TotalFunds).To(BeZero()) + + // ACT + payout, err := chargeFunders(s, 5000*i.KYVE) + + // ASSERT + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(BeZero()) pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(0)) + Expect(pool.TotalFunds).To(BeZero()) }) }) diff --git a/x/pool/keeper/logic_pool.go b/x/pool/keeper/logic_pool.go index b6348365..6bbc4855 100644 --- a/x/pool/keeper/logic_pool.go +++ b/x/pool/keeper/logic_pool.go @@ -2,6 +2,8 @@ package keeper import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" + globalTypes "github.com/KYVENetwork/chain/x/global/types" "github.com/KYVENetwork/chain/x/pool/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,6 +29,28 @@ func (k Keeper) AssertPoolExists(ctx sdk.Context, poolId uint64) error { return errors.Wrapf(errorsTypes.ErrNotFound, types.ErrPoolNotFound.Error(), poolId) } +// ChargeInflationPool charges the inflation pool and transfers the funds to the pool module +// so the payout can be performed +func (k Keeper) ChargeInflationPool(ctx sdk.Context, poolId uint64) (payout uint64, err error) { + pool, found := k.GetPool(ctx, poolId) + if !found { + return payout, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrPoolNotFound.Error(), poolId) + } + + account := pool.GetPoolAccount() + balance := k.bankKeeper.GetBalance(ctx, account, globalTypes.Denom).Amount.Int64() + + // charge X percent from current pool balance and use it as payout + payout = uint64(sdk.NewDec(balance).Mul(k.GetPoolInflationPayoutRate(ctx)).TruncateInt64()) + + // transfer funds to pool module account so bundle reward can be paid out from there + if err := util.TransferFromAddressToModule(k.bankKeeper, ctx, account.String(), types.ModuleName, payout); err != nil { + util.PanicHalt(k.upgradeKeeper, ctx, err.Error()) + } + + return payout, nil +} + // IncrementBundleInformation updates the latest finalized bundle of a pool func (k Keeper) IncrementBundleInformation( ctx sdk.Context, diff --git a/x/pool/keeper/msg_server_create_pool.go b/x/pool/keeper/msg_server_create_pool.go index 1b19972d..f69d29c8 100644 --- a/x/pool/keeper/msg_server_create_pool.go +++ b/x/pool/keeper/msg_server_create_pool.go @@ -26,7 +26,7 @@ func (k msgServer) CreatePool(goCtx context.Context, req *types.MsgCreatePool) ( ctx := sdk.UnwrapSDKContext(goCtx) - k.AppendPool(ctx, types.Pool{ + id := k.AppendPool(ctx, types.Pool{ Name: req.Name, Runtime: req.Runtime, Logo: req.Logo, @@ -46,6 +46,8 @@ func (k msgServer) CreatePool(goCtx context.Context, req *types.MsgCreatePool) ( CurrentCompressionId: req.CompressionId, }) + k.EnsurePoolAccount(ctx, id) + _ = ctx.EventManager().EmitTypedEvent(&types.EventCreatePool{ Id: k.GetPoolCount(ctx) - 1, Name: req.Name, diff --git a/x/pool/keeper/msg_server_defund_pool_test.go b/x/pool/keeper/msg_server_defund_pool_test.go index 324e49f9..e5b3aff8 100644 --- a/x/pool/keeper/msg_server_defund_pool_test.go +++ b/x/pool/keeper/msg_server_defund_pool_test.go @@ -30,7 +30,7 @@ var _ = Describe("msg_server_defund_pool.go", Ordered, func() { // create clean pool for every test case s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/pool/keeper/msg_server_disable_pool.go b/x/pool/keeper/msg_server_disable_pool.go index 6e2d98b4..fd34663c 100644 --- a/x/pool/keeper/msg_server_disable_pool.go +++ b/x/pool/keeper/msg_server_disable_pool.go @@ -3,6 +3,9 @@ package keeper import ( "context" + "github.com/KYVENetwork/chain/util" + globalTypes "github.com/KYVENetwork/chain/x/global/types" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -41,6 +44,13 @@ func (k msgServer) DisablePool( k.stakersKeeper.LeavePool(ctx, staker, pool.Id) } + // send remaining pool assets to treasury + if balance := k.bankKeeper.GetBalance(ctx, pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64(); balance > 0 { + if err := util.TransferFromAddressToTreasury(k.distrkeeper, ctx, pool.GetPoolAccount().String(), balance); err != nil { + return nil, err + } + } + _ = ctx.EventManager().EmitTypedEvent(&types.EventPoolDisabled{Id: req.Id}) return &types.MsgDisablePoolResponse{}, nil diff --git a/x/pool/keeper/msg_server_disable_pool_test.go b/x/pool/keeper/msg_server_disable_pool_test.go index 4ed81bf6..25251059 100644 --- a/x/pool/keeper/msg_server_disable_pool_test.go +++ b/x/pool/keeper/msg_server_disable_pool_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + globalTypes "github.com/KYVENetwork/chain/x/global/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,6 +24,7 @@ TEST CASES - msg_server_disabled_pool.go * Invalid authority (proposal) * Disable a non-existing pool * Disable pool which is active +* Disable pool which is active and has a balance * Disable pool which is already disabled * Disable multiple pools * Kick out all stakers from pool @@ -153,6 +155,88 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { Expect(proposal.Status).To(Equal(govV1Types.StatusFailed)) }) + It("Disable pool which is active", func() { + // ARRANGE + msg := &types.MsgDisablePool{ + Authority: gov, + Id: 0, + } + + p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) + + // ACT + _, submitErr := s.RunTx(&p) + _, voteErr := s.RunTx(&v) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + proposal, _ := s.App().GovKeeper.GetProposal(s.Ctx(), 1) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + Expect(submitErr).To(Not(HaveOccurred())) + Expect(voteErr).To(Not(HaveOccurred())) + + Expect(proposal.Status).To(Equal(govV1Types.StatusPassed)) + Expect(pool.Disabled).To(BeTrue()) + + bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) + Expect(bundleProposal.StorageId).To(BeEmpty()) + + // assert empty pool balance + b := s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() + Expect(b).To(BeZero()) + }) + + It("Disable pool which is active and has a balance", func() { + // ARRANGE + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + s.App().PoolKeeper.SetParams(s.Ctx(), types.Params{ + ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), + PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.05"), + }) + + for i := 0; i < 100; i++ { + s.Commit() + } + + b := s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() + Expect(b).To(BeNumerically(">", uint64(0))) + + msg := &types.MsgDisablePool{ + Authority: gov, + Id: 0, + } + + p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) + + // ACT + _, submitErr := s.RunTx(&p) + _, voteErr := s.RunTx(&v) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + proposal, _ := s.App().GovKeeper.GetProposal(s.Ctx(), 1) + pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + Expect(submitErr).To(Not(HaveOccurred())) + Expect(voteErr).To(Not(HaveOccurred())) + + Expect(proposal.Status).To(Equal(govV1Types.StatusPassed)) + Expect(pool.Disabled).To(BeTrue()) + + bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) + Expect(bundleProposal.StorageId).To(BeEmpty()) + + // assert empty pool balance + b = s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() + Expect(b).To(BeZero()) + }) + It("Disable pool which is active", func() { // ARRANGE msg := &types.MsgDisablePool{ diff --git a/x/pool/keeper/msg_server_fund_pool_test.go b/x/pool/keeper/msg_server_fund_pool_test.go index 6cc6fb8f..8dc9c6ba 100644 --- a/x/pool/keeper/msg_server_fund_pool_test.go +++ b/x/pool/keeper/msg_server_fund_pool_test.go @@ -33,7 +33,7 @@ var _ = Describe("msg_server_fund_pool.go", Ordered, func() { // create clean pool for every test case s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/pool/keeper/msg_server_update_params.go b/x/pool/keeper/msg_server_update_params.go new file mode 100644 index 00000000..9209b960 --- /dev/null +++ b/x/pool/keeper/msg_server_update_params.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + "encoding/json" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + // Gov + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + // Pool + "github.com/KYVENetwork/chain/x/pool/types" +) + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.authority != msg.Authority { + return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + oldParams := k.GetParams(ctx) + + newParams := oldParams + _ = json.Unmarshal([]byte(msg.Payload), &newParams) + k.SetParams(ctx, newParams) + + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + OldParams: oldParams, + NewParams: newParams, + Payload: msg.Payload, + }) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/pool/keeper/msg_server_update_params_test.go b/x/pool/keeper/msg_server_update_params_test.go new file mode 100644 index 00000000..b4703cc9 --- /dev/null +++ b/x/pool/keeper/msg_server_update_params_test.go @@ -0,0 +1,329 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + sdk "github.com/cosmos/cosmos-sdk/types" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + // Pool + "github.com/KYVENetwork/chain/x/pool/types" + // Gov + govV1Types "github.com/cosmos/cosmos-sdk/x/gov/types/v1" +) + +/* + +TEST CASES - msg_server_update_params.go + +* Check default params +* Invalid authority (transaction) +* Invalid authority (proposal) +* Update every param at once +* Update no param +* Update with invalid formatted payload + +* Update protocol inflation share +* Update protocol inflation share with invalid value + +* Update pool inflation payout rate +* Update pool inflation payout rate with invalid value + +*/ + +var _ = Describe("msg_server_update_params.go", Ordered, func() { + s := i.NewCleanChain() + + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + + minDeposit := s.App().GovKeeper.GetParams(s.Ctx()).MinDeposit + votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod + + delegations := s.App().StakingKeeper.GetAllDelegations(s.Ctx()) + voter := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + BeforeEach(func() { + s = i.NewCleanChain() + + delegations := s.App().StakingKeeper.GetAllDelegations(s.Ctx()) + voter = sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Check default params", func() { + // ASSERT + params := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(params.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(params.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) + + It("Invalid authority (transaction)", func() { + // ARRANGE + msg := &types.MsgUpdateParams{ + Authority: i.DUMMY[0], + Payload: "{}", + } + + // ACT + _, err := s.RunTx(msg) + + // ASSERT + Expect(err).To(HaveOccurred()) + }) + + It("Invalid authority (proposal)", func() { + // ARRANGE + msg := &types.MsgUpdateParams{ + Authority: i.DUMMY[0], + Payload: "{}", + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, err := s.RunTx(proposal) + + // ASSERT + Expect(err).To(HaveOccurred()) + }) + + It("Update every param at once", func() { + // ARRANGE + payload := `{ + "protocol_inflation_share": "0.2", + "pool_inflation_payout_rate": "0.05" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(sdk.MustNewDecFromStr("0.2"))) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(sdk.MustNewDecFromStr("0.05"))) + }) + + It("Update no params", func() { + // ARRANGE + payload := `{}` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) + + It("Update with invalid formatted payload", func() { + // ARRANGE + payload := `{ + "protocol_inflation_share: 20 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) + + It("Update protocol inflation share", func() { + // ARRANGE + payload := `{ + "protocol_inflation_share": "0.07" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(sdk.MustNewDecFromStr("0.07"))) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) + + It("Update protocol inflation share with invalid value", func() { + // ARRANGE + payload := `{ + "protocol_inflation_share": "invalid" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) + + It("Update pool inflation payout rate", func() { + // ARRANGE + payload := `{ + "pool_inflation_payout_rate": "0.2" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(sdk.MustNewDecFromStr("0.2"))) + }) + + It("Update pool inflation payout rate with invalid value", func() { + // ARRANGE + payload := `{ + "pool_inflation_payout_rate": "1.2" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().PoolKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.ProtocolInflationShare).To(Equal(types.DefaultProtocolInflationShare)) + Expect(updatedParams.PoolInflationPayoutRate).To(Equal(types.DefaultPoolInflationPayoutRate)) + }) +}) diff --git a/x/pool/keeper/msg_server_update_pool_test.go b/x/pool/keeper/msg_server_update_pool_test.go index 27a9cf3b..8468e995 100644 --- a/x/pool/keeper/msg_server_update_pool_test.go +++ b/x/pool/keeper/msg_server_update_pool_test.go @@ -322,33 +322,12 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { Expect(pool.Name).To(BeEmpty()) }) - It("Update pool with invalid UploadInterval", func() { - // ARRANGE - msg := &types.MsgUpdatePool{ - Authority: gov, - Id: 1, - Payload: "{\"UploadInterval\": 0}", - } - - p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) - - // ACT - _ = s.RunTxError(&p) - s.Commit() - - // ASSERT - pool, found := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(found).To(BeTrue()) - Expect(pool.Name).To(BeEmpty()) - }) - It("Update pool with invalid OperatingCost", func() { // ARRANGE msg := &types.MsgUpdatePool{ Authority: gov, Id: 1, - Payload: "{\"OperatingCost\": 0}", + Payload: "{\"OperatingCost\": -1}", } p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -369,7 +348,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { msg := &types.MsgUpdatePool{ Authority: gov, Id: 1, - Payload: "{\"MinDelegation\": 0}", + Payload: "{\"MinDelegation\": -1}", } p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) diff --git a/x/pool/module.go b/x/pool/module.go index 1cf2d113..08e4df6b 100644 --- a/x/pool/module.go +++ b/x/pool/module.go @@ -1,24 +1,30 @@ package pool import ( + "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/cometbft/cometbft/abci/types" + // Bank + bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + + // Pool "github.com/KYVENetwork/chain/x/pool/client/cli" "github.com/KYVENetwork/chain/x/pool/keeper" "github.com/KYVENetwork/chain/x/pool/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + + // Upgrade + upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" ) var ( @@ -69,7 +75,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module -func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module func (a AppModuleBasic) GetTxCmd() *cobra.Command { @@ -78,7 +86,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return nil + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- @@ -92,6 +100,7 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper bankKeeper.Keeper + upgradeKeeper upgradeKeeper.Keeper } func NewAppModule( @@ -99,12 +108,14 @@ func NewAppModule( keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper bankKeeper.Keeper, + upgradeKeeper upgradeKeeper.Keeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + upgradeKeeper: upgradeKeeper, } } @@ -114,6 +125,7 @@ func (AppModule) QuerierRoute() string { return types.RouterKey } // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) diff --git a/x/pool/spec/01_concepts.md b/x/pool/spec/01_concepts.md index 0c7dd605..ba23eb0a 100644 --- a/x/pool/spec/01_concepts.md +++ b/x/pool/spec/01_concepts.md @@ -26,3 +26,9 @@ stakeholders of the data that is being archived and therefore have a strong inte in further archiving the data. Once a valid bundle is produced and the reward is paid out the pool module takes care of correctly deducting the funds equally from each funder in order to guarantee a steady pool economy. + +## Inflation Splitting + +In order to support funders inflation splitting was introduced where a part of the block inflation +goes to the protocol and is paid out with the funds from the funders. This relieves the burden of the +funders to keep a pool alive and allows a pool to even run without any funds. diff --git a/x/pool/spec/02_state.md b/x/pool/spec/02_state.md index 2925d314..17c51672 100644 --- a/x/pool/spec/02_state.md +++ b/x/pool/spec/02_state.md @@ -8,12 +8,16 @@ The module is mainly responsible for holding the pools state and keeping track of pool funders. ## Pools + The pool object is rather large and holds multiple sub-objects grouped by functionality. ### Pool + Pool is the main type and holds everything a pool needs to know including some -sub-objects which are listed below. +sub-objects which are listed below. Each pool has their own module account, storing +the funds from the inflation split in order to pay those out with the funders to the +pool participants. The pool account is defined by the following: `pool/$ID` - Pool: `0x01 | PoolId -> ProtocolBuffer(pool)` diff --git a/x/pool/spec/05_params.md b/x/pool/spec/05_params.md index 563fc3ab..0ecb4a1a 100644 --- a/x/pool/spec/05_params.md +++ b/x/pool/spec/05_params.md @@ -4,4 +4,9 @@ order: 5 # Parameters -The pool module has no params +The pool module contains the following parameters: + +| Key | Type | Example | +|-------------------------|-------------------------|---------| +| ProtocolInflationShare | sdk.Dec (%) | 0.05 | +| PoolInflationPayoutRate | sdk.Dec (%) | 0.1 | diff --git a/x/pool/spec/07_exported.md b/x/pool/spec/07_exported.md index bc3b75d9..cdf6c302 100644 --- a/x/pool/spec/07_exported.md +++ b/x/pool/spec/07_exported.md @@ -28,10 +28,7 @@ type PoolKeeper interface { // ChargeFundersOfPool equally splits the amount between all funders and removes // the appropriate amount from each funder. // All funders who can't afford the amount, are kicked out. - // Their remaining amount is transferred to the Treasury. - // The function throws an error if pool ran out of funds. - // This method does not transfer any funds. The bundles-module - // is responsible for transferring the rewards out of the module. - ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) error + // The method returns the payout amount the pool was able to charge from the funders. + ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) } ``` diff --git a/x/pool/types/codec.go b/x/pool/types/codec.go index 394956cf..b6f742a4 100644 --- a/x/pool/types/codec.go +++ b/x/pool/types/codec.go @@ -22,6 +22,7 @@ func RegisterInterfaces(registry codecTypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgEnablePool{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgScheduleRuntimeUpgrade{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCancelRuntimeUpgrade{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}) } var ( diff --git a/x/pool/types/events.pb.go b/x/pool/types/events.pb.go index dc1213d8..e2718420 100644 --- a/x/pool/types/events.pb.go +++ b/x/pool/types/events.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -22,6 +23,71 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// EventUpdateParams is an event emitted when the module parameters are updated. +// emitted_by: MsgUpdateParams +type EventUpdateParams struct { + // old_params is the module's old parameters. + OldParams Params `protobuf:"bytes,1,opt,name=old_params,json=oldParams,proto3" json:"old_params"` + // new_params is the module's new parameters. + NewParams Params `protobuf:"bytes,2,opt,name=new_params,json=newParams,proto3" json:"new_params"` + // payload is the parameter updates that were performed. + Payload string `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *EventUpdateParams) Reset() { *m = EventUpdateParams{} } +func (m *EventUpdateParams) String() string { return proto.CompactTextString(m) } +func (*EventUpdateParams) ProtoMessage() {} +func (*EventUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_c1828a100d789238, []int{0} +} +func (m *EventUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateParams.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 *EventUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateParams.Merge(m, src) +} +func (m *EventUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateParams proto.InternalMessageInfo + +func (m *EventUpdateParams) GetOldParams() Params { + if m != nil { + return m.OldParams + } + return Params{} +} + +func (m *EventUpdateParams) GetNewParams() Params { + if m != nil { + return m.NewParams + } + return Params{} +} + +func (m *EventUpdateParams) GetPayload() string { + if m != nil { + return m.Payload + } + return "" +} + // EventCreatePool ... // emitted_by: EndBlock(gov) type EventCreatePool struct { @@ -67,7 +133,7 @@ func (m *EventCreatePool) Reset() { *m = EventCreatePool{} } func (m *EventCreatePool) String() string { return proto.CompactTextString(m) } func (*EventCreatePool) ProtoMessage() {} func (*EventCreatePool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{0} + return fileDescriptor_c1828a100d789238, []int{1} } func (m *EventCreatePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -205,7 +271,7 @@ func (m *EventPoolEnabled) Reset() { *m = EventPoolEnabled{} } func (m *EventPoolEnabled) String() string { return proto.CompactTextString(m) } func (*EventPoolEnabled) ProtoMessage() {} func (*EventPoolEnabled) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{1} + return fileDescriptor_c1828a100d789238, []int{2} } func (m *EventPoolEnabled) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +318,7 @@ func (m *EventPoolDisabled) Reset() { *m = EventPoolDisabled{} } func (m *EventPoolDisabled) String() string { return proto.CompactTextString(m) } func (*EventPoolDisabled) ProtoMessage() {} func (*EventPoolDisabled) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{2} + return fileDescriptor_c1828a100d789238, []int{3} } func (m *EventPoolDisabled) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -311,7 +377,7 @@ func (m *EventRuntimeUpgradeScheduled) Reset() { *m = EventRuntimeUpgrad func (m *EventRuntimeUpgradeScheduled) String() string { return proto.CompactTextString(m) } func (*EventRuntimeUpgradeScheduled) ProtoMessage() {} func (*EventRuntimeUpgradeScheduled) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{3} + return fileDescriptor_c1828a100d789238, []int{4} } func (m *EventRuntimeUpgradeScheduled) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -396,7 +462,7 @@ func (m *EventRuntimeUpgradeCancelled) Reset() { *m = EventRuntimeUpgrad func (m *EventRuntimeUpgradeCancelled) String() string { return proto.CompactTextString(m) } func (*EventRuntimeUpgradeCancelled) ProtoMessage() {} func (*EventRuntimeUpgradeCancelled) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{4} + return fileDescriptor_c1828a100d789238, []int{5} } func (m *EventRuntimeUpgradeCancelled) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -479,7 +545,7 @@ func (m *EventPoolUpdated) Reset() { *m = EventPoolUpdated{} } func (m *EventPoolUpdated) String() string { return proto.CompactTextString(m) } func (*EventPoolUpdated) ProtoMessage() {} func (*EventPoolUpdated) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{5} + return fileDescriptor_c1828a100d789238, []int{6} } func (m *EventPoolUpdated) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -607,7 +673,7 @@ func (m *EventFundPool) Reset() { *m = EventFundPool{} } func (m *EventFundPool) String() string { return proto.CompactTextString(m) } func (*EventFundPool) ProtoMessage() {} func (*EventFundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{6} + return fileDescriptor_c1828a100d789238, []int{7} } func (m *EventFundPool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -672,7 +738,7 @@ func (m *EventDefundPool) Reset() { *m = EventDefundPool{} } func (m *EventDefundPool) String() string { return proto.CompactTextString(m) } func (*EventDefundPool) ProtoMessage() {} func (*EventDefundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{7} + return fileDescriptor_c1828a100d789238, []int{8} } func (m *EventDefundPool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -737,7 +803,7 @@ func (m *EventPoolFundsSlashed) Reset() { *m = EventPoolFundsSlashed{} } func (m *EventPoolFundsSlashed) String() string { return proto.CompactTextString(m) } func (*EventPoolFundsSlashed) ProtoMessage() {} func (*EventPoolFundsSlashed) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{8} + return fileDescriptor_c1828a100d789238, []int{9} } func (m *EventPoolFundsSlashed) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -798,7 +864,7 @@ func (m *EventPoolOutOfFunds) Reset() { *m = EventPoolOutOfFunds{} } func (m *EventPoolOutOfFunds) String() string { return proto.CompactTextString(m) } func (*EventPoolOutOfFunds) ProtoMessage() {} func (*EventPoolOutOfFunds) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{9} + return fileDescriptor_c1828a100d789238, []int{10} } func (m *EventPoolOutOfFunds) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -835,6 +901,7 @@ func (m *EventPoolOutOfFunds) GetPoolId() uint64 { } func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.pool.v1beta1.EventUpdateParams") proto.RegisterType((*EventCreatePool)(nil), "kyve.pool.v1beta1.EventCreatePool") proto.RegisterType((*EventPoolEnabled)(nil), "kyve.pool.v1beta1.EventPoolEnabled") proto.RegisterType((*EventPoolDisabled)(nil), "kyve.pool.v1beta1.EventPoolDisabled") @@ -850,52 +917,107 @@ func init() { func init() { proto.RegisterFile("kyve/pool/v1beta1/events.proto", fileDescriptor_c1828a100d789238) } var fileDescriptor_c1828a100d789238 = []byte{ - // 706 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xc1, 0x4e, 0x1b, 0x3b, - 0x14, 0x65, 0x92, 0x10, 0xc0, 0x90, 0xe4, 0x65, 0xd0, 0x7b, 0x6f, 0xf4, 0x5e, 0x15, 0xa5, 0xa9, - 0x68, 0x69, 0x17, 0x89, 0x50, 0xbf, 0xa0, 0x04, 0x2a, 0x45, 0x48, 0x05, 0x25, 0xa2, 0x52, 0x51, - 0x25, 0xcb, 0x19, 0xdf, 0x4c, 0x2c, 0x66, 0xec, 0x91, 0xed, 0x09, 0x84, 0xaf, 0xe8, 0x17, 0xf4, - 0x6b, 0xba, 0xe8, 0x92, 0x45, 0x17, 0x5d, 0x56, 0xf0, 0x23, 0x95, 0x3d, 0x93, 0x51, 0x02, 0xa1, - 0xea, 0xa2, 0x95, 0xba, 0x9b, 0x7b, 0xee, 0xb1, 0xaf, 0x7d, 0xce, 0xbd, 0x63, 0xd4, 0x38, 0x9f, - 0x4e, 0xa0, 0x13, 0x0b, 0x11, 0x76, 0x26, 0x7b, 0x43, 0xd0, 0x64, 0xaf, 0x03, 0x13, 0xe0, 0x5a, - 0xb5, 0x63, 0x29, 0xb4, 0x70, 0xeb, 0x26, 0xdf, 0x36, 0xf9, 0x76, 0x96, 0x6f, 0x7d, 0x2a, 0xa2, - 0xda, 0xa1, 0xe1, 0x74, 0x25, 0x10, 0x0d, 0x27, 0x42, 0x84, 0x6e, 0x15, 0x15, 0x18, 0xf5, 0x9c, - 0xa6, 0xb3, 0x5b, 0xea, 0x17, 0x18, 0x75, 0x5d, 0x54, 0xe2, 0x24, 0x02, 0xaf, 0xd0, 0x74, 0x76, - 0x37, 0xfa, 0xf6, 0xdb, 0xf5, 0xd0, 0x9a, 0x4c, 0xb8, 0x66, 0x11, 0x78, 0x45, 0x0b, 0xcf, 0x42, - 0xc3, 0x0e, 0x45, 0x20, 0xbc, 0x52, 0xca, 0x36, 0xdf, 0xee, 0x3f, 0xa8, 0xec, 0x0b, 0x3e, 0x62, - 0x81, 0xb7, 0x6a, 0xd1, 0x2c, 0x72, 0xff, 0x47, 0x1b, 0x4a, 0x13, 0xa9, 0xf1, 0x39, 0x4c, 0xbd, - 0xb2, 0x4d, 0xad, 0x5b, 0xe0, 0x08, 0xa6, 0xee, 0x33, 0x54, 0x4b, 0xe2, 0x50, 0x10, 0x8a, 0x19, - 0xd7, 0x20, 0x27, 0x24, 0xf4, 0xd6, 0xec, 0x99, 0xaa, 0x29, 0xdc, 0xcb, 0x50, 0x77, 0x07, 0x55, - 0x45, 0x0c, 0x92, 0x68, 0xc6, 0x03, 0xec, 0x0b, 0xa5, 0xbd, 0x75, 0xcb, 0xab, 0xe4, 0x68, 0x57, - 0x28, 0x6d, 0x68, 0x11, 0xe3, 0x98, 0x42, 0x08, 0x01, 0xd1, 0x4c, 0x70, 0x6f, 0x23, 0xa5, 0x45, - 0x8c, 0x1f, 0xe4, 0xa0, 0xfb, 0x14, 0xd5, 0x22, 0x72, 0x89, 0x87, 0x09, 0xa7, 0x21, 0x60, 0xc5, - 0xae, 0xc0, 0x43, 0x19, 0x8f, 0x5c, 0xee, 0x5b, 0x74, 0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 0xb6, 0x2f, 0xa2, 0xce, 0xd1, 0xbb, 0xb7, 0x87, 0x6f, 0x40, 0x5f, - 0x08, 0x79, 0xde, 0xf1, 0xc7, 0x84, 0xf1, 0xce, 0x65, 0xfa, 0x3a, 0xe9, 0x69, 0x0c, 0x6a, 0x58, - 0xb6, 0xaf, 0xd2, 0xcb, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x13, 0xf3, 0x39, 0x99, 0xb7, 0x06, - 0x00, 0x00, + // 792 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xeb, 0x44, + 0x14, 0x8e, 0x93, 0x34, 0x6d, 0x26, 0x4d, 0x42, 0x7c, 0xf9, 0x31, 0x05, 0x85, 0x10, 0x74, 0xa1, + 0xb0, 0x70, 0x74, 0x61, 0x8f, 0x44, 0xd3, 0x22, 0x45, 0x57, 0xe2, 0x5e, 0x25, 0xba, 0x48, 0x54, + 0x48, 0xd6, 0xc4, 0x73, 0xe2, 0x8c, 0x6a, 0xcf, 0x58, 0x33, 0xe3, 0xa4, 0xe9, 0x53, 0xf0, 0x04, + 0xbc, 0x01, 0x6f, 0xc1, 0xa2, 0xcb, 0x2e, 0x58, 0xb0, 0x42, 0xa8, 0x7d, 0x11, 0x34, 0xe3, 0x1f, + 0x92, 0xd6, 0x45, 0x5d, 0x80, 0xc4, 0xce, 0xe7, 0x9c, 0xef, 0xfc, 0xcc, 0xf9, 0xce, 0x97, 0xa0, + 0xfe, 0xc5, 0x66, 0x05, 0xa3, 0x98, 0xf3, 0x70, 0xb4, 0x7a, 0x31, 0x07, 0x85, 0x5f, 0x8c, 0x60, + 0x05, 0x4c, 0x49, 0x37, 0x16, 0x5c, 0x71, 0xbb, 0xa7, 0xe3, 0xae, 0x8e, 0xbb, 0x59, 0xfc, 0xe8, + 0xed, 0x80, 0x07, 0xdc, 0x44, 0x47, 0xfa, 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0xd0, 0x53, 0x58, 0xfc, 0x07, 0xd5, 0xe7, 0xe8, + 0x9d, 0xe2, 0xb2, 0xf4, 0xf4, 0x72, 0x16, 0x62, 0xb9, 0x04, 0xf2, 0x6f, 0xf6, 0x70, 0xd1, 0xb3, + 0xa2, 0xc7, 0xab, 0x44, 0xbd, 0x5a, 0x98, 0x46, 0x8f, 0x76, 0x38, 0x19, 0x5f, 0xdf, 0xf6, 0xad, + 0x9b, 0xdb, 0xbe, 0xf5, 0xe7, 0x6d, 0xdf, 0xfa, 0xe9, 0xae, 0x5f, 0xb9, 0xb9, 0xeb, 0x57, 0x7e, + 0xbf, 0xeb, 0x57, 0xce, 0x3f, 0x0f, 0xa8, 0x5a, 0x26, 0x73, 0xd7, 0xe7, 0xd1, 0xe8, 0xe5, 0x0f, + 0xdf, 0x9f, 0x7d, 0x07, 0x6a, 0xcd, 0xc5, 0xc5, 0xc8, 0x5f, 0x62, 0xca, 0x46, 0x97, 0xe9, 0x5f, + 0xa7, 0xda, 0xc4, 0x20, 0xe7, 0x0d, 0xf3, 0x97, 0xf9, 0xd5, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xc1, 0xd7, 0x44, 0xf8, 0x9d, 0x07, 0x00, 0x00, +} + +func (m *EventUpdateParams) 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 *EventUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.OldParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } func (m *EventCreatePool) Marshal() (dAtA []byte, err error) { @@ -1082,20 +1204,20 @@ func (m *EventRuntimeUpgradeScheduled) MarshalToSizedBuffer(dAtA []byte) (int, e var l int _ = l if len(m.AffectedPools) > 0 { - dAtA2 := make([]byte, len(m.AffectedPools)*10) - var j1 int + dAtA4 := make([]byte, len(m.AffectedPools)*10) + var j3 int for _, num := range m.AffectedPools { for num >= 1<<7 { - dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j1++ + j3++ } - dAtA2[j1] = uint8(num) - j1++ + dAtA4[j3] = uint8(num) + j3++ } - i -= j1 - copy(dAtA[i:], dAtA2[:j1]) - i = encodeVarintEvents(dAtA, i, uint64(j1)) + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintEvents(dAtA, i, uint64(j3)) i-- dAtA[i] = 0x32 } @@ -1154,20 +1276,20 @@ func (m *EventRuntimeUpgradeCancelled) MarshalToSizedBuffer(dAtA []byte) (int, e var l int _ = l if len(m.AffectedPools) > 0 { - dAtA4 := make([]byte, len(m.AffectedPools)*10) - var j3 int + dAtA6 := make([]byte, len(m.AffectedPools)*10) + var j5 int for _, num := range m.AffectedPools { for num >= 1<<7 { - dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j3++ + j5++ } - dAtA4[j3] = uint8(num) - j3++ + dAtA6[j5] = uint8(num) + j5++ } - i -= j3 - copy(dAtA[i:], dAtA4[:j3]) - i = encodeVarintEvents(dAtA, i, uint64(j3)) + i -= j5 + copy(dAtA[i:], dAtA6[:j5]) + i = encodeVarintEvents(dAtA, i, uint64(j5)) i-- dAtA[i] = 0x12 } @@ -1433,6 +1555,23 @@ func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *EventUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OldParams.Size() + n += 1 + l + sovEvents(uint64(l)) + l = m.NewParams.Size() + n += 1 + l + sovEvents(uint64(l)) + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + func (m *EventCreatePool) Size() (n int) { if m == nil { return 0 @@ -1694,6 +1833,154 @@ func sovEvents(x uint64) (n int) { func sozEvents(x uint64) (n int) { return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *EventUpdateParams) 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: EventUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", 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.Payload = 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 (m *EventCreatePool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/pool/types/genesis.go b/x/pool/types/genesis.go index d30ce883..dff80bf7 100644 --- a/x/pool/types/genesis.go +++ b/x/pool/types/genesis.go @@ -4,7 +4,10 @@ import "fmt" // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } } // Validate performs basic genesis state validation returning an error upon any failure. @@ -26,5 +29,5 @@ func (gs GenesisState) Validate() error { } } - return nil + return gs.Params.Validate() } diff --git a/x/pool/types/genesis.pb.go b/x/pool/types/genesis.pb.go index a79e1bfb..d0546861 100644 --- a/x/pool/types/genesis.pb.go +++ b/x/pool/types/genesis.pb.go @@ -25,6 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the pool module's genesis state. type GenesisState struct { + // params ... + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // pool_list ... PoolList []Pool `protobuf:"bytes,2,rep,name=pool_list,json=poolList,proto3" json:"pool_list"` // pool_count ... @@ -64,6 +66,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func (m *GenesisState) GetPoolList() []Pool { if m != nil { return m.PoolList @@ -85,23 +94,24 @@ func init() { func init() { proto.RegisterFile("kyve/pool/v1beta1/genesis.proto", fileDescriptor_ba827ab14a3de899) } var fileDescriptor_ba827ab14a3de899 = []byte{ - // 250 bytes of a gzipped FileDescriptorProto + // 271 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0xae, 0x2c, 0x4b, 0xd5, 0x2f, 0xc8, 0xcf, 0xcf, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x04, 0x29, 0xd0, 0x03, 0x29, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xea, 0x83, 0x58, - 0x10, 0x85, 0x52, 0x32, 0x98, 0x26, 0x81, 0x75, 0x81, 0x65, 0x95, 0xca, 0xb9, 0x78, 0xdc, 0x21, - 0xe6, 0x06, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x59, 0x71, 0x71, 0x82, 0x64, 0xe3, 0x73, 0x32, 0x8b, - 0x4b, 0x24, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0xc4, 0xf5, 0x30, 0xac, 0xd2, 0x0b, 0xc8, 0xcf, - 0xcf, 0x71, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x88, 0x03, 0x24, 0xe1, 0x93, 0x59, 0x5c, 0x22, - 0x24, 0xcb, 0xc5, 0x05, 0xd6, 0x9b, 0x9c, 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, - 0x12, 0x04, 0x36, 0xcd, 0x19, 0x24, 0xe0, 0xc5, 0xc2, 0xc1, 0x28, 0xc0, 0x14, 0xc4, 0x56, 0x90, - 0x58, 0x94, 0x98, 0x5b, 0xec, 0xe4, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, - 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, - 0x51, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xde, 0x91, 0x61, - 0xae, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0xfa, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x15, - 0x10, 0xaf, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x3d, 0x61, 0x0c, 0x08, 0x00, 0x00, - 0xff, 0xff, 0x22, 0xa0, 0x4e, 0x17, 0x2e, 0x01, 0x00, 0x00, + 0x10, 0x85, 0x52, 0x72, 0x98, 0x26, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x0d, 0x92, 0x92, 0xc1, + 0x22, 0x0f, 0x32, 0x15, 0x2c, 0xab, 0xb4, 0x88, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x71, 0x70, 0x49, + 0x62, 0x49, 0xaa, 0x90, 0x39, 0x17, 0x1b, 0x44, 0xbb, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, + 0xa4, 0x1e, 0x86, 0x43, 0xf4, 0x02, 0xc0, 0x0a, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, + 0x2a, 0x17, 0xb2, 0xe2, 0xe2, 0x04, 0x29, 0x8a, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, 0x52, 0x60, + 0xd6, 0xe0, 0x36, 0x12, 0xc7, 0xa6, 0x37, 0x3f, 0x3f, 0x07, 0xaa, 0x93, 0x03, 0x24, 0xe1, 0x93, + 0x59, 0x5c, 0x22, 0x24, 0xcb, 0xc5, 0x05, 0xd6, 0x9b, 0x9c, 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0xac, + 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x36, 0xcd, 0x19, 0x24, 0xe0, 0xe4, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, + 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, + 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, + 0xb9, 0xfa, 0xde, 0x91, 0x61, 0xae, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0xfa, 0xc9, 0x19, + 0x89, 0x99, 0x79, 0xfa, 0x15, 0x10, 0x6f, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x3d, + 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc6, 0x79, 0x5b, 0xc5, 0x7a, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -143,6 +153,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -163,6 +183,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) if len(m.PoolList) > 0 { for _, e := range m.PoolList { l = e.Size() @@ -210,6 +232,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolList", wireType) diff --git a/x/pool/types/keys.go b/x/pool/types/keys.go index 39013aa0..715bf985 100644 --- a/x/pool/types/keys.go +++ b/x/pool/types/keys.go @@ -23,7 +23,13 @@ const ( ) var ( - PoolKey = []byte{1} + // ParamsKey is the prefix for all module params defined in params.proto + ParamsKey = []byte{0} + + // PoolKey is the prefix for all pools defined in pool.proto + PoolKey = []byte{1} + + // PoolCountKey is the prefix for the pool counter defined in pool.proto PoolCountKey = []byte{2} ) diff --git a/x/pool/types/msgs.go b/x/pool/types/msgs.go index e6ecaf36..7d6072aa 100644 --- a/x/pool/types/msgs.go +++ b/x/pool/types/msgs.go @@ -17,6 +17,7 @@ var ( _ sdk.Msg = &MsgEnablePool{} _ sdk.Msg = &MsgScheduleRuntimeUpgrade{} _ sdk.Msg = &MsgCancelRuntimeUpgrade{} + _ sdk.Msg = &MsgUpdateParams{} ) // GetSigners returns the expected signers for a MsgCreatePool message. @@ -35,14 +36,18 @@ func (msg *MsgCreatePool) ValidateBasic() error { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid upload interval") } - if err := util.ValidatePositiveNumber(msg.OperatingCost); err != nil { + if err := util.ValidateNumber(msg.OperatingCost); err != nil { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") } - if err := util.ValidatePositiveNumber(msg.MinDelegation); err != nil { + if err := util.ValidateNumber(msg.MinDelegation); err != nil { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid minimum delegation") } + if err := util.ValidatePositiveNumber(msg.MaxBundleSize); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid max bundle size") + } + return nil } @@ -84,17 +89,23 @@ func (msg *MsgUpdatePool) ValidateBasic() error { } if payload.OperatingCost != nil { - if err := util.ValidatePositiveNumber(*payload.OperatingCost); err != nil { + if err := util.ValidateNumber(*payload.OperatingCost); err != nil { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") } } if payload.MinDelegation != nil { - if err := util.ValidatePositiveNumber(*payload.MinDelegation); err != nil { + if err := util.ValidateNumber(*payload.MinDelegation); err != nil { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid minimum delegation") } } + if payload.MaxBundleSize != nil { + if err := util.ValidatePositiveNumber(*payload.MaxBundleSize); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid max bundle size") + } + } + return nil } @@ -157,3 +168,27 @@ func (msg *MsgCancelRuntimeUpgrade) ValidateBasic() error { return nil } + +// GetSigners returns the expected signers for a MsgCancelRuntimeUpgrade message. +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data. +func (msg *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errors.Wrap(err, "invalid authority address") + } + + params := DefaultParams() + if err := json.Unmarshal([]byte(msg.Payload), ¶ms); err != nil { + return err + } + + if err := params.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/pool/types/params.go b/x/pool/types/params.go new file mode 100644 index 00000000..d61e3d09 --- /dev/null +++ b/x/pool/types/params.go @@ -0,0 +1,44 @@ +package types + +import ( + "github.com/KYVENetwork/chain/util" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// DefaultProtocolInflationShare ... +var DefaultProtocolInflationShare = sdk.ZeroDec() + +// DefaultPoolInflationPayoutRate ... +var DefaultPoolInflationPayoutRate = sdk.MustNewDecFromStr("0.05") + +// NewParams creates a new Params instance +func NewParams( + protocolInflationShare sdk.Dec, + poolInflationPayoutRate sdk.Dec, +) Params { + return Params{ + ProtocolInflationShare: protocolInflationShare, + PoolInflationPayoutRate: poolInflationPayoutRate, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + DefaultProtocolInflationShare, + DefaultPoolInflationPayoutRate, + ) +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := util.ValidatePercentage(p.ProtocolInflationShare); err != nil { + return err + } + + if err := util.ValidatePercentage(p.PoolInflationPayoutRate); err != nil { + return err + } + + return nil +} diff --git a/x/pool/types/params.pb.go b/x/pool/types/params.pb.go new file mode 100644 index 00000000..f66b98eb --- /dev/null +++ b/x/pool/types/params.pb.go @@ -0,0 +1,369 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/pool/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = 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 + +// Params defines the pool module parameters. +type Params struct { + // protocol_inflation_share ... + ProtocolInflationShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=protocol_inflation_share,json=protocolInflationShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"protocol_inflation_share"` + // pool_inflation_payout_rate ... + PoolInflationPayoutRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=pool_inflation_payout_rate,json=poolInflationPayoutRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"pool_inflation_payout_rate"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_7d8646dfa6da3b4d, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "kyve.pool.v1beta1.Params") +} + +func init() { proto.RegisterFile("kyve/pool/v1beta1/params.proto", fileDescriptor_7d8646dfa6da3b4d) } + +var fileDescriptor_7d8646dfa6da3b4d = []byte{ + // 268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xae, 0x2c, 0x4b, + 0xd5, 0x2f, 0xc8, 0xcf, 0xcf, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, + 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x04, 0xc9, 0xeb, 0x81, + 0xe4, 0xf5, 0xa0, 0xf2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x59, 0x7d, 0x10, 0x0b, 0xa2, + 0x50, 0xe9, 0x3e, 0x23, 0x17, 0x5b, 0x00, 0x58, 0xa7, 0x50, 0x06, 0x97, 0x04, 0x58, 0x2c, 0x39, + 0x3f, 0x27, 0x3e, 0x33, 0x2f, 0x2d, 0x27, 0xb1, 0x24, 0x33, 0x3f, 0x2f, 0xbe, 0x38, 0x23, 0xb1, + 0x28, 0x55, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, 0x49, 0xef, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, + 0xe4, 0xd5, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x93, 0xf3, 0x8b, + 0x73, 0xf3, 0x8b, 0xa1, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0xb1, 0x9e, + 0x4b, 0x6a, 0x72, 0x90, 0x18, 0xcc, 0x3c, 0x4f, 0x98, 0x71, 0xc1, 0x20, 0xd3, 0x84, 0xb2, 0xb9, + 0xa4, 0x40, 0x4e, 0x43, 0xb2, 0xa5, 0x20, 0xb1, 0x32, 0xbf, 0xb4, 0x24, 0xbe, 0x28, 0xb1, 0x24, + 0x55, 0x82, 0x89, 0x2c, 0xbb, 0xc4, 0x41, 0x26, 0xc2, 0xed, 0x09, 0x00, 0x9b, 0x17, 0x94, 0x58, + 0x92, 0xea, 0xe4, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, + 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x9a, 0x48, + 0x46, 0x7b, 0x47, 0x86, 0xb9, 0xfa, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x27, 0x67, 0x24, + 0x66, 0xe6, 0xe9, 0x57, 0x40, 0x82, 0x17, 0x6c, 0x43, 0x12, 0x1b, 0xd8, 0x27, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xd3, 0x1a, 0xf2, 0x59, 0x78, 0x01, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.PoolInflationPayoutRate.Size() + i -= size + if _, err := m.PoolInflationPayoutRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.ProtocolInflationShare.Size() + i -= size + if _, err := m.ProtocolInflationShare.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + 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 (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ProtocolInflationShare.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.PoolInflationPayoutRate.Size() + n += 1 + l + sovParams(uint64(l)) + 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 *Params) 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolInflationShare", 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 + } + if err := m.ProtocolInflationShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolInflationPayoutRate", 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 + } + if err := m.PoolInflationPayoutRate.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 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/x/pool/types/pool.go b/x/pool/types/pool.go index ee7209f1..b9e46dbe 100644 --- a/x/pool/types/pool.go +++ b/x/pool/types/pool.go @@ -1,6 +1,12 @@ package types -import "math" +import ( + "fmt" + "math" + + sdk "github.com/cosmos/cosmos-sdk/types" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) // Handles the funders of a pool. Functions safely add and remove funds to funders. // If amount drops to zero the funder is automatically removed from the list. @@ -58,6 +64,12 @@ func (m *Pool) GetFunderAmount(address string) uint64 { return 0 } +func (m *Pool) GetPoolAccount() sdk.AccAddress { + name := fmt.Sprintf("%s/%d", ModuleName, m.Id) + + return authTypes.NewModuleAddress(name) +} + func (m *Pool) GetLowestFunder() Funder { if len(m.Funders) == 0 { return Funder{} diff --git a/x/pool/types/query.pb.go b/x/pool/types/query.pb.go new file mode 100644 index 00000000..7d9c678c --- /dev/null +++ b/x/pool/types/query.pb.go @@ -0,0 +1,535 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/pool/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = 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 + +// QueryParamsRequest is 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_9c2f559babbc8665, []int{0} +} +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 response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this 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_9c2f559babbc8665, []int{1} +} +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 (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "kyve.pool.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "kyve.pool.v1beta1.QueryParamsResponse") +} + +func init() { proto.RegisterFile("kyve/pool/v1beta1/query.proto", fileDescriptor_9c2f559babbc8665) } + +var fileDescriptor_9c2f559babbc8665 = []byte{ + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xae, 0x2c, 0x4b, + 0xd5, 0x2f, 0xc8, 0xcf, 0xcf, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, + 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x04, 0x49, 0xeb, 0x81, 0xa4, + 0xf5, 0xa0, 0xd2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x59, 0x7d, 0x10, 0x0b, 0xa2, 0x50, + 0x4a, 0x26, 0x3d, 0x3f, 0x3f, 0x3d, 0x27, 0x55, 0x3f, 0xb1, 0x20, 0x53, 0x3f, 0x31, 0x2f, 0x2f, + 0xbf, 0x24, 0xb1, 0x24, 0x33, 0x3f, 0xaf, 0x18, 0x2a, 0x2b, 0x87, 0x69, 0x4b, 0x41, 0x62, 0x51, + 0x62, 0x2e, 0x54, 0x5e, 0x49, 0x84, 0x4b, 0x28, 0x10, 0x64, 0x6b, 0x00, 0x58, 0x30, 0x28, 0xb5, + 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0xc9, 0x8f, 0x4b, 0x18, 0x45, 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, + 0x55, 0xc8, 0x9c, 0x8b, 0x0d, 0xa2, 0x59, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, 0x0f, + 0xc3, 0x91, 0x7a, 0x10, 0x2d, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x95, 0x1b, 0x35, + 0x33, 0x72, 0xb1, 0x82, 0x0d, 0x14, 0xaa, 0xe2, 0x62, 0x83, 0xa8, 0x10, 0x52, 0xc5, 0xa2, 0x19, + 0xd3, 0x29, 0x52, 0x6a, 0x84, 0x94, 0x41, 0xdc, 0xa6, 0xa4, 0xd8, 0x74, 0xf9, 0xc9, 0x64, 0x26, + 0x69, 0x21, 0x49, 0x7d, 0x5c, 0x3e, 0x76, 0x72, 0x3e, 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, 0xcd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xef, + 0xc8, 0x30, 0x57, 0xbf, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0xfd, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, + 0xfd, 0x0a, 0x88, 0x69, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x70, 0x33, 0x06, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x09, 0x81, 0xd4, 0xe5, 0xbf, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/kyve.pool.v1beta1.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 { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +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) +} + +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: "/kyve.pool.v1beta1.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: "kyve.pool.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kyve/pool/v1beta1/query.proto", +} + +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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +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 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/pool/types/query.pb.gw.go b/x/pool/types/query.pb.gw.go new file mode 100644 index 00000000..000d5948 --- /dev/null +++ b/x/pool/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kyve/pool/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +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. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + 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() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + 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 +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + 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 +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kyve", "pool", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/pool/types/tx.pb.go b/x/pool/types/tx.pb.go index 9f03faf0..9b045244 100644 --- a/x/pool/types/tx.pb.go +++ b/x/pool/types/tx.pb.go @@ -935,6 +935,98 @@ func (m *MsgCancelRuntimeUpgradeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCancelRuntimeUpgradeResponse proto.InternalMessageInfo +// MsgUpdateParams defines a SDK message for updating the module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // payload defines the x/stakers parameters to update. + Payload string `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_20ddefdf83388ddc, []int{16} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetPayload() string { + if m != nil { + return m.Payload + } + return "" +} + +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_20ddefdf83388ddc, []int{17} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgFundPool)(nil), "kyve.pool.v1beta1.MsgFundPool") proto.RegisterType((*MsgFundPoolResponse)(nil), "kyve.pool.v1beta1.MsgFundPoolResponse") @@ -952,65 +1044,70 @@ func init() { proto.RegisterType((*MsgScheduleRuntimeUpgradeResponse)(nil), "kyve.pool.v1beta1.MsgScheduleRuntimeUpgradeResponse") proto.RegisterType((*MsgCancelRuntimeUpgrade)(nil), "kyve.pool.v1beta1.MsgCancelRuntimeUpgrade") proto.RegisterType((*MsgCancelRuntimeUpgradeResponse)(nil), "kyve.pool.v1beta1.MsgCancelRuntimeUpgradeResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "kyve.pool.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "kyve.pool.v1beta1.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("kyve/pool/v1beta1/tx.proto", fileDescriptor_20ddefdf83388ddc) } var fileDescriptor_20ddefdf83388ddc = []byte{ - // 841 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0x8e, 0x93, 0xd4, 0x89, 0x4f, 0x6a, 0x57, 0x9d, 0xb6, 0xe9, 0x74, 0x91, 0x4c, 0x62, 0x44, - 0x49, 0x11, 0xd8, 0x6a, 0x41, 0xdc, 0x37, 0x69, 0x91, 0xa2, 0x2a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5e, - 0x9d, 0xf7, 0x5b, 0xbf, 0x9f, 0xf7, 0x5b, 0x3f, 0x5e, 0xf4, 0x57, 0x5e, 0x5d, 0xf4, 0x57, 0x7e, - 0xbb, 0xe8, 0xaf, 0x7c, 0x73, 0x2f, 0xe2, 0xe6, 0x24, 0x1b, 0x0f, 0x43, 0x99, 0x8c, 0x9e, 0x7c, - 0xfd, 0xe5, 0xe3, 0xcf, 0x98, 0xf9, 0x5e, 0xaa, 0xd3, 0x51, 0x78, 0x42, 0xb8, 0x18, 0x9d, 0xe5, - 0x9f, 0x5e, 0x66, 0x9a, 0x32, 0x3d, 0x6e, 0xbb, 0x0f, 0xa9, 0x8f, 0xfe, 0x0c, 0x00, 0x00, 0xff, - 0xff, 0x47, 0x15, 0xd0, 0xc0, 0x94, 0x09, 0x00, 0x00, + // 881 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x6e, 0x1b, 0x45, + 0x14, 0x8d, 0x9d, 0xd4, 0x89, 0x6f, 0x62, 0x47, 0xdd, 0xb6, 0xe9, 0x64, 0x91, 0x4c, 0x62, 0x44, + 0x49, 0x2b, 0xb0, 0xd5, 0x82, 0x78, 0x6f, 0xd2, 0x22, 0x45, 0x55, 0xa0, 0x6c, 0x54, 0x28, 0x20, + 0xb1, 0x1a, 0xef, 0x4c, 0x37, 0xa3, 0xec, 0xce, 0x2c, 0x33, 0xb3, 0x26, 0xae, 0xf8, 0x08, 0x3e, + 0x86, 0x8f, 0xe0, 0xb1, 0xe2, 0x89, 0x47, 0x94, 0xbc, 0xf1, 0xcc, 0x07, 0xa0, 0x99, 0x5d, 0xef, + 0xae, 0xb1, 0xb7, 0x01, 0x9a, 0xbe, 0xf9, 0xde, 0x7b, 0x7c, 0xce, 0x9d, 0x99, 0x33, 0x77, 0x16, + 0xdc, 0xd3, 0xc9, 0x98, 0x0e, 0x13, 0x21, 0xa2,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 0x36, + 0xbf, 0x4d, 0xf3, 0x81, 0xe0, 0x2f, 0x58, 0x88, 0xae, 0xd9, 0x6c, 0x1e, 0x39, 0xef, 0x40, 0x5b, + 0x69, 0x2c, 0xb5, 0x7f, 0x4a, 0x27, 0xa8, 0x65, 0x4b, 0x6b, 0x36, 0xf1, 0x84, 0x4e, 0x9c, 0x0f, + 0x60, 0x33, 0x4d, 0x22, 0x81, 0x89, 0xcf, 0xb8, 0xa6, 0x72, 0x8c, 0x23, 0xb4, 0x6a, 0x97, 0xde, + 0xcd, 0xd2, 0x87, 0x79, 0xd6, 0x79, 0x1f, 0xba, 0x22, 0xa1, 0x12, 0x6b, 0xc6, 0x43, 0x3f, 0x10, + 0x4a, 0xa3, 0x35, 0x8b, 0xeb, 0x14, 0xd9, 0x03, 0xa1, 0xb4, 0x81, 0xc5, 0x8c, 0xfb, 0x84, 0x46, + 0x34, 0xc4, 0x9a, 0x09, 0x8e, 0xda, 0x19, 0x2c, 0x66, 0xfc, 0x51, 0x91, 0x74, 0xee, 0xc0, 0x66, + 0x8c, 0xcf, 0xfc, 0x51, 0xca, 0x49, 0x44, 0x7d, 0xc5, 0x5e, 0x52, 0x04, 0x39, 0x0e, 0x9f, 0xed, + 0xdb, 0xec, 0x31, 0x7b, 0x69, 0x77, 0x60, 0x4c, 0xa5, 0x32, 0x3c, 0xeb, 0xd9, 0x0e, 0xe4, 0xa1, + 0xe3, 0xc2, 0xda, 0x88, 0x71, 0x2c, 0x19, 0x55, 0x68, 0x23, 0x5b, 0xd4, 0x34, 0x76, 0x06, 0x70, + 0x43, 0x69, 0x21, 0x71, 0x48, 0x8d, 0x0f, 0xc7, 0x8c, 0x50, 0xe9, 0x33, 0x82, 0x3a, 0x3b, 0x8d, + 0xbd, 0x8e, 0x77, 0x3d, 0x2f, 0x3d, 0xcd, 0x2b, 0x87, 0xc4, 0x34, 0x1d, 0x88, 0x38, 0x31, 0x07, + 0xc3, 0x04, 0x37, 0xd0, 0xae, 0x85, 0x76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x24, 0x1d, 0x0d, 0x02, 0x11, 0x0f, 0x9f, 0x7c, 0xf3, 0xd5, 0xe3, 0xcf, 0xa9, 0xfe, 0x51, 0xc8, + 0xd3, 0x61, 0x70, 0x82, 0x19, 0x1f, 0x9e, 0x65, 0x9f, 0x96, 0x7a, 0x92, 0x50, 0x35, 0x6a, 0xd9, + 0x0f, 0xc5, 0x8f, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x68, 0x62, 0xc8, 0xb4, 0x74, 0x0a, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1047,6 +1144,9 @@ type MsgClient interface { // CancelRuntimeUpgrade defines a governance operation for cancelling a runtime upgrade. // The authority is hard-coded to the x/gov module account. CancelRuntimeUpgrade(ctx context.Context, in *MsgCancelRuntimeUpgrade, opts ...grpc.CallOption) (*MsgCancelRuntimeUpgradeResponse, error) + // UpdateParams defines a governance operation for updating the x/pool module + // parameters. The authority is hard-coded to the x/gov module account. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -1129,6 +1229,15 @@ func (c *msgClient) CancelRuntimeUpgrade(ctx context.Context, in *MsgCancelRunti return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/kyve.pool.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // FundPool ... @@ -1153,6 +1262,9 @@ type MsgServer interface { // CancelRuntimeUpgrade defines a governance operation for cancelling a runtime upgrade. // The authority is hard-coded to the x/gov module account. CancelRuntimeUpgrade(context.Context, *MsgCancelRuntimeUpgrade) (*MsgCancelRuntimeUpgradeResponse, error) + // UpdateParams defines a governance operation for updating the x/pool module + // parameters. The authority is hard-coded to the x/gov module account. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1183,6 +1295,9 @@ func (*UnimplementedMsgServer) ScheduleRuntimeUpgrade(ctx context.Context, req * func (*UnimplementedMsgServer) CancelRuntimeUpgrade(ctx context.Context, req *MsgCancelRuntimeUpgrade) (*MsgCancelRuntimeUpgradeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CancelRuntimeUpgrade not implemented") } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1332,6 +1447,24 @@ func _Msg_CancelRuntimeUpgrade_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.pool.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "kyve.pool.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -1368,6 +1501,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CancelRuntimeUpgrade", Handler: _Msg_CancelRuntimeUpgrade_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "kyve/pool/v1beta1/tx.proto", @@ -1956,6 +2093,66 @@ func (m *MsgCancelRuntimeUpgradeResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintTx(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -2236,6 +2433,32 @@ func (m *MsgCancelRuntimeUpgradeResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3967,6 +4190,170 @@ func (m *MsgCancelRuntimeUpgradeResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", 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.Payload = string(dAtA[iNdEx:postIndex]) + 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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/query/client/cli/query_finalized_bundles.go b/x/query/client/cli/query_finalized_bundles.go index 1e3e2688..1b8b99e5 100644 --- a/x/query/client/cli/query_finalized_bundles.go +++ b/x/query/client/cli/query_finalized_bundles.go @@ -39,7 +39,7 @@ func CmdListFinalizedBundles() *cobra.Command { Pagination: pageReq, } - res, err := queryClient.FinalizedBundles(context.Background(), params) + res, err := queryClient.FinalizedBundlesQuery(context.Background(), params) if err != nil { return err } @@ -79,7 +79,7 @@ func CmdShowFinalizedBundle() *cobra.Command { Id: bundleId, } - res, err := queryClient.FinalizedBundle(context.Background(), params) + res, err := queryClient.FinalizedBundleQuery(context.Background(), params) if err != nil { return err } diff --git a/x/query/keeper/grpc_account_funded.go b/x/query/keeper/grpc_account_funded.go index 08d2bd58..73d48bee 100644 --- a/x/query/keeper/grpc_account_funded.go +++ b/x/query/keeper/grpc_account_funded.go @@ -18,22 +18,27 @@ func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccount var funded []types.Funded pools := k.poolKeeper.GetAllPools(ctx) + for i := range pools { pool := pools[i] - funded = append(funded, types.Funded{ - Amount: pool.GetFunderAmount(req.Address), - Pool: &types.BasicPool{ - Id: pool.Id, - Name: pool.Name, - Runtime: pool.Runtime, - Logo: pool.Logo, - OperatingCost: pool.OperatingCost, - UploadInterval: pool.UploadInterval, - TotalFunds: pool.TotalFunds, - TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), - Status: k.GetPoolStatus(ctx, &pool), - }, - }) + amount := pool.GetFunderAmount(req.Address) + + if amount > 0 { + funded = append(funded, types.Funded{ + Amount: amount, + Pool: &types.BasicPool{ + Id: pool.Id, + Name: pool.Name, + Runtime: pool.Runtime, + Logo: pool.Logo, + OperatingCost: pool.OperatingCost, + UploadInterval: pool.UploadInterval, + TotalFunds: pool.TotalFunds, + TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), + Status: k.GetPoolStatus(ctx, &pool), + }, + }) + } } return &types.QueryAccountFundedListResponse{ diff --git a/x/query/keeper/grpc_account_redelegation_test.go b/x/query/keeper/grpc_account_redelegation_test.go index adf0a9fe..1e8f1d9c 100644 --- a/x/query/keeper/grpc_account_redelegation_test.go +++ b/x/query/keeper/grpc_account_redelegation_test.go @@ -29,7 +29,7 @@ var _ = Describe("grpc_account_redelegation.go", Ordered, func() { s = i.NewCleanChain() s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "T", MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, diff --git a/x/query/keeper/grpc_query_can_propose_test.go b/x/query/keeper/grpc_query_can_propose_test.go index 85f8971e..963a1983 100644 --- a/x/query/keeper/grpc_query_can_propose_test.go +++ b/x/query/keeper/grpc_query_can_propose_test.go @@ -28,6 +28,7 @@ TEST CASES - grpc_query_can_propose.go * Call can propose before the upload interval passed * Call can propose with an invalid from height * Call can propose on an active pool as the next uploader with valid args +* Call can propose on an active pool without funds as the next uploader with valid args */ @@ -38,7 +39,7 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { s = i.NewCleanChain() s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, @@ -229,46 +230,6 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(txErr.Error()).To(Equal(canPropose.Reason)) }) - It("Call can propose if pool is out of funds", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ACT - canPropose, err := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ - PoolId: 0, - Staker: i.STAKER_1, - Proposer: i.VALADDRESS_1, - FromIndex: 100, - }) - - // ASSERT - Expect(err).To(BeNil()) - - Expect(canPropose.Possible).To(BeFalse()) - Expect(canPropose.Reason).To(Equal(bundletypes.ErrPoolOutOfFunds.Error())) - - _, txErr := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_1, - Staker: i.STAKER_1, - PoolId: 0, - StorageId: "test_storage_id", - DataSize: 100, - DataHash: "test_hash", - FromIndex: 100, - BundleSize: 100, - FromKey: "100", - ToKey: "199", - BundleSummary: "test_value", - }) - - Expect(txErr).NotTo(BeNil()) - Expect(txErr.Error()).To(Equal(canPropose.Reason)) - }) - It("Call can propose if pool has not reached the minimum stake", func() { // ARRANGE s.RunTxDelegatorSuccess(&delegationtypes.MsgUndelegate{ @@ -428,8 +389,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { // ACT canPropose, err := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ PoolId: 0, - Staker: i.STAKER_0, - Proposer: i.VALADDRESS_0, + Staker: i.STAKER_1, + Proposer: i.VALADDRESS_1, FromIndex: 100, }) @@ -442,8 +403,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(canPropose.Reason).To(Equal(errors.Wrapf(bundletypes.ErrUploadInterval, "expected %v < %v", s.Ctx().BlockTime().Unix(), bundleProposal.UpdatedAt+pool.UploadInterval).Error())) _, txErr := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_0, - Staker: i.STAKER_0, + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -463,15 +424,15 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { // ACT canPropose_1, err_1 := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ PoolId: 0, - Staker: i.STAKER_0, - Proposer: i.VALADDRESS_0, + Staker: i.STAKER_1, + Proposer: i.VALADDRESS_1, FromIndex: 99, }) canPropose_2, err_2 := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ PoolId: 0, - Staker: i.STAKER_0, - Proposer: i.VALADDRESS_0, + Staker: i.STAKER_1, + Proposer: i.VALADDRESS_1, FromIndex: 101, }) @@ -489,8 +450,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(canPropose_2.Reason).To(Equal(errors.Wrapf(bundletypes.ErrFromIndex, "expected %v received %v", pool.CurrentIndex+bundleProposal.BundleSize, 101).Error())) _, txErr_1 := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_0, - Staker: i.STAKER_0, + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -506,8 +467,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(txErr_1.Error()).To(Equal(canPropose_1.Reason)) _, txErr_2 := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_0, - Staker: i.STAKER_0, + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -527,8 +488,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { // ACT canPropose, err := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ PoolId: 0, - Staker: i.STAKER_0, - Proposer: i.VALADDRESS_0, + Staker: i.STAKER_1, + Proposer: i.VALADDRESS_1, FromIndex: 100, }) @@ -539,8 +500,47 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(canPropose.Reason).To(BeEmpty()) _, txErr := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_0, - Staker: i.STAKER_0, + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, + PoolId: 0, + StorageId: "test_storage_id", + DataSize: 100, + DataHash: "test_hash", + FromIndex: 100, + BundleSize: 100, + FromKey: "100", + ToKey: "199", + BundleSummary: "test_value", + }) + + Expect(txErr).To(BeNil()) + }) + + It("Call can propose on an active pool without funds as the next uploader with valid args", func() { + // ARRANGE + s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + // ACT + canPropose, err := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ + PoolId: 0, + Staker: i.STAKER_1, + Proposer: i.VALADDRESS_1, + FromIndex: 100, + }) + + // ASSERT + Expect(err).To(BeNil()) + + Expect(canPropose.Possible).To(BeTrue()) + Expect(canPropose.Reason).To(BeEmpty()) + + _, txErr := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, diff --git a/x/query/keeper/grpc_query_can_validate_test.go b/x/query/keeper/grpc_query_can_validate_test.go index 7324994a..89a49c41 100644 --- a/x/query/keeper/grpc_query_can_validate_test.go +++ b/x/query/keeper/grpc_query_can_validate_test.go @@ -30,7 +30,7 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { s = i.NewCleanChain() s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, @@ -51,7 +51,7 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { }) s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest2", + Name: "Test Pool2", MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, diff --git a/x/query/keeper/grpc_query_can_vote_test.go b/x/query/keeper/grpc_query_can_vote_test.go index 83c09dfa..1b18563b 100644 --- a/x/query/keeper/grpc_query_can_vote_test.go +++ b/x/query/keeper/grpc_query_can_vote_test.go @@ -21,7 +21,6 @@ TEST CASES - grpc_query_can_vote.go * Call can vote if pool does not exist * Call can vote if pool is currently upgrading * Call can vote if pool is disabled -* Call can vote if pool is out of funds * Call can vote if pool has not reached the minimum stake * Call can vote with a valaccount which does not exist * Call can vote if current bundle was dropped @@ -30,6 +29,7 @@ TEST CASES - grpc_query_can_vote.go * Call can vote if voter has already voted invalid * Call can vote if voter has already voted abstain * Call can vote on an active pool with a data bundle with valid args +* Call can vote on an active pool with no funds and a data bundle with valid args */ @@ -40,7 +40,7 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { s = i.NewCleanChain() s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, @@ -202,40 +202,6 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { Expect(txErr.Error()).To(Equal(canVote.Reason)) }) - It("Call can vote if pool is out of funds", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ACT - canVote, err := s.App().QueryKeeper.CanVote(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanVoteRequest{ - PoolId: 0, - Staker: i.STAKER_1, - Voter: i.VALADDRESS_1, - StorageId: "test_storage_id", - }) - - // ASSERT - Expect(err).To(BeNil()) - - Expect(canVote.Possible).To(BeFalse()) - Expect(canVote.Reason).To(Equal(bundletypes.ErrPoolOutOfFunds.Error())) - - _, txErr := s.RunTx(&bundletypes.MsgVoteBundleProposal{ - Creator: i.VALADDRESS_1, - Staker: i.STAKER_1, - PoolId: 0, - StorageId: "test_storage_id", - Vote: bundletypes.VOTE_TYPE_VALID, - }) - - Expect(txErr).NotTo(BeNil()) - Expect(txErr.Error()).To(Equal(canVote.Reason)) - }) - It("Call can vote if pool has not reached the minimum stake", func() { // ARRANGE s.RunTxDelegatorSuccess(&delegationtypes.MsgUndelegate{ @@ -498,4 +464,37 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { Expect(txErr).To(BeNil()) }) + + It("Call can vote on an active pool with no funds and a data bundle with valid args", func() { + // ARRANGE + s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + Creator: i.ALICE, + Id: 0, + Amount: 100 * i.KYVE, + }) + + // ACT + canVote, err := s.App().QueryKeeper.CanVote(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanVoteRequest{ + PoolId: 0, + Staker: i.STAKER_1, + Voter: i.VALADDRESS_1, + StorageId: "test_storage_id", + }) + + // ASSERT + Expect(err).To(BeNil()) + + Expect(canVote.Possible).To(BeTrue()) + Expect(canVote.Reason).To(BeEmpty()) + + _, txErr := s.RunTx(&bundletypes.MsgVoteBundleProposal{ + Creator: i.VALADDRESS_1, + Staker: i.STAKER_1, + PoolId: 0, + StorageId: "test_storage_id", + Vote: bundletypes.VOTE_TYPE_VALID, + }) + + Expect(txErr).To(BeNil()) + }) }) diff --git a/x/query/keeper/grpc_query_finalized_bundle.go b/x/query/keeper/grpc_query_finalized_bundle.go deleted file mode 100644 index a5af464d..00000000 --- a/x/query/keeper/grpc_query_finalized_bundle.go +++ /dev/null @@ -1,53 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/KYVENetwork/chain/x/query/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) FinalizedBundles(c context.Context, req *types.QueryFinalizedBundlesRequest) (*types.QueryFinalizedBundlesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(c) - - finalizedBundles, pageRes, err := k.bundleKeeper.GetPaginatedFinalizedBundleQuery(ctx, req.Pagination, req.PoolId) - if err != nil { - return nil, err - } - - return &types.QueryFinalizedBundlesResponse{FinalizedBundles: finalizedBundles, Pagination: pageRes}, nil -} - -func (k Keeper) FinalizedBundle(c context.Context, req *types.QueryFinalizedBundleRequest) (*types.QueryFinalizedBundleResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(c) - finalizedBundle, found := k.bundleKeeper.GetFinalizedBundle(ctx, req.PoolId, req.Id) - if !found { - return nil, sdkerrors.ErrKeyNotFound - } - - return &types.QueryFinalizedBundleResponse{FinalizedBundle: finalizedBundle}, nil -} - -func (k Keeper) FinalizedBundlesByHeight(goCtx context.Context, req *types.QueryFinalizedBundlesByHeightRequest) (*types.QueryFinalizedBundlesByHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - finalizedBundle, found := k.bundleKeeper.GetFinalizedBundleByHeight(ctx, req.PoolId, req.Height) - if !found { - return nil, sdkerrors.ErrKeyNotFound - } - - return &types.QueryFinalizedBundlesByHeightResponse{FinalizedBundle: finalizedBundle}, nil -} diff --git a/x/query/keeper/grpc_query_finalized_bundles.go b/x/query/keeper/grpc_query_finalized_bundles.go new file mode 100644 index 00000000..f792bd92 --- /dev/null +++ b/x/query/keeper/grpc_query_finalized_bundles.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "context" + "strconv" + + bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper" + "github.com/KYVENetwork/chain/x/query/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) FinalizedBundlesQuery(c context.Context, req *types.QueryFinalizedBundlesRequest) (*types.QueryFinalizedBundlesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + + if req.Index != "" { + index, err := strconv.ParseUint(req.Index, 10, 64) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "index needs to be an unsigned integer") + } + bundle, found := k.bundleKeeper.GetFinalizedBundleByIndex(ctx, req.PoolId, index) + data := make([]types.FinalizedBundle, 0) + if found { + data = append(data, bundle) + } + return &types.QueryFinalizedBundlesResponse{FinalizedBundles: data, Pagination: nil}, nil + } else { + finalizedBundles, pageRes, err := k.bundleKeeper.GetPaginatedFinalizedBundleQuery(ctx, req.Pagination, req.PoolId) + return &types.QueryFinalizedBundlesResponse{FinalizedBundles: finalizedBundles, Pagination: pageRes}, err + } +} + +func (k Keeper) FinalizedBundleQuery(c context.Context, req *types.QueryFinalizedBundleRequest) (*types.FinalizedBundle, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + finalizedBundle, found := k.bundleKeeper.GetFinalizedBundle(ctx, req.PoolId, req.Id) + if !found { + return nil, sdkerrors.ErrKeyNotFound + } + + versionMap := k.bundleKeeper.GetBundleVersionMap(ctx).GetMap() + response := bundlesKeeper.RawBundleToQueryBundle(finalizedBundle, versionMap) + return &response, nil +} diff --git a/x/query/keeper/grpc_query_pool.go b/x/query/keeper/grpc_query_pool.go index b321c2f6..71c692c1 100644 --- a/x/query/keeper/grpc_query_pool.go +++ b/x/query/keeper/grpc_query_pool.go @@ -3,12 +3,17 @@ package keeper import ( "context" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" - "github.com/KYVENetwork/chain/x/query/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + // Global + globalTypes "github.com/KYVENetwork/chain/x/global/types" + // Pool + poolTypes "github.com/KYVENetwork/chain/x/pool/types" + // Query + "github.com/KYVENetwork/chain/x/query/types" ) func (k Keeper) Pools(c context.Context, req *types.QueryPoolsRequest) (*types.QueryPoolsResponse, error) { @@ -38,13 +43,13 @@ func (k Keeper) Pool(c context.Context, req *types.QueryPoolRequest) (*types.Que pool, found := k.poolKeeper.GetPool(ctx, req.Id) if !found { - return nil, sdkerrors.ErrKeyNotFound + return nil, errorsTypes.ErrKeyNotFound } return &types.QueryPoolResponse{Pool: k.parsePoolResponse(ctx, &pool)}, nil } -func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *pooltypes.Pool) types.PoolResponse { +func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *poolTypes.Pool) types.PoolResponse { bundleProposal, _ := k.bundleKeeper.GetBundleProposal(ctx, pool.Id) stakers := k.stakerKeeper.GetAllStakerAddressesOfPool(ctx, pool.Id) @@ -55,6 +60,9 @@ func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *pooltypes.Pool) types.P totalDelegation := k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id) + poolAccount := pool.GetPoolAccount() + poolBalance := k.bankKeeper.GetBalance(ctx, poolAccount, globalTypes.Denom).Amount.Uint64() + return types.PoolResponse{ Id: pool.Id, Data: pool, @@ -63,5 +71,7 @@ func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *pooltypes.Pool) types.P TotalSelfDelegation: totalSelfDelegation, TotalDelegation: totalDelegation, Status: k.GetPoolStatus(ctx, pool), + Account: poolAccount.String(), + AccountBalance: poolBalance, } } diff --git a/x/query/keeper/helper.go b/x/query/keeper/helper.go index 83ecb35b..0536becd 100644 --- a/x/query/keeper/helper.go +++ b/x/query/keeper/helper.go @@ -27,6 +27,7 @@ func (k Keeper) GetFullStaker(ctx sdk.Context, stakerAddress string) *types.Full SecurityContact: staker.SecurityContact, Details: staker.Details, PendingCommissionChange: commissionChangeEntry, + CommissionRewards: staker.CommissionRewards, } delegationData, _ := k.delegationKeeper.GetDelegationData(ctx, staker.Address) diff --git a/x/query/spec/01_concept.md b/x/query/spec/01_concept.md new file mode 100644 index 00000000..17ce21c1 --- /dev/null +++ b/x/query/spec/01_concept.md @@ -0,0 +1,89 @@ + + +# Concepts + +The queries module is a little different from the other modules. It does +not maintain a state. Its purpose is to have one place to manage all queries. +A lot of queries require interaction with multiple modules and often do not +belong to a single module. + +Most queries align with the cosmos convention. Api documentation can be found +in the generated swagger file or in the proto files. + +## Finalized Bundles + +Finalized bundles are one of the main features of KYVE. This query will also be +the main query for people building applications on top of KYVE and using +KYVE's data. + +### Bundles query + +The basic structure of the bundles query works as follows. +For the field `finalized_bundles` always the latest schema version is +returned. The different version are explained below. + +**Query**: `/kyve/v1/bundles/{poolId}` + +**Params**: + +| Name | Type | Description | +|-------------------|---------|-------------------------------------------------------| +| pagination.limit | number | Defines the amount of bundles returned | +| pagination.offset | number | The amount of bundles to skip | +| pagination.key | string | Define key if next_key iteration should be used. | +| pagination.revers | boolean | Reverse order | +| index | number | Filters for the bundle which contains the given index | + + +**Response**: +```yaml +{ + "finalized_bundles": "[]FinalizedBundle", + "pagination": { + next_key: "string", + total: number + } +} +``` + + +#### Version 1 + +```yaml +{ + "pool_id": "number", + "id": "number", + "storage_id": "string", + "uploader": "string", + "from_index": "number", + "to_index": "number", + "to_key": "number", + "bundle_summary": "string", + "data_hash": "string", + "finalized_at": { + "height": "number", + "timestamp": "RFC3339 date string" + }, + "from_key": "number", + "storage_provider_id": "number", + "compression_id": "number", +} +``` + +#### Version 2 + +For version 2 the field `stake_security` was added. Bundles which +were finalized before the field existed return null. + +```yaml +{ + "stake_security": "number"|null +} +``` + +### Query by Id +To obtain a specific bundle specified by its Id use + +**Query**: `/kyve/v1/bundles/{poolId}/{id}` diff --git a/x/query/types/bundles.pb.go b/x/query/types/bundles.pb.go index b135c24a..c3a54e30 100644 --- a/x/query/types/bundles.pb.go +++ b/x/query/types/bundles.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - types "github.com/KYVENetwork/chain/x/bundles/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -31,19 +31,276 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// FinalizedBundle represents the latest version of a valid bundle of a pool +type FinalizedBundle struct { + // pool_id in which the bundle was created + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // id is is integrated with each valid bundle produced. + Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + // storage_id is the id with which the data can be retrieved from the configured data provider + StorageId string `protobuf:"bytes,3,opt,name=storage_id,json=storageId,proto3" json:"storage_id,omitempty"` + // uploader is the address of the staker who submitted this bundle + Uploader string `protobuf:"bytes,4,opt,name=uploader,proto3" json:"uploader,omitempty"` + // from_index is the index from where the bundle starts (inclusive) + FromIndex uint64 `protobuf:"varint,5,opt,name=from_index,json=fromIndex,proto3" json:"from_index,omitempty"` + // to_index is the index to which the bundle goes (exclusive) + ToIndex uint64 `protobuf:"varint,6,opt,name=to_index,json=toIndex,proto3" json:"to_index,omitempty"` + // from_key is the key of the first data item in the bundle proposal + FromKey string `protobuf:"bytes,11,opt,name=from_key,json=fromKey,proto3" json:"from_key,omitempty"` + // to_key the key of the last data item in the bundle + ToKey string `protobuf:"bytes,7,opt,name=to_key,json=toKey,proto3" json:"to_key,omitempty"` + // bundle_summary is a summary of the bundle. + BundleSummary string `protobuf:"bytes,8,opt,name=bundle_summary,json=bundleSummary,proto3" json:"bundle_summary,omitempty"` + // data_hash is a sha256 hash of the uploaded data. + DataHash string `protobuf:"bytes,9,opt,name=data_hash,json=dataHash,proto3" json:"data_hash,omitempty"` + // finalized_at contains details of the block that finalized this bundle. + FinalizedAt *FinalizedAt `protobuf:"bytes,10,opt,name=finalized_at,json=finalizedAt,proto3" json:"finalized_at,omitempty"` + // storage_provider_id the id of the storage provider where the bundle is stored + StorageProviderId uint64 `protobuf:"varint,12,opt,name=storage_provider_id,json=storageProviderId,proto3" json:"storage_provider_id,omitempty"` + // compression_id the id of the compression type with which the data was compressed + CompressionId uint64 `protobuf:"varint,13,opt,name=compression_id,json=compressionId,proto3" json:"compression_id,omitempty"` + // stake_security defines the amount of stake which was present in the pool during the finalization of the bundle. + // This field was added in schema version 2. Bundles finalized before that return `null`. + StakeSecurity *StakeSecurity `protobuf:"bytes,14,opt,name=stake_security,json=stakeSecurity,proto3" json:"stake_security,omitempty"` +} + +func (m *FinalizedBundle) Reset() { *m = FinalizedBundle{} } +func (m *FinalizedBundle) String() string { return proto.CompactTextString(m) } +func (*FinalizedBundle) ProtoMessage() {} +func (*FinalizedBundle) Descriptor() ([]byte, []int) { + return fileDescriptor_b49b126c38ac815c, []int{0} +} +func (m *FinalizedBundle) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalizedBundle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalizedBundle.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 *FinalizedBundle) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalizedBundle.Merge(m, src) +} +func (m *FinalizedBundle) XXX_Size() int { + return m.Size() +} +func (m *FinalizedBundle) XXX_DiscardUnknown() { + xxx_messageInfo_FinalizedBundle.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalizedBundle proto.InternalMessageInfo + +func (m *FinalizedBundle) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *FinalizedBundle) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *FinalizedBundle) GetStorageId() string { + if m != nil { + return m.StorageId + } + return "" +} + +func (m *FinalizedBundle) GetUploader() string { + if m != nil { + return m.Uploader + } + return "" +} + +func (m *FinalizedBundle) GetFromIndex() uint64 { + if m != nil { + return m.FromIndex + } + return 0 +} + +func (m *FinalizedBundle) GetToIndex() uint64 { + if m != nil { + return m.ToIndex + } + return 0 +} + +func (m *FinalizedBundle) GetFromKey() string { + if m != nil { + return m.FromKey + } + return "" +} + +func (m *FinalizedBundle) GetToKey() string { + if m != nil { + return m.ToKey + } + return "" +} + +func (m *FinalizedBundle) GetBundleSummary() string { + if m != nil { + return m.BundleSummary + } + return "" +} + +func (m *FinalizedBundle) GetDataHash() string { + if m != nil { + return m.DataHash + } + return "" +} + +func (m *FinalizedBundle) GetFinalizedAt() *FinalizedAt { + if m != nil { + return m.FinalizedAt + } + return nil +} + +func (m *FinalizedBundle) GetStorageProviderId() uint64 { + if m != nil { + return m.StorageProviderId + } + return 0 +} + +func (m *FinalizedBundle) GetCompressionId() uint64 { + if m != nil { + return m.CompressionId + } + return 0 +} + +func (m *FinalizedBundle) GetStakeSecurity() *StakeSecurity { + if m != nil { + return m.StakeSecurity + } + return nil +} + +// FinalizedAt stores information about finalization block and time. +type FinalizedAt struct { + // height is the block height in which the bundle got finalized. + Height *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=height,proto3,customtype=cosmossdk.io/math.Int" json:"height,omitempty"` + // timestamp is the UNIX timestamp of the block in which the bundle got finalized. + Timestamp string `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *FinalizedAt) Reset() { *m = FinalizedAt{} } +func (m *FinalizedAt) String() string { return proto.CompactTextString(m) } +func (*FinalizedAt) ProtoMessage() {} +func (*FinalizedAt) Descriptor() ([]byte, []int) { + return fileDescriptor_b49b126c38ac815c, []int{1} +} +func (m *FinalizedAt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalizedAt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalizedAt.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 *FinalizedAt) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalizedAt.Merge(m, src) +} +func (m *FinalizedAt) XXX_Size() int { + return m.Size() +} +func (m *FinalizedAt) XXX_DiscardUnknown() { + xxx_messageInfo_FinalizedAt.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalizedAt proto.InternalMessageInfo + +func (m *FinalizedAt) GetTimestamp() string { + if m != nil { + return m.Timestamp + } + return "" +} + +// StakeSecurity represents the relative security of a finalized bundle +type StakeSecurity struct { + // valid_vote_power gives the amount of $KYVE stake that voted `valid`. + ValidVotePower *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=valid_vote_power,json=validVotePower,proto3,customtype=cosmossdk.io/math.Int" json:"valid_vote_power,omitempty"` + // total_vote_power gives the amount of total $KYVE stake that was present in the pool + // during finalization. + TotalVotePower *cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=total_vote_power,json=totalVotePower,proto3,customtype=cosmossdk.io/math.Int" json:"total_vote_power,omitempty"` +} + +func (m *StakeSecurity) Reset() { *m = StakeSecurity{} } +func (m *StakeSecurity) String() string { return proto.CompactTextString(m) } +func (*StakeSecurity) ProtoMessage() {} +func (*StakeSecurity) Descriptor() ([]byte, []int) { + return fileDescriptor_b49b126c38ac815c, []int{2} +} +func (m *StakeSecurity) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakeSecurity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakeSecurity.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 *StakeSecurity) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakeSecurity.Merge(m, src) +} +func (m *StakeSecurity) XXX_Size() int { + return m.Size() +} +func (m *StakeSecurity) XXX_DiscardUnknown() { + xxx_messageInfo_StakeSecurity.DiscardUnknown(m) +} + +var xxx_messageInfo_StakeSecurity proto.InternalMessageInfo + // QueryFinalizedBundlesRequest is the request type for the Query/Staker RPC method. type QueryFinalizedBundlesRequest struct { // pagination defines an optional pagination for the request. Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` // pool_id ... PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // index is an optional parameter which tells the server to only show + // the bundle with the given index. This can not be combined with pagination. + Index string `protobuf:"bytes,3,opt,name=index,proto3" json:"index,omitempty"` } func (m *QueryFinalizedBundlesRequest) Reset() { *m = QueryFinalizedBundlesRequest{} } func (m *QueryFinalizedBundlesRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedBundlesRequest) ProtoMessage() {} func (*QueryFinalizedBundlesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{0} + return fileDescriptor_b49b126c38ac815c, []int{3} } func (m *QueryFinalizedBundlesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -86,10 +343,17 @@ func (m *QueryFinalizedBundlesRequest) GetPoolId() uint64 { return 0 } +func (m *QueryFinalizedBundlesRequest) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + // QueryStakersByPoolResponse is the response type for the Query/Staker RPC method. type QueryFinalizedBundlesResponse struct { // finalized_bundles ... - FinalizedBundles []types.FinalizedBundle `protobuf:"bytes,1,rep,name=finalized_bundles,json=finalizedBundles,proto3" json:"finalized_bundles"` + FinalizedBundles []FinalizedBundle `protobuf:"bytes,1,rep,name=finalized_bundles,json=finalizedBundles,proto3" json:"finalized_bundles"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -98,7 +362,7 @@ func (m *QueryFinalizedBundlesResponse) Reset() { *m = QueryFinalizedBun func (m *QueryFinalizedBundlesResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedBundlesResponse) ProtoMessage() {} func (*QueryFinalizedBundlesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{1} + return fileDescriptor_b49b126c38ac815c, []int{4} } func (m *QueryFinalizedBundlesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -127,7 +391,7 @@ func (m *QueryFinalizedBundlesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFinalizedBundlesResponse proto.InternalMessageInfo -func (m *QueryFinalizedBundlesResponse) GetFinalizedBundles() []types.FinalizedBundle { +func (m *QueryFinalizedBundlesResponse) GetFinalizedBundles() []FinalizedBundle { if m != nil { return m.FinalizedBundles } @@ -153,7 +417,7 @@ func (m *QueryFinalizedBundleRequest) Reset() { *m = QueryFinalizedBundl func (m *QueryFinalizedBundleRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedBundleRequest) ProtoMessage() {} func (*QueryFinalizedBundleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{2} + return fileDescriptor_b49b126c38ac815c, []int{5} } func (m *QueryFinalizedBundleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,15 +462,15 @@ func (m *QueryFinalizedBundleRequest) GetId() uint64 { // QueryFinalizedBundleResponse is the response type for the Query/Staker RPC method. type QueryFinalizedBundleResponse struct { - // finalized_bundle ... - FinalizedBundle types.FinalizedBundle `protobuf:"bytes,1,opt,name=finalized_bundle,json=finalizedBundle,proto3" json:"finalized_bundle"` + // finalized_bundles ... + FinalizedBundles FinalizedBundle `protobuf:"bytes,1,opt,name=finalized_bundles,json=finalizedBundles,proto3" json:"finalized_bundles"` } func (m *QueryFinalizedBundleResponse) Reset() { *m = QueryFinalizedBundleResponse{} } func (m *QueryFinalizedBundleResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedBundleResponse) ProtoMessage() {} func (*QueryFinalizedBundleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{3} + return fileDescriptor_b49b126c38ac815c, []int{6} } func (m *QueryFinalizedBundleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,112 +499,11 @@ func (m *QueryFinalizedBundleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFinalizedBundleResponse proto.InternalMessageInfo -func (m *QueryFinalizedBundleResponse) GetFinalizedBundle() types.FinalizedBundle { - if m != nil { - return m.FinalizedBundle - } - return types.FinalizedBundle{} -} - -// QueryFinalizedBundleRequest is the request type for the Query/Staker RPC method. -type QueryFinalizedBundlesByHeightRequest struct { - // pool_id ... - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - // id ... - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *QueryFinalizedBundlesByHeightRequest) Reset() { *m = QueryFinalizedBundlesByHeightRequest{} } -func (m *QueryFinalizedBundlesByHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFinalizedBundlesByHeightRequest) ProtoMessage() {} -func (*QueryFinalizedBundlesByHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{4} -} -func (m *QueryFinalizedBundlesByHeightRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryFinalizedBundlesByHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryFinalizedBundlesByHeightRequest.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 *QueryFinalizedBundlesByHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalizedBundlesByHeightRequest.Merge(m, src) -} -func (m *QueryFinalizedBundlesByHeightRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryFinalizedBundlesByHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalizedBundlesByHeightRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryFinalizedBundlesByHeightRequest proto.InternalMessageInfo - -func (m *QueryFinalizedBundlesByHeightRequest) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - -func (m *QueryFinalizedBundlesByHeightRequest) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -// QueryFinalizedBundleResponse is the response type for the Query/Staker RPC method. -type QueryFinalizedBundlesByHeightResponse struct { - // finalized_bundle ... - FinalizedBundle types.FinalizedBundle `protobuf:"bytes,1,opt,name=finalized_bundle,json=finalizedBundle,proto3" json:"finalized_bundle"` -} - -func (m *QueryFinalizedBundlesByHeightResponse) Reset() { *m = QueryFinalizedBundlesByHeightResponse{} } -func (m *QueryFinalizedBundlesByHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryFinalizedBundlesByHeightResponse) ProtoMessage() {} -func (*QueryFinalizedBundlesByHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{5} -} -func (m *QueryFinalizedBundlesByHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryFinalizedBundlesByHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryFinalizedBundlesByHeightResponse.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 *QueryFinalizedBundlesByHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalizedBundlesByHeightResponse.Merge(m, src) -} -func (m *QueryFinalizedBundlesByHeightResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryFinalizedBundlesByHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalizedBundlesByHeightResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryFinalizedBundlesByHeightResponse proto.InternalMessageInfo - -func (m *QueryFinalizedBundlesByHeightResponse) GetFinalizedBundle() types.FinalizedBundle { +func (m *QueryFinalizedBundleResponse) GetFinalizedBundles() FinalizedBundle { if m != nil { - return m.FinalizedBundle + return m.FinalizedBundles } - return types.FinalizedBundle{} + return FinalizedBundle{} } // QueryCurrentVoteStatusRequest is the request type for the Query/Staker RPC method. @@ -353,7 +516,7 @@ func (m *QueryCurrentVoteStatusRequest) Reset() { *m = QueryCurrentVoteS func (m *QueryCurrentVoteStatusRequest) String() string { return proto.CompactTextString(m) } func (*QueryCurrentVoteStatusRequest) ProtoMessage() {} func (*QueryCurrentVoteStatusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{6} + return fileDescriptor_b49b126c38ac815c, []int{7} } func (m *QueryCurrentVoteStatusRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -405,7 +568,7 @@ func (m *QueryCurrentVoteStatusResponse) Reset() { *m = QueryCurrentVote func (m *QueryCurrentVoteStatusResponse) String() string { return proto.CompactTextString(m) } func (*QueryCurrentVoteStatusResponse) ProtoMessage() {} func (*QueryCurrentVoteStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{7} + return fileDescriptor_b49b126c38ac815c, []int{8} } func (m *QueryCurrentVoteStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -474,7 +637,7 @@ func (m *QueryCanValidateRequest) Reset() { *m = QueryCanValidateRequest func (m *QueryCanValidateRequest) String() string { return proto.CompactTextString(m) } func (*QueryCanValidateRequest) ProtoMessage() {} func (*QueryCanValidateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{8} + return fileDescriptor_b49b126c38ac815c, []int{9} } func (m *QueryCanValidateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -529,7 +692,7 @@ func (m *QueryCanValidateResponse) Reset() { *m = QueryCanValidateRespon func (m *QueryCanValidateResponse) String() string { return proto.CompactTextString(m) } func (*QueryCanValidateResponse) ProtoMessage() {} func (*QueryCanValidateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{9} + return fileDescriptor_b49b126c38ac815c, []int{10} } func (m *QueryCanValidateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -588,7 +751,7 @@ func (m *QueryCanProposeRequest) Reset() { *m = QueryCanProposeRequest{} func (m *QueryCanProposeRequest) String() string { return proto.CompactTextString(m) } func (*QueryCanProposeRequest) ProtoMessage() {} func (*QueryCanProposeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{10} + return fileDescriptor_b49b126c38ac815c, []int{11} } func (m *QueryCanProposeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -657,7 +820,7 @@ func (m *QueryCanProposeResponse) Reset() { *m = QueryCanProposeResponse func (m *QueryCanProposeResponse) String() string { return proto.CompactTextString(m) } func (*QueryCanProposeResponse) ProtoMessage() {} func (*QueryCanProposeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{11} + return fileDescriptor_b49b126c38ac815c, []int{12} } func (m *QueryCanProposeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -716,7 +879,7 @@ func (m *QueryCanVoteRequest) Reset() { *m = QueryCanVoteRequest{} } func (m *QueryCanVoteRequest) String() string { return proto.CompactTextString(m) } func (*QueryCanVoteRequest) ProtoMessage() {} func (*QueryCanVoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{12} + return fileDescriptor_b49b126c38ac815c, []int{13} } func (m *QueryCanVoteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -785,7 +948,7 @@ func (m *QueryCanVoteResponse) Reset() { *m = QueryCanVoteResponse{} } func (m *QueryCanVoteResponse) String() string { return proto.CompactTextString(m) } func (*QueryCanVoteResponse) ProtoMessage() {} func (*QueryCanVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b49b126c38ac815c, []int{13} + return fileDescriptor_b49b126c38ac815c, []int{14} } func (m *QueryCanVoteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -829,12 +992,13 @@ func (m *QueryCanVoteResponse) GetReason() string { } func init() { + proto.RegisterType((*FinalizedBundle)(nil), "kyve.query.v1beta1.FinalizedBundle") + proto.RegisterType((*FinalizedAt)(nil), "kyve.query.v1beta1.FinalizedAt") + proto.RegisterType((*StakeSecurity)(nil), "kyve.query.v1beta1.StakeSecurity") proto.RegisterType((*QueryFinalizedBundlesRequest)(nil), "kyve.query.v1beta1.QueryFinalizedBundlesRequest") proto.RegisterType((*QueryFinalizedBundlesResponse)(nil), "kyve.query.v1beta1.QueryFinalizedBundlesResponse") proto.RegisterType((*QueryFinalizedBundleRequest)(nil), "kyve.query.v1beta1.QueryFinalizedBundleRequest") proto.RegisterType((*QueryFinalizedBundleResponse)(nil), "kyve.query.v1beta1.QueryFinalizedBundleResponse") - proto.RegisterType((*QueryFinalizedBundlesByHeightRequest)(nil), "kyve.query.v1beta1.QueryFinalizedBundlesByHeightRequest") - proto.RegisterType((*QueryFinalizedBundlesByHeightResponse)(nil), "kyve.query.v1beta1.QueryFinalizedBundlesByHeightResponse") proto.RegisterType((*QueryCurrentVoteStatusRequest)(nil), "kyve.query.v1beta1.QueryCurrentVoteStatusRequest") proto.RegisterType((*QueryCurrentVoteStatusResponse)(nil), "kyve.query.v1beta1.QueryCurrentVoteStatusResponse") proto.RegisterType((*QueryCanValidateRequest)(nil), "kyve.query.v1beta1.QueryCanValidateRequest") @@ -848,67 +1012,82 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/bundles.proto", fileDescriptor_b49b126c38ac815c) } var fileDescriptor_b49b126c38ac815c = []byte{ - // 960 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xb8, 0x21, 0xa9, 0x5f, 0x10, 0x4d, 0x87, 0xa8, 0xb5, 0x96, 0xd6, 0x44, 0x2b, 0x4a, - 0xa3, 0x14, 0xed, 0xd4, 0x89, 0x50, 0x1b, 0x71, 0x40, 0xa4, 0x25, 0x90, 0x52, 0xaa, 0xb2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0xc9, 0xfd, 0x0a, 0x41, - 0x79, 0x52, 0xa9, 0x05, 0xbd, 0x04, 0x2f, 0xb4, 0x68, 0xbd, 0x57, 0x69, 0x02, 0x5c, 0x82, 0xf9, - 0x28, 0x36, 0x79, 0x23, 0x46, 0x1a, 0xaa, 0x15, 0x5a, 0x13, 0x92, 0x46, 0x71, 0xe9, 0x82, 0x59, - 0xb1, 0xa1, 0xea, 0x24, 0xb9, 0xa4, 0xf5, 0xd2, 0xac, 0xe9, 0xa4, 0x03, 0xd7, 0x87, 0xab, 0x06, - 0x01, 0x8d, 0x77, 0x54, 0x03, 0x2a, 0xa7, 0x5f, 0xa9, 0x32, 0x40, 0x8b, 0xd6, 0x69, 0x10, 0x24, - 0x4c, 0x08, 0x0d, 0xa0, 0xe8, 0x67, 0x32, 0xee, 0x23, 0x28, 0x8d, 0xf6, 0xb4, 0x7c, 0x1c, 0xb8, - 0xd8, 0xe0, 0x42, 0x44, 0x35, 0x2b, 0xfe, 0x45, 0xbf, 0x17, 0xab, 0x13, 0x4e, 0x18, 0x15, 0xf6, - 0x3b, 0x29, 0xfa, 0x36, 0x72, 0xbf, 0x41, 0x70, 0x25, 0x6d, 0xf8, 0x38, 0xe1, 0x0d, 0x2e, 0x58, - 0x9e, 0xdb, 0x22, 0x24, 0x3d, 0x60, 0x49, 0xda, 0xcb, 0x44, 0x7a, 0xbe, 0x69, 0x91, 0x68, 0x81, - 0x8a, 0x7e, 0x2f, 0xc6, 0xd7, 0x01, 0xf6, 0x12, 0x7e, 0x58, 0x8d, 0xe2, 0x80, 0x3d, 0xb5, 0x32, - 0x15, 0x55, 0x66, 0x5b, 0x25, 0xdc, 0x0f, 0xfb, 0x52, 0xf5, 0x50, 0xfc, 0x07, 0x56, 0x1d, 0x78, - 0xb9, 0xa7, 0x12, 0x97, 0xe7, 0x67, 0xa4, 0x6e, 0x08, 0x97, 0x3d, 0x3a, 0x26, 0x50, 0x5c, 0x84, - 0xe4, 0x09, 0x0d, 0x99, 0xea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 0x00, 0x00, + // 1191 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xba, 0x8e, 0x7f, 0x3c, 0x37, 0xa1, 0x99, 0x26, 0xe9, 0xd6, 0x4d, 0x9d, 0x74, 0x11, + 0x24, 0x4a, 0xd1, 0x2e, 0x49, 0x0f, 0xd0, 0x13, 0x22, 0x2d, 0xa1, 0x6e, 0x4b, 0x15, 0x36, 0x52, + 0x24, 0x38, 0x60, 0x8d, 0xbd, 0x13, 0x7b, 0x15, 0x7b, 0x67, 0xbb, 0x33, 0x76, 0x6b, 0x22, 0x4b, + 0x08, 0x71, 0xe2, 0x84, 0x84, 0x8a, 0xc4, 0x8d, 0x2b, 0xdc, 0x39, 0x70, 0xe3, 0xd8, 0x63, 0x25, + 0x2e, 0x88, 0x43, 0x85, 0x12, 0xfe, 0x10, 0x34, 0x3f, 0xd6, 0xde, 0x38, 0x76, 0x9c, 0xb6, 0x37, + 0xbf, 0x37, 0xef, 0xbd, 0xf9, 0xde, 0xb7, 0xef, 0x7d, 0xbb, 0x86, 0x95, 0x83, 0x6e, 0x87, 0x38, + 0x8f, 0xdb, 0x24, 0xea, 0x3a, 0x9d, 0x8d, 0x2a, 0xe1, 0x78, 0xc3, 0xa9, 0xb6, 0x03, 0xaf, 0x49, + 0x98, 0x1d, 0x46, 0x94, 0x53, 0x84, 0x44, 0x84, 0x2d, 0x23, 0x6c, 0x1d, 0x51, 0x5c, 0xaf, 0x51, + 0xd6, 0xa2, 0xcc, 0xa9, 0x62, 0x36, 0x9c, 0x1c, 0xe2, 0xba, 0x1f, 0x60, 0xee, 0xd3, 0x40, 0xe5, + 0x17, 0xe7, 0xeb, 0xb4, 0x4e, 0xe5, 0x4f, 0x47, 0xfc, 0xd2, 0xde, 0xa5, 0x3a, 0xa5, 0xf5, 0x26, + 0x71, 0x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, 0x34, 0x55, 0x30, 0x37, 0x61, 0xc5, 0x58, 0x2b, 0x6c, + 0x2e, 0xdb, 0xa7, 0x1f, 0x99, 0xdd, 0xa7, 0xf3, 0x63, 0xee, 0x16, 0xf6, 0x07, 0x06, 0xb2, 0xe1, + 0x72, 0x4c, 0x57, 0x18, 0xd1, 0x8e, 0xef, 0x91, 0x48, 0xf0, 0x76, 0x51, 0xf6, 0x37, 0xa7, 0x8f, + 0x76, 0xf4, 0x49, 0xd9, 0x13, 0xb8, 0x6b, 0xb4, 0x15, 0x46, 0x84, 0x31, 0x9f, 0x06, 0x22, 0x74, + 0x46, 0x86, 0xce, 0x24, 0xbc, 0x65, 0x0f, 0xdd, 0x83, 0x59, 0xc6, 0xf1, 0x01, 0xa9, 0x30, 0x52, + 0x6b, 0x47, 0x3e, 0xef, 0x9a, 0xb3, 0x12, 0xdc, 0x8d, 0x51, 0xe0, 0x76, 0x45, 0xe4, 0xae, 0x0e, + 0x74, 0x67, 0x58, 0xd2, 0xb4, 0xbe, 0x82, 0x42, 0x02, 0x3c, 0xda, 0x80, 0x4c, 0x83, 0xf8, 0xf5, + 0x06, 0x97, 0x63, 0x90, 0xdf, 0xba, 0xfa, 0xcf, 0xcb, 0xe5, 0x05, 0x35, 0x8f, 0xcc, 0x3b, 0xb0, + 0x7d, 0xea, 0xb4, 0x30, 0x6f, 0xd8, 0xe5, 0x80, 0xbb, 0x3a, 0x10, 0x2d, 0x41, 0x9e, 0xfb, 0x2d, + 0xc2, 0x38, 0x6e, 0x85, 0x72, 0x50, 0xf2, 0xee, 0xc0, 0x61, 0xfd, 0x6c, 0xc0, 0xcc, 0x09, 0x00, + 0xe8, 0x0e, 0x5c, 0xea, 0xe0, 0xa6, 0xef, 0x55, 0x3a, 0x94, 0x93, 0x4a, 0x48, 0x9f, 0x90, 0x68, + 0xf2, 0x65, 0xb3, 0x32, 0x65, 0x8f, 0x72, 0xb2, 0x23, 0x12, 0x44, 0x11, 0x4e, 0x39, 0x6e, 0x26, + 0x8b, 0xa4, 0x26, 0x16, 0x91, 0x29, 0xfd, 0x22, 0xd6, 0x33, 0x03, 0x96, 0x3e, 0x17, 0x54, 0x0d, + 0x6d, 0x03, 0x73, 0xc9, 0xe3, 0x36, 0x61, 0x1c, 0x6d, 0x03, 0x0c, 0x36, 0x4e, 0x82, 0x2c, 0x6c, + 0xbe, 0x6b, 0xab, 0xe2, 0xb6, 0x58, 0xcf, 0x21, 0xa6, 0x77, 0x70, 0x9d, 0xe8, 0x5c, 0x37, 0x91, + 0x99, 0xdc, 0xae, 0xd4, 0x89, 0xed, 0x9a, 0x87, 0x69, 0x35, 0xf0, 0x6a, 0x91, 0x94, 0x61, 0xfd, + 0x69, 0xc0, 0xf5, 0x31, 0xb8, 0x58, 0x48, 0x03, 0x46, 0xd0, 0x1e, 0xcc, 0x0d, 0x46, 0x53, 0x2b, + 0x8a, 0x69, 0xac, 0x5c, 0x58, 0x2b, 0x6c, 0xbe, 0x7d, 0xe6, 0x7c, 0xaa, 0x42, 0x5b, 0xe9, 0xe7, + 0x2f, 0x97, 0xa7, 0xdc, 0x4b, 0xfb, 0x43, 0xf5, 0xd1, 0xa7, 0x27, 0x1a, 0x4e, 0xc9, 0x86, 0x57, + 0x27, 0x36, 0xac, 0x40, 0x25, 0x3b, 0xb6, 0xb6, 0xe1, 0xda, 0xa8, 0x0e, 0x62, 0x62, 0xcf, 0x2b, + 0x37, 0x56, 0x67, 0xf4, 0x13, 0x9a, 0x44, 0x84, 0xf1, 0x86, 0x44, 0x58, 0x1f, 0xea, 0x27, 0x70, + 0xa7, 0x1d, 0x45, 0x24, 0xe0, 0x62, 0x66, 0x76, 0x39, 0xe6, 0x6d, 0x36, 0xa9, 0x03, 0xeb, 0x1b, + 0x03, 0x4a, 0xe3, 0x52, 0x35, 0xe8, 0x79, 0x98, 0x96, 0xe3, 0xac, 0x33, 0x95, 0x81, 0x4c, 0xc8, + 0xfa, 0x81, 0xf2, 0xab, 0xfe, 0x63, 0x53, 0x9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c, 0x9b, 0x1c, 0xa8, 0x21, 0x3f, 0x94, 0x90, 0xb7, 0xd1, 0xdd, 0xb1, 0xdc, 0x52, 0x3e, + 0x1a, 0xaf, 0x54, 0x1d, 0xe9, 0x88, 0x45, 0xa7, 0xb7, 0x75, 0xf7, 0xf9, 0x51, 0xc9, 0x78, 0x71, + 0x54, 0x32, 0xfe, 0x3d, 0x2a, 0x19, 0x3f, 0x1c, 0x97, 0xa6, 0x5e, 0x1c, 0x97, 0xa6, 0xfe, 0x3e, + 0x2e, 0x4d, 0x7d, 0xb9, 0x5e, 0xf7, 0x79, 0xa3, 0x5d, 0xb5, 0x6b, 0xb4, 0xe5, 0x3c, 0xf8, 0x62, + 0xef, 0x93, 0x47, 0x84, 0x3f, 0xa1, 0xd1, 0x81, 0x53, 0x6b, 0x60, 0x3f, 0x70, 0x9e, 0xea, 0x8b, + 0x79, 0x37, 0x24, 0xac, 0x9a, 0x91, 0xff, 0x44, 0x6e, 0xfd, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x9f, + 0x9d, 0x46, 0xd3, 0x21, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -924,11 +1103,9 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryBundlesClient interface { // FinalizedBundles ... - FinalizedBundles(ctx context.Context, in *QueryFinalizedBundlesRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesResponse, error) + FinalizedBundlesQuery(ctx context.Context, in *QueryFinalizedBundlesRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesResponse, error) // FinalizedBundle ... - FinalizedBundle(ctx context.Context, in *QueryFinalizedBundleRequest, opts ...grpc.CallOption) (*QueryFinalizedBundleResponse, error) - // Queries the bundle which contains the data given height - FinalizedBundlesByHeight(ctx context.Context, in *QueryFinalizedBundlesByHeightRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesByHeightResponse, error) + FinalizedBundleQuery(ctx context.Context, in *QueryFinalizedBundleRequest, opts ...grpc.CallOption) (*FinalizedBundle, error) // CurrentVoteStatus ... CurrentVoteStatus(ctx context.Context, in *QueryCurrentVoteStatusRequest, opts ...grpc.CallOption) (*QueryCurrentVoteStatusResponse, error) // CanValidate ... @@ -947,27 +1124,18 @@ func NewQueryBundlesClient(cc grpc1.ClientConn) QueryBundlesClient { return &queryBundlesClient{cc} } -func (c *queryBundlesClient) FinalizedBundles(ctx context.Context, in *QueryFinalizedBundlesRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesResponse, error) { +func (c *queryBundlesClient) FinalizedBundlesQuery(ctx context.Context, in *QueryFinalizedBundlesRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesResponse, error) { out := new(QueryFinalizedBundlesResponse) - err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryBundles/FinalizedBundles", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryBundlesClient) FinalizedBundle(ctx context.Context, in *QueryFinalizedBundleRequest, opts ...grpc.CallOption) (*QueryFinalizedBundleResponse, error) { - out := new(QueryFinalizedBundleResponse) - err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryBundles/FinalizedBundle", in, out, opts...) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryBundles/FinalizedBundlesQuery", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryBundlesClient) FinalizedBundlesByHeight(ctx context.Context, in *QueryFinalizedBundlesByHeightRequest, opts ...grpc.CallOption) (*QueryFinalizedBundlesByHeightResponse, error) { - out := new(QueryFinalizedBundlesByHeightResponse) - err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryBundles/FinalizedBundlesByHeight", in, out, opts...) +func (c *queryBundlesClient) FinalizedBundleQuery(ctx context.Context, in *QueryFinalizedBundleRequest, opts ...grpc.CallOption) (*FinalizedBundle, error) { + out := new(FinalizedBundle) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryBundles/FinalizedBundleQuery", in, out, opts...) if err != nil { return nil, err } @@ -1013,11 +1181,9 @@ func (c *queryBundlesClient) CanVote(ctx context.Context, in *QueryCanVoteReques // QueryBundlesServer is the server API for QueryBundles service. type QueryBundlesServer interface { // FinalizedBundles ... - FinalizedBundles(context.Context, *QueryFinalizedBundlesRequest) (*QueryFinalizedBundlesResponse, error) + FinalizedBundlesQuery(context.Context, *QueryFinalizedBundlesRequest) (*QueryFinalizedBundlesResponse, error) // FinalizedBundle ... - FinalizedBundle(context.Context, *QueryFinalizedBundleRequest) (*QueryFinalizedBundleResponse, error) - // Queries the bundle which contains the data given height - FinalizedBundlesByHeight(context.Context, *QueryFinalizedBundlesByHeightRequest) (*QueryFinalizedBundlesByHeightResponse, error) + FinalizedBundleQuery(context.Context, *QueryFinalizedBundleRequest) (*FinalizedBundle, error) // CurrentVoteStatus ... CurrentVoteStatus(context.Context, *QueryCurrentVoteStatusRequest) (*QueryCurrentVoteStatusResponse, error) // CanValidate ... @@ -1032,14 +1198,11 @@ type QueryBundlesServer interface { type UnimplementedQueryBundlesServer struct { } -func (*UnimplementedQueryBundlesServer) FinalizedBundles(ctx context.Context, req *QueryFinalizedBundlesRequest) (*QueryFinalizedBundlesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalizedBundles not implemented") -} -func (*UnimplementedQueryBundlesServer) FinalizedBundle(ctx context.Context, req *QueryFinalizedBundleRequest) (*QueryFinalizedBundleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalizedBundle not implemented") +func (*UnimplementedQueryBundlesServer) FinalizedBundlesQuery(ctx context.Context, req *QueryFinalizedBundlesRequest) (*QueryFinalizedBundlesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalizedBundlesQuery not implemented") } -func (*UnimplementedQueryBundlesServer) FinalizedBundlesByHeight(ctx context.Context, req *QueryFinalizedBundlesByHeightRequest) (*QueryFinalizedBundlesByHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalizedBundlesByHeight not implemented") +func (*UnimplementedQueryBundlesServer) FinalizedBundleQuery(ctx context.Context, req *QueryFinalizedBundleRequest) (*FinalizedBundle, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalizedBundleQuery not implemented") } func (*UnimplementedQueryBundlesServer) CurrentVoteStatus(ctx context.Context, req *QueryCurrentVoteStatusRequest) (*QueryCurrentVoteStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CurrentVoteStatus not implemented") @@ -1058,80 +1221,62 @@ func RegisterQueryBundlesServer(s grpc1.Server, srv QueryBundlesServer) { s.RegisterService(&_QueryBundles_serviceDesc, srv) } -func _QueryBundles_FinalizedBundles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _QueryBundles_FinalizedBundlesQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryFinalizedBundlesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryBundlesServer).FinalizedBundles(ctx, in) + return srv.(QueryBundlesServer).FinalizedBundlesQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kyve.query.v1beta1.QueryBundles/FinalizedBundles", + FullMethod: "/kyve.query.v1beta1.QueryBundles/FinalizedBundlesQuery", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryBundlesServer).FinalizedBundles(ctx, req.(*QueryFinalizedBundlesRequest)) + return srv.(QueryBundlesServer).FinalizedBundlesQuery(ctx, req.(*QueryFinalizedBundlesRequest)) } return interceptor(ctx, in, info, handler) } -func _QueryBundles_FinalizedBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _QueryBundles_FinalizedBundleQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryFinalizedBundleRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryBundlesServer).FinalizedBundle(ctx, in) + return srv.(QueryBundlesServer).FinalizedBundleQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kyve.query.v1beta1.QueryBundles/FinalizedBundle", + FullMethod: "/kyve.query.v1beta1.QueryBundles/FinalizedBundleQuery", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryBundlesServer).FinalizedBundle(ctx, req.(*QueryFinalizedBundleRequest)) + return srv.(QueryBundlesServer).FinalizedBundleQuery(ctx, req.(*QueryFinalizedBundleRequest)) } return interceptor(ctx, in, info, handler) } -func _QueryBundles_FinalizedBundlesByHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalizedBundlesByHeightRequest) +func _QueryBundles_CurrentVoteStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCurrentVoteStatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryBundlesServer).FinalizedBundlesByHeight(ctx, in) + return srv.(QueryBundlesServer).CurrentVoteStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kyve.query.v1beta1.QueryBundles/FinalizedBundlesByHeight", + FullMethod: "/kyve.query.v1beta1.QueryBundles/CurrentVoteStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryBundlesServer).FinalizedBundlesByHeight(ctx, req.(*QueryFinalizedBundlesByHeightRequest)) + return srv.(QueryBundlesServer).CurrentVoteStatus(ctx, req.(*QueryCurrentVoteStatusRequest)) } return interceptor(ctx, in, info, handler) } -func _QueryBundles_CurrentVoteStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCurrentVoteStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryBundlesServer).CurrentVoteStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kyve.query.v1beta1.QueryBundles/CurrentVoteStatus", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryBundlesServer).CurrentVoteStatus(ctx, req.(*QueryCurrentVoteStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _QueryBundles_CanValidate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCanValidateRequest) +func _QueryBundles_CanValidate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCanValidateRequest) if err := dec(in); err != nil { return nil, err } @@ -1189,16 +1334,12 @@ var _QueryBundles_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryBundlesServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "FinalizedBundles", - Handler: _QueryBundles_FinalizedBundles_Handler, - }, - { - MethodName: "FinalizedBundle", - Handler: _QueryBundles_FinalizedBundle_Handler, + MethodName: "FinalizedBundlesQuery", + Handler: _QueryBundles_FinalizedBundlesQuery_Handler, }, { - MethodName: "FinalizedBundlesByHeight", - Handler: _QueryBundles_FinalizedBundlesByHeight_Handler, + MethodName: "FinalizedBundleQuery", + Handler: _QueryBundles_FinalizedBundleQuery_Handler, }, { MethodName: "CurrentVoteStatus", @@ -1221,7 +1362,7 @@ var _QueryBundles_serviceDesc = grpc.ServiceDesc{ Metadata: "kyve/query/v1beta1/bundles.proto", } -func (m *QueryFinalizedBundlesRequest) Marshal() (dAtA []byte, err error) { +func (m *FinalizedBundle) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1231,24 +1372,48 @@ func (m *QueryFinalizedBundlesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalizedBundlesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *FinalizedBundle) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundlesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *FinalizedBundle) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.PoolId != 0 { - i = encodeVarintBundles(dAtA, i, uint64(m.PoolId)) + if m.StakeSecurity != nil { + { + size, err := m.StakeSecurity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x10 + dAtA[i] = 0x72 } - if m.Pagination != nil { + if m.CompressionId != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.CompressionId)) + i-- + dAtA[i] = 0x68 + } + if m.StorageProviderId != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.StorageProviderId)) + i-- + dAtA[i] = 0x60 + } + if len(m.FromKey) > 0 { + i -= len(m.FromKey) + copy(dAtA[i:], m.FromKey) + i = encodeVarintBundles(dAtA, i, uint64(len(m.FromKey))) + i-- + dAtA[i] = 0x5a + } + if m.FinalizedAt != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.FinalizedAt.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1256,12 +1421,67 @@ func (m *QueryFinalizedBundlesRequest) MarshalToSizedBuffer(dAtA []byte) (int, e i = encodeVarintBundles(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x52 + } + if len(m.DataHash) > 0 { + i -= len(m.DataHash) + copy(dAtA[i:], m.DataHash) + i = encodeVarintBundles(dAtA, i, uint64(len(m.DataHash))) + i-- + dAtA[i] = 0x4a + } + if len(m.BundleSummary) > 0 { + i -= len(m.BundleSummary) + copy(dAtA[i:], m.BundleSummary) + i = encodeVarintBundles(dAtA, i, uint64(len(m.BundleSummary))) + i-- + dAtA[i] = 0x42 + } + if len(m.ToKey) > 0 { + i -= len(m.ToKey) + copy(dAtA[i:], m.ToKey) + i = encodeVarintBundles(dAtA, i, uint64(len(m.ToKey))) + i-- + dAtA[i] = 0x3a + } + if m.ToIndex != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.ToIndex)) + i-- + dAtA[i] = 0x30 + } + if m.FromIndex != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.FromIndex)) + i-- + dAtA[i] = 0x28 + } + if len(m.Uploader) > 0 { + i -= len(m.Uploader) + copy(dAtA[i:], m.Uploader) + i = encodeVarintBundles(dAtA, i, uint64(len(m.Uploader))) + i-- + dAtA[i] = 0x22 + } + if len(m.StorageId) > 0 { + i -= len(m.StorageId) + copy(dAtA[i:], m.StorageId) + i = encodeVarintBundles(dAtA, i, uint64(len(m.StorageId))) + i-- + dAtA[i] = 0x1a + } + if m.Id != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x10 + } + if m.PoolId != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QueryFinalizedBundlesResponse) Marshal() (dAtA []byte, err error) { +func (m *FinalizedAt) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1271,46 +1491,86 @@ func (m *QueryFinalizedBundlesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalizedBundlesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *FinalizedAt) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundlesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *FinalizedAt) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { + if len(m.Timestamp) > 0 { + i -= len(m.Timestamp) + copy(dAtA[i:], m.Timestamp) + i = encodeVarintBundles(dAtA, i, uint64(len(m.Timestamp))) + i-- + dAtA[i] = 0x12 + } + if m.Height != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Height.Size() + i -= size + if _, err := m.Height.MarshalTo(dAtA[i:]); err != nil { return 0, err } + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakeSecurity) 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 *StakeSecurity) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakeSecurity) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalVotePower != nil { + { + size := m.TotalVotePower.Size() i -= size + if _, err := m.TotalVotePower.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } i = encodeVarintBundles(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } - if len(m.FinalizedBundles) > 0 { - for iNdEx := len(m.FinalizedBundles) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FinalizedBundles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBundles(dAtA, i, uint64(size)) + if m.ValidVotePower != nil { + { + size := m.ValidVotePower.Size() + i -= size + if _, err := m.ValidVotePower.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i = encodeVarintBundles(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryFinalizedBundleRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalizedBundlesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1320,30 +1580,44 @@ func (m *QueryFinalizedBundleRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalizedBundleRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundlesRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundlesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Id != 0 { - i = encodeVarintBundles(dAtA, i, uint64(m.Id)) + if len(m.Index) > 0 { + i -= len(m.Index) + copy(dAtA[i:], m.Index) + i = encodeVarintBundles(dAtA, i, uint64(len(m.Index))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x1a } if m.PoolId != 0 { i = encodeVarintBundles(dAtA, i, uint64(m.PoolId)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x10 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryFinalizedBundleResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalizedBundlesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1353,30 +1627,46 @@ func (m *QueryFinalizedBundleResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryFinalizedBundleResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundlesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundlesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.FinalizedBundle.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.FinalizedBundles) > 0 { + for iNdEx := len(m.FinalizedBundles) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FinalizedBundles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - i -= size - i = encodeVarintBundles(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *QueryFinalizedBundlesByHeightRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalizedBundleRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1386,18 +1676,18 @@ func (m *QueryFinalizedBundlesByHeightRequest) Marshal() (dAtA []byte, err error return dAtA[:n], nil } -func (m *QueryFinalizedBundlesByHeightRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundleRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundlesByHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Height != 0 { - i = encodeVarintBundles(dAtA, i, uint64(m.Height)) + if m.Id != 0 { + i = encodeVarintBundles(dAtA, i, uint64(m.Id)) i-- dAtA[i] = 0x10 } @@ -1409,7 +1699,7 @@ func (m *QueryFinalizedBundlesByHeightRequest) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *QueryFinalizedBundlesByHeightResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalizedBundleResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1419,18 +1709,18 @@ func (m *QueryFinalizedBundlesByHeightResponse) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *QueryFinalizedBundlesByHeightResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundleResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalizedBundlesByHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalizedBundleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.FinalizedBundle.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.FinalizedBundles.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1775,68 +2065,139 @@ func encodeVarintBundles(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryFinalizedBundlesRequest) Size() (n int) { +func (m *FinalizedBundle) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovBundles(uint64(l)) - } if m.PoolId != 0 { n += 1 + sovBundles(uint64(m.PoolId)) } + if m.Id != 0 { + n += 1 + sovBundles(uint64(m.Id)) + } + l = len(m.StorageId) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.Uploader) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + if m.FromIndex != 0 { + n += 1 + sovBundles(uint64(m.FromIndex)) + } + if m.ToIndex != 0 { + n += 1 + sovBundles(uint64(m.ToIndex)) + } + l = len(m.ToKey) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.BundleSummary) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.DataHash) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + if m.FinalizedAt != nil { + l = m.FinalizedAt.Size() + n += 1 + l + sovBundles(uint64(l)) + } + l = len(m.FromKey) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + if m.StorageProviderId != 0 { + n += 1 + sovBundles(uint64(m.StorageProviderId)) + } + if m.CompressionId != 0 { + n += 1 + sovBundles(uint64(m.CompressionId)) + } + if m.StakeSecurity != nil { + l = m.StakeSecurity.Size() + n += 1 + l + sovBundles(uint64(l)) + } return n } -func (m *QueryFinalizedBundlesResponse) Size() (n int) { +func (m *FinalizedAt) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.FinalizedBundles) > 0 { - for _, e := range m.FinalizedBundles { - l = e.Size() - n += 1 + l + sovBundles(uint64(l)) - } + if m.Height != nil { + l = m.Height.Size() + n += 1 + l + sovBundles(uint64(l)) } - if m.Pagination != nil { - l = m.Pagination.Size() + l = len(m.Timestamp) + if l > 0 { n += 1 + l + sovBundles(uint64(l)) } return n } -func (m *QueryFinalizedBundleRequest) Size() (n int) { +func (m *StakeSecurity) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.PoolId != 0 { - n += 1 + sovBundles(uint64(m.PoolId)) + if m.ValidVotePower != nil { + l = m.ValidVotePower.Size() + n += 1 + l + sovBundles(uint64(l)) } - if m.Id != 0 { - n += 1 + sovBundles(uint64(m.Id)) + if m.TotalVotePower != nil { + l = m.TotalVotePower.Size() + n += 1 + l + sovBundles(uint64(l)) } return n } -func (m *QueryFinalizedBundleResponse) Size() (n int) { +func (m *QueryFinalizedBundlesRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.FinalizedBundle.Size() - n += 1 + l + sovBundles(uint64(l)) - return n -} + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovBundles(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovBundles(uint64(m.PoolId)) + } + l = len(m.Index) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + return n +} + +func (m *QueryFinalizedBundlesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FinalizedBundles) > 0 { + for _, e := range m.FinalizedBundles { + l = e.Size() + n += 1 + l + sovBundles(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovBundles(uint64(l)) + } + return n +} -func (m *QueryFinalizedBundlesByHeightRequest) Size() (n int) { +func (m *QueryFinalizedBundleRequest) Size() (n int) { if m == nil { return 0 } @@ -1845,19 +2206,19 @@ func (m *QueryFinalizedBundlesByHeightRequest) Size() (n int) { if m.PoolId != 0 { n += 1 + sovBundles(uint64(m.PoolId)) } - if m.Height != 0 { - n += 1 + sovBundles(uint64(m.Height)) + if m.Id != 0 { + n += 1 + sovBundles(uint64(m.Id)) } return n } -func (m *QueryFinalizedBundlesByHeightResponse) Size() (n int) { +func (m *QueryFinalizedBundleResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.FinalizedBundle.Size() + l = m.FinalizedBundles.Size() n += 1 + l + sovBundles(uint64(l)) return n } @@ -1987,32 +2348,460 @@ func (m *QueryCanVoteRequest) Size() (n int) { if l > 0 { n += 1 + l + sovBundles(uint64(l)) } - return n -} + return n +} + +func (m *QueryCanVoteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Possible { + n += 2 + } + l = len(m.Reason) + if l > 0 { + n += 1 + l + sovBundles(uint64(l)) + } + return n +} + +func sovBundles(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozBundles(x uint64) (n int) { + return sovBundles(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FinalizedBundle) 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 ErrIntOverflowBundles + } + 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: FinalizedBundle: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalizedBundle: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uploader", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uploader = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FromIndex", wireType) + } + m.FromIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FromIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToIndex", wireType) + } + m.ToIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ToIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ToKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BundleSummary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BundleSummary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DataHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalizedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FinalizedAt == nil { + m.FinalizedAt = &FinalizedAt{} + } + if err := m.FinalizedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + 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 ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageProviderId", wireType) + } + m.StorageProviderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StorageProviderId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CompressionId", wireType) + } + m.CompressionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CompressionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakeSecurity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StakeSecurity == nil { + m.StakeSecurity = &StakeSecurity{} + } + if err := m.StakeSecurity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBundles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBundles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *QueryCanVoteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Possible { - n += 2 - } - l = len(m.Reason) - if l > 0 { - n += 1 + l + sovBundles(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} - -func sovBundles(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozBundles(x uint64) (n int) { - return sovBundles(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { +func (m *FinalizedAt) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2035,17 +2824,17 @@ func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundlesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: FinalizedAt: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundlesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: FinalizedAt: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2055,33 +2844,33 @@ func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthBundles } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBundles } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v cosmossdk_io_math.Int + m.Height = &v + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) } - m.PoolId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2091,11 +2880,24 @@ func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Timestamp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBundles(dAtA[iNdEx:]) @@ -2117,7 +2919,7 @@ func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { +func (m *StakeSecurity) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2140,17 +2942,17 @@ func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundlesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: StakeSecurity: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundlesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StakeSecurity: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalizedBundles", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValidVotePower", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2160,31 +2962,33 @@ func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthBundles } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBundles } if postIndex > l { return io.ErrUnexpectedEOF } - m.FinalizedBundles = append(m.FinalizedBundles, types.FinalizedBundle{}) - if err := m.FinalizedBundles[len(m.FinalizedBundles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v cosmossdk_io_math.Int + m.ValidVotePower = &v + if err := m.ValidVotePower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalVotePower", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2194,25 +2998,25 @@ func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthBundles } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBundles } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v cosmossdk_io_math.Int + m.TotalVotePower = &v + if err := m.TotalVotePower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2237,7 +3041,7 @@ func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalizedBundlesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2260,13 +3064,49 @@ func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundleRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalizedBundlesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalizedBundlesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) } @@ -2285,11 +3125,11 @@ func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) } - m.Id = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2299,11 +3139,24 @@ func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Id |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBundles(dAtA[iNdEx:]) @@ -2325,7 +3178,7 @@ func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalizedBundleResponse) Unmarshal(dAtA []byte) error { +func (m *QueryFinalizedBundlesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2348,15 +3201,49 @@ func (m *QueryFinalizedBundleResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundleResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalizedBundlesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalizedBundlesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalizedBundle", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FinalizedBundles", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalizedBundles = append(m.FinalizedBundles, FinalizedBundle{}) + if err := m.FinalizedBundles[len(m.FinalizedBundles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2383,7 +3270,10 @@ func (m *QueryFinalizedBundleResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.FinalizedBundle.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2408,7 +3298,7 @@ func (m *QueryFinalizedBundleResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalizedBundlesByHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalizedBundleRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2431,10 +3321,10 @@ func (m *QueryFinalizedBundlesByHeightRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundlesByHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalizedBundleRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundlesByHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalizedBundleRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2458,9 +3348,9 @@ func (m *QueryFinalizedBundlesByHeightRequest) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - m.Height = 0 + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBundles @@ -2470,7 +3360,7 @@ func (m *QueryFinalizedBundlesByHeightRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2496,7 +3386,7 @@ func (m *QueryFinalizedBundlesByHeightRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalizedBundlesByHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryFinalizedBundleResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2519,15 +3409,15 @@ func (m *QueryFinalizedBundlesByHeightResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalizedBundlesByHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalizedBundleResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalizedBundlesByHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalizedBundleResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalizedBundle", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FinalizedBundles", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2554,7 +3444,7 @@ func (m *QueryFinalizedBundlesByHeightResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.FinalizedBundle.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.FinalizedBundles.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/query/types/bundles.pb.gw.go b/x/query/types/bundles.pb.gw.go index ab4ed045..a9b34985 100644 --- a/x/query/types/bundles.pb.gw.go +++ b/x/query/types/bundles.pb.gw.go @@ -34,10 +34,10 @@ var _ = descriptor.ForMessage var _ = metadata.Join var ( - filter_QueryBundles_FinalizedBundles_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_QueryBundles_FinalizedBundlesQuery_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_QueryBundles_FinalizedBundles_0(ctx context.Context, marshaler runtime.Marshaler, client QueryBundlesClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_QueryBundles_FinalizedBundlesQuery_0(ctx context.Context, marshaler runtime.Marshaler, client QueryBundlesClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFinalizedBundlesRequest var metadata runtime.ServerMetadata @@ -62,16 +62,16 @@ func request_QueryBundles_FinalizedBundles_0(ctx context.Context, marshaler runt if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryBundles_FinalizedBundles_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryBundles_FinalizedBundlesQuery_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.FinalizedBundles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.FinalizedBundlesQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_QueryBundles_FinalizedBundles_0(ctx context.Context, marshaler runtime.Marshaler, server QueryBundlesServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_QueryBundles_FinalizedBundlesQuery_0(ctx context.Context, marshaler runtime.Marshaler, server QueryBundlesServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFinalizedBundlesRequest var metadata runtime.ServerMetadata @@ -96,16 +96,16 @@ func local_request_QueryBundles_FinalizedBundles_0(ctx context.Context, marshale if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryBundles_FinalizedBundles_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryBundles_FinalizedBundlesQuery_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.FinalizedBundles(ctx, &protoReq) + msg, err := server.FinalizedBundlesQuery(ctx, &protoReq) return msg, metadata, err } -func request_QueryBundles_FinalizedBundle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryBundlesClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_QueryBundles_FinalizedBundleQuery_0(ctx context.Context, marshaler runtime.Marshaler, client QueryBundlesClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFinalizedBundleRequest var metadata runtime.ServerMetadata @@ -138,12 +138,12 @@ func request_QueryBundles_FinalizedBundle_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := client.FinalizedBundle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.FinalizedBundleQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_QueryBundles_FinalizedBundle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryBundlesServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_QueryBundles_FinalizedBundleQuery_0(ctx context.Context, marshaler runtime.Marshaler, server QueryBundlesServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFinalizedBundleRequest var metadata runtime.ServerMetadata @@ -176,83 +176,7 @@ func local_request_QueryBundles_FinalizedBundle_0(ctx context.Context, marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.FinalizedBundle(ctx, &protoReq) - return msg, metadata, err - -} - -func request_QueryBundles_FinalizedBundlesByHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryBundlesClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalizedBundlesByHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["pool_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") - } - - protoReq.PoolId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := client.FinalizedBundlesByHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_QueryBundles_FinalizedBundlesByHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryBundlesServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalizedBundlesByHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["pool_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") - } - - protoReq.PoolId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := server.FinalizedBundlesByHeight(ctx, &protoReq) + msg, err := server.FinalizedBundleQuery(ctx, &protoReq) return msg, metadata, err } @@ -633,30 +557,7 @@ func local_request_QueryBundles_CanVote_0(ctx context.Context, marshaler runtime // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryBundlesHandlerFromEndpoint instead. func RegisterQueryBundlesHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryBundlesServer) error { - mux.Handle("GET", pattern_QueryBundles_FinalizedBundles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - 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_QueryBundles_FinalizedBundles_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_QueryBundles_FinalizedBundles_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_QueryBundles_FinalizedBundle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_QueryBundles_FinalizedBundlesQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -667,7 +568,7 @@ func RegisterQueryBundlesHandlerServer(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_QueryBundles_FinalizedBundle_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_QueryBundles_FinalizedBundlesQuery_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -675,11 +576,11 @@ func RegisterQueryBundlesHandlerServer(ctx context.Context, mux *runtime.ServeMu return } - forward_QueryBundles_FinalizedBundle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_QueryBundles_FinalizedBundlesQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_QueryBundles_FinalizedBundlesByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_QueryBundles_FinalizedBundleQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -690,7 +591,7 @@ func RegisterQueryBundlesHandlerServer(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_QueryBundles_FinalizedBundlesByHeight_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_QueryBundles_FinalizedBundleQuery_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -698,7 +599,7 @@ func RegisterQueryBundlesHandlerServer(ctx context.Context, mux *runtime.ServeMu return } - forward_QueryBundles_FinalizedBundlesByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_QueryBundles_FinalizedBundleQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -835,7 +736,7 @@ func RegisterQueryBundlesHandler(ctx context.Context, mux *runtime.ServeMux, con // "QueryBundlesClient" to call the correct interceptors. func RegisterQueryBundlesHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryBundlesClient) error { - mux.Handle("GET", pattern_QueryBundles_FinalizedBundles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_QueryBundles_FinalizedBundlesQuery_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) @@ -844,18 +745,18 @@ func RegisterQueryBundlesHandlerClient(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_QueryBundles_FinalizedBundles_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_QueryBundles_FinalizedBundlesQuery_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_QueryBundles_FinalizedBundles_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_QueryBundles_FinalizedBundlesQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_QueryBundles_FinalizedBundle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_QueryBundles_FinalizedBundleQuery_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) @@ -864,34 +765,14 @@ func RegisterQueryBundlesHandlerClient(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_QueryBundles_FinalizedBundle_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_QueryBundles_FinalizedBundleQuery_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_QueryBundles_FinalizedBundle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_QueryBundles_FinalizedBundlesByHeight_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_QueryBundles_FinalizedBundlesByHeight_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_QueryBundles_FinalizedBundlesByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_QueryBundles_FinalizedBundleQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -979,11 +860,9 @@ func RegisterQueryBundlesHandlerClient(ctx context.Context, mux *runtime.ServeMu } var ( - pattern_QueryBundles_FinalizedBundles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "query", "v1beta1", "finalized_bundles", "pool_id"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_QueryBundles_FinalizedBundle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"kyve", "query", "v1beta1", "finalized_bundle", "pool_id", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_QueryBundles_FinalizedBundlesQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kyve", "v1", "bundles", "pool_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_QueryBundles_FinalizedBundlesByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"kyve", "query", "v1beta1", "finalized_bundle_by_height", "pool_id", "height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_QueryBundles_FinalizedBundleQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "v1", "bundles", "pool_id", "id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_QueryBundles_CurrentVoteStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "query", "v1beta1", "current_vote_status", "pool_id"}, "", runtime.AssumeColonVerbOpt(true))) @@ -995,11 +874,9 @@ var ( ) var ( - forward_QueryBundles_FinalizedBundles_0 = runtime.ForwardResponseMessage - - forward_QueryBundles_FinalizedBundle_0 = runtime.ForwardResponseMessage + forward_QueryBundles_FinalizedBundlesQuery_0 = runtime.ForwardResponseMessage - forward_QueryBundles_FinalizedBundlesByHeight_0 = runtime.ForwardResponseMessage + forward_QueryBundles_FinalizedBundleQuery_0 = runtime.ForwardResponseMessage forward_QueryBundles_CurrentVoteStatus_0 = runtime.ForwardResponseMessage diff --git a/x/query/types/params.pb.go b/x/query/types/params.pb.go index 99c68870..43458762 100644 --- a/x/query/types/params.pb.go +++ b/x/query/types/params.pb.go @@ -9,6 +9,7 @@ import ( types "github.com/KYVENetwork/chain/x/bundles/types" types1 "github.com/KYVENetwork/chain/x/delegation/types" types2 "github.com/KYVENetwork/chain/x/global/types" + types4 "github.com/KYVENetwork/chain/x/pool/types" types3 "github.com/KYVENetwork/chain/x/stakers/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -82,6 +83,8 @@ type QueryParamsResponse struct { GovParams *v1.Params `protobuf:"bytes,4,opt,name=gov_params,json=govParams,proto3" json:"gov_params,omitempty"` // stakers_params ... StakersParams *types3.Params `protobuf:"bytes,5,opt,name=stakers_params,json=stakersParams,proto3" json:"stakers_params,omitempty"` + // pool_params ... + PoolParams *types4.Params `protobuf:"bytes,6,opt,name=pool_params,json=poolParams,proto3" json:"pool_params,omitempty"` } func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } @@ -152,6 +155,13 @@ func (m *QueryParamsResponse) GetStakersParams() *types3.Params { return nil } +func (m *QueryParamsResponse) GetPoolParams() *types4.Params { + if m != nil { + return m.PoolParams + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "kyve.query.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kyve.query.v1beta1.QueryParamsResponse") @@ -160,34 +170,36 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/params.proto", fileDescriptor_b5269c0a69f1d3d4) } var fileDescriptor_b5269c0a69f1d3d4 = []byte{ - // 426 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4f, 0x4f, 0xdb, 0x30, - 0x18, 0xc6, 0x9b, 0x6e, 0xab, 0x34, 0x77, 0xad, 0xb6, 0x6c, 0xd3, 0xa6, 0xac, 0x4a, 0xbb, 0x68, - 0xda, 0x26, 0x0e, 0xb6, 0x5a, 0xf8, 0x00, 0x88, 0xc2, 0x09, 0x84, 0x80, 0x03, 0x12, 0x5c, 0x90, - 0xd3, 0x5a, 0x6e, 0xd4, 0x34, 0x4e, 0x63, 0x27, 0xd0, 0x03, 0x17, 0xce, 0x1c, 0x90, 0xf8, 0x52, - 0x1c, 0x2b, 0x71, 0xe1, 0x88, 0x5a, 0xf8, 0x1e, 0x28, 0xb6, 0xd3, 0xff, 0x88, 0x53, 0xeb, 0xf7, - 0x7d, 0x9e, 0xdf, 0x1b, 0x3f, 0xaf, 0x41, 0xb5, 0x3b, 0x48, 0x08, 0xea, 0xc7, 0x24, 0x1a, 0xa0, - 0xa4, 0xee, 0x12, 0x81, 0xeb, 0x28, 0xc4, 0x11, 0xee, 0x71, 0x18, 0x46, 0x4c, 0x30, 0xd3, 0x4c, - 0x05, 0x50, 0x0a, 0xa0, 0x16, 0x58, 0x3f, 0x5a, 0x8c, 0xf7, 0x18, 0x47, 0x94, 0x25, 0x28, 0xa9, - 0xa7, 0x3f, 0x4a, 0x6c, 0x55, 0x28, 0x63, 0xd4, 0x27, 0x08, 0x87, 0x1e, 0xc2, 0x41, 0xc0, 0x04, - 0x16, 0x1e, 0x0b, 0x34, 0xca, 0xfa, 0x2d, 0x67, 0xb9, 0x71, 0xd0, 0xf6, 0x09, 0x5f, 0x39, 0xcd, - 0xfa, 0x23, 0x25, 0x6d, 0xe2, 0x13, 0x2a, 0xad, 0xab, 0x55, 0x35, 0xa9, 0xa2, 0x3e, 0x73, 0xb1, - 0x3f, 0x51, 0xa8, 0xe3, 0xdc, 0x28, 0x2e, 0x70, 0x97, 0x44, 0xab, 0x47, 0x39, 0xdf, 0x80, 0x79, - 0x98, 0xde, 0xea, 0x40, 0x16, 0x8f, 0x48, 0x3f, 0x26, 0x5c, 0x38, 0xcf, 0x79, 0xf0, 0x75, 0xae, - 0xcc, 0x43, 0x16, 0x70, 0x62, 0x36, 0x41, 0x59, 0x7f, 0xf8, 0x99, 0xa2, 0xfc, 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, 0x06, 0x21, 0xe1, 0x6e, 0x41, 0xbe, 0xac, 0xf5, 0x97, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xdb, 0x64, 0x66, 0xff, 0x55, 0x03, 0x00, 0x00, + // 453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xb1, 0xae, 0xd3, 0x30, + 0x14, 0x86, 0x9b, 0x7b, 0xa1, 0x12, 0x2e, 0xb7, 0x82, 0x00, 0x02, 0x42, 0x95, 0x96, 0x08, 0x01, + 0x62, 0xb0, 0xd5, 0xc2, 0xc4, 0x84, 0x28, 0x4c, 0x20, 0x04, 0x0c, 0x48, 0xb0, 0x20, 0xa7, 0xb5, + 0xdc, 0xa8, 0x69, 0x4e, 0x1a, 0x3b, 0x81, 0x0e, 0x2c, 0xcc, 0x0c, 0x48, 0x3c, 0x01, 0x6f, 0xc3, + 0x58, 0x89, 0x85, 0x11, 0xb5, 0x3c, 0x08, 0x8a, 0x7d, 0xd2, 0x96, 0x36, 0xe8, 0x4e, 0x8d, 0xcf, + 0xf9, 0xff, 0xcf, 0xf6, 0x7f, 0x5c, 0xd2, 0x9d, 0x2e, 0x0a, 0xc1, 0xe6, 0xb9, 0xc8, 0x16, 0xac, + 0xe8, 0x87, 0x42, 0xf3, 0x3e, 0x4b, 0x79, 0xc6, 0x67, 0x8a, 0xa6, 0x19, 0x68, 0x70, 0xdd, 0x52, + 0x40, 0x8d, 0x80, 0xa2, 0xc0, 0xbb, 0x3a, 0x02, 0x35, 0x03, 0xc5, 0x24, 0x14, 0xac, 0xe8, 0x97, + 0x3f, 0x56, 0xec, 0x75, 0x24, 0x80, 0x8c, 0x05, 0xe3, 0x69, 0xc4, 0x78, 0x92, 0x80, 0xe6, 0x3a, + 0x82, 0x04, 0x51, 0xde, 0x4d, 0xb3, 0x57, 0x98, 0x27, 0xe3, 0x58, 0xa8, 0xda, 0xdd, 0xbc,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, 0xf8, 0xe2, 0x90, 0xd6, 0xce, 0x8c, 0xdc, 0x4f, 0xa4, 0x89, + 0x5f, 0xb7, 0xe9, 0xe1, 0x6b, 0xa6, 0x87, 0x53, 0xf6, 0xee, 0x9c, 0xaa, 0xb3, 0x63, 0x0f, 0x82, + 0xcf, 0x3f, 0xff, 0x7c, 0x3b, 0xea, 0xb8, 0x1e, 0xfb, 0xef, 0xff, 0xe8, 0xf1, 0x93, 0x1f, 0x2b, + 0xdf, 0x59, 0xae, 0x7c, 0xe7, 0xf7, 0xca, 0x77, 0xbe, 0xae, 0xfd, 0xc6, 0x72, 0xed, 0x37, 0x7e, + 0xad, 0xfd, 0xc6, 0xbb, 0x7b, 0x32, 0xd2, 0x93, 0x3c, 0xa4, 0x23, 0x98, 0xb1, 0x67, 0x6f, 0xdf, + 0x3c, 0x7d, 0x21, 0xf4, 0x07, 0xc8, 0xa6, 0x6c, 0x34, 0xe1, 0x51, 0xc2, 0x3e, 0x22, 0x4e, 0x2f, + 0x52, 0xa1, 0xc2, 0xa6, 0x79, 0x95, 0xf7, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x81, 0x22, 0x17, + 0x0f, 0xb1, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -315,6 +327,18 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.PoolParams != nil { + { + size, err := m.PoolParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } if m.StakersParams != nil { { size, err := m.StakersParams.MarshalToSizedBuffer(dAtA[:i]) @@ -424,6 +448,10 @@ func (m *QueryParamsResponse) Size() (n int) { l = m.StakersParams.Size() n += 1 + l + sovParams(uint64(l)) } + if m.PoolParams != nil { + l = m.PoolParams.Size() + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -692,6 +720,42 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolParams", 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 m.PoolParams == nil { + m.PoolParams = &types4.Params{} + } + if err := m.PoolParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/query/types/pools.pb.go b/x/query/types/pools.pb.go index 938e6be3..6cdad894 100644 --- a/x/query/types/pools.pb.go +++ b/x/query/types/pools.pb.go @@ -185,6 +185,10 @@ type PoolResponse struct { TotalDelegation uint64 `protobuf:"varint,6,opt,name=total_delegation,json=totalDelegation,proto3" json:"total_delegation,omitempty"` // status ... Status types.PoolStatus `protobuf:"varint,7,opt,name=status,proto3,enum=kyve.pool.v1beta1.PoolStatus" json:"status,omitempty"` + // account ... + Account string `protobuf:"bytes,8,opt,name=account,proto3" json:"account,omitempty"` + // account_balance ... + AccountBalance uint64 `protobuf:"varint,9,opt,name=account_balance,json=accountBalance,proto3" json:"account_balance,omitempty"` } func (m *PoolResponse) Reset() { *m = PoolResponse{} } @@ -269,6 +273,20 @@ func (m *PoolResponse) GetStatus() types.PoolStatus { return types.POOL_STATUS_UNSPECIFIED } +func (m *PoolResponse) GetAccount() string { + if m != nil { + return m.Account + } + return "" +} + +func (m *PoolResponse) GetAccountBalance() uint64 { + if m != nil { + return m.AccountBalance + } + return 0 +} + // QueryPoolRequest is the request type for the Query/Pool RPC method. type QueryPoolRequest struct { // id defines the unique ID of the pool. @@ -372,49 +390,51 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/pools.proto", fileDescriptor_b627739c2d7723dc) } var fileDescriptor_b627739c2d7723dc = []byte{ - // 659 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x4f, 0xd4, 0x40, - 0x14, 0xde, 0x96, 0xee, 0x02, 0x83, 0xf2, 0x63, 0xf0, 0x47, 0x5d, 0xa5, 0xd4, 0x06, 0x70, 0xc5, - 0xa4, 0x13, 0xd6, 0x78, 0x31, 0x9e, 0x08, 0x6a, 0x8c, 0x51, 0xd7, 0x92, 0x98, 0xe8, 0x65, 0x33, - 0xdd, 0x0e, 0x65, 0x42, 0xe9, 0x94, 0xce, 0x2c, 0xba, 0x1a, 0x2f, 0xfc, 0x05, 0x26, 0x1e, 0xfd, - 0x87, 0x88, 0x27, 0x12, 0x2f, 0x7a, 0x31, 0x06, 0xfc, 0x43, 0x4c, 0xa7, 0xd3, 0xda, 0x15, 0x71, - 0xbd, 0xf5, 0xf5, 0x7d, 0xdf, 0x7b, 0xdf, 0xfb, 0xde, 0x6b, 0x81, 0xb5, 0x33, 0xd8, 0x27, 0x68, - 0xaf, 0x4f, 0xd2, 0x01, 0xda, 0x5f, 0xf3, 0x89, 0xc0, 0x6b, 0x28, 0x61, 0x2c, 0xe2, 0x6e, 0x92, - 0x32, 0xc1, 0x20, 0xcc, 0xf2, 0xae, 0xcc, 0xbb, 0x2a, 0xdf, 0x5c, 0xed, 0x31, 0xbe, 0xcb, 0x38, - 0xf2, 0x31, 0x3f, 0x45, 0xc5, 0x21, 0x8d, 0xb1, 0xa0, 0x2c, 0xce, 0xf9, 0xcd, 0x0b, 0x21, 0x0b, - 0x99, 0x7c, 0x44, 0xd9, 0x93, 0x7a, 0x7b, 0x2d, 0x64, 0x2c, 0x8c, 0x08, 0xc2,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 0x2b, 0xc2, 0x01, 0xa8, - 0xcb, 0x3b, 0x83, 0xcb, 0x7f, 0x2b, 0x72, 0xea, 0x1b, 0x6b, 0xae, 0x8c, 0x82, 0xe5, 0x1d, 0x9d, - 0xeb, 0x07, 0x5f, 0x7e, 0x7e, 0xd4, 0xaf, 0xc2, 0x2b, 0xe8, 0xac, 0x1f, 0x10, 0x7c, 0x0b, 0x0c, - 0x29, 0x61, 0xe9, 0x9f, 0x25, 0x8b, 0xc6, 0xcb, 0x23, 0x50, 0xaa, 0xef, 0xb2, 0xec, 0xbb, 0x08, - 0x17, 0xce, 0xea, 0x8b, 0xde, 0xd1, 0xe0, 0xfd, 0xfa, 0xc6, 0xe1, 0xb1, 0xa5, 0x1d, 0x1d, 0x5b, - 0xda, 0x8f, 0x63, 0x4b, 0xfb, 0x70, 0x62, 0xd5, 0x8e, 0x4e, 0xac, 0xda, 0xd7, 0x13, 0xab, 0xf6, - 0x6a, 0x35, 0xa4, 0x62, 0xbb, 0xef, 0xbb, 0x3d, 0xb6, 0x8b, 0x1e, 0xbf, 0x7c, 0x71, 0xff, 0x29, - 0x11, 0xaf, 0x59, 0xba, 0x83, 0x7a, 0xdb, 0x98, 0xc6, 0xe8, 0x8d, 0xaa, 0x28, 0x06, 0x09, 0xe1, - 0x7e, 0x43, 0xfe, 0x8d, 0x6e, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x47, 0xf1, 0xcf, 0x38, 0x65, - 0x05, 0x00, 0x00, + // 693 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x4f, 0xd4, 0x4e, + 0x18, 0xde, 0xee, 0x76, 0x17, 0x18, 0x7e, 0xbf, 0x05, 0x06, 0x3f, 0xea, 0x2a, 0xa5, 0x36, 0x7c, + 0xac, 0x98, 0xb4, 0x61, 0x8d, 0x17, 0xe3, 0x69, 0x83, 0x1a, 0x63, 0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6a, 0x9f, 0xdb, 0x03, 0x89, 0x75, 0xda, 0xee, + 0x98, 0x9d, 0x0f, 0x88, 0x32, 0xb4, 0x83, 0x53, 0xaa, 0xa9, 0x46, 0x23, 0x1f, 0x90, 0x34, 0x61, + 0x0f, 0x5c, 0x64, 0x84, 0xa1, 0x68, 0x48, 0x71, 0xb4, 0x35, 0xf4, 0x71, 0x84, 0x03, 0xd1, 0x8a, + 0x26, 0x17, 0x3e, 0xcf, 0x9d, 0x9b, 0x38, 0xda, 0xda, 0x28, 0x5d, 0xf0, 0x06, 0x98, 0x15, 0x9c, + 0x0a, 0xbc, 0xc5, 0xe1, 0x33, 0xfc, 0xbe, 0x02, 0xbd, 0x0d, 0x5a, 0x94, 0x21, 0x96, 0x51, 0x6d, + 0xc2, 0x50, 0xba, 0xed, 0xde, 0xc2, 0x19, 0x65, 0x6f, 0x72, 0x90, 0x23, 0xc1, 0xb9, 0x5e, 0xe4, + 0x79, 0x24, 0x8b, 0x99, 0x36, 0x29, 0x16, 0x4a, 0x9a, 0x70, 0x15, 0xcc, 0xc8, 0xe3, 0xd0, 0x45, + 0x11, 0x8a, 0x3d, 0xac, 0x4d, 0xf1, 0xd4, 0x6d, 0x79, 0xdd, 0x17, 0xb7, 0xa6, 0x09, 0x66, 0xcb, + 0x65, 0x29, 0xde, 0xc1, 0x6f, 0x23, 0x31, 0x9f, 0x56, 0x1e, 0x4b, 0x39, 0xb7, 0x3b, 0x40, 0xcd, + 0xe5, 0xc9, 0x67, 0xf2, 0xaf, 0xeb, 0xc4, 0x39, 0xbd, 0x83, 0x3a, 0x98, 0x2a, 0x23, 0xc2, 0x11, + 0x68, 0xf2, 0x55, 0x85, 0xcb, 0x7f, 0x0a, 0x72, 0xea, 0x99, 0x76, 0x56, 0xce, 0x83, 0x89, 0x8c, + 0xe6, 0xf5, 0x83, 0xcf, 0x3f, 0x3e, 0xd6, 0xaf, 0xc2, 0x2b, 0xf6, 0x59, 0x7f, 0x18, 0x7c, 0x03, + 0x54, 0x2e, 0x61, 0xe9, 0xaf, 0x21, 0x8b, 0xc4, 0xcb, 0xe7, 0xa0, 0x64, 0xde, 0x65, 0x9e, 0x77, + 0x11, 0x2e, 0x9c, 0x95, 0xd7, 0x7e, 0x1b, 0xfa, 0xef, 0xfa, 0x1b, 0x87, 0xc7, 0xba, 0x72, 0x74, + 0xac, 0x2b, 0xdf, 0x8f, 0x75, 0xe5, 0xc3, 0x89, 0x5e, 0x3b, 0x3a, 0xd1, 0x6b, 0x5f, 0x4e, 0xf4, + 0xda, 0xcb, 0xb5, 0x20, 0x64, 0xdb, 0x99, 0x6b, 0x79, 0x64, 0xd7, 0x7e, 0xf4, 0xe2, 0xf9, 0xbd, + 0x27, 0x98, 0xbd, 0x22, 0xe9, 0x8e, 0xed, 0x6d, 0xa3, 0x30, 0xb6, 0x5f, 0xcb, 0x88, 0x6c, 0x94, + 0x60, 0xea, 0xb6, 0xf8, 0x87, 0x76, 0xeb, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xea, 0x63, 0x05, + 0xb9, 0xa8, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -670,6 +690,18 @@ func (m *PoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.AccountBalance != 0 { + i = encodeVarintPools(dAtA, i, uint64(m.AccountBalance)) + i-- + dAtA[i] = 0x48 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintPools(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0x42 + } if m.Status != 0 { i = encodeVarintPools(dAtA, i, uint64(m.Status)) i-- @@ -876,6 +908,13 @@ func (m *PoolResponse) Size() (n int) { if m.Status != 0 { n += 1 + sovPools(uint64(m.Status)) } + l = len(m.Account) + if l > 0 { + n += 1 + l + sovPools(uint64(l)) + } + if m.AccountBalance != 0 { + n += 1 + sovPools(uint64(m.AccountBalance)) + } return n } @@ -1426,6 +1465,57 @@ func (m *PoolResponse) Unmarshal(dAtA []byte) error { break } } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPools + } + 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 ErrInvalidLengthPools + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPools + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountBalance", wireType) + } + m.AccountBalance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPools + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountBalance |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipPools(dAtA[iNdEx:]) diff --git a/x/query/types/query.pb.go b/x/query/types/query.pb.go index b30446d7..24b741e6 100644 --- a/x/query/types/query.pb.go +++ b/x/query/types/query.pb.go @@ -280,6 +280,8 @@ type StakerMetadata struct { // the commission is applied. Users have time to redelegate // if they not agree with the new commission. PendingCommissionChange *CommissionChangeEntry `protobuf:"bytes,7,opt,name=pending_commission_change,json=pendingCommissionChange,proto3" json:"pending_commission_change,omitempty"` + // commission_rewards are the rewards in $KYVE earned through commission + CommissionRewards uint64 `protobuf:"varint,8,opt,name=commission_rewards,json=commissionRewards,proto3" json:"commission_rewards,omitempty"` } func (m *StakerMetadata) Reset() { *m = StakerMetadata{} } @@ -357,6 +359,13 @@ func (m *StakerMetadata) GetPendingCommissionChange() *CommissionChangeEntry { return nil } +func (m *StakerMetadata) GetCommissionRewards() uint64 { + if m != nil { + return m.CommissionRewards + } + return 0 +} + // CommissionChangeEntry shows when the old commission // of a staker will change to the new commission type CommissionChangeEntry struct { @@ -511,55 +520,56 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/query.proto", fileDescriptor_6b41255feae93a15) } var fileDescriptor_6b41255feae93a15 = []byte{ - // 765 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0xc7, 0xe3, 0x24, 0x4d, 0x93, 0x17, 0x9a, 0xa0, 0x11, 0x50, 0xb7, 0xa2, 0x6e, 0x15, 0x04, - 0x6d, 0x91, 0x70, 0xd4, 0x22, 0x24, 0xc4, 0x81, 0x43, 0x93, 0x56, 0x42, 0xd0, 0x0a, 0x19, 0x81, - 0x04, 0x17, 0x6b, 0x62, 0x4f, 0x9d, 0x51, 0xec, 0x19, 0xe3, 0x19, 0xa7, 0xe4, 0x3b, 0x70, 0xe0, - 0xa3, 0x70, 0xd8, 0x0f, 0xd1, 0x63, 0x8f, 0xbb, 0xab, 0x55, 0xb5, 0x6a, 0xbf, 0xc8, 0x6a, 0x66, - 0x6c, 0x6f, 0xd2, 0xcd, 0xde, 0xf6, 0x14, 0xbf, 0xff, 0xfb, 0xcf, 0xcb, 0xcc, 0xef, 0xbd, 0x19, - 0x70, 0x66, 0x8b, 0x39, 0x19, 0xfe, 0x9d, 0x93, 0x6c, 0x31, 0x9c, 0x9f, 0x4c, 0x88, 0xc4, 0x27, - 0x26, 0x72, 0xd3, 0x8c, 0x4b, 0x8e, 0x90, 0xca, 0xbb, 0x46, 0x29, 0xf2, 0xbb, 0x9f, 0x44, 0x3c, - 0xe2, 0x3a, 0x3d, 0x54, 0x5f, 0xc6, 0xb9, 0xfb, 0xb9, 0xae, 0x94, 0x72, 0x1e, 0x57, 0x85, 0x54, - 0x60, 0xb2, 0x83, 0xff, 0xe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ca, 0x10, 0xfd, 0x08, - 0xed, 0x84, 0x48, 0x1c, 0x62, 0x89, 0x35, 0xc1, 0xee, 0xe9, 0xc0, 0x7d, 0xb7, 0x6d, 0xae, 0xa9, - 0x73, 0x59, 0x38, 0xbd, 0x6a, 0x8d, 0x82, 0x22, 0x48, 0x7c, 0xbd, 0x7c, 0x92, 0x86, 0x81, 0xa2, - 0xe4, 0xa5, 0x83, 0xfc, 0x00, 0x3b, 0x4f, 0x8c, 0x7e, 0xce, 0x26, 0x9c, 0x85, 0x94, 0x45, 0xba, - 0x1b, 0x4d, 0x6f, 0x7b, 0x75, 0xc9, 0xef, 0x65, 0x7a, 0x2d, 0xaf, 0x8d, 0xf5, 0xbc, 0x0e, 0xa1, - 0x5f, 0x98, 0x78, 0xe6, 0x07, 0x3c, 0x67, 0xb2, 0x6c, 0x52, 0x25, 0x8f, 0x94, 0x8a, 0xbe, 0x87, - 0x0d, 0x05, 0x51, 0xb5, 0xa7, 0xf1, 0xbe, 0x53, 0x2b, 0xb0, 0x97, 0x24, 0x99, 0x90, 0x4c, 0x4c, - 0x69, 0xea, 0x99, 0x05, 0x83, 0x57, 0x75, 0xe8, 0xad, 0xf2, 0x40, 0x57, 0x00, 0x01, 0x4f, 0x12, - 0x2a, 0x84, 0xda, 0x9a, 0x46, 0x7c, 0xe6, 0xde, 0xde, 0xef, 0xd7, 0x5e, 0xde, 0xef, 0x7f, 0x15, - 0x51, 0x39, 0xcd, 0x27, 0x6e, 0xc0, 0x93, 0x61, 0xc0, 0x45, 0xc2, 0x45, 0xf1, 0xf3, 0x8d, 0x08, - 0x67, 0x43, 0xb9, 0x48, 0x89, 0x70, 0xc7, 0x24, 0xf0, 0x96, 0x2a, 0xa8, 0x7e, 0x25, 0x9c, 0xd1, - 0x19, 0xc9, 0x8a, 0xb1, 0x2e, 0x43, 0x95, 0xb9, 0x21, 0x13, 0x41, 0x65, 0x35, 0xd9, 0x45, 0x88, - 0x76, 0xa1, 0x4d, 0x43, 0xc2, 0x24, 0x95, 0x8b, 0x62, 0xba, 0xab, 0x58, 0x01, 0x14, 0x24, 0xc8, - 0x33, 0x2a, 0x17, 0x7e, 0xc0, 0x99, 0xc4, 0x81, 0x99, 0xf1, 0x8e, 0xd7, 0x2f, 0xf5, 0x91, 0x91, - 0xd5, 0x1f, 0x84, 0x44, 0x62, 0x1a, 0x0b, 0x0d, 0xae, 0xe3, 0x95, 0x21, 0x22, 0xb0, 0x93, 0x12, - 0xdd, 0x10, 0xff, 0xed, 0x56, 0xfd, 0x60, 0x8a, 0x59, 0x44, 0xf4, 0x90, 0x77, 0x4f, 0x8f, 0xd7, - 0x51, 0x1c, 0x55, 0xe6, 0x91, 0xf6, 0x9e, 0x33, 0x99, 0x2d, 0xbc, 0xed, 0xa2, 0xd6, 0xd3, 0xec, - 0xe0, 0x5f, 0x0b, 0x3e, 0x5d, 0xbb, 0xe4, 0x83, 0x53, 0xfe, 0x02, 0xb6, 0x82, 0x8c, 0x98, 0x59, - 0x0c, 0xb1, 0x34, 0x4f, 0x48, 0xc3, 0xfb, 0xa8, 0x14, 0xc7, 0x58, 0x92, 0xc1, 0x33, 0x0b, 0x7a, - 0xab, 0x73, 0x80, 0x4e, 0xa0, 0xa9, 0x26, 0x41, 0xef, 0xa0, 0x5b, 0xde, 0xc8, 0xd5, 0x33, 0x57, - 0xcf, 0x95, 0xa7, 0xad, 0xe8, 0x33, 0x68, 0xa5, 0x9c, 0x32, 0x29, 0xf4, 0x7f, 0x34, 0xbd, 0x22, - 0x42, 0x7b, 0x00, 0x54, 0xf8, 0x31, 0xc1, 0x73, 0x75, 0x0d, 0x54, 0x47, 0xdb, 0x5e, 0x87, 0x8a, - 0x5f, 0x8c, 0x80, 0x1c, 0x80, 0x39, 0x8e, 0xcb, 0xab, 0x6b, 0xba, 0xba, 0xa4, 0xa8, 0x66, 0x4d, - 0x70, 0x8c, 0x59, 0x40, 0x8a, 0xfb, 0x50, 0x86, 0x67, 0xe3, 0xdb, 0x07, 0xc7, 0xba, 0x7b, 0x70, - 0xac, 0xd7, 0x0f, 0x8e, 0xf5, 0xdf, 0xa3, 0x53, 0xbb, 0x7b, 0x74, 0x6a, 0xcf, 0x1f, 0x9d, 0xda, - 0x5f, 0x5f, 0x2f, 0x91, 0xfa, 0xf9, 0xcf, 0x3f, 0xce, 0xaf, 0x88, 0xbc, 0xe1, 0xd9, 0x6c, 0x18, - 0x4c, 0x31, 0x65, 0xc3, 0x7f, 0x8a, 0xf7, 0x5c, 0x13, 0x9b, 0xb4, 0xf4, 0x03, 0xfc, 0xed, 0x9b, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xdc, 0x12, 0x0e, 0xea, 0x05, 0x00, 0x00, + // 782 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x8f, 0xe3, 0x34, + 0x14, 0xc7, 0x9b, 0xb6, 0xd3, 0x6d, 0x5f, 0xd9, 0x16, 0x2c, 0x60, 0xb3, 0x23, 0x36, 0x33, 0x2a, + 0x82, 0x9d, 0x45, 0xda, 0x54, 0x33, 0x08, 0x09, 0x71, 0xe0, 0x30, 0xed, 0xae, 0x84, 0x60, 0x57, + 0xc8, 0x08, 0x24, 0xb8, 0x44, 0x6e, 0xe2, 0x4d, 0xad, 0x26, 0x76, 0xb0, 0x9d, 0x0e, 0xfd, 0x0c, + 0x70, 0xe0, 0xa3, 0x70, 0xe0, 0x43, 0xec, 0x71, 0x8e, 0xc0, 0x61, 0x84, 0x66, 0xbe, 0x08, 0xb2, + 0x9d, 0x64, 0xda, 0xa1, 0xdc, 0x38, 0x25, 0xef, 0xff, 0xfe, 0x79, 0xb1, 0x7f, 0xef, 0xd9, 0x10, + 0xac, 0x36, 0x6b, 0x3a, 0xfd, 0xb1, 0xa4, 0x72, 0x33, 0x5d, 0x9f, 0x2e, 0xa8, 0x26, 0xa7, 0x2e, + 0x0a, 0x0b, 0x29, 0xb4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xd1, 0xbb, 0xd0, 0x2b, 0x04, 0xe3, 0x5a, 0xd9, 0x7f, 0x74, 0x71, + 0x15, 0xa1, 0x47, 0x00, 0x4c, 0x45, 0x19, 0x25, 0x6b, 0x73, 0x6a, 0xcc, 0x00, 0xf4, 0xf1, 0x80, + 0xa9, 0xaf, 0x9c, 0x80, 0x02, 0x80, 0x35, 0xc9, 0xea, 0x93, 0xee, 0x86, 0x60, 0x4b, 0x31, 0xbd, + 0x5d, 0x90, 0x8c, 0xf0, 0x98, 0x56, 0xc7, 0xa7, 0x0e, 0xcf, 0xe7, 0xaf, 0xaf, 0x03, 0xef, 0xf2, + 0x3a, 0xf0, 0xfe, 0xbe, 0x0e, 0xbc, 0x5f, 0x6f, 0x82, 0xd6, 0xe5, 0x4d, 0xd0, 0xfa, 0xe3, 0x26, + 0x68, 0xfd, 0xf0, 0xd1, 0x16, 0xa9, 0x2f, 0xbf, 0xff, 0xee, 0xd9, 0x4b, 0xaa, 0x2f, 0x84, 0x5c, + 0x4d, 0xe3, 0x25, 0x61, 0x7c, 0xfa, 0x53, 0x75, 0xfd, 0x5b, 0x62, 0x8b, 0x9e, 0xbd, 0xaf, 0x3f, + 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0x50, 0x8f, 0x9d, 0x37, 0x19, 0x06, 0x00, 0x00, } func (m *BasicPool) Marshal() (dAtA []byte, err error) { @@ -732,6 +742,11 @@ func (m *StakerMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CommissionRewards != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CommissionRewards)) + i-- + dAtA[i] = 0x40 + } if m.PendingCommissionChange != nil { { size, err := m.PendingCommissionChange.MarshalToSizedBuffer(dAtA[:i]) @@ -1009,6 +1024,9 @@ func (m *StakerMetadata) Size() (n int) { l = m.PendingCommissionChange.Size() n += 1 + l + sovQuery(uint64(l)) } + if m.CommissionRewards != 0 { + n += 1 + sovQuery(uint64(m.CommissionRewards)) + } return n } @@ -1805,6 +1823,25 @@ func (m *StakerMetadata) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CommissionRewards", wireType) + } + m.CommissionRewards = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CommissionRewards |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/stakers/keeper/getters_staker.go b/x/stakers/keeper/getters_staker.go index e5922652..c803a042 100644 --- a/x/stakers/keeper/getters_staker.go +++ b/x/stakers/keeper/getters_staker.go @@ -33,20 +33,20 @@ func (k Keeper) UpdateStakerMetadata( } } -// UpdateStakerCommission ... -func (k Keeper) UpdateStakerCommission(ctx sdk.Context, address string, commission sdk.Dec) { +// updateStakerCommissionRewards ... +func (k Keeper) updateStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) { staker, found := k.GetStaker(ctx, address) if found { - staker.Commission = commission + staker.CommissionRewards += amount k.setStaker(ctx, staker) } } -// IncreaseStakerCommissionRewards ... -func (k Keeper) IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) { +// UpdateStakerCommission ... +func (k Keeper) UpdateStakerCommission(ctx sdk.Context, address string, commission sdk.Dec) { staker, found := k.GetStaker(ctx, address) if found { - staker.CommissionRewards += amount + staker.Commission = commission k.setStaker(ctx, staker) } } diff --git a/x/stakers/keeper/logic_stakers.go b/x/stakers/keeper/logic_stakers.go index ab8dffab..32f6f649 100644 --- a/x/stakers/keeper/logic_stakers.go +++ b/x/stakers/keeper/logic_stakers.go @@ -3,12 +3,38 @@ package keeper import ( "math" - "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" + poolTypes "github.com/KYVENetwork/chain/x/pool/types" "github.com/KYVENetwork/chain/x/stakers/types" + + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// IncreaseStakerCommissionRewards sets the uploader's commission rewards and transfers the funds from +// the pool module to the stakers module, so the funds can be later claimed and transferred from here +func (k Keeper) IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) error { + // Assert there is an amount + if amount == 0 { + return nil + } + + // Assert the staker exists + if _, found := k.GetStaker(ctx, address); !found { + return errors.Wrapf(sdkErrors.ErrNotFound, "Staker does not exist.") + } + + // transfer funds from pool to stakers module + if err := util.TransferFromModuleToModule(k.bankKeeper, ctx, poolTypes.ModuleName, types.ModuleName, amount); err != nil { + return err + } + + k.updateStakerCommissionRewards(ctx, address, amount) + return nil +} + // getLowestStaker returns the staker with the lowest total stake // (self-delegation + delegation) of a given pool. // If all pool slots are taken, this is the staker who then diff --git a/x/stakers/keeper/msg_server_claim_commission_rewards_test.go b/x/stakers/keeper/msg_server_claim_commission_rewards_test.go index df7d28bf..8c9b578b 100644 --- a/x/stakers/keeper/msg_server_claim_commission_rewards_test.go +++ b/x/stakers/keeper/msg_server_claim_commission_rewards_test.go @@ -14,7 +14,7 @@ import ( TEST CASES - msg_server_claim_commission_rewards.go -* Produce a valid bundle and check commission rewards // TODO: move to bundles module tests +* Produce a valid bundle and check commission rewards * Claim with non-staker account * Claim more rewards than available * Claim zero rewards @@ -127,20 +127,18 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) balanceUploader := s.GetBalanceFromAddress(i.STAKER_0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) - uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward + totalDelegationReward := totalUploaderReward - uploaderPayoutReward // assert payout transfer Expect(balanceUploader).To(Equal(initialBalanceStaker0)) // assert uploader self delegation rewards - Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(totalDelegationReward)) // assert commission rewards Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) @@ -149,7 +147,7 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - operatingReward - storageReward)) + Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) }) It("Claim with non-staker account", func() { @@ -164,14 +162,13 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) @@ -193,14 +190,13 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) @@ -218,14 +214,13 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) @@ -245,14 +240,13 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward - 100)) @@ -272,14 +266,13 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward := pool.OperatingCost - storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward - treasuryReward := uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward := operatingReward - treasuryReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward - 100)) @@ -314,17 +307,16 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards uploader, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - operatingReward = pool.OperatingCost - storageReward = 2 * uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + networkFee = s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) + treasuryReward = uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + storageReward = uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + totalUploaderReward = pool.OperatingCost - treasuryReward - storageReward - treasuryReward = uint64(sdk.NewDec(int64(operatingReward)).Mul(networkFee).TruncateInt64()) - totalUploaderReward = operatingReward - treasuryReward - uploaderPayoutReward = 2 * uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) + uploaderPayoutReward = uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) - Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward - 300)) + Expect(uploader.CommissionRewards).To(Equal(2*(uploaderPayoutReward+storageReward) - 300)) Expect(s.GetBalanceFromAddress(i.STAKER_0)).To(Equal(initialBalanceStaker0 + 300)) }) diff --git a/x/stakers/keeper/msg_server_join_pool_test.go b/x/stakers/keeper/msg_server_join_pool_test.go index 1691545f..841327b5 100644 --- a/x/stakers/keeper/msg_server_join_pool_test.go +++ b/x/stakers/keeper/msg_server_join_pool_test.go @@ -52,7 +52,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { // create pool s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -393,7 +393,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { }) s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest2", + Name: "Test Pool2", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -418,7 +418,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { It("Try to join pool with a valaddress that is already used by another staker", func() { // ARRANGE s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest2", + Name: "Test Pool2", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -489,7 +489,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { }) s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest2", + Name: "Test Pool2", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/stakers/keeper/msg_server_leave_pool_test.go b/x/stakers/keeper/msg_server_leave_pool_test.go index 6d2f755f..bc05b851 100644 --- a/x/stakers/keeper/msg_server_leave_pool_test.go +++ b/x/stakers/keeper/msg_server_leave_pool_test.go @@ -30,7 +30,7 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { // create pool s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -209,7 +209,7 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { It("Leave one of multiple pools a staker has previously joined", func() { // ARRANGE s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Moontest", + Name: "PoolTest", Protocol: &pooltypes.Protocol{ Version: "0.0.0", Binaries: "{}", diff --git a/x/stakers/spec/07_exported.md b/x/stakers/spec/07_exported.md index eae8a6d5..0a6700de 100644 --- a/x/stakers/spec/07_exported.md +++ b/x/stakers/spec/07_exported.md @@ -65,6 +65,6 @@ type StakersKeeper interface { // IncreaseStakerCommissionRewards increases the commission rewards of a // staker by a specific amount. It can not be decreased, only the // MsgClaimCommissionRewards message can decrease this value. - IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) + IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) error } ``` diff --git a/x/team/abci.go b/x/team/abci.go index 0772f18c..5a90a279 100644 --- a/x/team/abci.go +++ b/x/team/abci.go @@ -10,8 +10,7 @@ import ( authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" // Bank bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - // Mint - mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + // Team "github.com/KYVENetwork/chain/x/team/keeper" "github.com/KYVENetwork/chain/x/team/types" @@ -19,31 +18,9 @@ import ( upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" ) -func DistributeTeamInflation(ctx sdk.Context, bk bankKeeper.Keeper, mk mintKeeper.Keeper, tk keeper.Keeper, uk upgradeKeeper.Keeper) { - // Compute team allocation of minted coins. - minter := mk.GetMinter(ctx) - params := mk.GetParams(ctx) - - // get total inflation rewards for current block - blockProvision := minter.BlockProvision(params) - - // calculate theoretical team balance. We don't use team module balance because a third party could skew - // the team inflation rewards by simply transferring funds to the team module account - teamBalance := tk.GetTeamInfo(ctx).RequiredModuleBalance - - // calculate total inflation rewards for team module. - // We subtract current inflation because it was already applied to the total supply because BeginBlocker - // x/mint runs before this method - totalSupply := bk.GetSupply(ctx, blockProvision.Denom).Amount.Int64() - blockProvision.Amount.Int64() - teamModuleRewardsShare := sdk.NewDec(int64(teamBalance)).Quo(sdk.NewDec(totalSupply)) - - // if team module balance is greater than total supply panic - if teamModuleRewardsShare.GT(sdk.NewDec(int64(1))) { - util.PanicHalt(uk, ctx, fmt.Sprintf("team module balance %v is higher than total supply %v", teamBalance, totalSupply)) - } - - // calculate the total reward in $KYVE the entire team module receives this block - teamModuleRewards := uint64(teamModuleRewardsShare.Mul(sdk.NewDec(blockProvision.Amount.Int64())).TruncateInt64()) +func DistributeTeamInflation(ctx sdk.Context, bk bankKeeper.Keeper, tk keeper.Keeper, uk upgradeKeeper.Keeper) { + // get the total team reward the module is eligible for in this block + teamModuleRewards := tk.GetTeamBlockProvision(ctx) // count total account rewards totalAccountRewards := uint64(0) @@ -55,7 +32,7 @@ func DistributeTeamInflation(ctx sdk.Context, bk bankKeeper.Keeper, mk mintKeepe // calculate reward share of account accountShare := sdk.NewDec(int64(status.TotalVestedAmount - account.UnlockedClaimed)).Quo(sdk.NewDec(int64(types.TEAM_ALLOCATION))) // calculate total inflation rewards for account for this block - accountRewards := uint64(sdk.NewDec(int64(teamModuleRewards)).Mul(accountShare).TruncateInt64()) + accountRewards := uint64(sdk.NewDec(teamModuleRewards).Mul(accountShare).TruncateInt64()) // save inflation rewards to account account.TotalRewards += accountRewards @@ -66,17 +43,17 @@ func DistributeTeamInflation(ctx sdk.Context, bk bankKeeper.Keeper, mk mintKeepe } // panic if total account rewards are higher than team module rewards - if totalAccountRewards > teamModuleRewards { + if totalAccountRewards > uint64(teamModuleRewards) { util.PanicHalt(uk, ctx, fmt.Sprintf("account rewards %v are higher than entire team module rewards %v", totalAccountRewards, teamModuleRewards)) } // track total authority inflation rewards authority := tk.GetAuthority(ctx) - authority.TotalRewards += teamModuleRewards - totalAccountRewards + authority.TotalRewards += uint64(teamModuleRewards) - totalAccountRewards tk.SetAuthority(ctx, authority) // distribute part of block provision to team module - if err := util.TransferFromModuleToModule(bk, ctx, authTypes.FeeCollectorName, types.ModuleName, teamModuleRewards); err != nil { + if err := util.TransferFromModuleToModule(bk, ctx, authTypes.FeeCollectorName, types.ModuleName, uint64(teamModuleRewards)); err != nil { util.PanicHalt(uk, ctx, err.Error()) } diff --git a/x/team/keeper/keeper.go b/x/team/keeper/keeper.go index 00cfba81..7db97665 100644 --- a/x/team/keeper/keeper.go +++ b/x/team/keeper/keeper.go @@ -3,6 +3,9 @@ package keeper import ( "fmt" + mintKeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storeTypes "github.com/cosmos/cosmos-sdk/store/types" @@ -23,6 +26,8 @@ type ( accountKeeper authKeeper.AccountKeeper bankKeeper bankKeeper.Keeper + mintKeeper mintKeeper.Keeper + upgradeKeeper upgradeKeeper.Keeper } ) @@ -31,6 +36,8 @@ func NewKeeper( storeKey storeTypes.StoreKey, accountKeeper authKeeper.AccountKeeper, bankKeeper bankKeeper.Keeper, + mintKeeper mintKeeper.Keeper, + upgradeKeeper upgradeKeeper.Keeper, ) *Keeper { return &Keeper{ cdc: cdc, @@ -38,6 +45,8 @@ func NewKeeper( accountKeeper: accountKeeper, bankKeeper: bankKeeper, + mintKeeper: mintKeeper, + upgradeKeeper: upgradeKeeper, } } diff --git a/x/team/keeper/logic_team.go b/x/team/keeper/logic_team.go index 299b43b4..c9b6b470 100644 --- a/x/team/keeper/logic_team.go +++ b/x/team/keeper/logic_team.go @@ -1,12 +1,43 @@ package keeper import ( + "fmt" + "github.com/KYVENetwork/chain/util" globalTypes "github.com/KYVENetwork/chain/x/global/types" "github.com/KYVENetwork/chain/x/team/types" sdk "github.com/cosmos/cosmos-sdk/types" ) +// GetTeamBlockProvision gets the total reward amount for the team module +// for the current block +func (k Keeper) GetTeamBlockProvision(ctx sdk.Context) int64 { + // Compute team allocation of minted coins. + minter := k.mintKeeper.GetMinter(ctx) + params := k.mintKeeper.GetParams(ctx) + + // get total inflation rewards for current block + blockProvision := minter.BlockProvision(params) + + // calculate theoretical team balance. We don't use team module balance because a third party could skew + // the team inflation rewards by simply transferring funds to the team module account + teamBalance := k.GetTeamInfo(ctx).RequiredModuleBalance + + // calculate total inflation rewards for team module. + // We subtract current inflation because it was already applied to the total supply because BeginBlocker + // x/mint runs before this method + totalSupply := k.bankKeeper.GetSupply(ctx, blockProvision.Denom).Amount.Int64() - blockProvision.Amount.Int64() + teamModuleRewardsShare := sdk.NewDec(int64(teamBalance)).Quo(sdk.NewDec(totalSupply)) + + // if team module balance is greater than total supply panic + if teamModuleRewardsShare.GT(sdk.NewDec(int64(1))) { + util.PanicHalt(k.upgradeKeeper, ctx, fmt.Sprintf("team module balance %v is higher than total supply %v", teamBalance, totalSupply)) + } + + // calculate the total reward in $KYVE the entire team module receives this block + return teamModuleRewardsShare.Mul(sdk.NewDec(blockProvision.Amount.Int64())).TruncateInt64() +} + // GetVestingStatus returns all computed values which are dependent on the time // for the given account func GetVestingStatus(account types.TeamVestingAccount, time uint64) *types.VestingStatus { diff --git a/x/team/module.go b/x/team/module.go index 66dd1d1c..1606f61d 100644 --- a/x/team/module.go +++ b/x/team/module.go @@ -152,7 +152,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { - DistributeTeamInflation(ctx, am.bk, am.mk, am.keeper, am.uk) + DistributeTeamInflation(ctx, am.bk, am.keeper, am.uk) } // EndBlock contains the logic that is automatically triggered at the end of each block