Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Keefe Liu committed Dec 3, 2022
1 parent 0009760 commit 0d22fb2
Show file tree
Hide file tree
Showing 31 changed files with 1,340 additions and 1,350 deletions.
31 changes: 19 additions & 12 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,49 @@ message Validator {

// operator_address defines the address of the validator's operator; bech encoded in JSON.
string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// bls_pubkey defines the bls pubkey of the validator's authorized relayer/operator; bech encoded in JSON.
string bls_pubkey = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// consensus_pubkey is the consensus public key of the validator, as a Protobuf Any.
google.protobuf.Any consensus_pubkey = 3 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
google.protobuf.Any consensus_pubkey = 2 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
// jailed defined whether the validator has been jailed from bonded status or not.
bool jailed = 4;
bool jailed = 3;
// status is the validator status (bonded/unbonding/unbonded).
BondStatus status = 5;
BondStatus status = 4;
// tokens define the delegated tokens (incl. self-delegation).
string tokens = 6 [
string tokens = 5 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// delegator_shares defines total shares issued to a validator's delegators.
string delegator_shares = 7 [
string delegator_shares = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// description defines the description terms for the validator.
Description description = 8 [(gogoproto.nullable) = false];
Description description = 7 [(gogoproto.nullable) = false];
// unbonding_height defines, if unbonding, the height at which this validator has begun unbonding.
int64 unbonding_height = 9;
int64 unbonding_height = 8;
// unbonding_time defines, if unbonding, the min time for the validator to complete unbonding.
google.protobuf.Timestamp unbonding_time = 10 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
google.protobuf.Timestamp unbonding_time = 9 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// commission defines the commission parameters.
Commission commission = 11 [(gogoproto.nullable) = false];
Commission commission = 10 [(gogoproto.nullable) = false];
// min_self_delegation is the validator's self declared minimum self delegation.
//
// Since: cosmos-sdk 0.46
string min_self_delegation = 12 [
string min_self_delegation = 11 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
//
// For BNB Inscription
//
// self_delegation_address defines the address of the validator for self delegation ; bech encoded in JSON.
string self_delegation_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// bls_pubkey defines the bls pubkey of the validator's authorized relayer/operator;
bytes bls_pubkey = 13;
// removed defined whether the validator has been removed by governance or not.
bool removed = 14;
}

// BondStatus is the status of a validator.
Expand Down
57 changes: 21 additions & 36 deletions proto/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,29 @@ service Msg {
// RemoveValidator defines a method for removing an existing validator.
rpc RemoveValidator(MsgRemoveValidator) returns (MsgRemoveValidatorResponse);

// SelfDelegate defines a method for performing a delegation of coins
// for a validator itself.
rpc SelfDelegate(MsgSelfDelegate) returns (MsgSelfDelegateResponse);

// Delegate defines a method for performing a delegation of coins
// from a delegator to a validator.
// rpc Delegate(MsgDelegate) returns (MsgDelegateResponse);
rpc Delegate(MsgDelegate) returns (MsgDelegateResponse);

// BeginRedelegate defines a method for performing a redelegation
// of coins from a delegator and source validator to a destination validator.
// rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse);
rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse);

// Undelegate defines a method for performing an undelegation from a
// delegate and a validator.
// rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse);
rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse);

// CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation
// and delegate back to previous validator.
//
// Since: cosmos-sdk 0.46
// rpc CancelUnbondingDelegation(MsgCancelUnbondingDelegation) returns (MsgCancelUnbondingDelegationResponse);
rpc CancelUnbondingDelegation(MsgCancelUnbondingDelegation) returns (MsgCancelUnbondingDelegationResponse);
}

// MsgCreateValidator defines a SDK message for creating a new validator.
message MsgCreateValidator {
// NOTE(fdymylja): this is a particular case in which
// if validator_address == delegator_address then only one
// is expected to sign, otherwise both are.
option (cosmos.msg.v1.signer) = "delegator_address";
option (cosmos.msg.v1.signer) = "validator_address";
// NOTE: The validator should be created by the gov module account after the proposal passes.
option (cosmos.msg.v1.signer) = "from";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Expand All @@ -67,10 +60,12 @@ message MsgCreateValidator {
];
string delegator_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string bls_pubkey = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"];
google.protobuf.Any pubkey = 7 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
cosmos.base.v1beta1.Coin value = 8 [(gogoproto.nullable) = false];
uint64 proposal_id = 9;
google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false];

// For BNB Inscription
string from = 8 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string bls_pubkey = 9;
}

// MsgCreateValidatorResponse defines the Msg/CreateValidator response type.
Expand All @@ -85,49 +80,39 @@ message MsgEditValidator {

Description description = 1 [(gogoproto.nullable) = false];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string bls_pubkey = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// We pass a reference to the new commission rate and min self delegation as
// it's not mandatory to update. If not updated, the deserialized rate will be
// zero with no way to distinguish if an update was intended.
// REF: #2373
string commission_rate = 4
string commission_rate = 3
[(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"];
string min_self_delegation = 5
string min_self_delegation = 4
[(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];

// For BNB Inscription
string self_delegation_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string bls_pubkey = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgEditValidatorResponse defines the Msg/EditValidator response type.
message MsgEditValidatorResponse {}

// MsgRemoveValidator defines a SDK message for removing an existing validator.
message MsgRemoveValidator {
option (cosmos.msg.v1.signer) = "validator_address";
// NOTE: The validator should be removed by the gov module account after the proposal passes.
option (cosmos.msg.v1.signer) = "from";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 proposal_id = 2;
string from = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgRemoveValidatorResponse defines the Msg/RemoveValidator response type.
message MsgRemoveValidatorResponse {}

// MsgSelfDelegate defines a SDK message for performing a delegation of coins
// for a validator itself.
message MsgSelfDelegate {
option (cosmos.msg.v1.signer) = "validator_address";

option (gogoproto.equal) = false;

string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
}

// MsgSelfDelegateResponse defines the Msg/SelfDelegate response type.
message MsgSelfDelegateResponse {}

// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message MsgDelegate {
Expand Down
2 changes: 1 addition & 1 deletion x/auth/migrations/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i
app.GetSubspace(stakingtypes.ModuleName),
)

val1, err := stakingtypes.NewValidator(valAddrs[0], pks[0], stakingtypes.Description{})
val1, err := stakingtypes.NewSimpleValidator(valAddrs[0], pks[0], stakingtypes.Description{})
require.NoError(t, err)

app.StakingKeeper.SetValidator(ctx, val1)
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (suite *SimTestSuite) getTestingValidator(accounts []simtypes.Account, comm
account := accounts[n]
valPubKey := account.PubKey
valAddr := sdk.ValAddress(account.PubKey.Address().Bytes())
validator, err := stakingtypes.NewValidator(valAddr, valPubKey, stakingtypes.
validator, err := stakingtypes.NewSimpleValidator(valAddr, valPubKey, stakingtypes.
Description{})
require.NoError(err)
validator, err = validator.SetInitialCommission(commission)
Expand Down
6 changes: 3 additions & 3 deletions x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
app.GetSubspace(stakingtypes.ModuleName),
)

val1, err := stakingtypes.NewValidator(valAddrs[0], pks[0], stakingtypes.Description{})
val1, err := stakingtypes.NewSimpleValidator(valAddrs[0], pks[0], stakingtypes.Description{})
require.NoError(t, err)
val2, err := stakingtypes.NewValidator(valAddrs[1], pks[1], stakingtypes.Description{})
val2, err := stakingtypes.NewSimpleValidator(valAddrs[1], pks[1], stakingtypes.Description{})
require.NoError(t, err)
val3, err := stakingtypes.NewValidator(valAddrs[2], pks[2], stakingtypes.Description{})
val3, err := stakingtypes.NewSimpleValidator(valAddrs[2], pks[2], stakingtypes.Description{})
require.NoError(t, err)

app.StakingKeeper.SetValidator(ctx, val1)
Expand Down
32 changes: 0 additions & 32 deletions x/gov/keeper/validator.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/group/client/testutil/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
val := s.network.Validators[0]

// create a new account
info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSimpleValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
s.Require().NoError(err)

pk, err := info.GetPubKey()
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/keeper/unjail.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (k Keeper) Unjail(ctx sdk.Context, validatorAddr sdk.ValAddress) error {
}

// cannot be unjailed if no self-delegation exists
selfDel := k.sk.Delegation(ctx, sdk.AccAddress(validatorAddr), validatorAddr)
selfDel := k.sk.Delegation(ctx, validator.GetSelfDelegator(), validatorAddr)
if selfDel == nil {
return types.ErrMissingSelfDelegation
}
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func getTestingValidator(t *testing.T, app *simapp.SimApp, ctx sdk.Context, acco
account := accounts[n]
valPubKey := account.ConsKey.PubKey()
valAddr := sdk.ValAddress(account.PubKey.Address().Bytes())
validator, err := stakingtypes.NewValidator(valAddr, valPubKey, stakingtypes.Description{})
validator, err := stakingtypes.NewSimpleValidator(valAddr, valPubKey, stakingtypes.Description{})
require.NoError(t, err)
validator, err = validator.SetInitialCommission(commission)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions x/staking/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
require.NoError(err)
require.NotNil(consPubKeyBz)

k, _, err := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
k, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSimpleValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
require.NoError(err)

pub, err := k.GetPubKey()
Expand Down Expand Up @@ -191,7 +191,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
[]string{
fmt.Sprintf("--%s=%s", cli.FlagPubKey, consPubKeyBz),
fmt.Sprintf("--%s=%dstake", cli.FlagAmount, 100),
fmt.Sprintf("--%s=NewValidator", cli.FlagMoniker),
fmt.Sprintf("--%s=NewSimpleValidator", cli.FlagMoniker),
fmt.Sprintf("--%s=AFAF00C4", cli.FlagIdentity),
fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite),
fmt.Sprintf("--%[email protected]", cli.FlagSecurityContact),
Expand Down
20 changes: 0 additions & 20 deletions x/staking/keeper/alias_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,6 @@ func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress,
}
}

// iterate through all of the delegations to a validator
func (k Keeper) IterateDelegationsToValidator(ctx sdk.Context, valAddr sdk.AccAddress,
fn func(del types.DelegationI) (stop bool),
) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DelegationKey)
defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
del := types.MustUnmarshalDelegation(k.cdc, iterator.Value())
if del.ValidatorAddress != valAddr.String() {
continue
}
stop := fn(del)
if stop {
break
}
}
}

// return all delegations used during genesis dump
// TODO: remove this func, change all usage for iterate functionality
func (k Keeper) GetAllSDKDelegations(ctx sdk.Context) (delegations []types.Delegation) {
Expand Down
6 changes: 3 additions & 3 deletions x/staking/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,11 @@ func (k Keeper) Unbond(
return amount, err
}

isValidatorOperator := delegatorAddress.Equals(validator.GetOperator())
isSelfDelegator := delegatorAddress.Equals(validator.GetSelfDelegator())

// If the delegation is the operator of the validator and undelegating will decrease the validator's
// If the delegation is the self delegator of the validator and undelegating will decrease the validator's
// self-delegation below their minimum, we jail the validator.
if isValidatorOperator && !validator.Jailed &&
if isSelfDelegator && !validator.Jailed &&
validator.TokensFromShares(delegation.Shares).TruncateInt().LT(validator.MinSelfDelegation) {
k.jailValidator(ctx, validator)
validator = k.mustGetValidator(ctx, validator.GetOperator())
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) {

bondedPoolAmt := sdk.ZeroInt()
for i := range validators {
validators[i], err = types.NewValidator(
validators[i], err = types.NewSimpleValidator(
sdk.ValAddress(addrs[i]),
PKs[i],
types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", ""),
Expand Down
1 change: 0 additions & 1 deletion x/staking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Keeper struct {
cdc codec.BinaryCodec
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
govKeeper types.GovKeeper // TODO: how to init this keeper?
hooks types.StakingHooks
paramstore paramtypes.Subspace
}
Expand Down
Loading

0 comments on commit 0d22fb2

Please sign in to comment.