From 30313447173e7bc2dd1b157a84c73670c5ff0259 Mon Sep 17 00:00:00 2001 From: Toshihito Kikuchi Date: Thu, 21 Dec 2023 07:26:27 -0800 Subject: [PATCH] s/Delegators/RewardDelegators/g --- app/cmd/cli/node.go | 4 +- app/cmd/cli/txUtil.go | 2 +- app/cmd/rpc/rpc_test.go | 6 +- codec/codec.go | 6 +- proto/x/nodes/msg.proto | 6 +- proto/x/nodes/nodes.proto | 2 +- x/nodes/handler.go | 6 +- x/nodes/keeper/reward.go | 8 +- x/nodes/keeper/reward_test.go | 4 +- x/nodes/keeper/valStateChanges.go | 9 +- x/nodes/keeper/valStateChanges_test.go | 32 +++--- x/nodes/keeper/validator.go | 4 +- x/nodes/keeper/validator_test.go | 15 +-- x/nodes/types/errors.go | 8 +- x/nodes/types/msg.go | 56 +++++----- x/nodes/types/msg.pb.go | 127 +++++++++++------------ x/nodes/types/msg_test.go | 32 +++--- x/nodes/types/nodes.pb.go | 135 +++++++++++++------------ x/nodes/types/validator.go | 58 ++++++----- x/nodes/types/validator_legacy.go | 2 +- 20 files changed, 269 insertions(+), 253 deletions(-) diff --git a/app/cmd/cli/node.go b/app/cmd/cli/node.go index c7cb29384..acb74c8bf 100644 --- a/app/cmd/cli/node.go +++ b/app/cmd/cli/node.go @@ -121,7 +121,7 @@ Will prompt the user for the account passphrase.`, // stakeNewCmd is an upgraded version of `nodesCmd` that captures newer // on-chain functionality in a cleaner way var stakeNewCmd = &cobra.Command{ - Use: "stakeNew [Memo]", + Use: "stakeNew [Memo]", Short: "Stake a node in the network", Long: `Stake a node in the network, promoting it to a servicer or a validator. @@ -133,7 +133,7 @@ The command takes the following parameters. Stake Amount to stake in uPOKT ChainIDs Comma-separated chain IDs to host on the node ServiceURL Relay endpoint of the node. Must include the port number. - Delegators Delegator addresses to share rewards + RewardDelegators Addresses to share rewards NetworkID Network ID to submit a transaction to e.g. mainnet or testnet Fee Transaction fee in uPOKT Memo Optional. Text to include in the transaction. No functional effect. diff --git a/app/cmd/cli/txUtil.go b/app/cmd/cli/txUtil.go index 6232ee5b9..0bccd4943 100644 --- a/app/cmd/cli/txUtil.go +++ b/app/cmd/cli/txUtil.go @@ -305,7 +305,7 @@ func BuildStakeTx( } if len(delegatorsStr) > 0 { - if json.Unmarshal([]byte(delegatorsStr), &msg.Delegators); err != nil { + if json.Unmarshal([]byte(delegatorsStr), &msg.RewardDelegators); err != nil { return nil, err } } diff --git a/app/cmd/rpc/rpc_test.go b/app/cmd/rpc/rpc_test.go index ce542afe9..976ba811f 100644 --- a/app/cmd/rpc/rpc_test.go +++ b/app/cmd/rpc/rpc_test.go @@ -1651,7 +1651,7 @@ func generateTestTx() (string, error) { Value: types.NewInt(8000000000000), ServiceUrl: "https://x.com:443", Output: outputAddr, - Delegators: map[string]uint32{ + RewardDelegators: map[string]uint32{ "1000000000000000000000000000000000000000": 1, "2000000000000000000000000000000000000000": 2, }, @@ -1722,7 +1722,7 @@ func TestMsgStake_Marshaling_BackwardCompatibility(t *testing.T) { assert.Nil(t, err) msgStake, ok := stdTx.Msg.(*types2.MsgStake) assert.True(t, ok) - assert.Nil(t, msgStake.Delegators) + assert.Nil(t, msgStake.RewardDelegators) assert.Nil(t, msgStake.ValidateBasic()) // Validate that an old stake messages DOES have delegators @@ -1730,6 +1730,6 @@ func TestMsgStake_Marshaling_BackwardCompatibility(t *testing.T) { assert.Nil(t, err) msgStake, ok = stdTx.Msg.(*types2.MsgStake) assert.True(t, ok) - assert.NotNil(t, msgStake.Delegators) + assert.NotNil(t, msgStake.RewardDelegators) assert.Nil(t, msgStake.ValidateBasic()) } diff --git a/codec/codec.go b/codec/codec.go index 18ca368c5..817606f2c 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -60,7 +60,7 @@ const ( ClearUnjailedValSessionKey = "CRVAL" PerChainRTTM = "PerChainRTTM" AppTransferKey = "AppTransfer" - RewardsDelegatorKey = "RewardDelegator" + RewardDelegatorsKey = "RewardDelegators" ) func GetCodecUpgradeHeight() int64 { @@ -296,8 +296,8 @@ func (cdc *Codec) IsAfterAppTransferUpgrade(height int64) bool { } func (cdc *Codec) IsAfterDelegatorUpgrade(height int64) bool { - return (UpgradeFeatureMap[RewardsDelegatorKey] != 0 && - height >= UpgradeFeatureMap[RewardsDelegatorKey]) || + return (UpgradeFeatureMap[RewardDelegatorsKey] != 0 && + height >= UpgradeFeatureMap[RewardDelegatorsKey]) || TestMode <= -3 } diff --git a/proto/x/nodes/msg.proto b/proto/x/nodes/msg.proto index 053366d82..8e0a49d84 100755 --- a/proto/x/nodes/msg.proto +++ b/proto/x/nodes/msg.proto @@ -24,9 +24,9 @@ message MsgProtoStake { (gogoproto.moretags) = "yaml:\"output_address\"" ]; // Mapping from delegated-to addresses to a percentage of rewards. - map Delegators = 6 [ - (gogoproto.jsontag) = "delegators,omitempty", - (gogoproto.moretags) = "yaml:\"delegators\"" + map RewardDelegators = 6 [ + (gogoproto.jsontag) = "reward_delegators,omitempty", + (gogoproto.moretags) = "yaml:\"reward_delegators\"" ]; } diff --git a/proto/x/nodes/nodes.proto b/proto/x/nodes/nodes.proto index 23688173d..58ddf12bf 100755 --- a/proto/x/nodes/nodes.proto +++ b/proto/x/nodes/nodes.proto @@ -20,7 +20,7 @@ message ProtoValidator { string StakedTokens = 7 [(gogoproto.customtype) = "github.com/pokt-network/pocket-core/types.BigInt", (gogoproto.jsontag) = "tokens", (gogoproto.nullable) = false]; google.protobuf.Timestamp UnstakingCompletionTime = 8 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.jsontag) = "unstaking_time", (gogoproto.moretags) = "yaml:\"unstaking_time\""]; bytes OutputAddress = 9 [(gogoproto.casttype) = "github.com/pokt-network/pocket-core/types.Address", (gogoproto.jsontag) = "output_address,omitempty", (gogoproto.moretags) = "yaml:\"output_address\""]; - map Delegators = 10 [(gogoproto.jsontag) = "delegators,omitempty", (gogoproto.moretags) = "yaml:\"delegators\""]; + map RewardDelegators = 10 [(gogoproto.jsontag) = "reward_delegators,omitempty", (gogoproto.moretags) = "yaml:\"reward_delegators\""]; } message LegacyProtoValidator { diff --git a/x/nodes/handler.go b/x/nodes/handler.go index aabf1b3a7..139d30b17 100644 --- a/x/nodes/handler.go +++ b/x/nodes/handler.go @@ -61,12 +61,12 @@ func handleStake(ctx sdk.Ctx, msg types.MsgStake, k keeper.Keeper, signer crypto } if k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) { - if err := msg.CheckDelegators(); err != nil { + if err := msg.CheckRewardDelegators(); err != nil { return err.Result() } - } else if msg.Delegators != nil { + } else if msg.RewardDelegators != nil { // Ignore the delegators field before the upgrade - msg.Delegators = nil + msg.RewardDelegators = nil } validator := types.NewValidatorFromMsg(msg) diff --git a/x/nodes/keeper/reward.go b/x/nodes/keeper/reward.go index 78ee078e2..6ac69d238 100644 --- a/x/nodes/keeper/reward.go +++ b/x/nodes/keeper/reward.go @@ -146,7 +146,7 @@ func (k Keeper) RewardForRelaysPerChain(ctx sdk.Ctx, chain string, relays sdk.Bi ctx.Logger(), toNode, address, - validator.Delegators, + validator.RewardDelegators, func(recipient sdk.Address, share sdk.BigInt) { k.mint(ctx, share, recipient) }, @@ -180,7 +180,7 @@ func SplitNodeRewards( return errors.New("non-positive rewards") } - normalizedDelegators, err := types.NormalizeDelegators(delegators) + normalizedDelegators, err := types.NormalizeRewardDelegators(delegators) if err != nil { // If the delegators field is invalid, do nothing. return errors.New("invalid delegators") @@ -255,14 +255,14 @@ func (k Keeper) blockReward(ctx sdk.Ctx, previousProposer sdk.Address) { } if !k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) { - validator.Delegators = nil + validator.RewardDelegators = nil } err := SplitNodeRewards( ctx.Logger(), proposerCut, k.GetOutputAddressFromValidator(validator), - validator.Delegators, + validator.RewardDelegators, func(recipient sdk.Address, share sdk.BigInt) { err = k.AccountKeeper.SendCoins( ctx, diff --git a/x/nodes/keeper/reward_test.go b/x/nodes/keeper/reward_test.go index 0228fca27..509bb1717 100644 --- a/x/nodes/keeper/reward_test.go +++ b/x/nodes/keeper/reward_test.go @@ -564,10 +564,10 @@ func TestKeeper_RewardForRelaysPerChain(t *testing.T) { assert.True(t, rewardsHighProfit.Equal(expectedRewardsHighProfit)) assert.True(t, rewardsDefault.LT(rewardsHighProfit)) - // After the RewardsDelegator upgrade, a servicer is compensated for + // After the RewardDelegators upgrade, a servicer is compensated for // the reward cost (= transactions fees). Therefore the expected rewards // is decreased by the reward cost. - codec.UpgradeFeatureMap[codec.RewardsDelegatorKey] = Height_Delegator + codec.UpgradeFeatureMap[codec.RewardDelegatorsKey] = Height_Delegator rewardCost := keeper.GetRewardCost(ctx) expectedRewardsHighProfit = expectedRewardsHighProfit.Sub(rewardCost) rewardsHighProfit = keeper.RewardForRelaysPerChain( diff --git a/x/nodes/keeper/valStateChanges.go b/x/nodes/keeper/valStateChanges.go index a33be05b8..505d10643 100644 --- a/x/nodes/keeper/valStateChanges.go +++ b/x/nodes/keeper/valStateChanges.go @@ -262,11 +262,14 @@ func (k Keeper) ValidateEditStake(ctx sdk.Ctx, currentValidator, newValidtor typ } } - // Delegators can be set/edited only if: + // RewardDelegators can be set/edited only if: // 1) The feature has been activated AND // 2) the message is signed by the operator address. if k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) && - !types.CompareStringMaps(currentValidator.Delegators, newValidtor.Delegators) && + !types.CompareStringMaps( + currentValidator.RewardDelegators, + newValidtor.RewardDelegators, + ) && !signer.Equals(currentValidator.Address) { return types.ErrDisallowedDelegatorEdit(k.Codespace()) } @@ -341,7 +344,7 @@ func (k Keeper) EditStakeValidator(ctx sdk.Ctx, currentValidator, updatedValidat // After the upgrade, we allow delegators change if k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) { - currentValidator.Delegators = updatedValidator.Delegators + currentValidator.RewardDelegators = updatedValidator.RewardDelegators } } // update chains diff --git a/x/nodes/keeper/valStateChanges_test.go b/x/nodes/keeper/valStateChanges_test.go index b08642556..89116db04 100644 --- a/x/nodes/keeper/valStateChanges_test.go +++ b/x/nodes/keeper/valStateChanges_test.go @@ -500,13 +500,13 @@ func TestValidatorStateChange_Delegators(t *testing.T) { originalTestMode := codec.TestMode originalNCUST := codec.UpgradeFeatureMap[codec.NonCustodialUpdateKey] originalOEDIT := codec.UpgradeFeatureMap[codec.OutputAddressEditKey] - originalReward := codec.UpgradeFeatureMap[codec.RewardsDelegatorKey] + originalReward := codec.UpgradeFeatureMap[codec.RewardDelegatorsKey] t.Cleanup(func() { codec.UpgradeHeight = originalUpgradeHeight codec.TestMode = originalTestMode codec.UpgradeFeatureMap[codec.NonCustodialUpdateKey] = originalNCUST codec.UpgradeFeatureMap[codec.OutputAddressEditKey] = originalOEDIT - codec.UpgradeFeatureMap[codec.RewardsDelegatorKey] = originalReward + codec.UpgradeFeatureMap[codec.RewardDelegatorsKey] = originalReward }) // Enable EditStake, NCUST, and OEDIT @@ -534,12 +534,12 @@ func TestValidatorStateChange_Delegators(t *testing.T) { signer crypto.PublicKey, ) sdk.Error { msgStake := types.MsgStake{ - Chains: []string{"0021", "0040"}, - ServiceUrl: "https://www.pokt.network:443", - Value: stakeAmount.Amount, - PublicKey: operatorPubkey, - Output: outputAddress, - Delegators: delegators, + Chains: []string{"0021", "0040"}, + ServiceUrl: "https://www.pokt.network:443", + Value: stakeAmount.Amount, + PublicKey: operatorPubkey, + Output: outputAddress, + RewardDelegators: delegators, } return handleStakeForTesting(ctx, k, msgStake, signer) } @@ -551,10 +551,10 @@ func TestValidatorStateChange_Delegators(t *testing.T) { assert.Nil(t, runStake(operatorPubKey1, singleDelegator, outputPubKey)) validatorCur, found := k.GetValidator(ctx, operatorAddr1) assert.True(t, found) - assert.Nil(t, validatorCur.Delegators) + assert.Nil(t, validatorCur.RewardDelegators) // Enable DELE - codec.UpgradeFeatureMap[codec.RewardsDelegatorKey] = -1 + codec.UpgradeFeatureMap[codec.RewardDelegatorsKey] = -1 // Attempt to change the delegators with output's signature --> Fail err := runStake(operatorPubKey1, singleDelegator, outputPubKey) @@ -567,21 +567,27 @@ func TestValidatorStateChange_Delegators(t *testing.T) { assert.Nil(t, err) validatorCur, found = k.GetValidator(ctx, operatorAddr1) assert.True(t, found) - assert.True(t, types.CompareStringMaps(validatorCur.Delegators, singleDelegator)) + assert.True( + t, + types.CompareStringMaps(validatorCur.RewardDelegators, singleDelegator), + ) // Attempt to reset the delegators with operator's signature --> Success err = runStake(operatorPubKey1, nil, operatorPubKey1) assert.Nil(t, err) validatorCur, found = k.GetValidator(ctx, operatorAddr1) assert.True(t, found) - assert.Nil(t, validatorCur.Delegators) + assert.Nil(t, validatorCur.RewardDelegators) // New stake with delegators can be signed by the output --> Success err = runStake(operatorPubKey2, singleDelegator, outputPubKey) assert.Nil(t, err) validatorCur, found = k.GetValidator(ctx, operatorAddr2) assert.True(t, found) - assert.True(t, types.CompareStringMaps(validatorCur.Delegators, singleDelegator)) + assert.True( + t, + types.CompareStringMaps(validatorCur.RewardDelegators, singleDelegator), + ) } func TestKeeper_JailValidator(t *testing.T) { diff --git a/x/nodes/keeper/validator.go b/x/nodes/keeper/validator.go index b5210b384..8ea736c1c 100644 --- a/x/nodes/keeper/validator.go +++ b/x/nodes/keeper/validator.go @@ -12,7 +12,7 @@ import ( func (k Keeper) MarshalValidator(ctx sdk.Ctx, validator types.Validator) ([]byte, error) { if k.Cdc.IsAfterNonCustodialUpgrade(ctx.BlockHeight()) { if !k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) { - validator.Delegators = nil + validator.RewardDelegators = nil } bz, err := k.Cdc.MarshalBinaryLengthPrefixed(&validator, ctx.BlockHeight()) if err != nil { @@ -33,7 +33,7 @@ func (k Keeper) UnmarshalValidator(ctx sdk.Ctx, valBytes []byte) (val types.Vali err = k.Cdc.UnmarshalBinaryLengthPrefixed(valBytes, &val, ctx.BlockHeight()) if err == nil { if !k.Cdc.IsAfterDelegatorUpgrade(ctx.BlockHeight()) { - val.Delegators = nil + val.RewardDelegators = nil } } else { ctx.Logger().Error("could not unmarshal validator: " + err.Error()) diff --git a/x/nodes/keeper/validator_test.go b/x/nodes/keeper/validator_test.go index dc786599f..befbb420d 100644 --- a/x/nodes/keeper/validator_test.go +++ b/x/nodes/keeper/validator_test.go @@ -176,9 +176,9 @@ func TestValidator_Proto_MarshalingCompatibility(t *testing.T) { val_1 = getStakedValidator() val_1.OutputAddress = getRandomValidatorAddress() - val_1.Delegators = map[string]uint32{} - val_1.Delegators[getRandomValidatorAddress().String()] = 10 - val_1.Delegators[getRandomValidatorAddress().String()] = 20 + val_1.RewardDelegators = map[string]uint32{} + val_1.RewardDelegators[getRandomValidatorAddress().String()] = 10 + val_1.RewardDelegators[getRandomValidatorAddress().String()] = 20 valL_1 = val_1.ToLegacy() // Validator --> []byte --> Validator @@ -190,8 +190,11 @@ func TestValidator_Proto_MarshalingCompatibility(t *testing.T) { assert.Nil(t, err) assert.True(t, val_2.ToLegacy().Equals(val_1.ToLegacy())) assert.True(t, val_2.OutputAddress.Equals(val_1.OutputAddress)) - assert.NotNil(t, val_2.Delegators) - assert.True(t, types.CompareStringMaps(val_2.Delegators, val_1.Delegators)) + assert.NotNil(t, val_2.RewardDelegators) + assert.True( + t, + types.CompareStringMaps(val_2.RewardDelegators, val_1.RewardDelegators), + ) // Validator --> []byte --> LegacyValidator marshaled, err = Marshal(&val_1) @@ -211,5 +214,5 @@ func TestValidator_Proto_MarshalingCompatibility(t *testing.T) { assert.Nil(t, err) assert.True(t, val_2.ToLegacy().Equals(valL_1)) assert.Nil(t, val_2.OutputAddress) - assert.Nil(t, val_2.Delegators) + assert.Nil(t, val_2.RewardDelegators) } diff --git a/x/nodes/types/errors.go b/x/nodes/types/errors.go index 145ad29bf..d91ba4b88 100644 --- a/x/nodes/types/errors.go +++ b/x/nodes/types/errors.go @@ -37,7 +37,7 @@ const ( CodeUnauthorizedSigner CodeType = 125 CodeNilSigner CodeType = 126 CodeDisallowedOutputAddressEdit CodeType = 127 - CodeInvalidaDelegators CodeType = 128 + CodeInvalidDelegators CodeType = 128 CodeDisallowedDelegatorEdit CodeType = 129 ) @@ -164,11 +164,11 @@ func ErrDisallowedOutputAddressEdit(codespace sdk.CodespaceType) sdk.Error { } func ErrInvalidDelegators(codespace sdk.CodespaceType, reason string) sdk.Error { - return sdk.NewError(codespace, CodeInvalidaDelegators, - "Invalid delegators: %s", reason) + return sdk.NewError(codespace, CodeInvalidDelegators, + "Invalid reward delegators: %s", reason) } func ErrDisallowedDelegatorEdit(codespace sdk.CodespaceType) sdk.Error { return sdk.NewError(codespace, CodeDisallowedDelegatorEdit, - "Only the node operator address can edit delegators") + "Only the node operator address can edit reward delegators") } diff --git a/x/nodes/types/msg.go b/x/nodes/types/msg.go index 675f25e15..4e0b01213 100644 --- a/x/nodes/types/msg.go +++ b/x/nodes/types/msg.go @@ -148,12 +148,12 @@ var _ codec.ProtoMarshaler = &MsgStake{} // MsgStake - struct for staking transactions type MsgStake struct { - PublicKey crypto.PublicKey `json:"public_key" yaml:"public_key"` - Chains []string `json:"chains" yaml:"chains"` - Value sdk.BigInt `json:"value" yaml:"value"` - ServiceUrl string `json:"service_url" yaml:"service_url"` - Output sdk.Address `json:"output_address,omitempty" yaml:"output_address"` - Delegators map[string]uint32 `json:"delegators,omitempty" yaml:"delegators"` + PublicKey crypto.PublicKey `json:"public_key" yaml:"public_key"` + Chains []string `json:"chains" yaml:"chains"` + Value sdk.BigInt `json:"value" yaml:"value"` + ServiceUrl string `json:"service_url" yaml:"service_url"` + Output sdk.Address `json:"output_address,omitempty" yaml:"output_address"` + RewardDelegators map[string]uint32 `json:"reward_delegators,omitempty" yaml:"reward_delegators"` } func (msg *MsgStake) Marshal() ([]byte, error) { @@ -187,12 +187,12 @@ func (msg *MsgStake) Unmarshal(data []byte) error { return err } newMsg := MsgStake{ - PublicKey: publicKey, - Chains: m.Chains, - Value: m.Value, - ServiceUrl: m.ServiceUrl, - Output: m.OutputAddress, - Delegators: m.Delegators, + PublicKey: publicKey, + Chains: m.Chains, + Value: m.Value, + ServiceUrl: m.ServiceUrl, + Output: m.OutputAddress, + RewardDelegators: m.RewardDelegators, } *msg = newMsg return nil @@ -233,8 +233,8 @@ func (msg MsgStake) ValidateBasic() sdk.Error { if err := ValidateServiceURL(msg.ServiceUrl); err != nil { return err } - if msg.Delegators != nil { - if err := msg.CheckDelegators(); err != nil { + if msg.RewardDelegators != nil { + if err := msg.CheckRewardDelegators(); err != nil { return err } } @@ -262,8 +262,8 @@ func (msg *MsgStake) XXX_MessageName() string { func (msg MsgStake) String() string { delegatorsStr := "" - if msg.Delegators != nil { - if jsonBytes, err := json.Marshal(msg.Delegators); err == nil { + if msg.RewardDelegators != nil { + if jsonBytes, err := json.Marshal(msg.RewardDelegators); err == nil { delegatorsStr = string(jsonBytes) } else { delegatorsStr = err.Error() @@ -273,7 +273,7 @@ func (msg MsgStake) String() string { Chains: %s Value: %s OutputAddress: %s -Delegators: %s +RewardDelegators: %s `, msg.PublicKey.RawString(), msg.Chains, @@ -296,12 +296,12 @@ func (msg MsgStake) ToProto() MsgProtoStake { pubKeyBz = msg.PublicKey.RawBytes() } return MsgProtoStake{ - Publickey: pubKeyBz, - Chains: msg.Chains, - Value: msg.Value, - ServiceUrl: msg.ServiceUrl, - OutputAddress: msg.Output, - Delegators: msg.Delegators, + Publickey: pubKeyBz, + Chains: msg.Chains, + Value: msg.Value, + ServiceUrl: msg.ServiceUrl, + OutputAddress: msg.Output, + RewardDelegators: msg.RewardDelegators, } } @@ -312,8 +312,8 @@ func (msg MsgStake) CheckServiceUrlLength(url string) sdk.Error { return nil } -func (msg MsgStake) CheckDelegators() sdk.Error { - _, err := NormalizeDelegators(msg.Delegators) +func (msg MsgStake) CheckRewardDelegators() sdk.Error { + _, err := NormalizeRewardDelegators(msg.RewardDelegators) return err } @@ -322,9 +322,9 @@ type AddressAndShare struct { RewardShare uint32 // always positive } -// NormalizeDelegators returns an slice of delegator addresses and their shares -// if the map is valid. -func NormalizeDelegators( +// NormalizeRewardDelegators returns an slice of delegator addresses and +// their shares if the map is valid. +func NormalizeRewardDelegators( delegators map[string]uint32, ) ([]AddressAndShare, sdk.Error) { normalized := make([]AddressAndShare, 0, len(delegators)) diff --git a/x/nodes/types/msg.pb.go b/x/nodes/types/msg.pb.go index 16a92919c..eb8ec33d7 100644 --- a/x/nodes/types/msg.pb.go +++ b/x/nodes/types/msg.pb.go @@ -32,7 +32,7 @@ type MsgProtoStake struct { ServiceUrl string `protobuf:"bytes,4,opt,name=ServiceUrl,proto3" json:"service_url" yaml:"service_url"` OutputAddress github_com_pokt_network_pocket_core_types.Address `protobuf:"bytes,5,opt,name=OutputAddress,proto3,casttype=github.com/pokt-network/pocket-core/types.Address" json:"output_address,omitempty" yaml:"output_address"` // Mapping from delegated-to addresses to a percentage of rewards. - Delegators map[string]uint32 `protobuf:"bytes,6,rep,name=Delegators,proto3" json:"delegators,omitempty" yaml:"delegators" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + RewardDelegators map[string]uint32 `protobuf:"bytes,6,rep,name=RewardDelegators,proto3" json:"reward_delegators,omitempty" yaml:"reward_delegators" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (m *MsgProtoStake) Reset() { *m = MsgProtoStake{} } @@ -316,7 +316,7 @@ func (*MsgSend) XXX_MessageName() string { } func init() { proto.RegisterType((*MsgProtoStake)(nil), "x.nodes.MsgProtoStake") - proto.RegisterMapType((map[string]uint32)(nil), "x.nodes.MsgProtoStake.DelegatorsEntry") + proto.RegisterMapType((map[string]uint32)(nil), "x.nodes.MsgProtoStake.RewardDelegatorsEntry") proto.RegisterType((*LegacyMsgProtoStake)(nil), "x.nodes.LegacyMsgProtoStake") proto.RegisterType((*MsgBeginUnstake)(nil), "x.nodes.MsgBeginUnstake") proto.RegisterType((*LegacyMsgBeginUnstake)(nil), "x.nodes.LegacyMsgBeginUnstake") @@ -328,55 +328,56 @@ func init() { func init() { proto.RegisterFile("x/nodes/msg.proto", fileDescriptor_0de9b62fa75e413f) } var fileDescriptor_0de9b62fa75e413f = []byte{ - // 762 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xb1, 0x6f, 0xd3, 0x4a, - 0x1c, 0xce, 0x25, 0xaf, 0x89, 0x72, 0x4d, 0xda, 0xd7, 0x6b, 0x2b, 0x59, 0x7d, 0x52, 0x2e, 0xf2, - 0xd3, 0x7b, 0xca, 0xf0, 0x9a, 0x3c, 0xe8, 0x82, 0x22, 0x31, 0x34, 0x50, 0x24, 0x04, 0x11, 0xc5, - 0xa1, 0x08, 0x21, 0xa4, 0xe2, 0x26, 0x57, 0xd7, 0x8d, 0xed, 0x8b, 0xec, 0x73, 0x48, 0x16, 0x84, - 0x98, 0xba, 0x80, 0x3a, 0xc2, 0x56, 0xb1, 0xc0, 0x9f, 0x52, 0x89, 0xa5, 0x23, 0x62, 0x38, 0xa1, - 0x76, 0x41, 0x1e, 0x33, 0x22, 0x06, 0x14, 0x9f, 0x1d, 0xc7, 0x19, 0x50, 0x95, 0x4a, 0xc0, 0xc0, - 0xe6, 0xfb, 0x7e, 0x77, 0xf7, 0x7d, 0xfe, 0x7d, 0x9f, 0x7f, 0x32, 0x5c, 0xe8, 0x55, 0x2c, 0xda, - 0x22, 0x4e, 0xc5, 0x74, 0xb4, 0x72, 0xc7, 0xa6, 0x8c, 0xa2, 0x4c, 0xaf, 0xec, 0x43, 0x2b, 0x4b, - 0x1a, 0xd5, 0xa8, 0x8f, 0x55, 0x86, 0x4f, 0xa2, 0x2c, 0xbf, 0x9c, 0x81, 0xf9, 0xba, 0xa3, 0x6d, - 0x0e, 0x17, 0x0d, 0xa6, 0xb6, 0x09, 0x5a, 0x87, 0xd9, 0x4d, 0x77, 0xc7, 0xd0, 0x9b, 0x6d, 0xd2, - 0x97, 0x40, 0x11, 0x94, 0x72, 0xb5, 0xbf, 0x3d, 0x8e, 0x61, 0xc7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 0x39, 0x2d, 0x80, 0x4f, - 0xa7, 0x05, 0x70, 0x78, 0x56, 0x48, 0x9c, 0x9c, 0x15, 0x12, 0x1f, 0xce, 0x0a, 0x89, 0x87, 0xe7, - 0x7a, 0xa5, 0xf0, 0x77, 0xca, 0x17, 0xb1, 0x93, 0xf6, 0x7f, 0x99, 0xd6, 0xbe, 0x05, 0x00, 0x00, - 0xff, 0xff, 0xfb, 0xe0, 0xcf, 0x4b, 0x66, 0x09, 0x00, 0x00, + // 776 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xbf, 0x6b, 0x1b, 0x49, + 0x14, 0xd6, 0x48, 0x67, 0x09, 0x8d, 0x25, 0xff, 0x18, 0xdb, 0xb0, 0xd8, 0xa0, 0x11, 0x7b, 0x1c, + 0xa8, 0xb0, 0xa5, 0xbb, 0x73, 0x73, 0xe8, 0x2a, 0xcb, 0x71, 0x20, 0x24, 0x22, 0xce, 0x2a, 0x0e, + 0x21, 0x04, 0x94, 0xb5, 0x34, 0x5e, 0xaf, 0xb5, 0xbb, 0x23, 0x76, 0x47, 0xb2, 0xd4, 0x84, 0x90, + 0xca, 0x4d, 0xc0, 0x4d, 0x20, 0xe9, 0x4c, 0x9a, 0xe4, 0x1f, 0xc8, 0xff, 0x60, 0x48, 0xe3, 0x32, + 0xa4, 0x18, 0x82, 0xdd, 0x84, 0x2d, 0x55, 0x86, 0x14, 0x41, 0x3b, 0xbb, 0x96, 0x56, 0x0e, 0xc1, + 0xc8, 0x90, 0xa4, 0x48, 0xb7, 0xf3, 0xbd, 0x37, 0xf3, 0x7d, 0xf3, 0xde, 0xb7, 0x8f, 0x81, 0xb3, + 0x9d, 0x82, 0x45, 0xeb, 0xc4, 0x29, 0x98, 0x8e, 0x96, 0x6f, 0xda, 0x94, 0x51, 0x94, 0xe8, 0xe4, + 0x3d, 0x68, 0x71, 0x5e, 0xa3, 0x1a, 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xf7, 0xfb, 0x23, 0x94, 0xd1, 0x21, 0x6e, 0x7f, 0x84, + 0x0e, 0xb0, 0x31, 0x99, 0x07, 0x54, 0xa8, 0x01, 0xe3, 0xaa, 0x49, 0x5b, 0x16, 0xf3, 0x67, 0x68, + 0xe5, 0x0a, 0x33, 0xd4, 0x3f, 0x69, 0x30, 0xaf, 0xc5, 0x5a, 0x56, 0xfc, 0x40, 0x31, 0x15, 0x94, + 0xfe, 0xe0, 0x15, 0x06, 0xa5, 0x9b, 0xc7, 0xa7, 0x19, 0x70, 0x72, 0x9a, 0x01, 0x1f, 0x4f, 0x33, + 0xe0, 0xf0, 0x2c, 0x13, 0x39, 0x39, 0xcb, 0x44, 0xde, 0x9f, 0x65, 0x22, 0x0f, 0x2e, 0x75, 0xa5, + 0xe0, 0xd5, 0xe5, 0x89, 0xd8, 0x8e, 0x7b, 0x2f, 0xab, 0xd5, 0xaf, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xea, 0x5e, 0x67, 0x4f, 0x8d, 0x09, 0x00, 0x00, } func (this *MsgProtoStake) Equal(that interface{}) bool { @@ -418,11 +419,11 @@ func (this *MsgProtoStake) Equal(that interface{}) bool { if !bytes.Equal(this.OutputAddress, that1.OutputAddress) { return false } - if len(this.Delegators) != len(that1.Delegators) { + if len(this.RewardDelegators) != len(that1.RewardDelegators) { return false } - for i := range this.Delegators { - if this.Delegators[i] != that1.Delegators[i] { + for i := range this.RewardDelegators { + if this.RewardDelegators[i] != that1.RewardDelegators[i] { return false } } @@ -618,9 +619,9 @@ func (m *MsgProtoStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Delegators) > 0 { - for k := range m.Delegators { - v := m.Delegators[k] + if len(m.RewardDelegators) > 0 { + for k := range m.RewardDelegators { + v := m.RewardDelegators[k] baseI := i i = encodeVarintMsg(dAtA, i, uint64(v)) i-- @@ -952,8 +953,8 @@ func (m *MsgProtoStake) Size() (n int) { if l > 0 { n += 1 + l + sovMsg(uint64(l)) } - if len(m.Delegators) > 0 { - for k, v := range m.Delegators { + if len(m.RewardDelegators) > 0 { + for k, v := range m.RewardDelegators { _ = k _ = v mapEntrySize := 1 + len(k) + sovMsg(uint64(len(k))) + 1 + sovMsg(uint64(v)) @@ -1270,7 +1271,7 @@ func (m *MsgProtoStake) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardDelegators", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1297,8 +1298,8 @@ func (m *MsgProtoStake) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Delegators == nil { - m.Delegators = make(map[string]uint32) + if m.RewardDelegators == nil { + m.RewardDelegators = make(map[string]uint32) } var mapkey string var mapvalue uint32 @@ -1379,7 +1380,7 @@ func (m *MsgProtoStake) Unmarshal(dAtA []byte) error { iNdEx += skippy } } - m.Delegators[mapkey] = mapvalue + m.RewardDelegators[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/nodes/types/msg_test.go b/x/nodes/types/msg_test.go index 5e01c2587..2d1d1f9c2 100644 --- a/x/nodes/types/msg_test.go +++ b/x/nodes/types/msg_test.go @@ -670,45 +670,45 @@ func TestMsgStake_Delegators(t *testing.T) { delegator1 := crypto.Ed25519PrivateKey{}.GenPrivateKey() delegator2 := crypto.Ed25519PrivateKey{}.GenPrivateKey() msg := MsgStake{ - PublicKey: operator.PublicKey(), - Chains: []string{"0001", "0040", "03DF"}, - Value: sdk.NewInt(1000000000000), - ServiceUrl: "https://pokt.network:1", - Output: sdk.Address(output.PublicKey().Address()), - Delegators: nil, + PublicKey: operator.PublicKey(), + Chains: []string{"0001", "0040", "03DF"}, + Value: sdk.NewInt(1000000000000), + ServiceUrl: "https://pokt.network:1", + Output: sdk.Address(output.PublicKey().Address()), + RewardDelegators: nil, } assert.Nil(t, msg.ValidateBasic()) - msg.Delegators = map[string]uint32{} + msg.RewardDelegators = map[string]uint32{} invalidAddr := "1234" - msg.Delegators[invalidAddr] = 10 + msg.RewardDelegators[invalidAddr] = 10 err := msg.ValidateBasic() assert.NotNil(t, err) assert.Equal(t, CodeInvalidaDelegators, err.Code()) - // Delegators: {delegator1: 0} - delete(msg.Delegators, invalidAddr) - msg.Delegators[delegator1.PublicKey().Address().String()] = 0 + // RewardDelegators: {delegator1: 0} + delete(msg.RewardDelegators, invalidAddr) + msg.RewardDelegators[delegator1.PublicKey().Address().String()] = 0 assert.NotNil(t, err) assert.Equal(t, CodeInvalidaDelegators, err.Code()) - // Delegators: {delegator1: 100} - msg.Delegators[delegator1.PublicKey().Address().String()] = 100 + // RewardDelegators: {delegator1: 100} + msg.RewardDelegators[delegator1.PublicKey().Address().String()] = 100 assert.Nil(t, msg.ValidateBasic()) // Delegators: {delegator1: 100, delegator2: 1} - msg.Delegators[delegator2.PubKey().Address().String()] = 1 + msg.RewardDelegators[delegator2.PubKey().Address().String()] = 1 err = msg.ValidateBasic() assert.NotNil(t, err) assert.Equal(t, CodeInvalidaDelegators, err.Code()) // Delegators: {delegator1: 99, delegator2: 1} - msg.Delegators[delegator1.PublicKey().Address().String()] = 99 + msg.RewardDelegators[delegator1.PublicKey().Address().String()] = 99 assert.Nil(t, msg.ValidateBasic()) // Delegators: {delegator1: 98, delegator2: 1} - msg.Delegators[delegator1.PublicKey().Address().String()] = 98 + msg.RewardDelegators[delegator1.PublicKey().Address().String()] = 98 assert.Nil(t, msg.ValidateBasic()) } diff --git a/x/nodes/types/nodes.pb.go b/x/nodes/types/nodes.pb.go index 6147e4ba3..33e729066 100644 --- a/x/nodes/types/nodes.pb.go +++ b/x/nodes/types/nodes.pb.go @@ -39,7 +39,7 @@ type ProtoValidator struct { StakedTokens github_com_pokt_network_pocket_core_types.BigInt `protobuf:"bytes,7,opt,name=StakedTokens,proto3,customtype=github.com/pokt-network/pocket-core/types.BigInt" json:"tokens"` UnstakingCompletionTime time.Time `protobuf:"bytes,8,opt,name=UnstakingCompletionTime,proto3,stdtime" json:"unstaking_time" yaml:"unstaking_time"` OutputAddress github_com_pokt_network_pocket_core_types.Address `protobuf:"bytes,9,opt,name=OutputAddress,proto3,casttype=github.com/pokt-network/pocket-core/types.Address" json:"output_address,omitempty" yaml:"output_address"` - Delegators map[string]uint32 `protobuf:"bytes,10,rep,name=Delegators,proto3" json:"delegators,omitempty" yaml:"delegators" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + RewardDelegators map[string]uint32 `protobuf:"bytes,10,rep,name=RewardDelegators,proto3" json:"reward_delegators,omitempty" yaml:"reward_delegators" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (m *ProtoValidator) Reset() { *m = ProtoValidator{} } @@ -209,7 +209,7 @@ func (m *ValidatorSigningInfo) GetJailedBlocksCounter() int64 { func init() { proto.RegisterType((*ProtoValidator)(nil), "x.nodes.ProtoValidator") - proto.RegisterMapType((map[string]uint32)(nil), "x.nodes.ProtoValidator.DelegatorsEntry") + proto.RegisterMapType((map[string]uint32)(nil), "x.nodes.ProtoValidator.RewardDelegatorsEntry") proto.RegisterType((*LegacyProtoValidator)(nil), "x.nodes.LegacyProtoValidator") proto.RegisterType((*ValidatorSigningInfo)(nil), "x.nodes.ValidatorSigningInfo") } @@ -217,60 +217,61 @@ func init() { func init() { proto.RegisterFile("x/nodes/nodes.proto", fileDescriptor_63cb49073b61e33a) } var fileDescriptor_63cb49073b61e33a = []byte{ - // 846 bytes of a gzipped FileDescriptorProto + // 858 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x96, 0xbf, 0x6f, 0xdb, 0x46, - 0x14, 0xc7, 0xc5, 0xd8, 0xb2, 0xac, 0x93, 0xe2, 0xb4, 0xb4, 0x82, 0x12, 0x46, 0xa1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0xeb, 0xf2, 0x1a, 0xee, 0xfc, 0x1b, 0x00, 0x00, + 0xff, 0xff, 0x49, 0xf4, 0x43, 0x35, 0x3f, 0x09, 0x00, 0x00, } func (this *ProtoValidator) Equal(that interface{}) bool { @@ -324,11 +325,11 @@ func (this *ProtoValidator) Equal(that interface{}) bool { if !bytes.Equal(this.OutputAddress, that1.OutputAddress) { return false } - if len(this.Delegators) != len(that1.Delegators) { + if len(this.RewardDelegators) != len(that1.RewardDelegators) { return false } - for i := range this.Delegators { - if this.Delegators[i] != that1.Delegators[i] { + for i := range this.RewardDelegators { + if this.RewardDelegators[i] != that1.RewardDelegators[i] { return false } } @@ -443,9 +444,9 @@ func (m *ProtoValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Delegators) > 0 { - for k := range m.Delegators { - v := m.Delegators[k] + if len(m.RewardDelegators) > 0 { + for k := range m.RewardDelegators { + v := m.RewardDelegators[k] baseI := i i = encodeVarintNodes(dAtA, i, uint64(v)) i-- @@ -726,8 +727,8 @@ func (m *ProtoValidator) Size() (n int) { if l > 0 { n += 1 + l + sovNodes(uint64(l)) } - if len(m.Delegators) > 0 { - for k, v := range m.Delegators { + if len(m.RewardDelegators) > 0 { + for k, v := range m.RewardDelegators { _ = k _ = v mapEntrySize := 1 + len(k) + sovNodes(uint64(len(k))) + 1 + sovNodes(uint64(v)) @@ -1110,7 +1111,7 @@ func (m *ProtoValidator) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardDelegators", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1137,8 +1138,8 @@ func (m *ProtoValidator) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Delegators == nil { - m.Delegators = make(map[string]uint32) + if m.RewardDelegators == nil { + m.RewardDelegators = make(map[string]uint32) } var mapkey string var mapvalue uint32 @@ -1219,7 +1220,7 @@ func (m *ProtoValidator) Unmarshal(dAtA []byte) error { iNdEx += skippy } } - m.Delegators[mapkey] = mapvalue + m.RewardDelegators[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/nodes/types/validator.go b/x/nodes/types/validator.go index 344ef46a7..7f526e5af 100644 --- a/x/nodes/types/validator.go +++ b/x/nodes/types/validator.go @@ -15,16 +15,17 @@ import ( ) type Validator struct { - Address sdk.Address `json:"address" yaml:"address"` // address of the validator; hex encoded in JSON - PublicKey crypto.PublicKey `json:"public_key" yaml:"public_key"` // the consensus public key of the validator; hex encoded in JSON - Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from staked status? - Status sdk.StakeStatus `json:"status" yaml:"status"` // validator status (staked/unstaking/unstaked) - Chains []string `json:"chains" yaml:"chains"` // validator non native blockchains - ServiceURL string `json:"service_url" yaml:"service_url"` // url where the pocket service api is hosted - StakedTokens sdk.BigInt `json:"tokens" yaml:"tokens"` // tokens staked in the network - UnstakingCompletionTime time.Time `json:"unstaking_time" yaml:"unstaking_time"` // if unstaking, min time for the validator to complete unstaking - OutputAddress sdk.Address `json:"output_address,omitempty" yaml:"output_address"` // the custodial output address of the validator - Delegators map[string]uint32 `json:"delegators,omitempty" yaml:"delegators"` + Address sdk.Address `json:"address" yaml:"address"` // address of the validator; hex encoded in JSON + PublicKey crypto.PublicKey `json:"public_key" yaml:"public_key"` // the consensus public key of the validator; hex encoded in JSON + Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from staked status? + Status sdk.StakeStatus `json:"status" yaml:"status"` // validator status (staked/unstaking/unstaked) + Chains []string `json:"chains" yaml:"chains"` // validator non native blockchains + ServiceURL string `json:"service_url" yaml:"service_url"` // url where the pocket service api is hosted + StakedTokens sdk.BigInt `json:"tokens" yaml:"tokens"` // tokens staked in the network + UnstakingCompletionTime time.Time `json:"unstaking_time" yaml:"unstaking_time"` // if unstaking, min time for the validator to complete unstaking + OutputAddress sdk.Address `json:"output_address,omitempty" yaml:"output_address"` // the custodial output address of the validator + // Mapping from delegated-to addresses to a percentage of rewards + RewardDelegators map[string]uint32 `json:"reward_delegators,omitempty" yaml:"reward_delegators"` } // NewValidator - initialize a new validator @@ -53,7 +54,7 @@ func NewValidatorFromMsg(msg MsgStake) Validator { StakedTokens: msg.Value, UnstakingCompletionTime: time.Time{}, OutputAddress: msg.Output, - Delegators: msg.Delegators, + RewardDelegators: msg.RewardDelegators, } } @@ -184,8 +185,8 @@ func (v Validator) String() string { outputPubKeyString = v.OutputAddress.String() } delegatorsStr := "" - if v.Delegators != nil { - if jsonBytes, err := json.Marshal(v.Delegators); err == nil { + if v.RewardDelegators != nil { + if jsonBytes, err := json.Marshal(v.RewardDelegators); err == nil { delegatorsStr = string(jsonBytes) } else { delegatorsStr = err.Error() @@ -201,7 +202,7 @@ ServiceUrl: %s Chains: %v Unstaking Completion Time: %v Output Address: %s -Delegators: %s +Reward Delegators: %s ---- `, v.Address, @@ -231,7 +232,7 @@ func (v Validator) MarshalJSON() ([]byte, error) { StakedTokens: v.StakedTokens, UnstakingCompletionTime: v.UnstakingCompletionTime, OutputAddress: v.OutputAddress, - Delegators: v.Delegators, + RewardDelegators: v.RewardDelegators, }) } @@ -255,7 +256,7 @@ func (v *Validator) UnmarshalJSON(data []byte) error { Status: bv.Status, UnstakingCompletionTime: bv.UnstakingCompletionTime, OutputAddress: bv.OutputAddress, - Delegators: bv.Delegators, + RewardDelegators: bv.RewardDelegators, } return nil } @@ -276,7 +277,7 @@ func (v ProtoValidator) FromProto() (Validator, error) { StakedTokens: v.StakedTokens, UnstakingCompletionTime: v.UnstakingCompletionTime, OutputAddress: v.OutputAddress, - Delegators: v.Delegators, + RewardDelegators: v.RewardDelegators, }, nil } @@ -292,21 +293,22 @@ func (v Validator) ToProto() ProtoValidator { StakedTokens: v.StakedTokens, UnstakingCompletionTime: v.UnstakingCompletionTime, OutputAddress: v.OutputAddress, - Delegators: v.Delegators, + RewardDelegators: v.RewardDelegators, } } type JSONValidator struct { - Address sdk.Address `json:"address" yaml:"address"` // address of the validator; hex encoded in JSON - PublicKey string `json:"public_key" yaml:"public_key"` // the consensus public key of the validator; hex encoded in JSON - Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from staked status? - Status sdk.StakeStatus `json:"status" yaml:"status"` // validator status (staked/unstaking/unstaked) - Chains []string `json:"chains" yaml:"chains"` // validator non native blockchains - ServiceURL string `json:"service_url" yaml:"service_url"` // url where the pocket service api is hosted - StakedTokens sdk.BigInt `json:"tokens" yaml:"tokens"` // tokens staked in the network - UnstakingCompletionTime time.Time `json:"unstaking_time" yaml:"unstaking_time"` // if unstaking, min time for the validator to complete unstaking - OutputAddress sdk.Address `json:"output_address" yaml:"output_address"` // custodial output address of tokens - Delegators map[string]uint32 `json:"delegators" yaml:"delegators"` + Address sdk.Address `json:"address" yaml:"address"` // address of the validator; hex encoded in JSON + PublicKey string `json:"public_key" yaml:"public_key"` // the consensus public key of the validator; hex encoded in JSON + Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from staked status? + Status sdk.StakeStatus `json:"status" yaml:"status"` // validator status (staked/unstaking/unstaked) + Chains []string `json:"chains" yaml:"chains"` // validator non native blockchains + ServiceURL string `json:"service_url" yaml:"service_url"` // url where the pocket service api is hosted + StakedTokens sdk.BigInt `json:"tokens" yaml:"tokens"` // tokens staked in the network + UnstakingCompletionTime time.Time `json:"unstaking_time" yaml:"unstaking_time"` // if unstaking, min time for the validator to complete unstaking + OutputAddress sdk.Address `json:"output_address" yaml:"output_address"` // custodial output address of tokens + // Mapping from delegated-to addresses to a percentage of rewards + RewardDelegators map[string]uint32 `json:"reward_delegators" yaml:"reward_delegators"` } // Validators is a collection of Validator diff --git a/x/nodes/types/validator_legacy.go b/x/nodes/types/validator_legacy.go index 12b16525c..6b7ac615a 100644 --- a/x/nodes/types/validator_legacy.go +++ b/x/nodes/types/validator_legacy.go @@ -156,7 +156,7 @@ func (v LegacyValidator) ToValidator() Validator { StakedTokens: v.StakedTokens, UnstakingCompletionTime: v.UnstakingCompletionTime, OutputAddress: nil, - Delegators: nil, + RewardDelegators: nil, } }