Skip to content

Commit

Permalink
x/{distribution, staking, bank, mint, crisis} genesis protobuf migrat…
Browse files Browse the repository at this point in the history
…ion (cosmos#6835)

* distribution genesis types migrated to proto

* removed types from types/genesis.go

* fix lint

* added new line proto

* staking genesis migrated to proto

* fix lint

* x/bank: genesis types migrated to proto

* fix lint

* x/mint: genesis types changed to proto

* x/crisis: genesis types changed to proto

* Migrate genesis state of x/crisis

* add new lines

* whitespace

* Fix bad merge

* added missing field

* fixed error

Co-authored-by: sahith-narahari <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
  • Loading branch information
4 people authored Jul 28, 2020
1 parent 2651427 commit b33b1e9
Show file tree
Hide file tree
Showing 16 changed files with 5,713 additions and 107 deletions.
45 changes: 45 additions & 0 deletions proto/cosmos/bank/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
syntax = "proto3";
package cosmos.bank;

import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";
import "cosmos/bank/bank.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

// GenesisState defines the bank module's genesis state.
message GenesisState {
Params params = 1 [
(gogoproto.casttype) = "Params",
(gogoproto.nullable) = false
];

repeated Balance balances = 2 [
(gogoproto.casttype) = "Balance",
(gogoproto.nullable) = false
];

repeated cosmos.Coin supply = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];

repeated Metadata denom_metadata = 4 [
(gogoproto.casttype) = "Metadata",
(gogoproto.moretags) = "yaml:\"denom_metadata\"",
(gogoproto.nullable) = false
];
}

// Balance defines an account address and balance pair used in the bank module's
// genesis state.
message Balance {
option (gogoproto.goproto_getters) = false;

bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];

repeated cosmos.Coin coins = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
16 changes: 16 additions & 0 deletions proto/cosmos/crisis/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package cosmos.crisis;

option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types";

import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";

// GenesisState - genesis state of x/crisis
message GenesisState {
cosmos.Coin constant_fee = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"constant_fee\""
];
}
186 changes: 186 additions & 0 deletions proto/cosmos/distribution/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
syntax = "proto3";
package cosmos.distribution;

option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";
import "cosmos/distribution/distribution.proto";

// genesis types

// DelegatorWithdrawInfo
// the address for where distributions rewards are withdrawn to by default
// this struct is only used at genesis to feed in default withdraw addresses
message DelegatorWithdrawInfo {
bytes delegator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"delegator_address\""
];

bytes withdraw_address = 2 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"withdraw_address\""
];
}

// ValidatorOutstandingRewardsRecord
// used for import/export via genesis json
message ValidatorOutstandingRewardsRecord {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];

repeated cosmos.DecCoin outstanding_rewards = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outstanding_rewards\""
];
}

// ValidatorAccumulatedCommissionRecord
// used for import / export via genesis json
message ValidatorAccumulatedCommissionRecord {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];

ValidatorAccumulatedCommission accumulated = 2 [
(gogoproto.casttype) = "ValidatorAccumulatedCommission",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"accumulated\""
];
}

// ValidatorHistoricalRewardsRecord
// used for import / export via genesis json
message ValidatorHistoricalRewardsRecord {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];

uint64 period = 2;

ValidatorHistoricalRewards rewards = 3[
(gogoproto.casttype) = "ValidatorHistoricalRewards",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"rewards\""
];
}

// ValidatorCurrentRewardsRecord
// used for import / export via genesis json
message ValidatorCurrentRewardsRecord {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];

ValidatorCurrentRewards rewards = 2[
(gogoproto.casttype) = "ValidatorCurrentRewards",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"rewards\""
];
}

// DelegatorStartingInfoRecord
// used for import / export via genesis json
message DelegatorStartingInfoRecord {
bytes delegator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"delegator_address\""
];

bytes validator_address = 2 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];

DelegatorStartingInfo starting_info = 3 [
(gogoproto.casttype) = "DelegatorStartingInfo",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"starting_info\""
];
}

// ValidatorSlashEventRecord
// used for import / export via genesis json
message ValidatorSlashEventRecord {
bytes validator_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
(gogoproto.moretags) = "yaml:\"validator_address\""
];
uint64 height = 2;
uint64 period = 3;
ValidatorSlashEvent event = 4 [
(gogoproto.casttype) = "ValidatorSlashEvent",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"event\""
];
}

// GenesisState - all distribution state that must be provided at genesis
message GenesisState {
Params params = 1 [
(gogoproto.casttype) = "Params",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"params\""
];

FeePool fee_pool = 2 [
(gogoproto.casttype) = "FeePool",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"fee_pool\""
];

repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 [
(gogoproto.casttype) = "DelegatorWithdrawInfo",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"delegator_withdraw_infos\""
];

bytes previous_proposer = 4 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress",
(gogoproto.moretags) = "yaml:\"previous_proposer\""
];

repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 [
(gogoproto.casttype) = "ValidatorOutstandingRewardsRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outstanding_rewards\""
];

repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 [
(gogoproto.casttype) = "ValidatorAccumulatedCommissionRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"validator_accumulated_commissions\""
];

repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 [
(gogoproto.casttype) = "ValidatorHistoricalRewardsRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"validator_historical_rewards\""
];

repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 [
(gogoproto.casttype) = "ValidatorCurrentRewardsRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"validator_current_rewards\""
];

repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 [
(gogoproto.casttype) = "DelegatorStartingInfoRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"delegator_starting_infos\""
];

repeated ValidatorSlashEventRecord validator_slash_events = 10 [
(gogoproto.casttype) = "ValidatorSlashEventRecord",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"validator_slash_events\""
];
}
20 changes: 20 additions & 0 deletions proto/cosmos/mint/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package cosmos.mint;

import "gogoproto/gogo.proto";
import "cosmos/mint/mint.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types";

// GenesisState - minter state
message GenesisState {
Minter minter = 1 [
(gogoproto.casttype) = "Minter",
(gogoproto.nullable) = false
];

Params params = 2 [
(gogoproto.casttype) = "Params",
(gogoproto.nullable) = false
];
}
52 changes: 52 additions & 0 deletions proto/cosmos/staking/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package cosmos.staking;

option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types";

import "gogoproto/gogo.proto";
import "cosmos/staking/staking.proto";

// GenesisState - all staking state that must be provided at genesis
message GenesisState {
Params params = 1 [(gogoproto.casttype) = "Params", (gogoproto.nullable) = false];
bytes last_total_power = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"last_total_power\"",
(gogoproto.nullable) = false
];

repeated LastValidatorPower last_validator_powers = 3 [
(gogoproto.casttype) = "LastValidatorPower",
(gogoproto.moretags) = "yaml:\"last_validator_powers\"",
(gogoproto.nullable) = false
];

repeated Validator validators = 4 [
(gogoproto.casttype) = "Validator",
(gogoproto.nullable) = false
];

repeated Delegation delegations = 5 [
(gogoproto.casttype) = "Delegation",
(gogoproto.nullable) = false
];

repeated UnbondingDelegation unbonding_delegations = 6 [
(gogoproto.casttype) = "UnbondingDelegation",
(gogoproto.moretags) = "yaml:\"unbonding_delegations\"",
(gogoproto.nullable) = false
];

repeated Redelegation redelegations = 7 [
(gogoproto.casttype) = "Redelegation",
(gogoproto.nullable) = false
];

bool exported = 8;
}

// LastValidatorPower required for validator set update logic
message LastValidatorPower {
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
int64 power = 2;
}
3 changes: 2 additions & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"

servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
)

type IntegrationTestSuite struct {
Expand Down
15 changes: 0 additions & 15 deletions x/bank/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ import (

var _ exported.GenesisBalance = (*Balance)(nil)

// GenesisState defines the bank module's genesis state.
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
Balances []Balance `json:"balances" yaml:"balances"`
Supply sdk.Coins `json:"supply" yaml:"supply"`
DenomMetadata []Metadata `json:"denom_metadata" yaml:"denom_metadata"`
}

// Balance defines an account address and balance pair used in the bank module's
// genesis state.
type Balance struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
}

// GetAddress returns the account address of the Balance object.
func (b Balance) GetAddress() sdk.AccAddress {
return b.Address
Expand Down
Loading

0 comments on commit b33b1e9

Please sign in to comment.