diff --git a/CHANGELOG.md b/CHANGELOG.md index d4ef6ff9..09574398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,11 +18,21 @@ - (deps) [#21](https://github.com/KYVENetwork/chain/pull/21) Bump Cosmos SDK to [v0.46.11](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.11) ([`v0.46.11-kyve-rc0`](https://github.com/KYVENetwork/cosmos-sdk/releases/tag/v0.46.11-kyve-rc0)). - (deps) [#21](https://github.com/KYVENetwork/chain/pull/21) Switch to CometBFT from Informal Systems' Tendermint fork. +- [#22](https://github.com/KYVENetwork/chain/pull/22) Emit an event when updating module parameters. +- [#22](https://github.com/KYVENetwork/chain/pull/22) Various minor code improvements, cleanups, and validations. ### Bug Fixes - [#20](https://github.com/KYVENetwork/chain/pull/20) Adjust investor vesting schedules from second funding round. +### State Machine Breaking + +- (`x/bundles`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `NetworkFee` param to type `sdk.Dec`. +- (`x/delegation`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `VoteSlash`, `UploadSlash`, `TimeoutSlash` params to type `sdk.Dec`. +- (`x/stakers`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `Commission` to type `sdk.Dec`. +- (`x/bundles`) [#22](https://github.com/KYVENetwork/chain/pull/22) use non-manipulable pseudo-random source seed for uploader selection. + + ## [v1.0.0](https://github.com/KYVENetwork/chain/releases/tag/v1.0.0) - 2023-03-10 Release for the KYVE network launch. diff --git a/app/app.go b/app/app.go index d5ec4ed4..5f505aec 100644 --- a/app/app.go +++ b/app/app.go @@ -448,7 +448,6 @@ func NewKYVEApp( app.PoolKeeper, app.StakersKeeper, app.DelegationKeeper, - app.UpgradeKeeper, ) // Create IBC Keepers diff --git a/proto/kyve/bundles/v1beta1/events.proto b/proto/kyve/bundles/v1beta1/events.proto index 6bc7b503..f82143f0 100644 --- a/proto/kyve/bundles/v1beta1/events.proto +++ b/proto/kyve/bundles/v1beta1/events.proto @@ -2,11 +2,24 @@ syntax = "proto3"; package kyve.bundles.v1beta1; +import "gogoproto/gogo.proto"; import "kyve/bundles/v1beta1/bundles.proto"; +import "kyve/bundles/v1beta1/params.proto"; import "kyve/bundles/v1beta1/tx.proto"; option go_package = "github.com/KYVENetwork/chain/x/bundles/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.bundles.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.bundles.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} + // EventBundleVote is an event emitted when a protocol node votes on a bundle. // emitted_by: MsgVoteBundleProposal message EventBundleVote { diff --git a/proto/kyve/bundles/v1beta1/params.proto b/proto/kyve/bundles/v1beta1/params.proto index e2f2d93d..b31a4d25 100644 --- a/proto/kyve/bundles/v1beta1/params.proto +++ b/proto/kyve/bundles/v1beta1/params.proto @@ -16,7 +16,10 @@ message Params { (gogoproto.nullable) = false ]; // network_fee ... - string network_fee = 3; + string network_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // max_points ... uint64 max_points = 4; } diff --git a/proto/kyve/delegation/v1beta1/events.proto b/proto/kyve/delegation/v1beta1/events.proto index 13b45fbd..da13e687 100644 --- a/proto/kyve/delegation/v1beta1/events.proto +++ b/proto/kyve/delegation/v1beta1/events.proto @@ -2,10 +2,23 @@ syntax = "proto3"; package kyve.delegation.v1beta1; +import "gogoproto/gogo.proto"; import "kyve/delegation/v1beta1/delegation.proto"; +import "kyve/delegation/v1beta1/params.proto"; option go_package = "github.com/KYVENetwork/chain/x/delegation/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.delegation.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.delegation.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} + // ---------- Delegating Events ---------- // EventDelegate is an event emitted when someone delegates to a protocol node. diff --git a/proto/kyve/delegation/v1beta1/params.proto b/proto/kyve/delegation/v1beta1/params.proto index 1cf3053b..86ff72de 100644 --- a/proto/kyve/delegation/v1beta1/params.proto +++ b/proto/kyve/delegation/v1beta1/params.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package kyve.delegation.v1beta1; +import "gogoproto/gogo.proto"; + option go_package = "github.com/KYVENetwork/chain/x/delegation/types"; // Params defines the delegation module parameters. @@ -13,9 +15,18 @@ message Params { // unbonding_delegation_time ... uint64 redelegation_max_amount = 3; // vote_slash ... - string vote_slash = 4; + string vote_slash = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // upload_slash ... - string upload_slash = 5; + string upload_slash = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // timeout_slash ... - string timeout_slash = 6; + string timeout_slash = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } diff --git a/proto/kyve/global/v1beta1/events.proto b/proto/kyve/global/v1beta1/events.proto new file mode 100644 index 00000000..eab53058 --- /dev/null +++ b/proto/kyve/global/v1beta1/events.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package kyve.global.v1beta1; + +import "gogoproto/gogo.proto"; +import "kyve/global/v1beta1/global.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/global/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.global.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.global.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} diff --git a/proto/kyve/query/v1beta1/query.proto b/proto/kyve/query/v1beta1/query.proto index 88fa9dfb..04be74af 100644 --- a/proto/kyve/query/v1beta1/query.proto +++ b/proto/kyve/query/v1beta1/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package kyve.query.v1beta1; +import "gogoproto/gogo.proto"; import "kyve/pool/v1beta1/pool.proto"; option go_package = "github.com/KYVENetwork/chain/x/query/types"; @@ -94,7 +95,10 @@ message StakerMetadata { // commission is the percentage of the rewards that will // get transferred to the staker before the remaining // rewards are split across all delegators - string commission = 1; + string commission = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // moniker is a human-readable name for displaying // the staker in the UI @@ -119,7 +123,10 @@ message StakerMetadata { message CommissionChangeEntry { // commission is the new commission that will // become active once the change-time is over - string commission = 1; + string commission = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // creation_date is the UNIX-timestamp (in seconds) // of when the entry was created. diff --git a/proto/kyve/stakers/v1beta1/events.proto b/proto/kyve/stakers/v1beta1/events.proto index 3b7fba3d..5bc47f03 100644 --- a/proto/kyve/stakers/v1beta1/events.proto +++ b/proto/kyve/stakers/v1beta1/events.proto @@ -2,8 +2,22 @@ syntax = "proto3"; package kyve.stakers.v1beta1; +import "gogoproto/gogo.proto"; +import "kyve/stakers/v1beta1/params.proto"; + option go_package = "github.com/KYVENetwork/chain/x/stakers/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.stakers.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.stakers.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} + // EventCreateStaker is an event emitted when a protocol node stakes in a pool. // emitted_by: MsgCreateStaker message EventCreateStaker { @@ -32,7 +46,10 @@ message EventUpdateCommission { // staker is the account address of the protocol node. string staker = 1; // commission ... - string commission = 2; + string commission = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } // EventJoinPool ... diff --git a/proto/kyve/stakers/v1beta1/stakers.proto b/proto/kyve/stakers/v1beta1/stakers.proto index 66ac6513..bc7c85fd 100644 --- a/proto/kyve/stakers/v1beta1/stakers.proto +++ b/proto/kyve/stakers/v1beta1/stakers.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package kyve.stakers.v1beta1; +import "gogoproto/gogo.proto"; + option go_package = "github.com/KYVENetwork/chain/x/stakers/types"; // Staker contains all metadata for a staker @@ -10,7 +12,10 @@ message Staker { // address ... string address = 1; // commission ... - string commission = 2; + string commission = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // moniker ... string moniker = 3; // website ... @@ -50,7 +55,10 @@ message CommissionChangeEntry { string staker = 2; // commission is the new commission which will // be applied after the waiting time is over. - string commission = 3; + string commission = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // creation_date is the UNIX-timestamp in seconds // when the entry was created. int64 creation_date = 4; diff --git a/proto/kyve/stakers/v1beta1/tx.proto b/proto/kyve/stakers/v1beta1/tx.proto index 729f36ae..d1509d1f 100644 --- a/proto/kyve/stakers/v1beta1/tx.proto +++ b/proto/kyve/stakers/v1beta1/tx.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package kyve.stakers.v1beta1; import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/KYVENetwork/chain/x/stakers/types"; @@ -24,12 +25,18 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgStakePool defines a SDK message for staking in a pool. +// MsgCreateStaker defines a SDK message for creating a staker. message MsgCreateStaker { - // creator ... + // creator is the address of the staker. string creator = 1; - // amount ... + // amount is the initial self-stake of the staker. uint64 amount = 2; + // commission is the percentage that is deducted from rewards before + // distributing the staker's delegators. + string commission = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } // MsgStakePoolResponse defines the Msg/StakePool response type. @@ -55,7 +62,10 @@ message MsgUpdateCommission { // creator ... string creator = 1; // commission ... - string commission = 2; + string commission = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } // MsgUpdateCommissionResponse ... diff --git a/testutil/integration/transactions.go b/testutil/integration/transactions.go index 12a298e5..3dce58be 100644 --- a/testutil/integration/transactions.go +++ b/testutil/integration/transactions.go @@ -19,6 +19,13 @@ func (suite *KeeperTestSuite) RunTx(msg sdk.Msg) (*sdk.Result, error) { return res, nil } +func (suite *KeeperTestSuite) RunTxError(msg sdk.Msg) error { + _, err := suite.RunTx(msg) + Expect(err).To(HaveOccurred()) + + return err +} + func (suite *KeeperTestSuite) RunTxSuccess(msg sdk.Msg) *sdk.Result { result, err := suite.RunTx(msg) Expect(err).NotTo(HaveOccurred()) diff --git a/util/logic_bank.go b/util/logic_bank.go index bc2337c6..7160b861 100644 --- a/util/logic_bank.go +++ b/util/logic_bank.go @@ -7,9 +7,19 @@ import ( type BankKeeper interface { SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToAccount( + ctx sdk.Context, + senderModule string, + recipientAddr sdk.AccAddress, + amt sdk.Coins, + ) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule( + ctx sdk.Context, + senderAddr sdk.AccAddress, + recipientModule string, + amt sdk.Coins, + ) error } type DistrKeeper interface { @@ -21,7 +31,13 @@ type AccountKeeper interface { } // TransferFromAddressToAddress sends tokens from the given address to a specified address. -func TransferFromAddressToAddress(bankKeeper BankKeeper, ctx sdk.Context, fromAddress string, toAddress string, amount uint64) error { +func TransferFromAddressToAddress( + bankKeeper BankKeeper, + ctx sdk.Context, + fromAddress string, + toAddress string, + amount uint64, +) error { sender, errSenderAddress := sdk.AccAddressFromBech32(fromAddress) if errSenderAddress != nil { return errSenderAddress @@ -37,8 +53,14 @@ func TransferFromAddressToAddress(bankKeeper BankKeeper, ctx sdk.Context, fromAd return err } -// TransferToAddress sends tokens from the given module to a specified address. -func TransferFromModuleToAddress(bankKeeper BankKeeper, ctx sdk.Context, module string, address string, amount uint64) error { +// TransferFromModuleToAddress sends tokens from the given module to a specified address. +func TransferFromModuleToAddress( + bankKeeper BankKeeper, + ctx sdk.Context, + module string, + address string, + amount uint64, +) error { recipient, errAddress := sdk.AccAddressFromBech32(address) if errAddress != nil { return errAddress @@ -49,8 +71,14 @@ func TransferFromModuleToAddress(bankKeeper BankKeeper, ctx sdk.Context, module return err } -// TransferToRegistry sends tokens from a specified address to the given module. -func TransferFromAddressToModule(bankKeeper BankKeeper, ctx sdk.Context, address string, module string, amount uint64) error { +// TransferFromAddressToModule sends tokens from a specified address to the given module. +func TransferFromAddressToModule( + bankKeeper BankKeeper, + ctx sdk.Context, + address string, + module string, + amount uint64, +) error { sender, errAddress := sdk.AccAddressFromBech32(address) if errAddress != nil { return errAddress @@ -61,14 +89,20 @@ func TransferFromAddressToModule(bankKeeper BankKeeper, ctx sdk.Context, address return err } -// TransferInterModule ... -func TransferFromModuleToModule(bankKeeper BankKeeper, ctx sdk.Context, fromModule string, toModule string, amount uint64) error { +// TransferFromModuleToModule sends tokens from a specified module to the given module. +func TransferFromModuleToModule( + bankKeeper BankKeeper, + ctx sdk.Context, + fromModule string, + toModule string, + amount uint64, +) error { coins := sdk.NewCoins(sdk.NewInt64Coin(globalTypes.Denom, int64(amount))) err := bankKeeper.SendCoinsFromModuleToModule(ctx, fromModule, toModule, coins) return err } -// transferToTreasury sends tokens from this module to the treasury (community spend pool). +// TransferFromAddressToTreasury sends tokens from a given address to the treasury (community spend pool). func TransferFromAddressToTreasury(distrKeeper DistrKeeper, ctx sdk.Context, address string, amount uint64) error { sender, errAddress := sdk.AccAddressFromBech32(address) if errAddress != nil { @@ -83,8 +117,14 @@ func TransferFromAddressToTreasury(distrKeeper DistrKeeper, ctx sdk.Context, add return nil } -// transferToTreasury sends tokens from this module to the treasury (community spend pool). -func TransferFromModuleToTreasury(accountKeeper AccountKeeper, distrKeeper DistrKeeper, ctx sdk.Context, module string, amount uint64) error { +// TransferFromModuleToTreasury sends tokens from a module to the treasury (community spend pool). +func TransferFromModuleToTreasury( + accountKeeper AccountKeeper, + distrKeeper DistrKeeper, + ctx sdk.Context, + module string, + amount uint64, +) error { sender := accountKeeper.GetModuleAddress(module) coins := sdk.NewCoins(sdk.NewInt64Coin(globalTypes.Denom, int64(amount))) diff --git a/util/validate.go b/util/validate.go index b218e277..cc4169d5 100644 --- a/util/validate.go +++ b/util/validate.go @@ -3,33 +3,60 @@ package util import ( "fmt" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" ) -func ValidateUint64(v interface{}) error { - _, ok := v.(uint64) +func ValidateDecimal(i interface{}) error { + v, ok := i.(sdk.Dec) if !ok { - return fmt.Errorf("invalid parameter type: %T", v) + return fmt.Errorf("invalid type: %T", i) + } + + if v.IsNil() || v.IsNegative() { + return fmt.Errorf("invalid decimal: %s", v) } + return nil } -func ValidatePercentage(v interface{}) error { - val, ok := v.(string) +func ValidateNumber(i interface{}) error { + v, ok := i.(uint64) if !ok { - return fmt.Errorf("invalid parameter type: %T", v) + return fmt.Errorf("invalid type: %T", i) } - parsedVal, err := sdk.NewDecFromStr(val) - if err != nil { - return fmt.Errorf("invalid decimal representation: %T", v) + if math.NewIntFromUint64(v).IsNil() || math.NewIntFromUint64(v).IsNegative() { + return fmt.Errorf("invalid number: %d", v) } - if parsedVal.LT(sdk.NewDec(0)) { - return fmt.Errorf("percentage should be greater than or equal to 0") + return nil +} + +func ValidatePositiveNumber(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid type: %T", i) } - if parsedVal.GT(sdk.NewDec(1)) { - return fmt.Errorf("percentage should be less than or equal to 1") + + if math.NewIntFromUint64(v).IsNil() || + math.NewIntFromUint64(v).IsNegative() || + math.NewIntFromUint64(v).IsZero() { + return fmt.Errorf("invalid number: %d", v) + } + + return nil +} + +func ValidatePercentage(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid type: %T", i) + } + + if v.IsNil() || v.IsNegative() || v.GT(sdk.OneDec()) { + return fmt.Errorf("invalid percentage: %s", v) } return nil diff --git a/x/bundles/keeper/getters_params.go b/x/bundles/keeper/getters_params.go index 825ce6c7..ffe082e3 100644 --- a/x/bundles/keeper/getters_params.go +++ b/x/bundles/keeper/getters_params.go @@ -29,7 +29,7 @@ func (k Keeper) GetStorageCost(ctx sdk.Context) (res sdk.Dec) { } // GetNetworkFee returns the NetworkFee param -func (k Keeper) GetNetworkFee(ctx sdk.Context) (res string) { +func (k Keeper) GetNetworkFee(ctx sdk.Context) (res sdk.Dec) { return k.GetParams(ctx).NetworkFee } diff --git a/x/bundles/keeper/keeper.go b/x/bundles/keeper/keeper.go index 59c40483..69d0b6cb 100644 --- a/x/bundles/keeper/keeper.go +++ b/x/bundles/keeper/keeper.go @@ -25,7 +25,6 @@ type ( poolKeeper types.PoolKeeper stakerKeeper types.StakerKeeper delegationKeeper types.DelegationKeeper - upgradeKeeper types.UpgradeKeeper } ) @@ -42,7 +41,6 @@ func NewKeeper( poolKeeper types.PoolKeeper, stakerKeeper types.StakerKeeper, delegationKeeper types.DelegationKeeper, - upgradeKeeper types.UpgradeKeeper, ) *Keeper { return &Keeper{ cdc: cdc, diff --git a/x/bundles/keeper/keeper_suite_invalid_bundles_test.go b/x/bundles/keeper/keeper_suite_invalid_bundles_test.go index 2bdb65b0..8dfc69c4 100644 --- a/x/bundles/keeper/keeper_suite_invalid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_invalid_bundles_test.go @@ -196,7 +196,7 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) // calculate uploader slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetUploadSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetUploadSlash(s.Ctx()) slashAmount := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100*i.KYVE - slashAmount)) @@ -338,7 +338,7 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) // calculate uploader slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetUploadSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetUploadSlash(s.Ctx()) slashAmountUploader := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) slashAmountDelegator := uint64(sdk.NewDec(int64(300 * i.KYVE)).Mul(fraction).TruncateInt64()) @@ -510,7 +510,7 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) // calculate uploader slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetUploadSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetUploadSlash(s.Ctx()) slashAmountUploader := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) slashAmountDelegator1 := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) @@ -518,7 +518,7 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.ALICE)).To(Equal(100*i.KYVE - slashAmountDelegator1)) // calculate voter slashes - fraction, _ = sdk.NewDecFromStr(s.App().DelegationKeeper.GetVoteSlash(s.Ctx())) + fraction = s.App().DelegationKeeper.GetVoteSlash(s.Ctx()) slashAmountVoter := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) slashAmountDelegator2 := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) diff --git a/x/bundles/keeper/keeper_suite_points_test.go b/x/bundles/keeper/keeper_suite_points_test.go index 3e44a2b2..0fe53c3f 100644 --- a/x/bundles/keeper/keeper_suite_points_test.go +++ b/x/bundles/keeper/keeper_suite_points_test.go @@ -310,7 +310,7 @@ var _ = Describe("points", Ordered, func() { Expect(valaccountFound).To(BeFalse()) // check if voter got slashed - slashAmountRatio, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx())) + slashAmountRatio := s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx()) expectedBalance := 50*i.KYVE - uint64(sdk.NewDec(int64(50*i.KYVE)).Mul(slashAmountRatio).TruncateInt64()) Expect(expectedBalance).To(Equal(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1))) diff --git a/x/bundles/keeper/keeper_suite_stakers_leave_test.go b/x/bundles/keeper/keeper_suite_stakers_leave_test.go index 99707ca3..213799ba 100644 --- a/x/bundles/keeper/keeper_suite_stakers_leave_test.go +++ b/x/bundles/keeper/keeper_suite_stakers_leave_test.go @@ -218,13 +218,12 @@ var _ = Describe("stakers leave", Ordered, func() { balanceUploader := s.GetBalanceFromAddress(i.STAKER_0) totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward // assert payout transfer @@ -309,7 +308,7 @@ var _ = Describe("stakers leave", Ordered, func() { Expect(valaccountFound).To(BeFalse()) // check if next uploader got slashed - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetUploadSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetUploadSlash(s.Ctx()) slashAmount := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100*i.KYVE - slashAmount)) @@ -402,7 +401,7 @@ var _ = Describe("stakers leave", Ordered, func() { Expect(valaccountFound).To(BeFalse()) // check if voter got slashed - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetVoteSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetVoteSlash(s.Ctx()) slashAmount := uint64(sdk.NewDec(int64(50 * i.KYVE)).Mul(fraction).TruncateInt64()) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(50*i.KYVE - slashAmount)) diff --git a/x/bundles/keeper/keeper_suite_valid_bundles_test.go b/x/bundles/keeper/keeper_suite_valid_bundles_test.go index 74188ab8..82948132 100644 --- a/x/bundles/keeper/keeper_suite_valid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_valid_bundles_test.go @@ -179,13 +179,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward // assert payout transfer @@ -295,13 +294,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward // divide with 4 because uploader only has 25% of total delegation @@ -444,13 +442,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward // assert payout transfer @@ -599,13 +596,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward // divide with 4 because uploader only has 25% of total delegation @@ -759,13 +755,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward // divide with 4 because uploader only has 25% of total delegation @@ -927,13 +922,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward // divide with 4 because uploader only has 25% of total delegation @@ -1084,7 +1078,7 @@ var _ = Describe("valid bundles", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), valaccountUploader.Staker) // calculate voter slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetVoteSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetVoteSlash(s.Ctx()) slashAmountVoter := uint64(sdk.NewDec(int64(200 * i.KYVE)).Mul(fraction).TruncateInt64()) slashAmountDelegator := uint64(sdk.NewDec(int64(100 * i.KYVE)).Mul(fraction).TruncateInt64()) @@ -1105,13 +1099,12 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) - commission, _ := sdk.NewDecFromStr(uploader.Commission) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward - uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(commission).TruncateInt64()) + uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward // divide with 4 because uploader only has 25% of total delegation diff --git a/x/bundles/keeper/keeper_suite_zero_delegation_test.go b/x/bundles/keeper/keeper_suite_zero_delegation_test.go index 432e4464..e4d2c634 100644 --- a/x/bundles/keeper/keeper_suite_zero_delegation_test.go +++ b/x/bundles/keeper/keeper_suite_zero_delegation_test.go @@ -234,7 +234,7 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(bundleProposal.NextUploader).To(Equal(i.STAKER_0)) // calculate voter slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetVoteSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetVoteSlash(s.Ctx()) slashAmountVoter := uint64(sdk.NewDec(int64(0 * i.KYVE)).Mul(fraction).TruncateInt64()) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(Equal(0*i.KYVE - slashAmountVoter)) @@ -385,7 +385,7 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards totalReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) + pool.OperatingCost - networkFee, _ := sdk.NewDecFromStr(s.App().BundlesKeeper.GetNetworkFee(s.Ctx())) + networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalReward)).Mul(networkFee).TruncateInt64()) totalUploaderReward := totalReward - treasuryReward @@ -529,7 +529,7 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) // calculate uploader slashes - fraction, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetUploadSlash(s.Ctx())) + fraction := s.App().DelegationKeeper.GetUploadSlash(s.Ctx()) slashAmount := uint64(sdk.NewDec(int64(0 * i.KYVE)).Mul(fraction).TruncateInt64()) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(0*i.KYVE - slashAmount)) @@ -643,7 +643,7 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(valaccountFound).To(BeFalse()) // check if voter got slashed - slashAmountRatio, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx())) + slashAmountRatio := s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx()) expectedBalance := 0*i.KYVE - uint64(sdk.NewDec(int64(0*i.KYVE)).Mul(slashAmountRatio).TruncateInt64()) Expect(expectedBalance).To(Equal(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1))) diff --git a/x/bundles/keeper/logic_bundles.go b/x/bundles/keeper/logic_bundles.go index 2d6d1691..0a91567d 100644 --- a/x/bundles/keeper/logic_bundles.go +++ b/x/bundles/keeper/logic_bundles.go @@ -1,7 +1,6 @@ package keeper import ( - "encoding/binary" "math/rand" "sort" @@ -238,12 +237,8 @@ func (k Keeper) calculatePayouts(ctx sdk.Context, poolId uint64) (bundleReward t // formula for calculating the rewards bundleReward.Total = pool.OperatingCost + uint64(k.GetStorageCost(ctx).MulInt64(int64(bundleProposal.DataSize)).TruncateInt64()) - networkFee, err := sdk.NewDecFromStr(k.GetNetworkFee(ctx)) - if err != nil { - util.PanicHalt(k.upgradeKeeper, ctx, "Network Fee unparasable - "+k.GetNetworkFee(ctx)) - } // Add fee to treasury - bundleReward.Treasury = uint64(sdk.NewDec(int64(bundleReward.Total)).Mul(networkFee).TruncateInt64()) + bundleReward.Treasury = uint64(sdk.NewDec(int64(bundleReward.Total)).Mul(k.GetNetworkFee(ctx)).TruncateInt64()) // Remaining rewards to be split between staker and its delegators totalNodeReward := bundleReward.Total - bundleReward.Treasury @@ -474,8 +469,7 @@ func (k Keeper) chooseNextUploaderFromSelectedStakers(ctx sdk.Context, poolId ui } } - seed := int64(binary.BigEndian.Uint64(ctx.BlockHeader().AppHash)) - return k.getWeightedRandomChoice(_candidates, seed) + return k.getWeightedRandomChoice(_candidates, ctx.BlockHeader().Height) } // chooseNextUploaderFromAllStakers selects the next uploader based on all 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 d1d97f63..db7104eb 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 @@ -537,7 +537,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationOfPool(s.Ctx(), 0)).To(Equal(100 * i.KYVE)) // check if next uploader not got slashed - slashAmountRatio, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx())) + slashAmountRatio := s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx()) expectedBalance := 50*i.KYVE - uint64(sdk.NewDec(int64(50*i.KYVE)).Mul(slashAmountRatio).TruncateInt64()) Expect(expectedBalance).To(Equal(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_1, i.STAKER_1))) @@ -638,7 +638,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { 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()) @@ -986,7 +986,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationOfPool(s.Ctx(), 1)).To(Equal(100 * i.KYVE)) // check if next uploader not got slashed - slashAmountRatio, _ := sdk.NewDecFromStr(s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx())) + slashAmountRatio := s.App().DelegationKeeper.GetTimeoutSlash(s.Ctx()) expectedBalance := 50*i.KYVE - uint64(sdk.NewDec(int64(50*i.KYVE)).Mul(slashAmountRatio).TruncateInt64()) Expect(expectedBalance).To(Equal(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_2, i.STAKER_2))) diff --git a/x/bundles/keeper/msg_server_update_params.go b/x/bundles/keeper/msg_server_update_params.go index 72a4cd76..00407887 100644 --- a/x/bundles/keeper/msg_server_update_params.go +++ b/x/bundles/keeper/msg_server_update_params.go @@ -5,7 +5,6 @@ import ( "encoding/json" "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" // Bundles @@ -14,17 +13,23 @@ import ( govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { - return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) +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) - params := k.GetParams(ctx) + oldParams := k.GetParams(ctx) + + newParams := oldParams + _ = json.Unmarshal([]byte(msg.Payload), &newParams) + k.SetParams(ctx, newParams) - payload := params - _ = json.Unmarshal([]byte(req.Payload), &payload) - k.SetParams(ctx, payload) + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + OldParams: oldParams, + NewParams: newParams, + Payload: msg.Payload, + }) return &types.MsgUpdateParamsResponse{}, nil } diff --git a/x/bundles/keeper/msg_server_update_params_test.go b/x/bundles/keeper/msg_server_update_params_test.go index 3ffc04ba..9940ebf8 100644 --- a/x/bundles/keeper/msg_server_update_params_test.go +++ b/x/bundles/keeper/msg_server_update_params_test.go @@ -139,7 +139,7 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.UploadTimeout).To(Equal(uint64(20))) Expect(updatedParams.StorageCost).To(Equal(sdk.MustNewDecFromStr("0.05"))) - Expect(updatedParams.NetworkFee).To(Equal("0.05")) + Expect(updatedParams.NetworkFee).To(Equal(sdk.MustNewDecFromStr("0.05"))) Expect(updatedParams.MaxPoints).To(Equal(uint64(15))) }) @@ -385,7 +385,7 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.UploadTimeout).To(Equal(types.DefaultUploadTimeout)) Expect(updatedParams.StorageCost).To(Equal(types.DefaultStorageCost)) - Expect(updatedParams.NetworkFee).To(Equal("0.05")) + Expect(updatedParams.NetworkFee).To(Equal(sdk.MustNewDecFromStr("0.05"))) Expect(updatedParams.MaxPoints).To(Equal(types.DefaultMaxPoints)) }) diff --git a/x/bundles/spec/05_params.md b/x/bundles/spec/05_params.md index 60ebc75d..00257271 100644 --- a/x/bundles/spec/05_params.md +++ b/x/bundles/spec/05_params.md @@ -10,5 +10,5 @@ The bundles module contains the following parameters: |---------------|-------------------------|---------| | UploadTimeout | uint64 (time s) | 600 | | StorageCost | uint64 (tkyve per byte) | 25 | -| NetworkFee | string (%) | "0.01" | +| NetworkFee | sdk.Dec (%) | "0.01" | | MaxPoints | uint64 | 5 | diff --git a/x/bundles/spec/06_events.md b/x/bundles/spec/06_events.md index bcc2c805..a79557d4 100644 --- a/x/bundles/spec/06_events.md +++ b/x/bundles/spec/06_events.md @@ -6,6 +6,21 @@ order: 6 The bundles module contains the following events: +## EventUpdateParams + +EventUpdateParams is emitted when the parameters were changed by the governance. + +```protobuf +message EventUpdateParams { + // old_params is the module's old parameters. + kyve.bundles.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.bundles.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} +``` + ## EventBundleProposed EventBundleProposed indicates that a new bundle proposal was submitted diff --git a/x/bundles/types/events.pb.go b/x/bundles/types/events.pb.go index e5a803ee..a154c821 100644 --- a/x/bundles/types/events.pb.go +++ b/x/bundles/types/events.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/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_a02f505e55d81e92, []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 "" +} + // EventBundleVote is an event emitted when a protocol node votes on a bundle. // emitted_by: MsgVoteBundleProposal type EventBundleVote struct { @@ -39,7 +105,7 @@ func (m *EventBundleVote) Reset() { *m = EventBundleVote{} } func (m *EventBundleVote) String() string { return proto.CompactTextString(m) } func (*EventBundleVote) ProtoMessage() {} func (*EventBundleVote) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{0} + return fileDescriptor_a02f505e55d81e92, []int{1} } func (m *EventBundleVote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -137,7 +203,7 @@ func (m *EventBundleProposed) Reset() { *m = EventBundleProposed{} } func (m *EventBundleProposed) String() string { return proto.CompactTextString(m) } func (*EventBundleProposed) ProtoMessage() {} func (*EventBundleProposed) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{1} + return fileDescriptor_a02f505e55d81e92, []int{2} } func (m *EventBundleProposed) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -301,7 +367,7 @@ func (m *EventBundleFinalized) Reset() { *m = EventBundleFinalized{} } func (m *EventBundleFinalized) String() string { return proto.CompactTextString(m) } func (*EventBundleFinalized) ProtoMessage() {} func (*EventBundleFinalized) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{2} + return fileDescriptor_a02f505e55d81e92, []int{3} } func (m *EventBundleFinalized) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -444,7 +510,7 @@ func (m *EventClaimedUploaderRole) Reset() { *m = EventClaimedUploaderRo func (m *EventClaimedUploaderRole) String() string { return proto.CompactTextString(m) } func (*EventClaimedUploaderRole) ProtoMessage() {} func (*EventClaimedUploaderRole) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{3} + return fileDescriptor_a02f505e55d81e92, []int{4} } func (m *EventClaimedUploaderRole) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -511,7 +577,7 @@ func (m *EventSkippedUploaderRole) Reset() { *m = EventSkippedUploaderRo func (m *EventSkippedUploaderRole) String() string { return proto.CompactTextString(m) } func (*EventSkippedUploaderRole) ProtoMessage() {} func (*EventSkippedUploaderRole) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{4} + return fileDescriptor_a02f505e55d81e92, []int{5} } func (m *EventSkippedUploaderRole) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -583,7 +649,7 @@ func (m *EventPointIncreased) Reset() { *m = EventPointIncreased{} } func (m *EventPointIncreased) String() string { return proto.CompactTextString(m) } func (*EventPointIncreased) ProtoMessage() {} func (*EventPointIncreased) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{5} + return fileDescriptor_a02f505e55d81e92, []int{6} } func (m *EventPointIncreased) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -646,7 +712,7 @@ func (m *EventPointsReset) Reset() { *m = EventPointsReset{} } func (m *EventPointsReset) String() string { return proto.CompactTextString(m) } func (*EventPointsReset) ProtoMessage() {} func (*EventPointsReset) Descriptor() ([]byte, []int) { - return fileDescriptor_a02f505e55d81e92, []int{6} + return fileDescriptor_a02f505e55d81e92, []int{7} } func (m *EventPointsReset) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -690,6 +756,7 @@ func (m *EventPointsReset) GetStaker() string { } func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.bundles.v1beta1.EventUpdateParams") proto.RegisterType((*EventBundleVote)(nil), "kyve.bundles.v1beta1.EventBundleVote") proto.RegisterType((*EventBundleProposed)(nil), "kyve.bundles.v1beta1.EventBundleProposed") proto.RegisterType((*EventBundleFinalized)(nil), "kyve.bundles.v1beta1.EventBundleFinalized") @@ -702,56 +769,111 @@ func init() { func init() { proto.RegisterFile("kyve/bundles/v1beta1/events.proto", fileDescriptor_a02f505e55d81e92) } var fileDescriptor_a02f505e55d81e92 = []byte{ - // 775 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4b, 0x4f, 0x1b, 0x49, - 0x10, 0x66, 0x60, 0xf0, 0xa3, 0xfd, 0x00, 0x06, 0x76, 0x77, 0x96, 0x15, 0x5e, 0xdb, 0xab, 0xd5, - 0x5a, 0x62, 0x65, 0x0b, 0xf6, 0xb6, 0x37, 0x60, 0x41, 0x6b, 0x21, 0x45, 0x68, 0x20, 0x48, 0xc9, - 0xc5, 0x6a, 0x7b, 0x0a, 0xdc, 0xf2, 0x78, 0x7a, 0xd4, 0xdd, 0xe3, 0x07, 0xbf, 0x22, 0x52, 0x94, - 0x7f, 0x94, 0x43, 0x8e, 0x1c, 0x73, 0x4c, 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0x39, 0xaf, 0x2d, 0x33, - 0xe8, 0x7c, 0x40, 0xa2, 0xe8, 0x47, 0x07, 0xed, 0xa2, 0x8d, 0x88, 0xc1, 0x88, 0xd0, 0x98, 0x3f, - 0x9c, 0xb6, 0x9e, 0x24, 0x52, 0x3b, 0x1e, 0xaa, 0xb2, 0xbf, 0x54, 0x35, 0x34, 0xdf, 0xa9, 0x33, - 0x4a, 0x42, 0xd1, 0x0e, 0x7b, 0xd2, 0xf2, 0xaf, 0xed, 0xf7, 0x63, 0xdf, 0x50, 0xf9, 0xa0, 0x62, - 0xc6, 0x20, 0x14, 0x9d, 0x48, 0xb6, 0xe2, 0x66, 0xe1, 0x4b, 0x06, 0x55, 0xfd, 0x79, 0xfd, 0x08, - 0xad, 0xcf, 0xc6, 0x71, 0x0f, 0x38, 0x88, 0x27, 0xcf, 0x3a, 0x3c, 0x79, 0x77, 0x57, 0xb1, 0x6e, - 0xef, 0x2a, 0xd6, 0x87, 0xbb, 0x8a, 0xf5, 0xea, 0xbe, 0xb2, 0x74, 0x7b, 0x5f, 0x59, 0x7a, 0x7f, - 0x5f, 0x59, 0x7a, 0xf9, 0xf7, 0x35, 0x11, 0xfd, 0xb8, 0xdb, 0xec, 0xd1, 0x61, 0xeb, 0xf4, 0xc5, - 0xe5, 0xf1, 0x33, 0x10, 0x63, 0xca, 0x06, 0xad, 0x5e, 0x1f, 0x93, 0xb0, 0x35, 0x49, 0xff, 0x23, - 0x62, 0x1a, 0x01, 0xef, 0x66, 0xd4, 0x3f, 0xe4, 0x9f, 0x4f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb8, - 0xe3, 0xf5, 0xed, 0xc1, 0x06, 0x00, 0x00, + // 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,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x9a, 0x48, 0x89, 0xb9, 0xee, 0x09, 0xd3, 0x4a, 0xf9, 0x85, 0xaf, 0x7b, 0xd4, 0xf6, 0x57, 0xad, + 0x27, 0xb0, 0xb3, 0x18, 0xa7, 0x52, 0x54, 0xa8, 0xdf, 0x7b, 0xd6, 0xe9, 0xb3, 0xd7, 0x37, 0xcd, + 0xe0, 0xcd, 0x4d, 0x33, 0xf8, 0xe3, 0xa6, 0x19, 0xfc, 0x78, 0xdb, 0x5c, 0x7b, 0x73, 0xdb, 0x5c, + 0xfb, 0xed, 0xb6, 0xb9, 0xf6, 0xc3, 0x97, 0x03, 0xa6, 0x87, 0x93, 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, +} + +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 *EventBundleVote) Marshal() (dAtA []byte, err error) { @@ -1176,6 +1298,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 *EventBundleVote) Size() (n int) { if m == nil { return 0 @@ -1392,6 +1531,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 *EventBundleVote) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/bundles/types/params.go b/x/bundles/types/params.go index dc7992a4..aba3bc6e 100644 --- a/x/bundles/types/params.go +++ b/x/bundles/types/params.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -14,7 +12,7 @@ var DefaultUploadTimeout = uint64(600) var DefaultStorageCost = sdk.MustNewDecFromStr("0.025") // DefaultNetworkFee ... -var DefaultNetworkFee = "0.01" +var DefaultNetworkFee = sdk.MustNewDecFromStr("0.01") // DefaultMaxPoints ... var DefaultMaxPoints = uint64(24) @@ -23,7 +21,7 @@ var DefaultMaxPoints = uint64(24) func NewParams( uploadTimeout uint64, storageCost sdk.Dec, - networkFee string, + networkFee sdk.Dec, maxPoints uint64, ) Params { return Params{ @@ -46,11 +44,11 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - if err := util.ValidateUint64(p.UploadTimeout); err != nil { + if err := util.ValidatePositiveNumber(p.UploadTimeout); err != nil { return err } - if err := validateStorageCost(p.StorageCost); err != nil { + if err := util.ValidateDecimal(p.StorageCost); err != nil { return err } @@ -58,28 +56,9 @@ func (p Params) Validate() error { return err } - if err := util.ValidateUint64(p.MaxPoints); err != nil { + if err := util.ValidatePositiveNumber(p.MaxPoints); err != nil { return err } return nil } - -// validateStorageCost ... -func validateStorageCost(i interface{}) error { - v, ok := i.(sdk.Dec) - - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("invalid parameter: nil") - } - - if v.IsNegative() { - return fmt.Errorf("value cannot be negative: %s", i) - } - - return nil -} diff --git a/x/bundles/types/params.pb.go b/x/bundles/types/params.pb.go index 0a2382ff..7cff9951 100644 --- a/x/bundles/types/params.pb.go +++ b/x/bundles/types/params.pb.go @@ -31,7 +31,7 @@ type Params struct { // storage_cost ... StorageCost github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=storage_cost,json=storageCost,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"storage_cost"` // network_fee ... - NetworkFee string `protobuf:"bytes,3,opt,name=network_fee,json=networkFee,proto3" json:"network_fee,omitempty"` + NetworkFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=network_fee,json=networkFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"network_fee"` // max_points ... MaxPoints uint64 `protobuf:"varint,4,opt,name=max_points,json=maxPoints,proto3" json:"max_points,omitempty"` } @@ -76,13 +76,6 @@ func (m *Params) GetUploadTimeout() uint64 { return 0 } -func (m *Params) GetNetworkFee() string { - if m != nil { - return m.NetworkFee - } - return "" -} - func (m *Params) GetMaxPoints() uint64 { if m != nil { return m.MaxPoints @@ -97,26 +90,26 @@ func init() { func init() { proto.RegisterFile("kyve/bundles/v1beta1/params.proto", fileDescriptor_cfd3a74b72a01aaa) } var fileDescriptor_cfd3a74b72a01aaa = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x41, 0x4b, 0xc3, 0x30, - 0x18, 0x86, 0x1b, 0x1d, 0x83, 0x65, 0xea, 0xa1, 0xec, 0x50, 0x04, 0xb3, 0x29, 0x28, 0x3b, 0x68, - 0xc2, 0xf0, 0x1f, 0x4c, 0xdd, 0x45, 0x90, 0x39, 0x44, 0xd0, 0x4b, 0x49, 0xbb, 0xcf, 0xae, 0x6c, - 0xe9, 0x57, 0x9a, 0x74, 0x6e, 0xff, 0xc2, 0xdf, 0xe4, 0x69, 0xc7, 0x1d, 0xc5, 0xc3, 0x90, 0xed, - 0x8f, 0x48, 0xd3, 0x22, 0x9e, 0x12, 0x1e, 0x9e, 0xef, 0xe5, 0xe5, 0xa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0x98, 0xf3, 0x7a, 0xf9, 0xaf, 0xce, 0xfd, 0xcb, 0xf3, 0xdd, 0x43, 0x99, 0x29, 0xc2, 0x89, - 0x8c, 0x13, 0xb1, 0xf8, 0xdb, 0xd1, 0x16, 0x0b, 0xea, 0x76, 0x93, 0xeb, 0xdf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xc8, 0x63, 0x93, 0xce, 0x64, 0x01, 0x00, 0x00, + // 300 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x90, 0xc1, 0x4a, 0xc3, 0x30, + 0x1c, 0xc6, 0x1b, 0x1d, 0x83, 0x65, 0xea, 0xa1, 0xec, 0x50, 0x04, 0xb3, 0x29, 0x28, 0x3b, 0x68, + 0xc2, 0xf0, 0x0d, 0xa6, 0xee, 0x22, 0xe8, 0x1c, 0x22, 0xe8, 0xa5, 0xa4, 0xdd, 0xdf, 0xae, 0x6c, + 0xe9, 0xbf, 0x34, 0xe9, 0xdc, 0xde, 0xc2, 0xc7, 0xda, 0x71, 0x47, 0xf1, 0x30, 0x64, 0x7b, 0x03, + 0x9f, 0x40, 0x96, 0x16, 0xf1, 0xec, 0x29, 0xe1, 0xe3, 0x97, 0xdf, 0x47, 0x3e, 0x7a, 0x3c, 0x9e, + 0x4f, 0x41, 0x04, 0x79, 0x32, 0x9c, 0x80, 0x16, 0xd3, 0x4e, 0x00, 0x46, 0x76, 0x44, 0x2a, 0x33, + 0xa9, 0x34, 0x4f, 0x33, 0x34, 0xe8, 0x36, 0xb6, 0x08, 0x2f, 0x11, 0x5e, 0x22, 0x87, 0x8d, 0x08, + 0x23, 0xb4, 0x80, 0xd8, 0xde, 0x0a, 0xf6, 0xe4, 0x9b, 0xd0, 0x6a, 0xdf, 0x3e, 0x76, 0x4f, 0xe9, + 0x41, 0x9e, 0x4e, 0x50, 0x0e, 0x7d, 0x13, 0x2b, 0xc0, 0xdc, 0x78, 0xa4, 0x45, 0xda, 0x95, 0xc1, + 0x7e, 0x91, 0x3e, 0x16, 0xa1, 0xfb, 0x40, 0xf7, 0xb4, 0xc1, 0x4c, 0x46, 0xe0, 0x87, 0xa8, 0x8d, + 0xb7, 0xd3, 0x22, 0xed, 0x5a, 0x97, 0x2f, 0x56, 0x4d, 0xe7, 0x73, 0xd5, 0x3c, 0x8b, 0x62, 0x33, + 0xca, 0x03, 0x1e, 0xa2, 0x12, 0x21, 0x6a, 0x85, 0xba, 0x3c, 0x2e, 0xf4, 0x70, 0x2c, 0xcc, 0x3c, + 0x05, 0xcd, 0xaf, 0x21, 0x1c, 0xd4, 0x4b, 0xc7, 0x15, 0x6a, 0xe3, 0xde, 0xd3, 0x7a, 0x02, 0xe6, + 0x0d, 0xb3, 0xb1, 0xff, 0x0a, 0xe0, 0xed, 0xfe, 0xcb, 0x48, 0x4b, 0x45, 0x0f, 0xc0, 0x3d, 0xa2, + 0x54, 0xc9, 0x99, 0x9f, 0x62, 0x9c, 0x18, 0xed, 0x55, 0xec, 0x37, 0x6a, 0x4a, 0xce, 0xfa, 0x36, + 0xe8, 0xf6, 0x16, 0x6b, 0x46, 0x96, 0x6b, 0x46, 0xbe, 0xd6, 0x8c, 0xbc, 0x6f, 0x98, 0xb3, 0xdc, + 0x30, 0xe7, 0x63, 0xc3, 0x9c, 0x97, 0xf3, 0x3f, 0x65, 0xb7, 0xcf, 0x4f, 0x37, 0x77, 0x85, 0x53, + 0x84, 0x23, 0x19, 0x27, 0x62, 0xf6, 0xbb, 0xbb, 0xad, 0x0d, 0xaa, 0x76, 0xc3, 0xcb, 0x9f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x7b, 0x35, 0x55, 0xa9, 0x94, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -144,13 +137,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.NetworkFee) > 0 { - i -= len(m.NetworkFee) - copy(dAtA[i:], m.NetworkFee) - i = encodeVarintParams(dAtA, i, uint64(len(m.NetworkFee))) - i-- - dAtA[i] = 0x1a + { + size := m.NetworkFee.Size() + i -= size + if _, err := m.NetworkFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a { size := m.StorageCost.Size() i -= size @@ -191,10 +187,8 @@ func (m *Params) Size() (n int) { } l = m.StorageCost.Size() n += 1 + l + sovParams(uint64(l)) - l = len(m.NetworkFee) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } + l = m.NetworkFee.Size() + n += 1 + l + sovParams(uint64(l)) if m.MaxPoints != 0 { n += 1 + sovParams(uint64(m.MaxPoints)) } @@ -319,7 +313,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NetworkFee = string(dAtA[iNdEx:postIndex]) + if err := m.NetworkFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 4: if wireType != 0 { diff --git a/x/delegation/keeper/getters_params.go b/x/delegation/keeper/getters_params.go index 4099ba44..2c315b77 100644 --- a/x/delegation/keeper/getters_params.go +++ b/x/delegation/keeper/getters_params.go @@ -34,17 +34,17 @@ func (k Keeper) GetRedelegationMaxAmount(ctx sdk.Context) (res uint64) { } // GetVoteSlash returns the VoteSlash param -func (k Keeper) GetVoteSlash(ctx sdk.Context) (res string) { +func (k Keeper) GetVoteSlash(ctx sdk.Context) (res sdk.Dec) { return k.GetParams(ctx).VoteSlash } // GetUploadSlash returns the UploadSlash param -func (k Keeper) GetUploadSlash(ctx sdk.Context) (res string) { +func (k Keeper) GetUploadSlash(ctx sdk.Context) (res sdk.Dec) { return k.GetParams(ctx).UploadSlash } // GetTimeoutSlash returns the TimeoutSlash param -func (k Keeper) GetTimeoutSlash(ctx sdk.Context) (res string) { +func (k Keeper) GetTimeoutSlash(ctx sdk.Context) (res sdk.Dec) { return k.GetParams(ctx).TimeoutSlash } @@ -52,11 +52,11 @@ func (k Keeper) getSlashFraction(ctx sdk.Context, slashType types.SlashType) (sl // Retrieve slash fraction from params switch slashType { case types.SLASH_TYPE_TIMEOUT: - slashAmountRatio, _ = sdk.NewDecFromStr(k.GetTimeoutSlash(ctx)) + slashAmountRatio = k.GetTimeoutSlash(ctx) case types.SLASH_TYPE_VOTE: - slashAmountRatio, _ = sdk.NewDecFromStr(k.GetVoteSlash(ctx)) + slashAmountRatio = k.GetVoteSlash(ctx) case types.SLASH_TYPE_UPLOAD: - slashAmountRatio, _ = sdk.NewDecFromStr(k.GetUploadSlash(ctx)) + slashAmountRatio = k.GetUploadSlash(ctx) } return } diff --git a/x/delegation/keeper/msg_server_redelegate.go b/x/delegation/keeper/msg_server_redelegate.go index 44ba7f8c..f53d376a 100644 --- a/x/delegation/keeper/msg_server_redelegate.go +++ b/x/delegation/keeper/msg_server_redelegate.go @@ -19,7 +19,7 @@ func (k msgServer) Redelegate(goCtx context.Context, msg *types.MsgRedelegate) ( // Check if the sender is a delegator if !k.DoesDelegatorExist(ctx, msg.FromStaker, msg.Creator) { - return nil, sdkErrors.WithType(types.ErrNotADelegator, msg.FromStaker) + return nil, sdkErrors.Wrapf(types.ErrNotADelegator, "%s does not delegate to %s", msg.Creator, msg.FromStaker) } // Check if destination staker exists diff --git a/x/delegation/keeper/msg_server_undelegate_test.go b/x/delegation/keeper/msg_server_undelegate_test.go index 93cabec4..7c2225c1 100644 --- a/x/delegation/keeper/msg_server_undelegate_test.go +++ b/x/delegation/keeper/msg_server_undelegate_test.go @@ -2,6 +2,7 @@ package keeper_test import ( pooltypes "github.com/KYVENetwork/chain/x/pool/types" + sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -244,7 +245,7 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { }) params := s.App().DelegationKeeper.GetParams(s.Ctx()) - params.UploadSlash = "0.1" + params.UploadSlash = sdk.MustNewDecFromStr("0.1") s.App().DelegationKeeper.SetParams(s.Ctx(), params) s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) @@ -413,7 +414,7 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { // Slash 10% params := s.App().DelegationKeeper.GetParams(s.Ctx()) - params.UploadSlash = "0.1" + params.UploadSlash = sdk.MustNewDecFromStr("0.1") s.App().DelegationKeeper.SetParams(s.Ctx(), params) s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) @@ -464,7 +465,7 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { }) params := s.App().DelegationKeeper.GetParams(s.Ctx()) - params.UploadSlash = "0.5" + params.UploadSlash = sdk.MustNewDecFromStr("0.5") s.App().DelegationKeeper.SetParams(s.Ctx(), params) s.PerformValidityChecks() @@ -512,7 +513,7 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { // ACT params := s.App().DelegationKeeper.GetParams(s.Ctx()) - params.UploadSlash = "0.5" + params.UploadSlash = sdk.MustNewDecFromStr("0.5") s.App().DelegationKeeper.SetParams(s.Ctx(), params) // Slash 50% twice @@ -557,7 +558,7 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { // ACT params := s.App().DelegationKeeper.GetParams(s.Ctx()) - params.UploadSlash = "0.5" + params.UploadSlash = sdk.MustNewDecFromStr("0.5") s.App().DelegationKeeper.SetParams(s.Ctx(), params) s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) diff --git a/x/delegation/keeper/msg_server_update_params.go b/x/delegation/keeper/msg_server_update_params.go index b77b5220..712e584f 100644 --- a/x/delegation/keeper/msg_server_update_params.go +++ b/x/delegation/keeper/msg_server_update_params.go @@ -5,7 +5,6 @@ import ( "encoding/json" "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" // Delegation @@ -14,21 +13,23 @@ import ( govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -// UpdateParams is a governance message to update module-wide parameters. -// req.payload is a valid json string -// This is already checked and validated by the `types/params.go` -// Only the provided properties will be updated, the rest remains the same. -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { - return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) +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) - params := k.GetParams(ctx) + oldParams := k.GetParams(ctx) + + newParams := oldParams + _ = json.Unmarshal([]byte(msg.Payload), &newParams) + k.SetParams(ctx, newParams) - payload := params - _ = json.Unmarshal([]byte(req.Payload), &payload) - k.SetParams(ctx, payload) + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + OldParams: oldParams, + NewParams: newParams, + Payload: msg.Payload, + }) return &types.MsgUpdateParamsResponse{}, nil } diff --git a/x/delegation/keeper/msg_server_update_params_test.go b/x/delegation/keeper/msg_server_update_params_test.go index caa8990c..f6a2f702 100644 --- a/x/delegation/keeper/msg_server_update_params_test.go +++ b/x/delegation/keeper/msg_server_update_params_test.go @@ -152,9 +152,9 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.UnbondingDelegationTime).To(Equal(uint64(3600))) Expect(updatedParams.RedelegationCooldown).To(Equal(uint64(3600))) Expect(updatedParams.RedelegationMaxAmount).To(Equal(uint64(1))) - Expect(updatedParams.VoteSlash).To(Equal("0.05")) - Expect(updatedParams.UploadSlash).To(Equal("0.05")) - Expect(updatedParams.TimeoutSlash).To(Equal("0.05")) + Expect(updatedParams.VoteSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) + Expect(updatedParams.UploadSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) + Expect(updatedParams.TimeoutSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) }) It("Update no param", func() { @@ -488,7 +488,7 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.RedelegationMaxAmount).To(Equal(types.DefaultRedelegationMaxAmount)) Expect(updatedParams.UploadSlash).To(Equal(types.DefaultUploadSlash)) Expect(updatedParams.TimeoutSlash).To(Equal(types.DefaultTimeoutSlash)) - Expect(updatedParams.VoteSlash).To(Equal("0.05")) + Expect(updatedParams.VoteSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) }) It("Update vote slash with invalid value", func() { @@ -561,7 +561,7 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.UnbondingDelegationTime).To(Equal(types.DefaultUnbondingDelegationTime)) Expect(updatedParams.RedelegationCooldown).To(Equal(types.DefaultRedelegationCooldown)) Expect(updatedParams.RedelegationMaxAmount).To(Equal(types.DefaultRedelegationMaxAmount)) - Expect(updatedParams.UploadSlash).To(Equal("0.05")) + Expect(updatedParams.UploadSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) Expect(updatedParams.TimeoutSlash).To(Equal(types.DefaultTimeoutSlash)) Expect(updatedParams.VoteSlash).To(Equal(types.DefaultVoteSlash)) }) @@ -636,7 +636,7 @@ var _ = Describe("msg_server_update_params.go", Ordered, func() { Expect(updatedParams.RedelegationCooldown).To(Equal(types.DefaultRedelegationCooldown)) Expect(updatedParams.RedelegationMaxAmount).To(Equal(types.DefaultRedelegationMaxAmount)) Expect(updatedParams.UploadSlash).To(Equal(types.DefaultUploadSlash)) - Expect(updatedParams.TimeoutSlash).To(Equal("0.05")) + Expect(updatedParams.TimeoutSlash).To(Equal(sdk.MustNewDecFromStr("0.05"))) Expect(updatedParams.VoteSlash).To(Equal(types.DefaultVoteSlash)) }) diff --git a/x/delegation/keeper/msg_server_withdraw_rewards.go b/x/delegation/keeper/msg_server_withdraw_rewards.go index b23812c9..44d550a0 100644 --- a/x/delegation/keeper/msg_server_withdraw_rewards.go +++ b/x/delegation/keeper/msg_server_withdraw_rewards.go @@ -12,12 +12,15 @@ import ( // WithdrawRewards calculates the current rewards of a delegator and transfers the balance to // the delegator's wallet. Only the delegator himself can call this transaction. -func (k msgServer) WithdrawRewards(goCtx context.Context, msg *types.MsgWithdrawRewards) (*types.MsgWithdrawRewardsResponse, error) { +func (k msgServer) WithdrawRewards( + goCtx context.Context, + msg *types.MsgWithdrawRewards, +) (*types.MsgWithdrawRewardsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Check if the sender has delegated to the given staker if !k.DoesDelegatorExist(ctx, msg.Staker, msg.Creator) { - return nil, sdkErrors.WithType(types.ErrNotADelegator, msg.Creator) + return nil, sdkErrors.Wrapf(types.ErrNotADelegator, "%s does not delegate to %s", msg.Creator, msg.Staker) } // Withdraw all rewards of the sender. diff --git a/x/delegation/spec/05_events.md b/x/delegation/spec/05_events.md index 20b5b405..1de68327 100644 --- a/x/delegation/spec/05_events.md +++ b/x/delegation/spec/05_events.md @@ -6,6 +6,21 @@ order: 5 The `x/delegation` module emits the following events: +## EventUpdateParams + +EventUpdateParams is emitted when the parameters were changed by the governance. + +```protobuf +message EventUpdateParams { + // old_params is the module's old parameters. + kyve.bundles.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.bundles.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} +``` + ## EndBlocker | Type | Attribute Key | Attribute Value | diff --git a/x/delegation/spec/06_params.md b/x/delegation/spec/06_params.md index 278b293a..878455bd 100644 --- a/x/delegation/spec/06_params.md +++ b/x/delegation/spec/06_params.md @@ -11,3 +11,6 @@ The `x/delegation` module relies on the following parameters: | `UnbondingDelegationTime` | uint64 (time s) | 432000 | | `RedelegationCooldown` | uint64 (time s) | 432000 | | `RedelegationMaxAmount` | uint64 (time s) | 5 | +| `VoteSlash` | sdk.Dec (%) | 0.1 | +| `UploadSlash` | sdk.Dec (%) | 0.2 | +| `TimeoutSlash` | sdk.Dec (%) | 0.02 | diff --git a/x/delegation/types/events.pb.go b/x/delegation/types/events.pb.go index 0092d011..78b9e598 100644 --- a/x/delegation/types/events.pb.go +++ b/x/delegation/types/events.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/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_d01988a9108a2e89, []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 "" +} + // EventDelegate is an event emitted when someone delegates to a protocol node. // emitted_by: MsgDelegate type EventDelegate struct { @@ -37,7 +103,7 @@ func (m *EventDelegate) Reset() { *m = EventDelegate{} } func (m *EventDelegate) String() string { return proto.CompactTextString(m) } func (*EventDelegate) ProtoMessage() {} func (*EventDelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_d01988a9108a2e89, []int{0} + return fileDescriptor_d01988a9108a2e89, []int{1} } func (m *EventDelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -102,7 +168,7 @@ func (m *EventUndelegate) Reset() { *m = EventUndelegate{} } func (m *EventUndelegate) String() string { return proto.CompactTextString(m) } func (*EventUndelegate) ProtoMessage() {} func (*EventUndelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_d01988a9108a2e89, []int{1} + return fileDescriptor_d01988a9108a2e89, []int{2} } func (m *EventUndelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -169,7 +235,7 @@ func (m *EventRedelegate) Reset() { *m = EventRedelegate{} } func (m *EventRedelegate) String() string { return proto.CompactTextString(m) } func (*EventRedelegate) ProtoMessage() {} func (*EventRedelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_d01988a9108a2e89, []int{2} + return fileDescriptor_d01988a9108a2e89, []int{3} } func (m *EventRedelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -241,7 +307,7 @@ func (m *EventWithdrawRewards) Reset() { *m = EventWithdrawRewards{} } func (m *EventWithdrawRewards) String() string { return proto.CompactTextString(m) } func (*EventWithdrawRewards) ProtoMessage() {} func (*EventWithdrawRewards) Descriptor() ([]byte, []int) { - return fileDescriptor_d01988a9108a2e89, []int{3} + return fileDescriptor_d01988a9108a2e89, []int{4} } func (m *EventWithdrawRewards) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -308,7 +374,7 @@ func (m *EventSlash) Reset() { *m = EventSlash{} } func (m *EventSlash) String() string { return proto.CompactTextString(m) } func (*EventSlash) ProtoMessage() {} func (*EventSlash) Descriptor() ([]byte, []int) { - return fileDescriptor_d01988a9108a2e89, []int{4} + return fileDescriptor_d01988a9108a2e89, []int{5} } func (m *EventSlash) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -366,6 +432,7 @@ func (m *EventSlash) GetSlashType() SlashType { } func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.delegation.v1beta1.EventUpdateParams") proto.RegisterType((*EventDelegate)(nil), "kyve.delegation.v1beta1.EventDelegate") proto.RegisterType((*EventUndelegate)(nil), "kyve.delegation.v1beta1.EventUndelegate") proto.RegisterType((*EventRedelegate)(nil), "kyve.delegation.v1beta1.EventRedelegate") @@ -378,30 +445,85 @@ func init() { } var fileDescriptor_d01988a9108a2e89 = []byte{ - // 357 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xcf, 0x4e, 0xf2, 0x40, - 0x14, 0xc5, 0x99, 0x0f, 0x02, 0x1f, 0xd7, 0xa8, 0x49, 0x63, 0xa4, 0xd1, 0xa4, 0x12, 0xe2, 0x82, - 0x55, 0x1b, 0xf4, 0x09, 0x34, 0xb2, 0x20, 0x26, 0x2e, 0x8a, 0x7f, 0x82, 0x2e, 0x70, 0x60, 0xae, - 0xb4, 0x01, 0x3a, 0xcd, 0xcc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, 0x4c, 0x45, 0xbd, - 0x47, 0x65, 0x60, 0x15, 0x20, 0x17, 0x73, 0xde, 0x6b, 0x86, 0xcc, 0x80, 0x33, 0x7e, 0x56, 0xcb, - 0x1a, 0xfb, 0x2b, 0xd7, 0x3a, 0x03, 0x90, 0x9a, 0xd8, 0x54, 0xe3, 0x18, 0xcd, 0x56, 0x3b, 0x27, - 0x25, 0x77, 0xcd, 0x35, 0xb9, 0xa6, 0xfc, 0x7a, 0x1c, 0xa3, 0x9f, 0x97, 0x8b, 0xcf, 0xf3, 0xda, - 0xfb, 0xd4, 0x21, 0x93, 0xa9, 0x43, 0x3e, 0xa7, 0x0e, 0x79, 0x9d, 0x39, 0xa9, 0xc9, 0xcc, 0x49, - 0x7d, 0xcc, 0x9c, 0xd4, 0xbd, 0xd7, 0x09, 0x55, 0x30, 0x68, 0xb9, 0x6d, 0xde, 0xf7, 0x2e, 0x1b, - 0xb7, 0xd5, 0x2b, 0x54, 0x23, 0x2e, 0xba, 0x5e, 0x3b, 0xa0, 0x61, 0xe4, 0x3d, 0x2f, 0x9f, 0xa5, - 0xae, 0x97, 0xad, 0xac, 0x39, 0xc5, 0xd3, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0xe5, 0x5e, - 0x91, 0xf5, 0x02, 0x00, 0x00, + // 443 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0x33, 0x1a, 0x52, 0xf7, 0x2d, 0x2a, 0x2e, 0xc5, 0x86, 0x0a, 0x9b, 0x12, 0x3c, 0xe4, + 0xb4, 0x4b, 0xeb, 0x27, 0xb0, 0xb4, 0x87, 0x22, 0x88, 0x4c, 0xfc, 0x43, 0xf5, 0x10, 0x27, 0x9d, + 0xd7, 0x64, 0xc9, 0x66, 0xdf, 0x65, 0x66, 0x9a, 0x35, 0x47, 0xb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f, 0x6f, 0x8e, 0x93, 0x8d, 0xd7, 0xe3, 0x8e, 0x1b, 0xa3, 0x17, 0x7f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0xa8, 0xcd, 0x73, 0x6b, 0xed, 0x03, 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 *EventDelegate) Marshal() (dAtA []byte, err error) { @@ -635,6 +757,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 *EventDelegate) Size() (n int) { if m == nil { return 0 @@ -747,6 +886,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 *EventDelegate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/delegation/types/params.go b/x/delegation/types/params.go index 6cd04f4b..fe707569 100644 --- a/x/delegation/types/params.go +++ b/x/delegation/types/params.go @@ -2,6 +2,7 @@ package types import ( "github.com/KYVENetwork/chain/util" + sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultUnbondingDelegationTime ... @@ -14,22 +15,22 @@ var DefaultRedelegationCooldown = uint64(60 * 60 * 24 * 5) var DefaultRedelegationMaxAmount = uint64(5) // DefaultVoteSlash ... -var DefaultVoteSlash = "0.1" +var DefaultVoteSlash = sdk.MustNewDecFromStr("0.1") // DefaultUploadSlash ... -var DefaultUploadSlash = "0.2" +var DefaultUploadSlash = sdk.MustNewDecFromStr("0.2") // DefaultTimeoutSlash ... -var DefaultTimeoutSlash = "0.02" +var DefaultTimeoutSlash = sdk.MustNewDecFromStr("0.02") // NewParams creates a new Params instance func NewParams( unbondingDelegationTime uint64, redelegationCooldown uint64, redelegationMaxAmount uint64, - voteSlash string, - uploadSlash string, - timeoutSlash string, + voteSlash sdk.Dec, + uploadSlash sdk.Dec, + timeoutSlash sdk.Dec, ) Params { return Params{ UnbondingDelegationTime: unbondingDelegationTime, @@ -55,15 +56,15 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - if err := util.ValidateUint64(p.UnbondingDelegationTime); err != nil { + if err := util.ValidateNumber(p.UnbondingDelegationTime); err != nil { return err } - if err := util.ValidateUint64(p.RedelegationCooldown); err != nil { + if err := util.ValidateNumber(p.RedelegationCooldown); err != nil { return err } - if err := util.ValidateUint64(p.RedelegationMaxAmount); err != nil { + if err := util.ValidateNumber(p.RedelegationMaxAmount); err != nil { return err } diff --git a/x/delegation/types/params.pb.go b/x/delegation/types/params.pb.go index 89fde3a9..fffc1de2 100644 --- a/x/delegation/types/params.pb.go +++ b/x/delegation/types/params.pb.go @@ -5,6 +5,8 @@ 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/gogo/protobuf/proto" io "io" math "math" @@ -31,11 +33,11 @@ type Params struct { // unbonding_delegation_time ... RedelegationMaxAmount uint64 `protobuf:"varint,3,opt,name=redelegation_max_amount,json=redelegationMaxAmount,proto3" json:"redelegation_max_amount,omitempty"` // vote_slash ... - VoteSlash string `protobuf:"bytes,4,opt,name=vote_slash,json=voteSlash,proto3" json:"vote_slash,omitempty"` + VoteSlash github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=vote_slash,json=voteSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_slash"` // upload_slash ... - UploadSlash string `protobuf:"bytes,5,opt,name=upload_slash,json=uploadSlash,proto3" json:"upload_slash,omitempty"` + UploadSlash github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=upload_slash,json=uploadSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"upload_slash"` // timeout_slash ... - TimeoutSlash string `protobuf:"bytes,6,opt,name=timeout_slash,json=timeoutSlash,proto3" json:"timeout_slash,omitempty"` + TimeoutSlash github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=timeout_slash,json=timeoutSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"timeout_slash"` } func (m *Params) Reset() { *m = Params{} } @@ -92,27 +94,6 @@ func (m *Params) GetRedelegationMaxAmount() uint64 { return 0 } -func (m *Params) GetVoteSlash() string { - if m != nil { - return m.VoteSlash - } - return "" -} - -func (m *Params) GetUploadSlash() string { - if m != nil { - return m.UploadSlash - } - return "" -} - -func (m *Params) GetTimeoutSlash() string { - if m != nil { - return m.TimeoutSlash - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "kyve.delegation.v1beta1.Params") } @@ -122,27 +103,29 @@ func init() { } var fileDescriptor_17019e1d49c878a9 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0xd1, 0xbb, 0x4e, 0xf3, 0x30, - 0x1c, 0x05, 0xf0, 0xba, 0x5f, 0xbf, 0x4a, 0x35, 0x65, 0xb1, 0x40, 0x0d, 0x03, 0x56, 0xb9, 0x0c, - 0x9d, 0x62, 0x55, 0x95, 0x18, 0xd8, 0xb8, 0x0d, 0x08, 0x81, 0x50, 0x41, 0x48, 0xb0, 0x44, 0x4e, - 0x63, 0xb5, 0x56, 0x63, 0xff, 0xa3, 0xc4, 0xe9, 0xe5, 0x2d, 0x18, 0x79, 0x24, 0xc6, 0x8e, 0x8c, - 0x28, 0x79, 0x11, 0x14, 0x37, 0x6a, 0xd3, 0xf5, 0x9c, 0xdf, 0xb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0xb5, 0x0f, 0x36, 0x96, 0x66, 0x92, 0xfa, 0xee, 0x08, 0x14, 0x7b, 0x78, 0x7f, 0xbb, 0x7b, - 0x12, 0x66, 0x0e, 0xf1, 0x94, 0x8d, 0x26, 0x5c, 0x6a, 0xb6, 0xa8, 0x5e, 0xc3, 0x2c, 0x23, 0x91, - 0xf8, 0x4d, 0x7b, 0x85, 0xc1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0x17, 0x6d, 0x46, 0xad, - 0x01, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x3f, 0x4f, 0xfa, 0x40, + 0x1c, 0x06, 0xf0, 0xf6, 0x07, 0x3f, 0x12, 0x4e, 0x5c, 0x1a, 0x0c, 0xd5, 0xa1, 0x10, 0x63, 0x0c, + 0x8b, 0xbd, 0x10, 0x12, 0x07, 0x37, 0x11, 0x07, 0x63, 0x30, 0x0a, 0xc6, 0x44, 0x97, 0xe6, 0xda, + 0x5e, 0x4a, 0x43, 0x7b, 0xdf, 0xa6, 0x77, 0xe5, 0xcf, 0xbb, 0xf0, 0x65, 0xf8, 0x52, 0x18, 0x19, + 0x8d, 0x03, 0x31, 0xf0, 0x46, 0x4c, 0x8f, 0x06, 0xca, 0xca, 0xd4, 0x26, 0xcf, 0xf3, 0x7c, 0x86, + 0xbb, 0x43, 0x17, 0xa3, 0xd9, 0x98, 0x62, 0x97, 0x06, 0xd4, 0x23, 0xc2, 0x07, 0x86, 0xc7, 0x2d, + 0x9b, 0x0a, 0xd2, 0xc2, 0x11, 0x89, 0x49, 0xc8, 0xcd, 0x28, 0x06, 0x01, 0x5a, 0x2d, 0x6d, 0x99, + 0xbb, 0x96, 0x99, 0xb5, 0xce, 0xaa, 0x1e, 0x78, 0x20, 0x3b, 0x38, 0xfd, 0xdb, 0xd4, 0xcf, 0xbf, + 0x0a, 0xa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, 0xe3, 0xfb, 0xdb, 0xfd, 0x13, 0x15, 0x13, + 0x88, 0x47, 0xd8, 0x19, 0x12, 0x9f, 0xe1, 0x69, 0xfe, 0xcd, 0x48, 0xdc, 0x2e, 0xc9, 0xcb, 0x6f, + 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x45, 0xa8, 0x27, 0x47, 0x53, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -165,27 +148,36 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TimeoutSlash) > 0 { - i -= len(m.TimeoutSlash) - copy(dAtA[i:], m.TimeoutSlash) - i = encodeVarintParams(dAtA, i, uint64(len(m.TimeoutSlash))) - i-- - dAtA[i] = 0x32 + { + size := m.TimeoutSlash.Size() + i -= size + if _, err := m.TimeoutSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } - if len(m.UploadSlash) > 0 { - i -= len(m.UploadSlash) - copy(dAtA[i:], m.UploadSlash) - i = encodeVarintParams(dAtA, i, uint64(len(m.UploadSlash))) - i-- - dAtA[i] = 0x2a + i-- + dAtA[i] = 0x32 + { + size := m.UploadSlash.Size() + i -= size + if _, err := m.UploadSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } - if len(m.VoteSlash) > 0 { - i -= len(m.VoteSlash) - copy(dAtA[i:], m.VoteSlash) - i = encodeVarintParams(dAtA, i, uint64(len(m.VoteSlash))) - i-- - dAtA[i] = 0x22 + i-- + dAtA[i] = 0x2a + { + size := m.VoteSlash.Size() + i -= size + if _, err := m.VoteSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 if m.RedelegationMaxAmount != 0 { i = encodeVarintParams(dAtA, i, uint64(m.RedelegationMaxAmount)) i-- @@ -230,18 +222,12 @@ func (m *Params) Size() (n int) { if m.RedelegationMaxAmount != 0 { n += 1 + sovParams(uint64(m.RedelegationMaxAmount)) } - l = len(m.VoteSlash) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.UploadSlash) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.TimeoutSlash) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } + l = m.VoteSlash.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.UploadSlash.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.TimeoutSlash.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -367,7 +353,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.VoteSlash = string(dAtA[iNdEx:postIndex]) + if err := m.VoteSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 5: if wireType != 2 { @@ -399,7 +387,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UploadSlash = string(dAtA[iNdEx:postIndex]) + if err := m.UploadSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 6: if wireType != 2 { @@ -431,7 +421,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TimeoutSlash = string(dAtA[iNdEx:postIndex]) + if err := m.TimeoutSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/global/keeper/msg_server_update_params.go b/x/global/keeper/msg_server_update_params.go index ba7d4591..4189a238 100644 --- a/x/global/keeper/msg_server_update_params.go +++ b/x/global/keeper/msg_server_update_params.go @@ -13,17 +13,23 @@ import ( govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { - return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) +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) - params := k.GetParams(ctx) + oldParams := k.GetParams(ctx) - payload := params - _ = json.Unmarshal([]byte(req.Payload), &payload) - k.SetParams(ctx, payload) + 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/global/types/events.pb.go b/x/global/types/events.pb.go new file mode 100644 index 00000000..3c6b587a --- /dev/null +++ b/x/global/types/events.pb.go @@ -0,0 +1,432 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/global/v1beta1/events.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/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 + +// 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_e23fcddbe36854a4, []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 "" +} + +func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.global.v1beta1.EventUpdateParams") +} + +func init() { proto.RegisterFile("kyve/global/v1beta1/events.proto", fileDescriptor_e23fcddbe36854a4) } + +var fileDescriptor_e23fcddbe36854a4 = []byte{ + // 252 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0xae, 0x2c, 0x4b, + 0xd5, 0x4f, 0xcf, 0xc9, 0x4f,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, 0xf5, 0xbd, 0x23, + 0xc3, 0x5c, 0xfd, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, + 0x2b, 0x60, 0x21, 0x51, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x01, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xe5, 0x68, 0x7b, 0x75, 0x72, 0x01, 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 encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *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 sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *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 skipEvents(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/pool/keeper/msg_server_update_pool.go b/x/pool/keeper/msg_server_update_pool.go index 3803bd5a..c68d80d5 100644 --- a/x/pool/keeper/msg_server_update_pool.go +++ b/x/pool/keeper/msg_server_update_pool.go @@ -13,19 +13,6 @@ import ( govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -type Update struct { - Name *string - Runtime *string - Logo *string - Config *string - UploadInterval *uint64 - OperatingCost *uint64 - MinDelegation *uint64 - MaxBundleSize *uint64 - StorageProviderId *uint32 - CompressionId *uint32 -} - func (k msgServer) UpdatePool(goCtx context.Context, req *types.MsgUpdatePool) (*types.MsgUpdatePoolResponse, error) { if k.authority != req.Authority { return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) @@ -37,7 +24,7 @@ func (k msgServer) UpdatePool(goCtx context.Context, req *types.MsgUpdatePool) ( return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrPoolNotFound.Error(), req.Id) } - var update Update + var update types.PoolUpdate if err := json.Unmarshal([]byte(req.Payload), &update); err != nil { return nil, err } diff --git a/x/pool/keeper/msg_server_update_pool_test.go b/x/pool/keeper/msg_server_update_pool_test.go index 7833de3d..c212e292 100644 --- a/x/pool/keeper/msg_server_update_pool_test.go +++ b/x/pool/keeper/msg_server_update_pool_test.go @@ -288,23 +288,97 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { Payload: "invalid_json_payload\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } - p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) + p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) // ACT - _, submitErr := s.RunTx(&p) - _, voteErr := s.RunTx(&v) + _ = s.RunTxError(&p) + s.Commit() - s.CommitAfter(*votingPeriod) + // ASSERT + pool, found := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + + Expect(found).To(BeTrue()) + 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 - proposal, _ := s.App().GovKeeper.GetProposal(s.Ctx(), 1) + pool, found := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(submitErr).To(Not(HaveOccurred())) - Expect(voteErr).To(Not(HaveOccurred())) + Expect(found).To(BeTrue()) + Expect(pool.Name).To(BeEmpty()) + }) - Expect(proposal.Status).To(Equal(govV1Types.StatusFailed)) + 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}", + } + + 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 MinDelegation", func() { + // ARRANGE + msg := &types.MsgUpdatePool{ + Authority: gov, + Id: 1, + Payload: "{\"MinDelegation\": 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()) diff --git a/x/pool/types/message_fund_pool.go b/x/pool/types/message_fund_pool.go index aae047ea..2cb637fc 100644 --- a/x/pool/types/message_fund_pool.go +++ b/x/pool/types/message_fund_pool.go @@ -2,12 +2,11 @@ package types import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgFundPool = "fund_pool" - var _ sdk.Msg = &MsgFundPool{} func NewMsgFundPool(creator string, id uint64, amount uint64) *MsgFundPool { @@ -18,31 +17,23 @@ func NewMsgFundPool(creator string, id uint64, amount uint64) *MsgFundPool { } } -func (msg *MsgFundPool) Route() string { - return RouterKey -} - -func (msg *MsgFundPool) Type() string { - return TypeMsgFundPool -} - func (msg *MsgFundPool) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) } - return []sdk.AccAddress{creator} -} -func (msg *MsgFundPool) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) + return []sdk.AccAddress{creator} } func (msg *MsgFundPool) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address (%s)", err) + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) } + + if util.ValidateNumber(msg.Amount) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount") + } + return nil } diff --git a/x/pool/types/msg.go b/x/pool/types/msgs.go similarity index 66% rename from x/pool/types/msg.go rename to x/pool/types/msgs.go index 8bc391f0..e6ecaf36 100644 --- a/x/pool/types/msg.go +++ b/x/pool/types/msgs.go @@ -1,8 +1,13 @@ package types import ( + "encoding/json" + "cosmossdk.io/errors" + + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" ) var ( @@ -26,6 +31,18 @@ func (msg *MsgCreatePool) ValidateBasic() error { return errors.Wrap(err, "invalid authority address") } + if err := util.ValidatePositiveNumber(msg.UploadInterval); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid upload interval") + } + + if err := util.ValidatePositiveNumber(msg.OperatingCost); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") + } + + if err := util.ValidatePositiveNumber(msg.MinDelegation); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid minimum delegation") + } + return nil } @@ -35,12 +52,49 @@ func (msg *MsgUpdatePool) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } +// PoolUpdate ... +type PoolUpdate struct { + Name *string + Runtime *string + Logo *string + Config *string + UploadInterval *uint64 + OperatingCost *uint64 + MinDelegation *uint64 + MaxBundleSize *uint64 + StorageProviderId *uint32 + CompressionId *uint32 +} + // ValidateBasic does a sanity check on the provided data. func (msg *MsgUpdatePool) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errors.Wrap(err, "invalid authority address") } + var payload PoolUpdate + if err := json.Unmarshal([]byte(msg.Payload), &payload); err != nil { + return err + } + + if payload.UploadInterval != nil { + if err := util.ValidatePositiveNumber(*payload.UploadInterval); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid upload interval") + } + } + + if payload.OperatingCost != nil { + if err := util.ValidatePositiveNumber(*payload.OperatingCost); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") + } + } + + if payload.MinDelegation != nil { + if err := util.ValidatePositiveNumber(*payload.MinDelegation); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid minimum delegation") + } + } + return nil } diff --git a/x/query/keeper/grpc_account_asssets.go b/x/query/keeper/grpc_account_assets.go similarity index 100% rename from x/query/keeper/grpc_account_asssets.go rename to x/query/keeper/grpc_account_assets.go diff --git a/x/query/keeper/grpc_account_funded.go b/x/query/keeper/grpc_account_funded.go index f5355a6e..08d2bd58 100644 --- a/x/query/keeper/grpc_account_funded.go +++ b/x/query/keeper/grpc_account_funded.go @@ -17,7 +17,9 @@ func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccount ctx := sdk.UnwrapSDKContext(goCtx) var funded []types.Funded - for _, pool := range k.poolKeeper.GetAllPools(ctx) { + 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{ diff --git a/x/query/keeper/grpc_query_can_propose_test.go b/x/query/keeper/grpc_query_can_propose_test.go index f9455053..85f8971e 100644 --- a/x/query/keeper/grpc_query_can_propose_test.go +++ b/x/query/keeper/grpc_query_can_propose_test.go @@ -428,8 +428,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_1, - Proposer: i.VALADDRESS_1, + Staker: i.STAKER_0, + Proposer: i.VALADDRESS_0, FromIndex: 100, }) @@ -442,8 +442,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_1, - Staker: i.STAKER_1, + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -463,15 +463,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_1, - Proposer: i.VALADDRESS_1, + Staker: i.STAKER_0, + Proposer: i.VALADDRESS_0, FromIndex: 99, }) canPropose_2, err_2 := s.App().QueryKeeper.CanPropose(sdk.WrapSDKContext(s.Ctx()), &querytypes.QueryCanProposeRequest{ PoolId: 0, - Staker: i.STAKER_1, - Proposer: i.VALADDRESS_1, + Staker: i.STAKER_0, + Proposer: i.VALADDRESS_0, FromIndex: 101, }) @@ -489,8 +489,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_1, - Staker: i.STAKER_1, + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -506,8 +506,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_1, - Staker: i.STAKER_1, + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, @@ -527,8 +527,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_1, - Proposer: i.VALADDRESS_1, + Staker: i.STAKER_0, + Proposer: i.VALADDRESS_0, FromIndex: 100, }) @@ -539,8 +539,8 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(canPropose.Reason).To(BeEmpty()) _, txErr := s.RunTx(&bundletypes.MsgSubmitBundleProposal{ - Creator: i.VALADDRESS_1, - Staker: i.STAKER_1, + Creator: i.VALADDRESS_0, + Staker: i.STAKER_0, PoolId: 0, StorageId: "test_storage_id", DataSize: 100, diff --git a/x/query/types/keys.go b/x/query/types/keys.go index 7237b127..2d7ca9b4 100644 --- a/x/query/types/keys.go +++ b/x/query/types/keys.go @@ -7,13 +7,9 @@ const ( // StoreKey defines the primary module store key StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for query RouterKey = ModuleName // MemStoreKey defines the in-memory store key MemStoreKey = "mem_query" ) - -func KeyPrefix(p string) []byte { - return []byte(p) -} diff --git a/x/query/types/query.pb.go b/x/query/types/query.pb.go index 775dae00..efd01080 100644 --- a/x/query/types/query.pb.go +++ b/x/query/types/query.pb.go @@ -6,6 +6,8 @@ package types import ( fmt "fmt" types "github.com/KYVENetwork/chain/x/pool/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -260,7 +262,7 @@ type StakerMetadata struct { // commission is the percentage of the rewards that will // get transferred to the staker before the remaining // rewards are split across all delegators - Commission string `protobuf:"bytes,1,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` // moniker is a human-readable name for displaying // the staker in the UI Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` @@ -309,13 +311,6 @@ func (m *StakerMetadata) XXX_DiscardUnknown() { var xxx_messageInfo_StakerMetadata proto.InternalMessageInfo -func (m *StakerMetadata) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - func (m *StakerMetadata) GetMoniker() string { if m != nil { return m.Moniker @@ -349,7 +344,7 @@ func (m *StakerMetadata) GetPendingCommissionChange() *CommissionChangeEntry { type CommissionChangeEntry struct { // commission is the new commission that will // become active once the change-time is over - Commission string `protobuf:"bytes,1,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` // creation_date is the UNIX-timestamp (in seconds) // of when the entry was created. CreationDate int64 `protobuf:"varint,2,opt,name=creation_date,json=creationDate,proto3" json:"creation_date,omitempty"` @@ -388,13 +383,6 @@ func (m *CommissionChangeEntry) XXX_DiscardUnknown() { var xxx_messageInfo_CommissionChangeEntry proto.InternalMessageInfo -func (m *CommissionChangeEntry) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - func (m *CommissionChangeEntry) GetCreationDate() int64 { if m != nil { return m.CreationDate @@ -505,49 +493,52 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/query.proto", fileDescriptor_6b41255feae93a15) } var fileDescriptor_6b41255feae93a15 = []byte{ - // 671 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xc1, 0x6e, 0xd3, 0x4c, - 0x10, 0xc7, 0xeb, 0x24, 0x4d, 0x9b, 0xc9, 0xd7, 0xf4, 0xd3, 0x4a, 0x50, 0x17, 0x51, 0x53, 0x05, - 0xa1, 0xb6, 0x1c, 0x12, 0xb5, 0x08, 0x09, 0x71, 0xe0, 0xd0, 0xb4, 0x95, 0x10, 0x14, 0x21, 0x23, - 0x90, 0x40, 0x48, 0xd6, 0xda, 0xde, 0x26, 0xab, 0xd8, 0xbb, 0x66, 0x77, 0x9d, 0x92, 0xb7, 0xe0, - 0x51, 0x38, 0xf0, 0x10, 0x1c, 0x7b, 0x84, 0x13, 0xa8, 0x7d, 0x11, 0xb4, 0xbb, 0xb6, 0x49, 0x4a, - 0x10, 0x37, 0xcf, 0x7f, 0xfe, 0x33, 0xc9, 0xfc, 0x66, 0x6c, 0xf0, 0xc6, 0xd3, 0x09, 0xe9, 0x7f, - 0xc8, 0x89, 0x98, 0xf6, 0x27, 0xfb, 0x21, 0x51, 0x78, 0xdf, 0x46, 0xbd, 0x4c, 0x70, 0xc5, 0x11, - 0xd2, 0xf9, 0x9e, 0x55, 0x8a, 0xfc, 0xad, 0xdb, 0xa6, 0x26, 0xe3, 0x3c, 0xa9, 0x4a, 0x74, 0x60, - 0x2b, 0xba, 0x9f, 0x6b, 0xd0, 0x3a, 0xc4, 0x92, 0x46, 0x2f, 0x39, 0x4f, 0x50, 0x07, 0x6a, 0x34, - 0x76, 0x9d, 0x6d,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5, 0xac, 0xfb, 0xff, 0x95, 0xe2, 0x11, 0x56, 0xa4, 0xfb, 0xc5, 0x81, 0xce, 0x3c, 0x59, 0xb4, - 0x0f, 0x0d, 0xcd, 0xd6, 0x74, 0x6c, 0x97, 0x37, 0x3e, 0x3f, 0x42, 0xf5, 0x01, 0xf0, 0x8d, 0x15, - 0xdd, 0x84, 0x66, 0xc6, 0x29, 0x53, 0xd2, 0xfc, 0x46, 0xc3, 0x2f, 0x22, 0xb4, 0x05, 0x40, 0x65, - 0x90, 0x10, 0x3c, 0xd1, 0x87, 0xa5, 0x99, 0xae, 0xfa, 0x2d, 0x2a, 0x9f, 0x5b, 0x41, 0x4f, 0x30, - 0xc1, 0x49, 0xf9, 0x32, 0x58, 0xb6, 0x33, 0x8a, 0xde, 0x47, 0x88, 0x13, 0xcc, 0x22, 0x52, 0x5c, - 0x58, 0x19, 0x1e, 0x1e, 0x7d, 0xbd, 0xf4, 0x9c, 0x8b, 0x4b, 0xcf, 0xf9, 0x79, 0xe9, 0x39, 0x9f, - 0xae, 0xbc, 0xa5, 0x8b, 0x2b, 0x6f, 0xe9, 0xdb, 0x95, 0xb7, 0xf4, 0xee, 0xfe, 0x90, 0xaa, 0x51, - 0x1e, 0xf6, 0x22, 0x9e, 0xf6, 0x9f, 0xbd, 0x7d, 0x73, 0xfc, 0x82, 0xa8, 0x73, 0x2e, 0xc6, 0xfd, - 0x68, 0x84, 0x29, 0xeb, 0x7f, 0x2c, 0xbe, 0x85, 0x6a, 0x9a, 0x11, 0x19, 0x36, 0xcd, 0x27, 0xed, - 0xc1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa5, 0xc1, 0x00, 0x26, 0x05, 0x00, 0x00, + // 719 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xe3, 0x24, 0x4d, 0x9b, 0x93, 0xdb, 0xf4, 0x6a, 0x74, 0xef, 0xad, 0x5b, 0xdd, 0xba, + 0x55, 0x10, 0xb4, 0x45, 0xc2, 0x51, 0x8b, 0x90, 0x10, 0x0b, 0x16, 0x4d, 0x5a, 0x09, 0x41, 0x2b, + 0x64, 0x04, 0x12, 0x6c, 0xac, 0x89, 0x3d, 0x75, 0x46, 0xb1, 0x67, 0x8c, 0x67, 0x9c, 0x92, 0x77, + 0x40, 0x82, 0x47, 0x61, 0xc1, 0x43, 0x74, 0xd9, 0x25, 0xb0, 0xa8, 0x50, 0xfb, 0x22, 0x68, 0xc6, + 0x7f, 0x48, 0x4a, 0xd8, 0xb1, 0xca, 0x9c, 0xef, 0x7c, 0x73, 0xe2, 0xf9, 0x9d, 0x33, 0x03, 0xd6, + 0x68, 0x32, 0x26, 0xdd, 0xb7, 0x29, 0x49, 0x26, 0xdd, 0xf1, 0xde, 0x80, 0x48, 0xbc, 0x97, 0x45, + 0x76, 0x9c, 0x70, 0xc9, 0x11, 0x52, 0x79, 0x3b, 0x53, 0xf2, 0xfc, 0xfa, 0x3f, 0x01, 0x0f, 0xb8, + 0x4e, 0x77, 0xd5, 0x2a, 0x73, 0xae, 0xff, 0xaf, 0x2b, 0xc5, 0x9c, 0x87, 0x65, 0x21, 0x15, 0x64, + 0xd9, 0xce, 0xa7, 0x2a, 0x34, 0x0f, 0xb0, 0xa0, 0xde, 0x73, 0xce, 0x43, 0xd4, 0x86, 0x2a, 0xf5, + 0x4d, 0x63, 0xcb, 0xd8, 0xa9, 0x3b, 0x55, 0xea, 0x23, 0x04, 0x75, 0x86, 0x23, 0x62, 0x56, 0xb7, + 0x8c, 0x9d, 0xa6, 0xa3, 0xd7, 0xc8, 0x84, 0xc5, 0x24, 0x65, 0x92, 0x46, 0xc4, 0xac, 0x69, 0xb9, + 0x08, 0x95, 0x3b, 0xe4, 0x01, 0x37, 0xeb, 0x99, 0x5b, 0xad, 0xd1, 0x6d, 0x68, 0xf3, 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x1f, 0x4b, 0xd2, + 0xf9, 0x6c, 0x40, 0x7b, 0xb6, 0x75, 0x68, 0x0f, 0xea, 0xaa, 0x79, 0xfa, 0x0b, 0x5a, 0xc5, 0x25, + 0x9a, 0x3d, 0x73, 0xf9, 0xc2, 0x38, 0xda, 0x8a, 0xfe, 0x83, 0x46, 0xcc, 0x29, 0x93, 0x42, 0xff, + 0x47, 0xdd, 0xc9, 0x23, 0xb4, 0x01, 0x40, 0x85, 0x1b, 0x12, 0x3c, 0x56, 0x93, 0xab, 0x9a, 0xb0, + 0xe4, 0x34, 0xa9, 0x78, 0x96, 0x09, 0xc8, 0x02, 0x18, 0xe3, 0xb0, 0xb8, 0x6d, 0x59, 0x33, 0xa6, + 0x14, 0xd5, 0xc0, 0x01, 0x0e, 0x31, 0xf3, 0x48, 0x3e, 0xc2, 0x45, 0x78, 0xd0, 0x3f, 0xbf, 0xb2, + 0x8c, 0x8b, 0x2b, 0xcb, 0xf8, 0x7e, 0x65, 0x19, 0x1f, 0xaf, 0xad, 0xca, 0xc5, 0xb5, 0x55, 0xf9, + 0x72, 0x6d, 0x55, 0xde, 0xdc, 0x9d, 0x22, 0xf5, 0xf4, 0xf5, 0xab, 0xc3, 0x13, 0x22, 0xcf, 0x78, + 0x32, 0xea, 0x7a, 0x43, 0x4c, 0x59, 0xf7, 0x5d, 0xfe, 0x04, 0x6b, 0x62, 0x83, 0x86, 0x7e, 0x33, + 0xef, 0xff, 0x08, 0x00, 0x00, 0xff, 0xff, 0x97, 0x7e, 0xc8, 0xa1, 0x9d, 0x05, 0x00, 0x00, } func (m *BasicPool) Marshal() (dAtA []byte, err error) { @@ -753,13 +744,16 @@ func (m *StakerMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0xa + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -788,13 +782,16 @@ func (m *CommissionChangeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0xa + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -951,10 +948,8 @@ func (m *StakerMetadata) Size() (n int) { } var l int _ = l - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovQuery(uint64(l)) l = len(m.Moniker) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -980,10 +975,8 @@ func (m *CommissionChangeEntry) Size() (n int) { } var l int _ = l - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovQuery(uint64(l)) if m.CreationDate != 0 { n += 1 + sovQuery(uint64(m.CreationDate)) } @@ -1569,7 +1562,9 @@ func (m *StakerMetadata) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { @@ -1783,7 +1778,9 @@ func (m *CommissionChangeEntry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 0 { diff --git a/x/stakers/client/cli/tx_stake.go b/x/stakers/client/cli/tx_create_staker.go similarity index 71% rename from x/stakers/client/cli/tx_stake.go rename to x/stakers/client/cli/tx_create_staker.go index 310dab85..2b12fadb 100644 --- a/x/stakers/client/cli/tx_stake.go +++ b/x/stakers/client/cli/tx_create_staker.go @@ -5,29 +5,36 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cast" "github.com/spf13/cobra" ) func CmdCreateStaker() *cobra.Command { cmd := &cobra.Command{ - Use: "create-staker [amount]", + Use: "create-staker [amount] [commission]", Short: "Broadcast message create-staker", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argAmount, err := cast.ToUint64E(args[0]) if err != nil { return err } + argCommission, err := sdk.NewDecFromStr(args[1]) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } msg := types.MsgCreateStaker{ - Creator: clientCtx.GetFromAddress().String(), - Amount: argAmount, + Creator: clientCtx.GetFromAddress().String(), + Amount: argAmount, + Commission: argCommission, } if err := msg.ValidateBasic(); err != nil { diff --git a/x/stakers/client/cli/tx_update_commission.go b/x/stakers/client/cli/tx_update_commission.go index 4bf925a5..9274fc34 100644 --- a/x/stakers/client/cli/tx_update_commission.go +++ b/x/stakers/client/cli/tx_update_commission.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" ) @@ -19,9 +20,14 @@ func CmdUpdateCommission() *cobra.Command { return err } + commission, err := sdk.NewDecFromStr(args[0]) + if err != nil { + return err + } + msg := types.MsgUpdateCommission{ Creator: clientCtx.GetFromAddress().String(), - Commission: args[0], + Commission: commission, } if err := msg.ValidateBasic(); err != nil { diff --git a/x/stakers/keeper/exported_functions.go b/x/stakers/keeper/exported_functions.go index d53765e6..901666d9 100644 --- a/x/stakers/keeper/exported_functions.go +++ b/x/stakers/keeper/exported_functions.go @@ -2,7 +2,6 @@ package keeper import ( "cosmossdk.io/math" - "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" // Gov @@ -41,11 +40,7 @@ func (k Keeper) GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (sta // GetCommission returns the commission of a staker as a parsed sdk.Dec func (k Keeper) GetCommission(ctx sdk.Context, stakerAddress string) sdk.Dec { staker, _ := k.GetStaker(ctx, stakerAddress) - uploaderCommission, err := sdk.NewDecFromStr(staker.Commission) - if err != nil { - util.PanicHalt(k.upgradeKeeper, ctx, "Commission not parsable: "+staker.Commission) - } - return uploaderCommission + return staker.Commission } // AssertValaccountAuthorized checks if the given `valaddress` is allowed to vote in pool diff --git a/x/stakers/keeper/getters_staker.go b/x/stakers/keeper/getters_staker.go index 32d7641e..db8436c7 100644 --- a/x/stakers/keeper/getters_staker.go +++ b/x/stakers/keeper/getters_staker.go @@ -24,7 +24,7 @@ func (k Keeper) UpdateStakerMetadata(ctx sdk.Context, address string, moniker st } // UpdateStakerCommission ... -func (k Keeper) UpdateStakerCommission(ctx sdk.Context, address string, commission string) { +func (k Keeper) UpdateStakerCommission(ctx sdk.Context, address string, commission sdk.Dec) { staker, found := k.GetStaker(ctx, address) if found { staker.Commission = commission diff --git a/x/stakers/keeper/logic_commission.go b/x/stakers/keeper/logic_commission.go index 1d888adc..894ff913 100644 --- a/x/stakers/keeper/logic_commission.go +++ b/x/stakers/keeper/logic_commission.go @@ -9,7 +9,7 @@ import ( // The queue is checked in every endBlock and when the commissionChangeTime // is over the new commission will be applied to the user. // If another entry is currently in the queue it will be removed. -func (k Keeper) orderNewCommissionChange(ctx sdk.Context, staker string, commission string) { +func (k Keeper) orderNewCommissionChange(ctx sdk.Context, staker string, commission sdk.Dec) { // Remove existing queue entry queueEntry, found := k.GetCommissionChangeEntryByIndex2(ctx, staker) if found { diff --git a/x/stakers/keeper/msg_server_create_staker.go b/x/stakers/keeper/msg_server_create_staker.go index 19599dea..7bd95860 100644 --- a/x/stakers/keeper/msg_server_create_staker.go +++ b/x/stakers/keeper/msg_server_create_staker.go @@ -15,7 +15,10 @@ import ( // Every user can create a staker object with some stake. However, // only if self_delegation + delegation is large enough to join a pool the staker // is able to participate in the protocol -func (k msgServer) CreateStaker(goCtx context.Context, msg *types.MsgCreateStaker) (*types.MsgCreateStakerResponse, error) { +func (k msgServer) CreateStaker( + goCtx context.Context, + msg *types.MsgCreateStaker, +) (*types.MsgCreateStakerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Only create new stakers @@ -26,7 +29,7 @@ func (k msgServer) CreateStaker(goCtx context.Context, msg *types.MsgCreateStake // Create and append new staker to store k.AppendStaker(ctx, types.Staker{ Address: msg.Creator, - Commission: types.DefaultCommission, + Commission: msg.Commission, }) // Perform initial self delegation diff --git a/x/stakers/keeper/msg_server_create_staker_test.go b/x/stakers/keeper/msg_server_create_staker_test.go index c8897310..cc933974 100644 --- a/x/stakers/keeper/msg_server_create_staker_test.go +++ b/x/stakers/keeper/msg_server_create_staker_test.go @@ -2,6 +2,7 @@ package keeper_test import ( delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" + sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -39,8 +40,9 @@ var _ = Describe("msg_server_create_staker.go", Ordered, func() { It("Create a first new staker and delegate 100 $KYVE", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ - Creator: i.STAKER_0, - Amount: 100 * i.KYVE, + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + Commission: sdk.MustNewDecFromStr("0.2"), }) // ASSERT @@ -56,7 +58,7 @@ var _ = Describe("msg_server_create_staker.go", Ordered, func() { Expect(staker.Address).To(Equal(i.STAKER_0)) Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.STAKER_0)).To(Equal(100 * i.KYVE)) Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(100 * i.KYVE)) - Expect(staker.Commission).To(Equal(types.DefaultCommission)) + Expect(staker.Commission).To(Equal(sdk.MustNewDecFromStr("0.2"))) Expect(staker.Moniker).To(BeEmpty()) Expect(staker.Logo).To(BeEmpty()) @@ -68,8 +70,9 @@ var _ = Describe("msg_server_create_staker.go", Ordered, func() { It("Do an additional 50 $KYVE self delegation after staker has already delegated 100 $KYVE", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ - Creator: i.STAKER_0, - Amount: 100 * i.KYVE, + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + Commission: types.DefaultCommission, }) // ACT diff --git a/x/stakers/keeper/msg_server_join_pool.go b/x/stakers/keeper/msg_server_join_pool.go index 6f0c4caa..cf843ddf 100644 --- a/x/stakers/keeper/msg_server_join_pool.go +++ b/x/stakers/keeper/msg_server_join_pool.go @@ -48,6 +48,11 @@ func (k msgServer) JoinPool(goCtx context.Context, msg *types.MsgJoinPool) (*typ return nil, errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrAlreadyJoinedPool.Error()) } + // Only join if it is possible + if errFreeSlot := k.ensureFreeSlot(ctx, msg.PoolId, staker.Address); errFreeSlot != nil { + return nil, errFreeSlot + } + // Every valaddress can only be used for one pool. It is not allowed // to use the same valaddress for multiple pools. (to avoid account sequence errors, // when two processes try so submit transactions simultaneously) @@ -66,11 +71,6 @@ func (k msgServer) JoinPool(goCtx context.Context, msg *types.MsgJoinPool) (*typ } } - // Only join if it is possible - if errFreeSlot := k.ensureFreeSlot(ctx, msg.PoolId, staker.Address); errFreeSlot != nil { - return nil, errFreeSlot - } - k.AddValaccountToPool(ctx, msg.PoolId, msg.Creator, msg.Valaddress) if err := util.TransferFromAddressToAddress(k.bankKeeper, ctx, msg.Creator, msg.Valaddress, msg.Amount); err != nil { diff --git a/x/stakers/keeper/msg_server_update_commission.go b/x/stakers/keeper/msg_server_update_commission.go index 36ae8af8..0eb30c8d 100644 --- a/x/stakers/keeper/msg_server_update_commission.go +++ b/x/stakers/keeper/msg_server_update_commission.go @@ -21,16 +21,6 @@ func (k msgServer) UpdateCommission(goCtx context.Context, msg *types.MsgUpdateC return nil, errors.Wrap(errorsTypes.ErrUnauthorized, types.ErrNoStaker.Error()) } - // Validate commission. - commission, err := sdk.NewDecFromStr(msg.Commission) - if err != nil { - return nil, errors.Wrapf(errorsTypes.ErrLogic, types.ErrInvalidCommission.Error(), msg.Commission) - } - - if commission.LT(sdk.NewDec(int64(0))) || commission.GT(sdk.NewDec(int64(1))) { - return nil, errors.Wrapf(errorsTypes.ErrLogic, types.ErrInvalidCommission.Error(), msg.Commission) - } - // Insert commission change into queue k.orderNewCommissionChange(ctx, msg.Creator, msg.Commission) diff --git a/x/stakers/keeper/msg_server_update_commission_test.go b/x/stakers/keeper/msg_server_update_commission_test.go index 852a20a5..43e5ff60 100644 --- a/x/stakers/keeper/msg_server_update_commission_test.go +++ b/x/stakers/keeper/msg_server_update_commission_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -53,7 +54,7 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.5", + Commission: sdk.MustNewDecFromStr("0.5"), }) s.PerformValidityChecks() @@ -66,14 +67,14 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.CommitAfterSeconds(1) staker, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker.Commission).To(Equal("0.5")) + Expect(staker.Commission).To(Equal(sdk.MustNewDecFromStr("0.5"))) }) It("Update commission to 0% from previously default commission", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0", + Commission: sdk.ZeroDec(), }) s.PerformValidityChecks() @@ -86,14 +87,14 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.CommitAfterSeconds(1) staker, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker.Commission).To(Equal("0")) + Expect(staker.Commission).To(Equal(sdk.ZeroDec())) }) It("Update commission to 100% from previously default commission", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "1", + Commission: sdk.OneDec(), }) s.PerformValidityChecks() @@ -106,27 +107,14 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.CommitAfterSeconds(1) staker, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker.Commission).To(Equal("1")) - }) - - It("Update commission with an invalid number from previously default commission", func() { - // ACT - s.RunTxStakersError(&stakerstypes.MsgUpdateCommission{ - Creator: i.STAKER_0, - Commission: "teset", - }) - s.PerformValidityChecks() - - // ASSERT - staker, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker.Commission).To(Equal(stakerstypes.DefaultCommission)) + Expect(staker.Commission).To(Equal(sdk.OneDec())) }) It("Update commission with a negative number from previously default commission", func() { // ACT s.RunTxStakersError(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "-0.5", + Commission: sdk.MustNewDecFromStr("-0.5"), }) s.PerformValidityChecks() @@ -139,7 +127,7 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { // ACT s.RunTxStakersError(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "2", + Commission: sdk.NewDec(2), }) s.PerformValidityChecks() @@ -152,19 +140,19 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.5", + Commission: sdk.MustNewDecFromStr("0.5"), }) s.PerformValidityChecks() s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.2", + Commission: sdk.MustNewDecFromStr("0.2"), }) s.PerformValidityChecks() s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.3", + Commission: sdk.MustNewDecFromStr("0.3"), }) s.PerformValidityChecks() @@ -177,19 +165,19 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.CommitAfterSeconds(1) staker, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker.Commission).To(Equal("0.3")) + Expect(staker.Commission).To(Equal(sdk.MustNewDecFromStr("0.3"))) }) It("Update commission multiple times during the commission change time with the same value", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.5", + Commission: sdk.MustNewDecFromStr("0.5"), }) s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.2", + Commission: sdk.MustNewDecFromStr("0.2"), }) s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ @@ -220,12 +208,12 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_0, - Commission: "0.5", + Commission: sdk.MustNewDecFromStr("0.5"), }) s.RunTxStakersSuccess(&stakerstypes.MsgUpdateCommission{ Creator: i.STAKER_1, - Commission: "0.5", + Commission: sdk.MustNewDecFromStr("0.5"), }) s.PerformValidityChecks() @@ -242,9 +230,9 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.CommitAfterSeconds(1) staker0, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - Expect(staker0.Commission).To(Equal("0.5")) + Expect(staker0.Commission).To(Equal(sdk.MustNewDecFromStr("0.5"))) staker1, _ = s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_1) - Expect(staker1.Commission).To(Equal("0.5")) + Expect(staker1.Commission).To(Equal(sdk.MustNewDecFromStr("0.5"))) }) }) diff --git a/x/stakers/keeper/msg_server_update_params.go b/x/stakers/keeper/msg_server_update_params.go index 0268d464..0e5e6a6a 100644 --- a/x/stakers/keeper/msg_server_update_params.go +++ b/x/stakers/keeper/msg_server_update_params.go @@ -5,7 +5,6 @@ import ( "encoding/json" "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" // Gov @@ -14,17 +13,23 @@ import ( "github.com/KYVENetwork/chain/x/stakers/types" ) -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { - return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) +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) - params := k.GetParams(ctx) + oldParams := k.GetParams(ctx) + + newParams := oldParams + _ = json.Unmarshal([]byte(msg.Payload), &newParams) + k.SetParams(ctx, newParams) - payload := params - _ = json.Unmarshal([]byte(req.Payload), &payload) - k.SetParams(ctx, payload) + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + OldParams: oldParams, + NewParams: newParams, + Payload: msg.Payload, + }) return &types.MsgUpdateParamsResponse{}, nil } diff --git a/x/stakers/spec/02_state.md b/x/stakers/spec/02_state.md index ceb03135..cf918dcf 100644 --- a/x/stakers/spec/02_state.md +++ b/x/stakers/spec/02_state.md @@ -15,7 +15,7 @@ people can delegate to it and the staker can start joining pools type Staker struct { Address string // Needs to be a valid decimal representation - Commission uint64 + Commission sdk.Dec Moniker uint64 Website uint64 Logo uint64 @@ -101,7 +101,7 @@ type CommissionChangeEntry struct { Staker string // Commission is the new commission which will // be applied after the waiting time is over. - Commission String + Commission sdk.Dec // CreationDate is the UNIX-timestamp in seconds // when the entry was created. CreationDate uint64 diff --git a/x/stakers/spec/05_events.md b/x/stakers/spec/05_events.md index 9fa8007b..8ee8ebcd 100644 --- a/x/stakers/spec/05_events.md +++ b/x/stakers/spec/05_events.md @@ -6,6 +6,21 @@ order: 5 The `x/stakers` module contains the following events: +## EventUpdateParams + +EventUpdateParams is emitted when the parameters were changed by the governance. + +```protobuf +message EventUpdateParams { + // old_params is the module's old parameters. + kyve.bundles.v1beta1.Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + kyve.bundles.v1beta1.Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} +``` + ## EventCreateStaker EventBundleProposed indicates that a new staker was created. @@ -54,7 +69,10 @@ message EventUpdateCommission { // staker is the account address of the protocol node. string staker = 1; // commission ... - string commission = 2; + string commission = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } ``` diff --git a/x/stakers/types/errors.go b/x/stakers/types/errors.go index f12025f8..35a19780 100644 --- a/x/stakers/types/errors.go +++ b/x/stakers/types/errors.go @@ -17,7 +17,6 @@ var ( ErrValaddressSameAsStaker = errors.Register(ModuleName, 1111, "Valaddress has same address as Valaddress") ErrCanNotJoinDisabledPool = errors.Register(ModuleName, 1112, "can not join disabled pool") - ErrInvalidCommission = errors.Register(ModuleName, 1116, "invalid commission %v") ErrPoolLeaveAlreadyInProgress = errors.Register(ModuleName, 1117, "Pool leave is already in progress") ErrValaccountUnauthorized = errors.Register(ModuleName, 1118, "valaccount unauthorized") ) diff --git a/x/stakers/types/events.pb.go b/x/stakers/types/events.pb.go index 23c49708..c865279a 100644 --- a/x/stakers/types/events.pb.go +++ b/x/stakers/types/events.pb.go @@ -5,6 +5,8 @@ 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/gogo/protobuf/proto" io "io" math "math" @@ -22,6 +24,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_7a1b3dc9634155a0, []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 "" +} + // EventCreateStaker is an event emitted when a protocol node stakes in a pool. // emitted_by: MsgCreateStaker type EventCreateStaker struct { @@ -35,7 +102,7 @@ func (m *EventCreateStaker) Reset() { *m = EventCreateStaker{} } func (m *EventCreateStaker) String() string { return proto.CompactTextString(m) } func (*EventCreateStaker) ProtoMessage() {} func (*EventCreateStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_7a1b3dc9634155a0, []int{0} + return fileDescriptor_7a1b3dc9634155a0, []int{1} } func (m *EventCreateStaker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -95,7 +162,7 @@ func (m *EventUpdateMetadata) Reset() { *m = EventUpdateMetadata{} } func (m *EventUpdateMetadata) String() string { return proto.CompactTextString(m) } func (*EventUpdateMetadata) ProtoMessage() {} func (*EventUpdateMetadata) Descriptor() ([]byte, []int) { - return fileDescriptor_7a1b3dc9634155a0, []int{1} + return fileDescriptor_7a1b3dc9634155a0, []int{2} } func (m *EventUpdateMetadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -158,14 +225,14 @@ type EventUpdateCommission struct { // staker is the account address of the protocol node. Staker string `protobuf:"bytes,1,opt,name=staker,proto3" json:"staker,omitempty"` // commission ... - Commission string `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` } func (m *EventUpdateCommission) Reset() { *m = EventUpdateCommission{} } func (m *EventUpdateCommission) String() string { return proto.CompactTextString(m) } func (*EventUpdateCommission) ProtoMessage() {} func (*EventUpdateCommission) Descriptor() ([]byte, []int) { - return fileDescriptor_7a1b3dc9634155a0, []int{2} + return fileDescriptor_7a1b3dc9634155a0, []int{3} } func (m *EventUpdateCommission) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -201,13 +268,6 @@ func (m *EventUpdateCommission) GetStaker() string { return "" } -func (m *EventUpdateCommission) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - // EventJoinPool ... // emitted_by: MsgJoinPool type EventJoinPool struct { @@ -226,7 +286,7 @@ func (m *EventJoinPool) Reset() { *m = EventJoinPool{} } func (m *EventJoinPool) String() string { return proto.CompactTextString(m) } func (*EventJoinPool) ProtoMessage() {} func (*EventJoinPool) Descriptor() ([]byte, []int) { - return fileDescriptor_7a1b3dc9634155a0, []int{3} + return fileDescriptor_7a1b3dc9634155a0, []int{4} } func (m *EventJoinPool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -296,7 +356,7 @@ func (m *EventLeavePool) Reset() { *m = EventLeavePool{} } func (m *EventLeavePool) String() string { return proto.CompactTextString(m) } func (*EventLeavePool) ProtoMessage() {} func (*EventLeavePool) Descriptor() ([]byte, []int) { - return fileDescriptor_7a1b3dc9634155a0, []int{4} + return fileDescriptor_7a1b3dc9634155a0, []int{5} } func (m *EventLeavePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -340,6 +400,7 @@ func (m *EventLeavePool) GetStaker() string { } func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.stakers.v1beta1.EventUpdateParams") proto.RegisterType((*EventCreateStaker)(nil), "kyve.stakers.v1beta1.EventCreateStaker") proto.RegisterType((*EventUpdateMetadata)(nil), "kyve.stakers.v1beta1.EventUpdateMetadata") proto.RegisterType((*EventUpdateCommission)(nil), "kyve.stakers.v1beta1.EventUpdateCommission") @@ -350,29 +411,86 @@ func init() { func init() { proto.RegisterFile("kyve/stakers/v1beta1/events.proto", fileDescriptor_7a1b3dc9634155a0) } var fileDescriptor_7a1b3dc9634155a0 = []byte{ - // 342 bytes of a gzipped FileDescriptorProto - 0x1f,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 0x3b, 0xc6, 0x21, 0xba, 0xb6, 0xb6, 0xf5, - 0xb7, 0x77, 0xc3, 0x76, 0x2b, 0xd8, 0x2e, 0x26, 0x89, 0x54, 0x4a, 0x62, 0xba, 0x15, 0xcc, 0x19, - 0x1b, 0x6c, 0x5a, 0x86, 0x5d, 0x71, 0xbc, 0x19, 0xfb, 0xa3, 0x07, 0xcf, 0x51, 0xa6, 0xb7, 0x88, - 0xb1, 0xb3, 0xcf, 0x9a, 0x19, 0x62, 0xfc, 0x2c, 0x23, 0xbd, 0x64, 0xf7, 0x1b, 0xa5, 0x3c, 0x8b, - 0x2a, 0x84, 0xfa, 0x77, 0x42, 0x21, 0x62, 0x11, 0x45, 0x39, 0x28, 0x65, 0xfe, 0xa1, 0xe2, 0x54, - 0x5e, 0xd0, 0xfe, 0xf2, 0x82, 0xc7, 0xec, 0xaf, 0x26, 0x5f, 0x82, 0x28, 0xe0, 0x47, 0xe8, 0x93, - 0xd3, 0xd7, 0x25, 0xb7, 0x16, 0x4b, 0x6e, 0xbd, 0x2f, 0xb9, 0xf5, 0xb2, 0xe2, 0xb5, 0xc5, 0x8a, - 0xd7, 0xde, 0x56, 0xbc, 0xf6, 0x74, 0x38, 0x94, 0x34, 0x9a, 0x84, 0xfe, 0x00, 0x93, 0xe0, 0xe2, - 0xf1, 0xa1, 0x77, 0x0d, 0x34, 0xc5, 0x7c, 0x1c, 0x0c, 0x46, 0x42, 0xa6, 0xc1, 0x6c, 0x73, 0x36, - 0x34, 0xcf, 0x40, 0x85, 0x0d, 0x7d, 0x2e, 0x47, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x2b, - 0x0f, 0x0f, 0x53, 0x02, 0x00, 0x00, + // 462 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xdf, 0x6a, 0xd4, 0x40, + 0x14, 0xc6, 0x37, 0x6b, 0xd8, 0x65, 0x8f, 0x28, 0x18, 0xab, 0x86, 0x22, 0x69, 0xcd, 0x85, 0xf4, + 0x42, 0x13, 0xaa, 0x4f, 0xd0, 0x5d, 0x2b, 0xf8, 0xaf, 0x94, 0x88, 0x82, 0xde, 0x94, 0xb3, 0x99, + 0xc3, 0x36, 0x6c, 0x92, 0x13, 0x32, 0xb3, 0xd9, 0xee, 0x95, 0xaf, 0xe0, 0xbb, 0xf8, 0x12, 0xbd, + 0xec, 0xa5, 0x78, 0x51, 0x64, 0xf7, 0x45, 0x24, 0x93, 0xd9, 0x9a, 0x42, 0x17, 0xc4, 0xab, 0xcc, + 0x37, 0xf3, 0xe5, 0xf7, 0x7d, 0x73, 0x48, 0xe0, 0xc9, 0x74, 0x51, 0x51, 0x28, 0x15, 0x4e, 0xa9, + 0x94, 0x61, 0xb5, 0x3f, 0x26, 0x85, 0xfb, 0x21, 0x55, 0x94, 0x2b, 0x19, 0x14, 0x25, 0x2b, 0x76, + 0xb6, 0x6a, 0x4b, 0x60, 0x2c, 0x81, 0xb1, 0x6c, 0x6f, 0x4d, 0x78, 0xc2, 0xda, 0x10, 0xd6, 0xab, + 0xc6, 0xbb, 0x7d, 0x33, 0xae, 0xc0, 0x12, 0x33, 0x83, 0xf3, 0x7f, 0x58, 0x70, 0xef, 0xb0, 0xe6, + 0x7f, 0x2a, 0x04, 0x2a, 0x3a, 0xd6, 0x67, 0xce, 0x01, 0x00, 0xa7, 0xe2, 0xa4, 0x71, 0xba, 0xd6, + 0xae, 0xb5, 0x77, 0xfb, 0xc5, 0xe3, 0xe0, 0xa6, 0xe4, 0xa0, 0x79, 0x63, 0x68, 0x9f, 0x5f, 0xee, + 0x74, 0xa2, 0x01, 0xa7, 0xe2, 0x2f, 0x22, 0xa7, 0xf9, 0x1a, 0xd1, 0xfd, 0x77, 0x44, 0x4e, 0x73, + 0x83, 0x70, 0xa1, 0x5f, 0xe0, 0x22, 0x65, 0x14, 0xee, 0xad, 0x5d, 0x6b, 0x6f, 0x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x3a, 0xf9, 0x3d, 0x61, 0x45, 0xff, 0x15, 0x3d, 0x7c, 0x7d, 0xbe, 0xf4, 0xac, + 0x8b, 0xa5, 0x67, 0xfd, 0x5e, 0x7a, 0xd6, 0xf7, 0x95, 0xd7, 0xb9, 0x58, 0x79, 0x9d, 0x9f, 0x2b, + 0xaf, 0xf3, 0xf5, 0x59, 0x6b, 0x14, 0xef, 0xbe, 0x7c, 0x3e, 0x3c, 0x22, 0x35, 0xe7, 0x72, 0x1a, + 0xc6, 0xa7, 0x98, 0xe4, 0xe1, 0xd9, 0xd5, 0x6f, 0xa0, 0x87, 0x32, 0xee, 0xe9, 0xcf, 0xff, 0xe5, + 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0xd7, 0xac, 0xc1, 0x72, 0x03, 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 *EventCreateStaker) Marshal() (dAtA []byte, err error) { @@ -481,13 +599,16 @@ func (m *EventUpdateCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0x12 + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Staker) > 0 { i -= len(m.Staker) copy(dAtA[i:], m.Staker) @@ -591,6 +712,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 *EventCreateStaker) Size() (n int) { if m == nil { return 0 @@ -642,10 +780,8 @@ func (m *EventUpdateCommission) Size() (n int) { if l > 0 { n += 1 + l + sovEvents(uint64(l)) } - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovEvents(uint64(l)) return n } @@ -694,6 +830,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 *EventCreateStaker) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1064,7 +1348,9 @@ func (m *EventUpdateCommission) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/stakers/types/keys.go b/x/stakers/types/keys.go index 01295ead..d025544f 100644 --- a/x/stakers/types/keys.go +++ b/x/stakers/types/keys.go @@ -2,6 +2,7 @@ package types import ( "github.com/KYVENetwork/chain/util" + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( @@ -59,10 +60,9 @@ var ( QUEUE_IDENTIFIER_LEAVE QUEUE_IDENTIFIER = []byte{30, 3} ) -const ( - MaxStakers = 50 - DefaultCommission = "0.9" -) +const MaxStakers = 50 + +var DefaultCommission = sdk.MustNewDecFromStr("0.1") // StakerKey returns the store Key to retrieve a Staker from the index fields func StakerKey(staker string) []byte { diff --git a/x/stakers/types/message_create_staker.go b/x/stakers/types/message_create_staker.go index 95ee7485..7947ec07 100644 --- a/x/stakers/types/message_create_staker.go +++ b/x/stakers/types/message_create_staker.go @@ -2,39 +2,37 @@ package types import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgCreateStaker = "create_staker" - var _ sdk.Msg = &MsgCreateStaker{} -func (msg *MsgCreateStaker) Route() string { - return RouterKey -} - -func (msg *MsgCreateStaker) Type() string { - return TypeMsgCreateStaker -} - func (msg *MsgCreateStaker) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) } - return []sdk.AccAddress{creator} -} -func (msg *MsgCreateStaker) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) + return []sdk.AccAddress{creator} } func (msg *MsgCreateStaker) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address (%s)", err) + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) + } + + if util.ValidateNumber(msg.Amount) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount") } + + if msg.Commission.IsNil() { + msg.Commission = DefaultCommission + } + if util.ValidatePercentage(msg.Commission) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid commission") + } + return nil } diff --git a/x/stakers/types/message_join_pool.go b/x/stakers/types/message_join_pool.go index 0049914a..20a857f9 100644 --- a/x/stakers/types/message_join_pool.go +++ b/x/stakers/types/message_join_pool.go @@ -2,39 +2,34 @@ package types import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgJoinPool = "join_pool" - var _ sdk.Msg = &MsgJoinPool{} -func (msg *MsgJoinPool) Route() string { - return RouterKey -} - -func (msg *MsgJoinPool) Type() string { - return TypeMsgJoinPool -} - func (msg *MsgJoinPool) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) } - return []sdk.AccAddress{creator} -} -func (msg *MsgJoinPool) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) + return []sdk.AccAddress{creator} } func (msg *MsgJoinPool) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address (%s)", err) + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) + } + + if _, err := sdk.AccAddressFromBech32(msg.Valaddress); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid validator address: %s", err) } + + if util.ValidateNumber(msg.Amount) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount") + } + return nil } diff --git a/x/stakers/types/message_leavel_pool.go b/x/stakers/types/message_leave_pool.go similarity index 100% rename from x/stakers/types/message_leavel_pool.go rename to x/stakers/types/message_leave_pool.go diff --git a/x/stakers/types/message_update_commission.go b/x/stakers/types/message_update_commission.go index bf8dd513..e8fb1aed 100644 --- a/x/stakers/types/message_update_commission.go +++ b/x/stakers/types/message_update_commission.go @@ -2,39 +2,28 @@ package types import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgUpdateCommission = "update_commission" - var _ sdk.Msg = &MsgUpdateCommission{} -func (msg *MsgUpdateCommission) Route() string { - return RouterKey -} - -func (msg *MsgUpdateCommission) Type() string { - return TypeMsgUpdateCommission -} - +// GetSigners returns the expected signers for a MsgUpdateCommission message. func (msg *MsgUpdateCommission) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgUpdateCommission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) + validator, _ := sdk.AccAddressFromBech32(msg.Creator) + return []sdk.AccAddress{validator} } +// ValidateBasic does a sanity check on the provided data. func (msg *MsgUpdateCommission) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address (%s)", err) + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid validator address: %s", err) } + + if util.ValidatePercentage(msg.Commission) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid commission") + } + return nil } diff --git a/x/stakers/types/params.go b/x/stakers/types/params.go index 76a01b9b..2ecb0884 100644 --- a/x/stakers/types/params.go +++ b/x/stakers/types/params.go @@ -31,11 +31,11 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - if err := util.ValidateUint64(p.CommissionChangeTime); err != nil { + if err := util.ValidateNumber(p.CommissionChangeTime); err != nil { return err } - if err := util.ValidateUint64(p.LeavePoolTime); err != nil { + if err := util.ValidateNumber(p.LeavePoolTime); err != nil { return err } diff --git a/x/stakers/types/stakers.pb.go b/x/stakers/types/stakers.pb.go index 11d4cc75..879a0ceb 100644 --- a/x/stakers/types/stakers.pb.go +++ b/x/stakers/types/stakers.pb.go @@ -5,6 +5,8 @@ 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/gogo/protobuf/proto" io "io" math "math" @@ -28,7 +30,7 @@ type Staker struct { // address ... Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // commission ... - Commission string `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` // moniker ... Moniker string `protobuf:"bytes,3,opt,name=moniker,proto3" json:"moniker,omitempty"` // website ... @@ -77,13 +79,6 @@ func (m *Staker) GetAddress() string { return "" } -func (m *Staker) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - func (m *Staker) GetMoniker() string { if m != nil { return m.Moniker @@ -204,7 +199,7 @@ type CommissionChangeEntry struct { Staker string `protobuf:"bytes,2,opt,name=staker,proto3" json:"staker,omitempty"` // commission is the new commission which will // be applied after the waiting time is over. - Commission string `protobuf:"bytes,3,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` // creation_date is the UNIX-timestamp in seconds // when the entry was created. CreationDate int64 `protobuf:"varint,4,opt,name=creation_date,json=creationDate,proto3" json:"creation_date,omitempty"` @@ -257,13 +252,6 @@ func (m *CommissionChangeEntry) GetStaker() string { return "" } -func (m *CommissionChangeEntry) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - func (m *CommissionChangeEntry) GetCreationDate() int64 { if m != nil { return m.CreationDate @@ -421,34 +409,37 @@ func init() { } var fileDescriptor_d209d1a2a74d375d = []byte{ - // 429 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x9b, 0x6d, 0xb7, 0xbb, 0x7d, 0xa8, 0x87, 0x61, 0xd5, 0x80, 0x6c, 0x90, 0x7a, 0xf1, - 0x20, 0x0d, 0x8b, 0xdf, 0xc0, 0x75, 0xc5, 0x45, 0x11, 0xed, 0xc2, 0x82, 0x5e, 0xca, 0x34, 0x79, - 0x24, 0x43, 0xa7, 0xf3, 0x42, 0x66, 0x92, 0x6c, 0xc1, 0x4f, 0xe0, 0xc9, 0x83, 0x1f, 0xca, 0xe3, - 0x1e, 0x3d, 0x4a, 0xfb, 0x45, 0x64, 0x26, 0x93, 0x12, 0x11, 0x44, 0xbc, 0xe5, 0xff, 0xff, 0xcf, - 0xcb, 0xfc, 0xde, 0x9f, 0x81, 0xe9, 0x6a, 0x53, 0x63, 0xac, 0x0d, 0x5f, 0x61, 0xa9, 0xe3, 0xfa, - 0x6c, 0x89, 0x86, 0x9f, 0x75, 0x7a, 0x56, 0x94, 0x64, 0x88, 0x9d, 0xd8, 0x33, 0xb3, 0xce, 0xf3, - 0x67, 0xa6, 0x5f, 0x02, 0x18, 0x5f, 0x39, 0x8f, 0x85, 0x70, 0xc4, 0xd3, 0xb4, 0x44, 0xad, 0xc3, - 0xe0, 0x71, 0xf0, 0x74, 0x32, 0xef, 0x24, 0x8b, 0x00, 0x12, 0x5a, 0xaf, 0x85, 0xd6, 0x82, 0x54, - 0x78, 0xe0, 0xc2, 0x9e, 0x63, 0x27, 0xd7, 0xa4, 0xc4, 0x0a, 0xcb, 0x70, 0xd8, 0x4e, 0x7a, 0x69, - 0x93, 0x06, 0x97, 0x5a, 0x18, 0x0c, 0x47, 0x6d, 0xe2, 0x25, 0x63, 0x30, 0x92, 0x94, 0x51, 0x78, - 0xe8, 0x6c, 0xf7, 0x3d, 0xfd, 0x16, 0x00, 0x5c, 0x73, 0xc9, 0x93, 0x84, 0x2a, 0x65, 0xd8, 0x43, - 0x38, 0x2a, 0x88, 0xe4, 0x42, 0xa4, 0x0e, 0x68, 0x34, 0x1f, 0x5b, 0x79, 0x99, 0xb2, 0x07, 0x30, - 0x6e, 0xf7, 0xf0, 0x2c, 0x5e, 0x59, 0xce, 0x9a, 0xcb, 0x6e, 0x89, 0x16, 0xa5, 0xe7, 0xd8, 0xb9, - 0x82, 0x84, 0x32, 0xda, 0xc1, 0xb8, 0xff, 0x59, 0xc5, 0x4e, 0x01, 0x84, 0x5e, 0x48, 0xe4, 0xb5, - 0x50, 0x99, 0x23, 0x3a, 0x9e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, 0x43, 0xbf, 0x03, 0x03, 0x00, 0x00, + // 475 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xdd, 0x6a, 0xd4, 0x40, + 0x14, 0xde, 0x74, 0xb7, 0xdb, 0xee, 0x41, 0xbd, 0x18, 0x56, 0x0d, 0x4a, 0x53, 0x59, 0x41, 0xbc, + 0xd0, 0x84, 0xe2, 0x1b, 0xf4, 0x47, 0x2c, 0x4a, 0xd1, 0x14, 0x0a, 0x7a, 0xb3, 0xcc, 0x26, 0x87, + 0x64, 0x48, 0x32, 0x67, 0xc9, 0xcc, 0xee, 0x76, 0xc1, 0x87, 0xf0, 0xc2, 0xa7, 0xf1, 0x09, 0x7a, + 0xd9, 0x4b, 0xf1, 0xa2, 0xc8, 0xee, 0x8b, 0xc8, 0x4c, 0x92, 0x92, 0xbd, 0x10, 0xc4, 0x5e, 0x65, + 0xbe, 0xef, 0x3b, 0x99, 0xf3, 0x9d, 0x6f, 0x38, 0x30, 0xca, 0x96, 0x73, 0x0c, 0x94, 0xe6, 0x19, + 0x96, 0x2a, 0x98, 0x1f, 0x4c, 0x50, 0xf3, 0x83, 0x06, 0xfb, 0xd3, 0x92, 0x34, 0xb1, 0xa1, 0xa9, + 0xf1, 0x1b, 0xae, 0xae, 0x79, 0x32, 0x4c, 0x28, 0x21, 0x5b, 0x10, 0x98, 0x53, 0x55, 0x3b, 0xfa, + 0xe1, 0x40, 0xff, 0xdc, 0x56, 0x32, 0x17, 0x76, 0x78, 0x1c, 0x97, 0xa8, 0x94, 0xeb, 0x3c, 0x73, + 0x5e, 0x0e, 0xc2, 0x06, 0xb2, 0x33, 0x80, 0x88, 0x8a, 0x42, 0x28, 0x25, 0x48, 0xba, 0x5b, 0x46, + 0x3c, 0xf4, 0xaf, 0x6e, 0xf6, 0x3b, 0xbf, 0x6e, 0xf6, 0x5f, 0x24, 0x42, 0xa7, 0xb3,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c, 0x30, 0x73, 0xe0, 0x47, 0xa2, 0xfc, 0x7f, 0x4c, 0xb7, 0x1e, 0xa1, + 0xbb, 0xf1, 0x08, 0xff, 0xd4, 0xfd, 0x1d, 0xc0, 0xa7, 0x19, 0xce, 0xf0, 0x5c, 0x73, 0x8d, 0xec, + 0x29, 0x0c, 0x72, 0x5a, 0x8c, 0xdb, 0xdd, 0x77, 0x73, 0x5a, 0x9c, 0x5a, 0x03, 0x7b, 0x00, 0xa9, + 0x48, 0xd2, 0x5a, 0xdd, 0xb2, 0xea, 0xc0, 0x30, 0x56, 0x3e, 0x7c, 0x7b, 0xb5, 0xf2, 0x9c, 0xeb, + 0x95, 0xe7, 0xfc, 0x5e, 0x79, 0xce, 0xb7, 0xb5, 0xd7, 0xb9, 0x5e, 0x7b, 0x9d, 0x9f, 0x6b, 0xaf, + 0xf3, 0xe5, 0x55, 0x2b, 0xba, 0xf7, 0x9f, 0x2f, 0x4e, 0xce, 0x50, 0x2f, 0xa8, 0xcc, 0x82, 0x28, + 0xe5, 0x42, 0x06, 0x97, 0xb7, 0xcb, 0x65, 0x43, 0x9c, 0xf4, 0xed, 0x9e, 0xbc, 0xf9, 0x13, 0x00, + 0x00, 0xff, 0xff, 0xbc, 0x83, 0xaf, 0xf4, 0x79, 0x03, 0x00, 0x00, } func (m *Staker) Marshal() (dAtA []byte, err error) { @@ -492,13 +483,16 @@ func (m *Staker) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintStakers(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0x12 + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStakers(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -591,13 +585,16 @@ func (m *CommissionChangeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintStakers(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0x1a + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStakers(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.Staker) > 0 { i -= len(m.Staker) copy(dAtA[i:], m.Staker) @@ -712,10 +709,8 @@ func (m *Staker) Size() (n int) { if l > 0 { n += 1 + l + sovStakers(uint64(l)) } - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovStakers(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovStakers(uint64(l)) l = len(m.Moniker) if l > 0 { n += 1 + l + sovStakers(uint64(l)) @@ -770,10 +765,8 @@ func (m *CommissionChangeEntry) Size() (n int) { if l > 0 { n += 1 + l + sovStakers(uint64(l)) } - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovStakers(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovStakers(uint64(l)) if m.CreationDate != 0 { n += 1 + sovStakers(uint64(m.CreationDate)) } @@ -914,7 +907,9 @@ func (m *Staker) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 { @@ -1315,7 +1310,9 @@ func (m *CommissionChangeEntry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 4: if wireType != 0 { diff --git a/x/stakers/types/tx.pb.go b/x/stakers/types/tx.pb.go index 5058724c..114d99e5 100644 --- a/x/stakers/types/tx.pb.go +++ b/x/stakers/types/tx.pb.go @@ -7,6 +7,8 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" @@ -28,12 +30,15 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgStakePool defines a SDK message for staking in a pool. +// MsgCreateStaker defines a SDK message for creating a staker. type MsgCreateStaker struct { - // creator ... + // creator is the address of the staker. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // amount ... + // amount is the initial self-stake of the staker. Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + // commission is the percentage that is deducted from rewards before + // distributing the staker's delegators. + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` } func (m *MsgCreateStaker) Reset() { *m = MsgCreateStaker{} } @@ -235,7 +240,7 @@ type MsgUpdateCommission struct { // creator ... Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // commission ... - Commission string `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission,omitempty"` + Commission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission"` } func (m *MsgUpdateCommission) Reset() { *m = MsgUpdateCommission{} } @@ -278,13 +283,6 @@ func (m *MsgUpdateCommission) GetCreator() string { return "" } -func (m *MsgUpdateCommission) GetCommission() string { - if m != nil { - return m.Commission - } - return "" -} - // MsgUpdateCommissionResponse ... type MsgUpdateCommissionResponse struct { } @@ -634,43 +632,46 @@ func init() { func init() { proto.RegisterFile("kyve/stakers/v1beta1/tx.proto", fileDescriptor_f52b730e69b9fb06) } var fileDescriptor_f52b730e69b9fb06 = []byte{ - // 568 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0xad, 0x69, 0xd4, 0x90, 0x4b, 0xc4, 0xc3, 0x84, 0xd6, 0x71, 0x55, 0xab, 0x58, 0xaa, 0x68, - 0x11, 0xb5, 0x15, 0x90, 0xd8, 0xb7, 0x11, 0x48, 0x3c, 0x0c, 0x55, 0x2a, 0x10, 0x8f, 0x45, 0x35, - 0xb1, 0x47, 0x8e, 0x49, 0xec, 0x6b, 0x79, 0x26, 0x69, 0xf2, 0x17, 0x7c, 0x0c, 0x1f, 0xc1, 0xb2, - 0x62, 0xc5, 0x12, 0x25, 0x12, 0xdf, 0x81, 0xfc, 0x9a, 0x3c, 0x9a, 0x97, 0xd8, 0xe5, 0xcc, 0x3d, - 0xf7, 0x9c, 0x7b, 0x3d, 0x27, 0x03, 0x7b, 0xed, 0x41, 0x8f, 0x9a, 0x8c, 0x93, 0x36, 0x8d, 0x98, - 0xd9, 0xab, 0x35, 0x29, 0x27, 0x35, 0x93, 0xf7, 0x8d, 0x30, 0x42, 0x8e, 0x72, 0x25, 0x2e, 0x1b, - 0x59, 0xd9, 0xc8, 0xca, 0x6a, 0xd5, 0x46, 0xe6, 0x23, 0xbb, 0x48, 0x38, 0x66, 0x0a, 0xd2, 0x06, - 0xbd, 0x0e, 0x77, 0x2c, 0xe6, 0xd6, 0x23, 0x4a, 0x38, 0x3d, 0x4f, 0xda, 0x64, 0x05, 0x8a, 0x76, - 0x8c, 0x31, 0x52, 0xa4, 0x7d, 0xe9, 0xb0, 0xd4, 0xc8, 0xa1, 0xbc, 0x0d, 0x5b, 0xc4, 0xc7, 0x6e, - 0xc0, 0x95, 0x1b, 0xfb, 0xd2, 0x61, 0xa1, 0x91, 0x21, 0xbd, 0x0a, 0x3b, 0x33, 0x22, 0x0d, 0xca, - 0x42, 0x0c, 0x18, 0xd5, 0xbb, 0x70, 0xcf, 0x62, 0xee, 0x87, 0xd0, 0x21, 0x9c, 0x5a, 0x94, 0x13, - 0x87, 0x70, 0xb2, 0xc4, 0x41, 0x81, 0xa2, 0x8f, 0x81, 0xd7, 0xa6, 0x51, 0x62, 0x51, 0x6a, 0xe4, - 0x30, 0xae, 0x5c, 0xd2, 0x26, 0xf3, 0x38, 0x55, 0x36, 0xd3, 0x4a, 0x06, 0x65, 0x19, 0x0a, 0x1d, - 0x74, 0x51, 0x29, 0x24, 0xc7, 0xc9, 0x6f, 0x7d, 0x17, 0xaa, 0xd7, 0x6c, 0xc5, 0x4c, 0xef, 0xe1, - 0xbe, 0x28, 0xd6, 0xd1, 0xf7, 0x3d, 0xc6, 0x3c, 0x0c, 0x96, 0x4c, 0xa5, 0x01, 0xd8, 0x82, 0x97, - 0x0d, 0x36, 0x71, 0xa2, 0xef, 0xc1, 0xee, 0x1c, 0x41, 0xe1, 0xd7, 0x87, 0x5b, 0x16, 0x73, 0x5f, - 0xa3, 0x17, 0x9c, 0x21, 0x76, 0x96, 0xf8, 0xec, 0x40, 0x31, 0x44, 0xec, 0x5c, 0x78, 0x4e, 0xfe, - 0x81, 0x63, 0xf8, 0xca, 0x89, 0x07, 0xe8, 0x91, 0x0e, 0x71, 0x9c, 0x88, 0x32, 0x96, 0xed, 0x3f, - 0x71, 0x32, 0x71, 0x31, 0x85, 0xa9, 0x8b, 0x79, 0x90, 0x6c, 0x9a, 0x3b, 0x8b, 0x81, 0x4e, 0xa0, - 0x6c, 0x31, 0xf7, 0x2d, 0x25, 0x3d, 0xfa, 0x9f, 0x13, 0xe9, 0xdb, 0x50, 0x99, 0x94, 0x10, 0xd2, - 0x76, 0x92, 0xa7, 0xf4, 0x53, 0x9c, 0x91, 0x88, 0xf8, 0x4c, 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e8, 0x9b, 0x6f, - 0x3e, 0x7f, 0x7c, 0xf1, 0x8e, 0xf2, 0x4b, 0x8c, 0xda, 0xa6, 0xdd, 0x22, 0x5e, 0x60, 0xf6, 0xc5, - 0xe3, 0xcd, 0x07, 0x21, 0x65, 0xcd, 0xad, 0xe4, 0x1d, 0x7e, 0xf6, 0x2f, 0x00, 0x00, 0xff, 0xff, - 0x89, 0xab, 0x3b, 0x78, 0xd9, 0x05, 0x00, 0x00, + // 623 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0xdb, 0xa8, 0x25, 0x97, 0x8a, 0x87, 0x09, 0xad, 0xeb, 0xaa, 0x6e, 0xb1, 0x54, 0x68, + 0x11, 0xb5, 0x15, 0x90, 0xd8, 0x37, 0x05, 0x24, 0x1e, 0xae, 0x2a, 0x57, 0x20, 0x1e, 0x8b, 0x6a, + 0x62, 0x8f, 0x1c, 0x93, 0xd8, 0x63, 0x79, 0x26, 0x69, 0xb2, 0xe2, 0x17, 0x90, 0xf8, 0x15, 0x3e, + 0xa2, 0xcb, 0x8a, 0x15, 0x62, 0x51, 0xa1, 0x44, 0xe2, 0x3b, 0x90, 0x5f, 0x13, 0x27, 0xcd, 0x4b, + 0xb0, 0xb2, 0xef, 0xdc, 0x33, 0xe7, 0x9e, 0xb9, 0x3e, 0xd7, 0x03, 0x9b, 0x8d, 0x6e, 0x1b, 0xeb, + 0x94, 0xa1, 0x06, 0x0e, 0xa9, 0xde, 0xae, 0xd4, 0x30, 0x43, 0x15, 0x9d, 0x75, 0xb4, 0x20, 0x24, + 0x8c, 0x88, 0xe5, 0x28, 0xad, 0xa5, 0x69, 0x2d, 0x4d, 0xcb, 0xeb, 0x16, 0xa1, 0x1e, 0xa1, 0xa7, + 0x31, 0x46, 0x4f, 0x82, 0x64, 0x83, 0x5c, 0x76, 0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40, 0xe5, 0xca, 0xdc, 0x50, 0x5e, 0xf1, 0x3d, 0x5c, + 0xe3, 0xa6, 0xbd, 0x37, 0x71, 0x7b, 0x06, 0x91, 0xf7, 0x66, 0x42, 0x38, 0xf3, 0x27, 0x28, 0x0d, + 0xdc, 0xa7, 0x4e, 0xdc, 0xc7, 0x31, 0xf2, 0xc3, 0xd9, 0x18, 0x4e, 0x6e, 0xc3, 0xca, 0x90, 0xff, + 0x76, 0x66, 0x9c, 0x3c, 0x81, 0x4d, 0xf9, 0xf4, 0xe3, 0x8c, 0x56, 0x7d, 0x71, 0xde, 0x53, 0x84, + 0x8b, 0x9e, 0x22, 0xfc, 0xee, 0x29, 0xc2, 0xd7, 0xbe, 0x52, 0xb8, 0xe8, 0x2b, 0x85, 0x9f, 0x7d, + 0xa5, 0xf0, 0xf1, 0x51, 0xee, 0x0f, 0xf2, 0xfa, 0xc3, 0xbb, 0xe7, 0x47, 0x98, 0x9d, 0x91, 0xb0, + 0xa1, 0x5b, 0x75, 0xe4, 0xfa, 0x7a, 0x87, 0xdf, 0x29, 0xf1, 0xbf, 0xa4, 0xb6, 0x14, 0x5f, 0x04, + 0x4f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xb9, 0x9d, 0xe9, 0x70, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -967,6 +968,16 @@ func (m *MsgCreateStaker) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a if m.Amount != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Amount)) i-- @@ -1099,13 +1110,16 @@ func (m *MsgUpdateCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Commission) > 0 { - i -= len(m.Commission) - copy(dAtA[i:], m.Commission) - i = encodeVarintTx(dAtA, i, uint64(len(m.Commission))) - i-- - dAtA[i] = 0x12 + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) @@ -1351,6 +1365,8 @@ func (m *MsgCreateStaker) Size() (n int) { if m.Amount != 0 { n += 1 + sovTx(uint64(m.Amount)) } + l = m.Commission.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1407,10 +1423,8 @@ func (m *MsgUpdateCommission) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Commission) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } + l = m.Commission.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1592,6 +1606,40 @@ func (m *MsgCreateStaker) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", 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 + } + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1982,7 +2030,9 @@ func (m *MsgUpdateCommission) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Commission = string(dAtA[iNdEx:postIndex]) + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/team/abci.go b/x/team/abci.go index 06c72bc3..0772f18c 100644 --- a/x/team/abci.go +++ b/x/team/abci.go @@ -4,17 +4,17 @@ import ( "fmt" "github.com/KYVENetwork/chain/util" - teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" - "github.com/KYVENetwork/chain/x/team/types" sdk "github.com/cosmos/cosmos-sdk/types" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/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" // Team "github.com/KYVENetwork/chain/x/team/keeper" + "github.com/KYVENetwork/chain/x/team/types" // Upgrade upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" ) @@ -51,7 +51,7 @@ func DistributeTeamInflation(ctx sdk.Context, bk bankKeeper.Keeper, mk mintKeepe // distribute team module rewards between vesting accounts based on their vesting progress for _, account := range tk.GetTeamVestingAccounts(ctx) { // get current vesting progress - status := teamKeeper.GetVestingStatus(account, uint64(ctx.BlockTime().Unix())) + status := keeper.GetVestingStatus(account, uint64(ctx.BlockTime().Unix())) // 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