Skip to content

Commit

Permalink
refactor: incorporate code review changes (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: mbreithecker <max@kyve.network>
  • Loading branch information
johnletey and mbreithecker authored Mar 31, 2023
1 parent 94aeb3a commit 5e7292e
Show file tree
Hide file tree
Showing 76 changed files with 2,460 additions and 839 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ func NewKYVEApp(
app.PoolKeeper,
app.StakersKeeper,
app.DelegationKeeper,
app.UpgradeKeeper,
)

// Create IBC Keepers
Expand Down
13 changes: 13 additions & 0 deletions proto/kyve/bundles/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion proto/kyve/bundles/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 13 additions & 0 deletions proto/kyve/delegation/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions proto/kyve/delegation/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
];
}
19 changes: 19 additions & 0 deletions proto/kyve/global/v1beta1/events.proto
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 9 additions & 2 deletions proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
19 changes: 18 additions & 1 deletion proto/kyve/stakers/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ...
Expand Down
12 changes: 10 additions & 2 deletions proto/kyve/stakers/v1beta1/stakers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ...
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 14 additions & 4 deletions proto/kyve/stakers/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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.
Expand All @@ -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 ...
Expand Down
7 changes: 7 additions & 0 deletions testutil/integration/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading

0 comments on commit 5e7292e

Please sign in to comment.