Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multiple coins in bundles module #184

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/upgrades/v1_5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,

// TODO: migrate delegation outstanding rewards

// TODO: migrate network fee and whitelist weights

troykessler marked this conversation as resolved.
Show resolved Hide resolved
return mm.RunMigrations(ctx, configurator, fromVM)
}
}
Expand Down
27 changes: 21 additions & 6 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ paths:
storage_provider_id:
type: integer
format: int64
description: storage_provider_id ...
description: >-
storage_provider_id is a unique identifier for each
storage provider, such as Arweave, Irys, Filecoin,
etc.
cost:
type: string
description: cost ...
description: >-
cost is the amount in USD to store one byte on the
storage provider. This value should be kept
up-to-date.
title: StorageCost defines the cost for storage providers
description: storage_costs ...
network_fee:
Expand Down Expand Up @@ -4423,10 +4429,16 @@ paths:
storage_provider_id:
type: integer
format: int64
description: storage_provider_id ...
description: >-
storage_provider_id is a unique identifier for each
storage provider, such as Arweave, Irys, Filecoin,
etc.
cost:
type: string
description: cost ...
description: >-
cost is the amount in USD to store one byte on the
storage provider. This value should be kept
up-to-date.
title: StorageCost defines the cost for storage providers
description: storage_costs ...
network_fee:
Expand Down Expand Up @@ -4723,9 +4735,12 @@ paths:
that needs to be funded per bundle
coin_weight:
type: string
title: >-
description: >-
coin_weight is a factor used to sort funders after
their funding amounts
their funding amounts.

This should be the market price of the coin in
USD/coin. This value should be kept up-to-date.
title: >-
WhitelistCoinEntry is an object containing information
around a coin which
Expand Down
47 changes: 38 additions & 9 deletions proto/kyve/bundles/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.bundles.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "kyve/bundles/v1beta1/bundles.proto";
import "kyve/bundles/v1beta1/params.proto";
Expand Down Expand Up @@ -87,24 +89,51 @@ 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 funders provided to the total bundle reward
repeated cosmos.base.v1beta1.Coin funders_payout = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// 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 = 10;
// rewardUploader rewards directly transferred to uploader (in ukyve)
uint64 reward_uploader = 11;
// rewardDelegation rewards distributed among all delegators (in ukyve)
uint64 reward_delegation = 12;
// rewards transferred to treasury
repeated cosmos.base.v1beta1.Coin reward_treasury = 10 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// reward_uploader_commission are the commission rewards of the uploader.
// if the uploader has no delegations the delegation rewards are included here
repeated cosmos.base.v1beta1.Coin reward_uploader_commission = 11 [
troykessler marked this conversation as resolved.
Show resolved Hide resolved
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// rewardDelegation rewards distributed among all delegators
repeated cosmos.base.v1beta1.Coin reward_delegation = 12 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// rewardTotal the total bundle reward
uint64 reward_total = 13;
repeated cosmos.base.v1beta1.Coin reward_total = 13 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// finalized_at the block height where the bundle got finalized
uint64 finalized_at = 14;
// uploader the address of the uploader of this bundle
string uploader = 15;
// next_uploader the address of the next uploader after this bundle
string next_uploader = 16;
// reward_uploader_storage_cost are the storage cost rewards for the uploader
repeated cosmos.base.v1beta1.Coin reward_uploader_storage_cost = 17 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// EventClaimedUploaderRole is an event emitted when an uploader claims the uploader role
Expand Down
4 changes: 2 additions & 2 deletions proto/kyve/bundles/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ option go_package = "github.com/KYVENetwork/chain/x/bundles/types";

// StorageCost defines the cost for storage providers
message StorageCost {
// storage_provider_id ...
// storage_provider_id is a unique identifier for each storage provider, such as Arweave, Irys, Filecoin, etc.
uint32 storage_provider_id = 1;
// cost ...
// cost is the amount in USD to store one byte on the storage provider. This value should be kept up-to-date.
string cost = 2 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
Expand Down
3 changes: 2 additions & 1 deletion proto/kyve/funders/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ message WhitelistCoinEntry {
// min_funding_amount_per_bundle is the minimum required amount of this denom
// that needs to be funded per bundle
uint64 min_funding_amount_per_bundle = 3;
// coin_weight is a factor used to sort funders after their funding amounts
// coin_weight is a factor used to sort funders after their funding amounts.
// This should be the market price of the coin in USD/coin. This value should be kept up-to-date.
string coin_weight = 4 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
Expand Down
4 changes: 2 additions & 2 deletions x/bundles/keeper/keeper_suite_valid_bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,11 @@ var _ = Describe("valid bundles", Ordered, func() {
balanceVoter := s.GetBalanceFromAddress(valaccountVoter.Staker)
Expect(balanceVoter).To(Equal(initialBalanceStaker1))

// calculate uploader rewards
// calculate uploader rewards
networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx())
whitelist := s.App().FundersKeeper.GetCoinWhitelistMap(s.Ctx())
treasuryReward := uint64(math.LegacyNewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64())
storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx(), storageProviderId).MulInt64(100).TruncateInt64())
storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx(), storageProviderId).Quo(whitelist[globalTypes.Denom].CoinWeight).MulInt64(100).TruncateInt64())
totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward

uploaderPayoutReward := uint64(math.LegacyNewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64())
Expand Down
Loading
Loading