Skip to content

Instantly share code, notes, and snippets.

@xlab
Last active March 10, 2023 16:57
Show Gist options
  • Save xlab/96e7d546645333d154d761578ba0dff9 to your computer and use it in GitHub Desktop.
Save xlab/96e7d546645333d154d761578ba0dff9 to your computer and use it in GitHub Desktop.
LSM diff surplus for SDK v0.46.11
#!/bin/sh
export WITH_IGNORE="-x '*.pb.go' -x '*.pb.gw.go' -x 'third_party'"
diff $WITH_IGNORE -ur ../pstake-native/x/lsnative/distribution x/distribution > distribution.diff
diff $WITH_IGNORE -ur ../pstake-native/x/lsnative/genutil x/genutil > genutil.diff
diff $WITH_IGNORE -ur ../pstake-native/x/lsnative/slashing x/slashing > slashing.diff
diff $WITH_IGNORE -ur ../pstake-native/x/lsnative/staking x/staking > staking.diff
diff $WITH_IGNORE -ur ../pstake-native/x/lsnative/proto/lsnative proto > proto.diff
#!/bin/sh
export WITH_IGNORE="-x '*.pb.go' -x '*.pb.gw.go' -x 'third_party'"
diff $WITH_IGNORE -ur x/distribution ../pstake-native/x/lsnative/distribution > distribution_surplus.diff
diff $WITH_IGNORE -ur x/genutil ../pstake-native/x/lsnative/genutil > genutil_surplus.diff
diff $WITH_IGNORE -ur x/slashing ../pstake-native/x/lsnative/slashing > slashing_surplus.diff
diff $WITH_IGNORE -ur x/staking ../pstake-native/x/lsnative/staking > staking_surplus.diff
diff $WITH_IGNORE -ur proto ../pstake-native/x/lsnative/proto/lsnative > proto_surplus.diff
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/client/cli/query.go ../pstake-native/x/lsnative/staking/client/cli/query.go
--- x/staking/client/cli/query.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/staking/client/cli/query.go 2023-03-10 17:39:45
@@ -39,6 +39,7 @@
GetCmdQueryHistoricalInfo(),
GetCmdQueryParams(),
GetCmdQueryPool(),
+
GetCmdQueryTokenizeShareRecordById(),
GetCmdQueryTokenizeShareRecordByDenom(),
GetCmdQueryTokenizeShareRecordsOwned(),
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/client/cli/tx.go ../pstake-native/x/lsnative/staking/client/cli/tx.go
--- x/staking/client/cli/tx.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/staking/client/cli/tx.go 2023-03-10 17:39:45
@@ -14,6 +14,7 @@
"github.com/cosmos/cosmos-sdk/client/tx"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/version"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
)
@@ -43,6 +44,8 @@
NewDelegateCmd(),
NewRedelegateCmd(),
NewUnbondCmd(),
+ NewCancelUnbondingDelegation(),
+
NewUnbondValidatorCmd(),
NewTokenizeSharesCmd(),
NewRedeemTokensCmd(),
@@ -53,6 +56,7 @@
return stakingTxCmd
}
+// NewCreateValidatorCmd returns a CLI command handler for creating a MsgCreateValidator transaction.
func NewCreateValidatorCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create-validator",
@@ -91,6 +95,7 @@
return cmd
}
+// NewEditValidatorCmd returns a CLI command handler for creating a MsgEditValidator transaction.
func NewEditValidatorCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "edit-validator",
@@ -133,6 +138,7 @@
return cmd
}
+// NewDelegateCmd returns a CLI command handler for creating a MsgDelegate transaction.
func NewDelegateCmd() *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()
@@ -176,6 +182,7 @@
return cmd
}
+// NewRedelegateCmd returns a CLI command handler for creating a MsgBeginRedelegate transaction.
func NewRedelegateCmd() *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()
@@ -224,6 +231,7 @@
return cmd
}
+// NewUnbondCmd returns a CLI command handler for creating a MsgUndelegate transaction.
func NewUnbondCmd() *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()
@@ -267,6 +275,57 @@
return cmd
}
+// NewCancelUnbondingDelegation returns a CLI command handler for creating a MsgCancelUnbondingDelegation transaction.
+func NewCancelUnbondingDelegation() *cobra.Command {
+ bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()
+
+ cmd := &cobra.Command{
+ Use: "cancel-unbond [validator-addr] [amount] [creation-height]",
+ Short: "Cancel unbonding delegation and delegate back to the validator",
+ Args: cobra.ExactArgs(3),
+ Long: strings.TrimSpace(
+ fmt.Sprintf(`Cancel Unbonding Delegation and delegate back to the validator.
+
+Example:
+$ %s tx staking cancel-unbond %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 2 --from mykey
+`,
+ version.AppName, bech32PrefixValAddr,
+ ),
+ ),
+ Example: fmt.Sprintf(`$ %s tx staking cancel-unbond %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 2 --from mykey`,
+ version.AppName, bech32PrefixValAddr),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ clientCtx, err := client.GetClientTxContext(cmd)
+ if err != nil {
+ return err
+ }
+ delAddr := clientCtx.GetFromAddress()
+ valAddr, err := sdk.ValAddressFromBech32(args[0])
+ if err != nil {
+ return err
+ }
+
+ amount, err := sdk.ParseCoinNormalized(args[1])
+ if err != nil {
+ return err
+ }
+
+ creationHeight, err := strconv.ParseInt(args[2], 10, 64)
+ if err != nil {
+ return sdkerrors.Wrap(fmt.Errorf("invalid height: %d", creationHeight), "invalid height")
+ }
+
+ msg := types.NewMsgCancelUnbondingDelegation(delAddr, valAddr, creationHeight, amount)
+
+ return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
+ },
+ }
+
+ flags.AddTxFlagsToCmd(cmd)
+
+ return cmd
+}
+
func NewUnbondValidatorCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "unbond-validator",
@@ -340,7 +399,8 @@
}
msg, err := types.NewMsgCreateValidator(
- sdk.ValAddress(valAddr), pk, amount, description, commissionRates)
+ sdk.ValAddress(valAddr), pk, amount, description, commissionRates,
+ )
if err != nil {
return txf, nil, err
}
@@ -496,7 +556,6 @@
func BuildCreateValidatorMsg(clientCtx client.Context, config TxCreateValidatorConfig, txBldr tx.Factory, generateOnly bool) (tx.Factory, sdk.Msg, error) {
amounstStr := config.Amount
amount, err := sdk.ParseCoinNormalized(amounstStr)
-
if err != nil {
return txBldr, nil, err
}
@@ -515,7 +574,6 @@
maxRateStr := config.CommissionMaxRate
maxChangeRateStr := config.CommissionMaxChangeRate
commissionRates, err := buildCommissionRates(rateStr, maxRateStr, maxChangeRateStr)
-
if err != nil {
return txBldr, nil, err
}
@@ -536,6 +594,7 @@
}
return txBldr, msg, nil
+
}
// NewTokenizeSharesCmd defines a command for tokenizing shares from a validator.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/genesis.go ../pstake-native/x/lsnative/staking/genesis.go
--- x/staking/genesis.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/staking/genesis.go 2023-03-10 17:39:45
@@ -13,14 +13,16 @@
)
// WriteValidators returns a slice of bonded genesis validators.
-func WriteValidators(ctx sdk.Context, keeper keeper.Keeper) (vals []tmtypes.GenesisValidator, err error) {
+func WriteValidators(ctx sdk.Context, keeper keeper.Keeper) (vals []tmtypes.GenesisValidator, returnErr error) {
keeper.IterateLastValidators(ctx, func(_ int64, validator sdkstaking.ValidatorI) (stop bool) {
pk, err := validator.ConsPubKey()
if err != nil {
+ returnErr = err
return true
}
tmPk, err := cryptocodec.ToTmPubKeyInterface(pk)
if err != nil {
+ returnErr = err
return true
}
Only in x/staking: handler.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/alias_functions.go ../pstake-native/x/lsnative/staking/keeper/alias_functions.go
--- x/staking/keeper/alias_functions.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/alias_functions.go 2023-03-10 17:39:45
@@ -115,7 +115,8 @@
// iterate through all of the delegations from a delegator
func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress,
- fn func(index int64, del sdkstaking.DelegationI) (stop bool)) {
+ fn func(index int64, del sdkstaking.DelegationI) (stop bool),
+) {
store := ctx.KVStore(k.storeKey)
delegatorPrefixKey := types.GetLiquidDelegationsKey(delAddr)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/delegation.go ../pstake-native/x/lsnative/staking/keeper/delegation.go
--- x/staking/keeper/delegation.go 2023-03-08 16:57:01
+++ ../pstake-native/x/lsnative/staking/keeper/delegation.go 2023-03-10 17:39:45
@@ -5,6 +5,7 @@
"fmt"
"time"
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -26,7 +27,7 @@
return delegation, true
}
-// GetLiquidDelegation returns a specific delegation.
+// GetDelegation returns a specific delegation.
func (k Keeper) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation sdkstaking.Delegation, found bool) {
store := ctx.KVStore(k.storeKey)
key := types.GetLiquidDelegationKey(delAddr, valAddr)
@@ -197,7 +198,7 @@
}
// GetDelegatorUnbonding returns the total amount a delegator has unbonding.
-func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int {
+func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) math.Int {
unbonding := sdk.ZeroInt()
k.IterateDelegatorUnbondingDelegations(ctx, delegator, func(ubd types.UnbondingDelegation) bool {
for _, entry := range ubd.Entries {
@@ -224,7 +225,7 @@
}
// GetDelegatorBonded returs the total amount a delegator has bonded.
-func (k Keeper) GetDelegatorBonded(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int {
+func (k Keeper) GetDelegatorBonded(ctx sdk.Context, delegator sdk.AccAddress) math.Int {
bonded := sdk.ZeroDec()
k.IterateDelegatorDelegations(ctx, delegator, func(delegation types.Delegation) bool {
@@ -317,7 +318,7 @@
// the given addresses. It creates the unbonding delegation if it does not exist.
func (k Keeper) SetUnbondingDelegationEntry(
ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress,
- creationHeight int64, minTime time.Time, balance sdk.Int,
+ creationHeight int64, minTime time.Time, balance math.Int,
) types.UnbondingDelegation {
ubd, found := k.GetUnbondingDelegation(ctx, delegatorAddr, validatorAddr)
if found {
@@ -499,7 +500,7 @@
func (k Keeper) SetRedelegationEntry(ctx sdk.Context,
delegatorAddr sdk.AccAddress, validatorSrcAddr,
validatorDstAddr sdk.ValAddress, creationHeight int64,
- minTime time.Time, balance sdk.Int,
+ minTime time.Time, balance math.Int,
sharesSrc, sharesDst sdk.Dec,
) types.Redelegation {
red, found := k.GetRedelegation(ctx, delegatorAddr, validatorSrcAddr, validatorDstAddr)
@@ -627,7 +628,7 @@
// Delegate performs a delegation, set/update everything necessary within the store.
// tokenSrc indicates the bond status of the incoming funds.
func (k Keeper) Delegate(
- ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Int, tokenSrc sdkstaking.BondStatus,
+ ctx sdk.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc sdkstaking.BondStatus,
validator types.Validator, subtractAccount bool,
) (newShares sdk.Dec, err error) {
// In some situations, the exchange rate becomes invalid, e.g. if
@@ -714,7 +715,7 @@
// Unbond unbonds a particular delegation and perform associated store operations.
func (k Keeper) Unbond(
ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, shares sdk.Dec,
-) (amount sdk.Int, err error) {
+) (amount math.Int, err error) {
// check if a delegation object exists in the store
delegation, found := k.GetLiquidDelegation(ctx, delAddr, valAddr)
if !found {
@@ -979,7 +980,7 @@
// valied based on upon the converted shares. If the amount is valid, the total
// amount of respective shares is returned, otherwise an error is returned.
func (k Keeper) ValidateUnbondAmount(
- ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk.Int,
+ ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int,
) (shares sdk.Dec, err error) {
validator, found := k.GetLiquidValidator(ctx, valAddr)
if !found {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/grpc_query.go ../pstake-native/x/lsnative/staking/keeper/grpc_query.go
--- x/staking/keeper/grpc_query.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/grpc_query.go 2023-03-10 17:39:45
@@ -32,34 +32,30 @@
return nil, status.Errorf(codes.InvalidArgument, "invalid validator status %s", req.Status)
}
- var validators types.Validators
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(k.storeKey)
valStore := prefix.NewStore(store, types.ValidatorsKey)
- pageRes, err := query.FilteredPaginate(valStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
- val, err := types.UnmarshalValidator(k.cdc, value)
- if err != nil {
- return false, err
- }
-
+ validators, pageRes, err := query.GenericFilteredPaginate(k.cdc, valStore, req.Pagination, func(key []byte, val *types.Validator) (*types.Validator, error) {
if req.Status != "" && !strings.EqualFold(val.GetStatus().String(), req.Status) {
- return false, nil
+ return nil, nil
}
- if accumulate {
- validators = append(validators, val)
- }
-
- return true, nil
+ return val, nil
+ }, func() *types.Validator {
+ return &types.Validator{}
})
-
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
- return &types.QueryValidatorsResponse{Validators: validators, Pagination: pageRes}, nil
+ vals := types.Validators{}
+ for _, val := range validators {
+ vals = append(vals, *val)
+ }
+
+ return &types.QueryValidatorsResponse{Validators: vals, Pagination: pageRes}, nil
}
// Validator queries validator info for given validator address
@@ -95,42 +91,41 @@
if req.ValidatorAddr == "" {
return nil, status.Error(codes.InvalidArgument, "validator address cannot be empty")
}
- var delegations []types.Delegation
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(k.storeKey)
valStore := prefix.NewStore(store, types.DelegationKey)
- pageRes, err := query.FilteredPaginate(valStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
- delegation, err := types.UnmarshalDelegation(k.cdc, value)
- if err != nil {
- return false, err
- }
-
+ delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, valStore, req.Pagination, func(key []byte, delegation *types.Delegation) (*types.Delegation, error) {
valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr)
if err != nil {
- return false, err
+ return nil, err
}
if !delegation.GetValidatorAddr().Equals(valAddr) {
- return false, nil
+ return nil, nil
}
- if accumulate {
- delegations = append(delegations, delegation)
- }
- return true, nil
+ return delegation, nil
+ }, func() *types.Delegation {
+ return &types.Delegation{}
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
- delResponses, err := DelegationsToDelegationResponses(ctx, k.Keeper, delegations)
+ dels := types.Delegations{}
+ for _, d := range delegations {
+ dels = append(dels, *d)
+ }
+
+ delResponses, err := DelegationsToDelegationResponses(ctx, k.Keeper, dels)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryValidatorDelegationsResponse{
- DelegationResponses: delResponses, Pagination: pageRes}, nil
+ DelegationResponses: delResponses, Pagination: pageRes,
+ }, nil
}
// ValidatorUnbondingDelegations queries unbonding delegations of a validator
@@ -288,7 +283,6 @@
}
return &types.QueryDelegatorDelegationsResponse{DelegationResponses: delegationResps, Pagination: pageRes}, nil
-
}
// DelegatorValidator queries validator info for given delegator validator pair
@@ -355,7 +349,8 @@
}
return &types.QueryDelegatorUnbondingDelegationsResponse{
- UnbondingResponses: unbondingDelegations, Pagination: pageRes}, nil
+ UnbondingResponses: unbondingDelegations, Pagination: pageRes,
+ }, nil
}
// HistoricalInfo queries the historical info for given height
@@ -440,7 +435,6 @@
validators = append(validators, validator)
return nil
})
-
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
@@ -472,7 +466,6 @@
}
func queryRedelegation(ctx sdk.Context, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, err error) {
-
delAddr, err := sdk.AccAddressFromBech32(req.DelegatorAddr)
if err != nil {
return nil, err
@@ -539,6 +532,7 @@
})
return redels, res, err
+
}
// Query for individual tokenize share record information by share by id
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/historical_info.go ../pstake-native/x/lsnative/staking/keeper/historical_info.go
--- x/staking/keeper/historical_info.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/historical_info.go 2023-03-10 17:39:45
@@ -6,6 +6,7 @@
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
)
+// GetLiquidStakingHistoricalInfo gets the historical info at a given height
func (k Keeper) GetLiquidStakingHistoricalInfo(ctx sdk.Context, height int64) (types.HistoricalInfo, bool) {
store := ctx.KVStore(k.storeKey)
key := types.GetHistoricalInfoKey(height)
@@ -48,7 +49,9 @@
}
// IterateHistoricalInfo provides an interator over all stored HistoricalInfo
-// objects. For each HistoricalInfo object, cb will be called. If the cb returns
+//
+// objects. For each HistoricalInfo object, cb will be called. If the cb returns
+//
// true, the iterator will close and stop.
func (k Keeper) IterateHistoricalInfo(ctx sdk.Context, cb func(types.HistoricalInfo) bool) {
store := ctx.KVStore(k.storeKey)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/keeper.go ../pstake-native/x/lsnative/staking/keeper/keeper.go
--- x/staking/keeper/keeper.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/keeper.go 2023-03-10 17:39:45
@@ -3,6 +3,7 @@
import (
"fmt"
+ "cosmossdk.io/math"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
@@ -74,7 +75,7 @@
}
// Load the last total validator power.
-func (k Keeper) GetLastTotalPower(ctx sdk.Context) sdk.Int {
+func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.LastTotalPowerKey)
@@ -89,7 +90,7 @@
}
// Set the last total validator power.
-func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdk.Int) {
+func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
store.Set(types.LastTotalPowerKey, bz)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/migrations.go ../pstake-native/x/lsnative/staking/keeper/migrations.go
--- x/staking/keeper/migrations.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/keeper/migrations.go 2023-03-10 17:35:24
@@ -1 +1,29 @@
package keeper
+
+import (
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ v043 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v043"
+ v046 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v046"
+)
+
+// Migrator is a struct for handling in-place store migrations.
+type Migrator struct {
+ keeper Keeper
+}
+
+// NewMigrator returns a new Migrator.
+func NewMigrator(keeper Keeper) Migrator {
+ return Migrator{
+ keeper: keeper,
+ }
+}
+
+// Migrate1to2 migrates from version 1 to 2.
+func (m Migrator) Migrate1to2(ctx sdk.Context) error {
+ return v043.MigrateStore(ctx, m.keeper.storeKey)
+}
+
+// Migrate2to3 migrates x/staking state from consensus version 2 to 3.
+func (m Migrator) Migrate2to3(ctx sdk.Context) error {
+ return v046.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.keeper.paramstore)
+}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/msg_server.go ../pstake-native/x/lsnative/staking/keeper/msg_server.go
--- x/staking/keeper/msg_server.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/msg_server.go 2023-03-10 17:39:45
@@ -6,10 +6,11 @@
"strconv"
"time"
- metrics "github.com/armon/go-metrics"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "github.com/armon/go-metrics"
+
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -263,7 +264,6 @@
if err != nil {
return nil, err
}
-
delegation, found := k.GetLiquidDelegation(ctx, delegatorAddress, valSrcAddr)
if !found {
return nil, status.Errorf(
@@ -272,7 +272,6 @@
msg.DelegatorAddress, msg.ValidatorSrcAddress,
)
}
-
shares, err := k.ValidateUnbondAmount(
ctx, delegatorAddress, valSrcAddr, msg.Amount.Amount,
)
@@ -552,7 +551,8 @@
return nil, err
}
// validator must already be registered
- validator, found := k.GetValidator(ctx, valAddr)
+ // FIXME: used to be GetValidator but struct changes prevent from being used in jailValidator
+ validator, found := k.GetLiquidValidator(ctx, valAddr)
if !found {
return nil, sdkstaking.ErrNoValidatorFound
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/params.go ../pstake-native/x/lsnative/staking/keeper/params.go
--- x/staking/keeper/params.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/params.go 2023-03-10 17:39:45
@@ -3,6 +3,7 @@
import (
"time"
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
)
@@ -43,7 +44,7 @@
// Currently, this returns a global variable that the app developer can tweak.
// TODO: we might turn this into an on-chain param:
// https://github.com/cosmos/cosmos-sdk/issues/8365
-func (k Keeper) PowerReduction(ctx sdk.Context) sdk.Int {
+func (k Keeper) PowerReduction(ctx sdk.Context) math.Int {
return sdk.DefaultPowerReduction
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/pool.go ../pstake-native/x/lsnative/staking/keeper/pool.go
--- x/staking/keeper/pool.go 2023-03-08 16:57:01
+++ ../pstake-native/x/lsnative/staking/keeper/pool.go 2023-03-10 17:39:45
@@ -1,6 +1,7 @@
package keeper
import (
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
@@ -17,7 +18,7 @@
}
// bondedTokensToNotBonded transfers coins from the bonded to the not bonded pool within staking
-func (k Keeper) bondedTokensToNotBonded(ctx sdk.Context, tokens sdk.Int) {
+func (k Keeper) bondedTokensToNotBonded(ctx sdk.Context, tokens math.Int) {
coins := sdk.NewCoins(sdk.NewCoin(k.BondDenom(ctx), tokens))
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.BondedPoolName, types.NotBondedPoolName, coins); err != nil {
panic(err)
@@ -25,7 +26,7 @@
}
// notBondedTokensToBonded transfers coins from the not bonded to the bonded pool within staking
-func (k Keeper) notBondedTokensToBonded(ctx sdk.Context, tokens sdk.Int) {
+func (k Keeper) notBondedTokensToBonded(ctx sdk.Context, tokens math.Int) {
coins := sdk.NewCoins(sdk.NewCoin(k.BondDenom(ctx), tokens))
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.NotBondedPoolName, types.BondedPoolName, coins); err != nil {
panic(err)
@@ -33,7 +34,7 @@
}
// burnBondedTokens removes coins from the bonded pool module account
-func (k Keeper) burnBondedTokens(ctx sdk.Context, amt sdk.Int) error {
+func (k Keeper) burnBondedTokens(ctx sdk.Context, amt math.Int) error {
if !amt.IsPositive() {
// skip as no coins need to be burned
return nil
@@ -45,7 +46,7 @@
}
// burnNotBondedTokens removes coins from the not bonded pool module account
-func (k Keeper) burnNotBondedTokens(ctx sdk.Context, amt sdk.Int) error {
+func (k Keeper) burnNotBondedTokens(ctx sdk.Context, amt math.Int) error {
if !amt.IsPositive() {
// skip as no coins need to be burned
return nil
@@ -57,13 +58,13 @@
}
// TotalBondedTokens total staking tokens supply which is bonded
-func (k Keeper) TotalBondedTokens(ctx sdk.Context) sdk.Int {
+func (k Keeper) TotalBondedTokens(ctx sdk.Context) math.Int {
bondedPool := k.GetBondedPool(ctx)
return k.bankKeeper.GetBalance(ctx, bondedPool.GetAddress(), k.BondDenom(ctx)).Amount
}
// StakingTokenSupply staking tokens from the total supply
-func (k Keeper) StakingTokenSupply(ctx sdk.Context) sdk.Int {
+func (k Keeper) StakingTokenSupply(ctx sdk.Context) math.Int {
return k.bankKeeper.GetSupply(ctx, k.BondDenom(ctx)).Amount
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/power_reduction.go ../pstake-native/x/lsnative/staking/keeper/power_reduction.go
--- x/staking/keeper/power_reduction.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/keeper/power_reduction.go 2023-03-10 17:35:24
@@ -1,15 +1,16 @@
package keeper
import (
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// TokensToConsensusPower - convert input tokens to potential consensus-engine power
-func (k Keeper) TokensToConsensusPower(ctx sdk.Context, tokens sdk.Int) int64 {
+func (k Keeper) TokensToConsensusPower(ctx sdk.Context, tokens math.Int) int64 {
return sdk.TokensToConsensusPower(tokens, k.PowerReduction(ctx))
}
// TokensFromConsensusPower - convert input power to tokens
-func (k Keeper) TokensFromConsensusPower(ctx sdk.Context, power int64) sdk.Int {
+func (k Keeper) TokensFromConsensusPower(ctx sdk.Context, power int64) math.Int {
return sdk.TokensFromConsensusPower(power, k.PowerReduction(ctx))
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/slash.go ../pstake-native/x/lsnative/staking/keeper/slash.go
--- x/staking/keeper/slash.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/slash.go 2023-03-10 17:39:45
@@ -3,6 +3,7 @@
import (
"fmt"
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"
types "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
@@ -13,16 +14,23 @@
// of it, updating unbonding delegations & redelegations appropriately
//
// CONTRACT:
-// slashFactor is non-negative
+//
+// slashFactor is non-negative
+//
// CONTRACT:
-// Infraction was committed equal to or less than an unbonding period in the past,
-// so all unbonding delegations and redelegations from that height are stored
+//
+// Infraction was committed equal to or less than an unbonding period in the past,
+// so all unbonding delegations and redelegations from that height are stored
+//
// CONTRACT:
-// Slash will not slash unbonded validators (for the above reason)
+//
+// Slash will not slash unbonded validators (for the above reason)
+//
// CONTRACT:
-// Infraction was committed at the current height or at a past height,
-// not at a height in the future
-func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) sdk.Int {
+//
+// Infraction was committed at the current height or at a past height,
+// not at a height in the future
+func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int {
logger := k.Logger(ctx)
if slashFactor.IsNegative() {
@@ -167,7 +175,7 @@
// insufficient stake remaining)
func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation types.UnbondingDelegation,
infractionHeight int64, slashFactor sdk.Dec,
-) (totalSlashAmount sdk.Int) {
+) (totalSlashAmount math.Int) {
now := ctx.BlockHeader().Time
totalSlashAmount = sdk.ZeroInt()
burnedAmount := sdk.ZeroInt()
@@ -221,7 +229,7 @@
// NOTE this is only slashing for prior infractions from the source validator
func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, redelegation types.Redelegation,
infractionHeight int64, slashFactor sdk.Dec,
-) (totalSlashAmount sdk.Int) {
+) (totalSlashAmount math.Int) {
now := ctx.BlockHeader().Time
totalSlashAmount = sdk.ZeroInt()
bondedBurnedAmount, notBondedBurnedAmount := sdk.ZeroInt(), sdk.ZeroInt()
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/keeper/validator.go ../pstake-native/x/lsnative/staking/keeper/validator.go
--- x/staking/keeper/validator.go 2023-03-08 16:57:00
+++ ../pstake-native/x/lsnative/staking/keeper/validator.go 2023-03-10 17:39:45
@@ -4,6 +4,7 @@
"fmt"
"time"
+ "cosmossdk.io/math"
gogotypes "github.com/gogo/protobuf/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -11,7 +12,7 @@
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
)
-// get a single validator
+// GetLiquidValidator gets a single validator
func (k Keeper) GetLiquidValidator(ctx sdk.Context, addr sdk.ValAddress) (validator types.Validator, found bool) {
store := ctx.KVStore(k.storeKey)
@@ -24,7 +25,7 @@
return validator, true
}
-// get a single validator as sdktypes for other module use
+// GetValidator gets a single validator
func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator sdkstaking.Validator, found bool) {
store := ctx.KVStore(k.storeKey)
@@ -40,7 +41,7 @@
func (k Keeper) mustGetLiquidValidator(ctx sdk.Context, addr sdk.ValAddress) types.Validator {
validator, found := k.GetLiquidValidator(ctx, addr)
if !found {
- panic(fmt.Sprintf("validator record not found for address: %X\n", addr))
+ panic(fmt.Sprintf("liquid validator record not found for address: %X\n", addr))
}
return validator
@@ -110,7 +111,7 @@
// Update the tokens of an existing validator, update the validators power index key
func (k Keeper) AddValidatorTokensAndShares(ctx sdk.Context, validator types.Validator,
- tokensToAdd sdk.Int,
+ tokensToAdd math.Int,
) (valOut types.Validator, addedShares sdk.Dec) {
k.DeleteValidatorByPowerIndex(ctx, validator)
validator, addedShares = validator.AddTokensFromDel(tokensToAdd)
@@ -123,7 +124,7 @@
// Update the tokens of an existing validator, update the validators power index key
func (k Keeper) RemoveValidatorTokensAndShares(ctx sdk.Context, validator types.Validator,
sharesToRemove sdk.Dec,
-) (valOut types.Validator, removedTokens sdk.Int) {
+) (valOut types.Validator, removedTokens math.Int) {
k.DeleteValidatorByPowerIndex(ctx, validator)
validator, removedTokens = validator.RemoveDelShares(sharesToRemove)
k.SetValidator(ctx, validator)
@@ -134,7 +135,7 @@
// Update the tokens of an existing validator, update the validators power index key
func (k Keeper) RemoveValidatorTokens(ctx sdk.Context,
- validator types.Validator, tokensToRemove sdk.Int,
+ validator types.Validator, tokensToRemove math.Int,
) types.Validator {
k.DeleteValidatorByPowerIndex(ctx, validator)
validator = validator.RemoveTokens(tokensToRemove)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/module.go ../pstake-native/x/lsnative/staking/module.go
--- x/staking/module.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/staking/module.go 2023-03-10 17:39:45
@@ -6,7 +6,6 @@
"fmt"
"math/rand"
- "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
@@ -71,11 +70,6 @@
return ValidateGenesis(&data)
}
-// RegisterRESTRoutes registers the REST routes for the staking module.
-// Deprecated: RegisterRESTRoutes is deprecated. `x/staking` legacy REST implementation
-// has been removed from the SDK.
-func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {}
-
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
@@ -142,6 +136,10 @@
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
querier := keeper.Querier{Keeper: am.keeper}
types.RegisterQueryServer(cfg.QueryServer(), querier)
+
+ m := keeper.NewMigrator(am.keeper)
+ cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
+ cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
}
// InitGenesis performs genesis initialization for the staking module. It returns
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/simulation/operations.go ../pstake-native/x/lsnative/staking/simulation/operations.go
--- x/staking/simulation/operations.go 2023-03-08 16:57:01
+++ ../pstake-native/x/lsnative/staking/simulation/operations.go 2023-03-10 17:39:45
@@ -23,15 +23,15 @@
// Simulation operation weights constants
const (
- OpWeightMsgCreateValidator = "op_weight_msg_create_validator"
- OpWeightMsgEditValidator = "op_weight_msg_edit_validator"
- OpWeightMsgDelegate = "op_weight_msg_delegate"
- OpWeightMsgUndelegate = "op_weight_msg_undelegate"
- OpWeightMsgBeginRedelegate = "op_weight_msg_begin_redelegate"
- OpWeightMsgCancelUnbondingDelegation = "op_weight_msg_cancel_unbonding_delegation"
- OpWeightMsgTokenizeShares = "op_weight_msg_tokenize_shares"
- OpWeightMsgRedeemTokensforShares = "op_weight_msg_redeem_tokens_for_shares"
- OpWeightMsgTransferTokenizeShareRecord = "op_weight_msg_transfer_tokenize_share_record"
+ OpWeightMsgCreateValidator = "op_weight_msg_create_validator" //nolint:gosec
+ OpWeightMsgEditValidator = "op_weight_msg_edit_validator" //nolint:gosec
+ OpWeightMsgDelegate = "op_weight_msg_delegate" //nolint:gosec
+ OpWeightMsgUndelegate = "op_weight_msg_undelegate" //nolint:gosec
+ OpWeightMsgBeginRedelegate = "op_weight_msg_begin_redelegate" //nolint:gosec
+ OpWeightMsgCancelUnbondingDelegation = "op_weight_msg_cancel_unbonding_delegation" //nolint:gosec
+ OpWeightMsgTokenizeShares = "op_weight_msg_tokenize_shares" //nolint:gosec
+ OpWeightMsgRedeemTokensforShares = "op_weight_msg_redeem_tokens_for_shares" //nolint:gosec
+ OpWeightMsgTransferTokenizeShareRecord = "op_weight_msg_transfer_tokenize_share_record" //nolint:gosec
)
// WeightedOperations returns all the operations from the module with their respective weights
@@ -453,8 +453,22 @@
return simtypes.NoOpMsg(types.ModuleName, sdkstaking.TypeMsgCancelUnbondingDelegation, "account does have any unbonding delegation"), nil, nil
}
- // get random unbonding delegation entry at block height
- unbondingDelegationEntry := unbondingDelegation.Entries[r.Intn(len(unbondingDelegation.Entries))]
+ // This is a temporary fix to make staking simulation pass. We should fetch
+ // the first unbondingDelegationEntry that matches the creationHeight, because
+ // currently the staking msgServer chooses the first unbondingDelegationEntry
+ // with the matching creationHeight.
+ //
+ // ref: https://github.com/cosmos/cosmos-sdk/issues/12932
+ creationHeight := unbondingDelegation.Entries[r.Intn(len(unbondingDelegation.Entries))].CreationHeight
+
+ var unbondingDelegationEntry types.UnbondingDelegationEntry
+
+ for _, entry := range unbondingDelegation.Entries {
+ if entry.CreationHeight == creationHeight {
+ unbondingDelegationEntry = entry
+ break
+ }
+ }
if unbondingDelegationEntry.CompletionTime.Before(ctx.BlockTime()) {
return simtypes.NoOpMsg(types.ModuleName, sdkstaking.TypeMsgCancelUnbondingDelegation, "unbonding delegation is already processed"), nil, nil
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/01_state.md ../pstake-native/x/lsnative/staking/spec/01_state.md
--- x/staking/spec/01_state.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/01_state.md 2023-03-10 17:39:45
@@ -13,31 +13,29 @@
LastTotalPower tracks the total amounts of bonded tokens recorded during the previous end block.
Store entries prefixed with "Last" must remain unchanged until EndBlock.
-- LastTotalPower: `0x12 -> ProtocolBuffer(sdk.Int)`
+* LastTotalPower: `0x12 -> ProtocolBuffer(math.Int)`
## Params
Params is a module-wide configuration structure that stores system parameters
and defines overall functioning of the staking module.
-- Params: `Paramsspace("staking") -> legacy_amino(params)`
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L285-L306
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.1/proto/cosmos/staking/v1beta1/staking.proto#L230-L241
-
## Validator
Validators can have one of three statuses
-- `Unbonded`: The validator is not in the active set. They cannot sign blocks and do not earn
+* `Unbonded`: The validator is not in the active set. They cannot sign blocks and do not earn
rewards. They can receive delegations.
-- `Bonded`": Once the validator receives sufficient bonded tokens they automtically join the
+* `Bonded`: Once the validator receives sufficient bonded tokens they automtically join the
active set during [`EndBlock`](./05_end_block.md#validator-set-changes) and their status is updated to `Bonded`.
They are signing blocks and receiving rewards. They can receive further delegations.
They can be slashed for misbehavior. Delegators to this validator who unbond their delegation
must wait the duration of the UnbondingTime, a chain-specific param, during which time
they are still slashable for offences of the source validator if those offences were committed
during the period of time that the tokens were bonded.
-- `Unbonding`: When a validator leaves the active set, either by choice or due to slashing, jailing or
+* `Unbonding`: When a validator leaves the active set, either by choice or due to slashing, jailing or
tombstoning, an unbonding of all their delegations begins. All delegations must then wait the UnbondingTime
before their tokens are moved to their accounts from the `BondedPool`.
@@ -49,10 +47,10 @@
throughout each block, unlike the first two indices which mirror the validator
records within a block.
-- Validators: `0x21 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(validator)`
-- ValidatorsByConsAddr: `0x22 | ConsAddrLen (1 byte) | ConsAddr -> OperatorAddr`
-- ValidatorsByPower: `0x23 | BigEndian(ConsensusPower) | OperatorAddrLen (1 byte) | OperatorAddr -> OperatorAddr`
-- LastValidatorsPower: `0x11 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(ConsensusPower)`
+* Validators: `0x21 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(validator)`
+* ValidatorsByConsAddr: `0x22 | ConsAddrLen (1 byte) | ConsAddr -> OperatorAddr`
+* ValidatorsByPower: `0x23 | BigEndian(ConsensusPower) | OperatorAddrLen (1 byte) | OperatorAddr -> OperatorAddr`
+* LastValidatorsPower: `0x11 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(ConsensusPower)`
`Validators` is the primary index - it ensures that each operator can have only one
associated validator, where the public key of that validator can change in the
@@ -75,23 +73,23 @@
Each validator's state is stored in a `Validator` struct:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L65-L99
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L78-L127
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L24-L63
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L24-L76
## Delegation
Delegations are identified by combining `DelegatorAddr` (the address of the delegator)
with the `ValidatorAddr` Delegators are indexed in the store as follows:
-- Delegation: `0x31 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(delegation)`
+* Delegation: `0x31 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(delegation)`
Stake holders may delegate coins to validators; under this circumstance their
funds are held in a `Delegation` data structure. It is owned by one
delegator, and is associated with the shares for one validator. The sender of
the transaction is the owner of the bond.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L159-L170
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L187-L205
### Delegator Shares
@@ -120,8 +118,8 @@
`UnbondingDelegation` are indexed in the store as:
-- UnbondingDelegation: `0x32 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(unbondingDelegation)`
-- UnbondingDelegationsFromValidator: `0x33 | ValidatorAddrLen (1 byte) | ValidatorAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* UnbondingDelegation: `0x32 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(unbondingDelegation)`
+* UnbondingDelegationsFromValidator: `0x33 | ValidatorAddrLen (1 byte) | ValidatorAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
The first map here is used in queries, to lookup all unbonding delegations for
a given delegator, while the second map is used in slashing, to lookup all
@@ -130,7 +128,7 @@
A UnbondingDelegation object is created every time an unbonding is initiated.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L172-L198
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L207-L220
## Redelegation
@@ -142,9 +140,9 @@
`Redelegation` are indexed in the store as:
-- Redelegations: `0x34 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddr -> ProtocolBuffer(redelegation)`
-- RedelegationsBySrc: `0x35 | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
-- RedelegationsByDst: `0x36 | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* Redelegations: `0x34 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddr -> ProtocolBuffer(redelegation)`
+* RedelegationsBySrc: `0x35 | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* RedelegationsByDst: `0x36 | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
The first map here is used for queries, to lookup all redelegations for a given
delegator. The second map is used for slashing based on the `ValidatorSrcAddr`,
@@ -153,22 +151,22 @@
A redelegation object is created every time a redelegation occurs. To prevent
"redelegation hopping" redelegations may not occur under the situation that:
-- the (re)delegator already has another immature redelegation in progress
+* the (re)delegator already has another immature redelegation in progress
with a destination to a validator (let's call it `Validator X`)
-- and, the (re)delegator is attempting to create a _new_ redelegation
+* and, the (re)delegator is attempting to create a _new_ redelegation
where the source validator for this new redelegation is `Validator X`.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L200-L228
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L245-L283
## Queues
All queues objects are sorted by timestamp. The time used within any queue is
first rounded to the nearest nanosecond then sorted. The sortable time format
-used is a slight modification of the RFC3339Nano and uses the the format string
+used is a slight modification of the RFC3339Nano and uses the format string
`"2006-01-02T15:04:05.000000000"`. Notably this format:
-- right pads all zeros
-- drops the time zone info (uses UTC)
+* right pads all zeros
+* drops the time zone info (uses UTC)
In all cases, the stored timestamp represents the maturation time of the queue
element.
@@ -178,25 +176,25 @@
For the purpose of tracking progress of unbonding delegations the unbonding
delegations queue is kept.
-- UnbondingDelegation: `0x41 | format(time) -> []DVPair`
+* UnbondingDelegation: `0x41 | format(time) -> []DVPair`
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L123-L133
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L151-L161
### RedelegationQueue
For the purpose of tracking progress of redelegations the redelegation queue is
kept.
-- RedelegationQueue: `0x42 | format(time) -> []DVVTriplet`
+* RedelegationQueue: `0x42 | format(time) -> []DVVTriplet`
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L140-L152
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L168-L179
### ValidatorQueue
For the purpose of tracking progress of unbonding validators the validator
queue is kept.
-- ValidatorQueueTime: `0x43 | format(time) -> []sdk.ValAddress`
+* ValidatorQueueTime: `0x43 | format(time) -> []sdk.ValAddress`
The stored object as each key is an array of validator operator addresses from
which the validator object can be accessed. Typically it is expected that only
@@ -208,7 +206,7 @@
HistoricalInfo objects are stored and pruned at each block such that the staking keeper persists
the `n` most recent historical info defined by staking module parameter: `HistoricalEntries`.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/staking.proto#L15-L22
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L15-L22
At each BeginBlock, the staking keeper will persist the current Header and the Validators that committed
the current block in a `HistoricalInfo` object. The Validators are sorted on their address to ensure that
@@ -224,11 +222,11 @@
```go
type TokenizeShareRecord struct {
- Id uint64
- Owner string
- ShareTokenDenom string
- ModuleAccount string
- Validator string
+ Id uint64
+ Owner string
+ ShareTokenDenom string
+ ModuleAccount string
+ Validator string
}
```
@@ -241,4 +239,4 @@
LastTokenizeShareRecordIdKey is used to maintain unique id of tokenize share record.
-It is stored on `0x64 -> LastTokenizeShareRecordId`
+It is stored on `0x64 -> LastTokenizeShareRecordId`
\ No newline at end of file
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/02_state_transitions.md ../pstake-native/x/lsnative/staking/spec/02_state_transitions.md
--- x/staking/spec/02_state_transitions.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/02_state_transitions.md 2023-03-10 17:39:45
@@ -24,44 +24,44 @@
The following transition occurs when a validator's ranking in the `ValidatorPowerIndex` surpasses
that of the `LastValidator`.
-- set `validator.Status` to `Bonded`
-- send the `validator.Tokens` from the `NotBondedTokens` to the `BondedPool` `ModuleAccount`
-- delete the existing record from `ValidatorByPowerIndex`
-- add a new updated record to the `ValidatorByPowerIndex`
-- update the `Validator` object for this validator
-- if it exists, delete any `ValidatorQueue` record for this validator
+* set `validator.Status` to `Bonded`
+* send the `validator.Tokens` from the `NotBondedTokens` to the `BondedPool` `ModuleAccount`
+* delete the existing record from `ValidatorByPowerIndex`
+* add a new updated record to the `ValidatorByPowerIndex`
+* update the `Validator` object for this validator
+* if it exists, delete any `ValidatorQueue` record for this validator
### Bonded to Unbonding
When a validator begins the unbonding process the following operations occur:
-- send the `validator.Tokens` from the `BondedPool` to the `NotBondedTokens` `ModuleAccount`
-- set `validator.Status` to `Unbonding`
-- delete the existing record from `ValidatorByPowerIndex`
-- add a new updated record to the `ValidatorByPowerIndex`
-- update the `Validator` object for this validator
-- insert a new record into the `ValidatorQueue` for this validator
+* send the `validator.Tokens` from the `BondedPool` to the `NotBondedTokens` `ModuleAccount`
+* set `validator.Status` to `Unbonding`
+* delete the existing record from `ValidatorByPowerIndex`
+* add a new updated record to the `ValidatorByPowerIndex`
+* update the `Validator` object for this validator
+* insert a new record into the `ValidatorQueue` for this validator
### Unbonding to Unbonded
A validator moves from unbonding to unbonded when the `ValidatorQueue` object
moves from bonded to unbonded
-- update the `Validator` object for this validator
-- set `validator.Status` to `Unbonded`
+* update the `Validator` object for this validator
+* set `validator.Status` to `Unbonded`
### Jail/Unjail
when a validator is jailed it is effectively removed from the Tendermint set.
this process may be also be reversed. the following operations occur:
-- set `Validator.Jailed` and update object
-- if jailed delete record from `ValidatorByPowerIndex`
-- if unjailed add record to `ValidatorByPowerIndex`
+* set `Validator.Jailed` and update object
+* if jailed delete record from `ValidatorByPowerIndex`
+* if unjailed add record to `ValidatorByPowerIndex`
Jailed validators are not present in any of the following stores:
-- the power store (from consensus power to address)
+* the power store (from consensus power to address)
## Delegations
@@ -69,49 +69,53 @@
When a delegation occurs both the validator and the delegation objects are affected
-- determine the delegators shares based on tokens delegated and the validator's exchange rate
-- remove tokens from the sending account
-- add shares the delegation object or add them to a created validator object
-- add new delegator shares and update the `Validator` object
-- transfer the `delegation.Amount` from the delegator's account to the `BondedPool` or the `NotBondedPool` `ModuleAccount` depending if the `validator.Status` is `Bonded` or not
-- delete the existing record from `ValidatorByPowerIndex`
-- add an new updated record to the `ValidatorByPowerIndex`
+* determine the delegators shares based on tokens delegated and the validator's exchange rate
+* remove tokens from the sending account
+* add shares the delegation object or add them to a created validator object
+* add new delegator shares and update the `Validator` object
+* transfer the `delegation.Amount` from the delegator's account to the `BondedPool` or the `NotBondedPool` `ModuleAccount` depending if the `validator.Status` is `Bonded` or not
+* delete the existing record from `ValidatorByPowerIndex`
+* add an new updated record to the `ValidatorByPowerIndex`
### Begin Unbonding
As a part of the Undelegate and Complete Unbonding state transitions Unbond
Delegation may be called.
-- subtract the unbonded shares from delegator
-- if the validator is `Unbonding` or `Bonded` add the tokens to an `UnbondingDelegation` Entry
-- if the validator is `Unbonded` send the tokens directly to the withdraw
- account
-- update the delegation or remove the delegation if there are no more shares
-- if the delegation is the operator of the validator and no more shares exist then trigger a jail validator
-- update the validator with removed the delegator shares and associated coins
-- if the validator state is `Bonded`, transfer the `Coins` worth of the unbonded
+* subtract the unbonded shares from delegator
+* add the unbonded tokens to an `UnbondingDelegation` Entry
+* update the delegation or remove the delegation if there are no more shares
+* if the delegation is the operator of the validator and no more shares exist then trigger a jail validator
+* update the validator with removed the delegator shares and associated coins
+* if the validator state is `Bonded`, transfer the `Coins` worth of the unbonded
shares from the `BondedPool` to the `NotBondedPool` `ModuleAccount`
-- remove the validator if it is unbonded and there are no more delegation shares.
+* remove the validator if it is unbonded and there are no more delegation shares.
+### Cancel an `UnbondingDelegation` Entry
+When a `cancel unbond delegation` occurs both the `validator`, the `delegation` and an `UnbondingDelegationQueue` state will be updated.
+* if cancel unbonding delegation amount equals to the `UnbondingDelegation` entry `balance`, then the `UnbondingDelegation` entry deleted from `UnbondingDelegationQueue`.
+* if the `cancel unbonding delegation amount is less than the `UnbondingDelegation` entry balance, then the `UnbondingDelegation` entry will be updated with new balance in the `UnbondingDelegationQueue`.
+* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to the original `validator`.
+
### Complete Unbonding
For undelegations which do not complete immediately, the following operations
occur when the unbonding delegation queue element matures:
-- remove the entry from the `UnbondingDelegation` object
-- transfer the tokens from the `NotBondedPool` `ModuleAccount` to the delegator `Account`
+* remove the entry from the `UnbondingDelegation` object
+* transfer the tokens from the `NotBondedPool` `ModuleAccount` to the delegator `Account`
### Begin Redelegation
Redelegations affect the delegation, source and destination validators.
-- perform an `unbond` delegation from the source validator to retrieve the tokens worth of the unbonded shares
-- using the unbonded tokens, `Delegate` them to the destination validator
-- if the `sourceValidator.Status` is `Bonded`, and the `destinationValidator` is not,
+* perform an `unbond` delegation from the source validator to retrieve the tokens worth of the unbonded shares
+* using the unbonded tokens, `Delegate` them to the destination validator
+* if the `sourceValidator.Status` is `Bonded`, and the `destinationValidator` is not,
transfer the newly delegated tokens from the `BondedPool` to the `NotBondedPool` `ModuleAccount`
-- otherwise, if the `sourceValidator.Status` is not `Bonded`, and the `destinationValidator`
+* otherwise, if the `sourceValidator.Status` is not `Bonded`, and the `destinationValidator`
is `Bonded`, transfer the newly delegated tokens from the `NotBondedPool` to the `BondedPool` `ModuleAccount`
-- record the token amount in an new entry in the relevant `Redelegation`
+* record the token amount in an new entry in the relevant `Redelegation`
From when a redelegation begins until it completes, the delegator is in a state of "pseudo-unbonding", and can still be
slashed for infractions that occured before the redelegation began.
@@ -120,7 +124,7 @@
When a redelegations complete the following occurs:
-- remove the entry from the `Redelegation` object
+* remove the entry from the `Redelegation` object
## Slashing
@@ -128,13 +132,13 @@
When a Validator is slashed, the following occurs:
-- The total `slashAmount` is calculated as the `slashFactor` (a chain parameter) \* `TokensFromConsensusPower`,
+* The total `slashAmount` is calculated as the `slashFactor` (a chain parameter) \* `TokensFromConsensusPower`,
the total number of tokens bonded to the validator at the time of the infraction.
-- Every unbonding delegation and pseudo-unbonding redelegation such that the infraction occured before the unbonding or
+* Every unbonding delegation and pseudo-unbonding redelegation such that the infraction occured before the unbonding or
redelegation began from the validator are slashed by the `slashFactor` percentage of the initialBalance.
-- Each amount slashed from redelegations and unbonding delegations is subtracted from the
+* Each amount slashed from redelegations and unbonding delegations is subtracted from the
total slash amount.
-- The `remaingSlashAmount` is then slashed from the validator's tokens in the `BondedPool` or
+* The `remaingSlashAmount` is then slashed from the validator's tokens in the `BondedPool` or
`NonBondedPool` depending on the validator's status. This reduces the total supply of tokens.
In the case of a slash due to any infraction that requires evidence to submitted (for example double-sign), the slash
@@ -212,4 +216,4 @@
1. Check tokenize share record exists and the owner is the sender of the message
2. Delete old owner's reference to tokenize share record
3. Update tokenize share record to have new owner
-4. Add new owner's reference to tokenize share record
+4. Add new owner's reference to tokenize share record
\ No newline at end of file
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/03_messages.md ../pstake-native/x/lsnative/staking/spec/03_messages.md
--- x/staking/spec/03_messages.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/03_messages.md 2023-03-10 17:39:45
@@ -11,20 +11,20 @@
A validator is created using the `MsgCreateValidator` message.
The validator must be created with an initial delegation from the operator.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L16-L17
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L18-L19
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L35-L51
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L43-L65
This message is expected to fail if:
-- another validator with this operator address is already registered
-- another validator with this pubkey is already registered
-- the initial self-delegation tokens are of a denom not specified as the bonding denom
-- the commission parameters are faulty, namely:
- - `MaxRate` is either > 1 or < 0
- - the initial `Rate` is either negative or > `MaxRate`
- - the initial `MaxChangeRate` is either negative or > `MaxRate`
-- the description fields are too large
+* another validator with this operator address is already registered
+* another validator with this pubkey is already registered
+* the initial self-delegation tokens are of a denom not specified as the bonding denom
+* the commission parameters are faulty, namely:
+ * `MaxRate` is either > 1 or < 0
+ * the initial `Rate` is either negative or > `MaxRate`
+ * the initial `MaxChangeRate` is either negative or > `MaxRate`
+* the description fields are too large
This message creates and stores the `Validator` object at appropriate indexes.
Additionally a self-delegation is made with the initial tokens delegation
@@ -36,16 +36,16 @@
The `Description`, `CommissionRate` of a validator can be updated using the
`MsgEditValidator` message.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L19-L20
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L21-L22
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L56-L76
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L70-L88
This message is expected to fail if:
-- the initial `CommissionRate` is either negative or > `MaxRate`
-- the `CommissionRate` has already been updated within the previous 24 hours
-- the `CommissionRate` is > `MaxChangeRate`
-- the description fields are too large
+* the initial `CommissionRate` is either negative or > `MaxRate`
+* the `CommissionRate` has already been updated within the previous 24 hours
+* the `CommissionRate` is > `MaxChangeRate`
+* the description fields are too large
This message stores the updated `Validator` object.
@@ -55,16 +55,16 @@
some amount of their validator's (newly created) delegator-shares that are
assigned to `Delegation.Shares`.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L22-L24
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L24-L26
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L93-L104
This message is expected to fail if:
-- the validator does not exist
-- the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom`
-- the exchange rate is invalid, meaning the validator has no tokens (due to slashing) but there are outstanding shares
-- the amount delegated is less than the minimum allowed delegation
+* the validator does not exist
+* the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom`
+* the exchange rate is invalid, meaning the validator has no tokens (due to slashing) but there are outstanding shares
+* the amount delegated is less than the minimum allowed delegation
If an existing `Delegation` object for provided addresses does not already
exist then it is created as part of this message otherwise the existing
@@ -87,69 +87,90 @@
The `MsgUndelegate` message allows delegators to undelegate their tokens from
validator.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L30-L32
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L32-L34
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L128-L139
This message returns a response containing the completion time of the undelegation:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L123-L126
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L128-L144
This message is expected to fail if:
-- the delegation doesn't exist
-- the validator doesn't exist
-- the delegation has less shares than the ones worth of `Amount`
-- existing `UnbondingDelegation` has maximum entries as defined by `params.MaxEntries`
-- the `Amount` has a denomination different than one defined by `params.BondDenom`
+* the delegation doesn't exist
+* the validator doesn't exist
+* the delegation has less shares than the ones worth of `Amount`
+* existing `UnbondingDelegation` has maximum entries as defined by `params.MaxEntries`
+* the `Amount` has a denomination different than one defined by `params.BondDenom`
When this message is processed the following actions occur:
-- validator's `DelegatorShares` and the delegation's `Shares` are both reduced by the message `SharesAmount`
-- calculate the token worth of the shares remove that amount tokens held within the validator
-- with those removed tokens, if the validator is:
- - `Bonded` - add them to an entry in `UnbondingDelegation` (create `UnbondingDelegation` if it doesn't exist) with a completion time a full unbonding period from the current time. Update pool shares to reduce BondedTokens and increase NotBondedTokens by token worth of the shares.
- - `Unbonding` - add them to an entry in `UnbondingDelegation` (create `UnbondingDelegation` if it doesn't exist) with the same completion time as the validator (`UnbondingMinTime`).
- - `Unbonded` - then send the coins the message `DelegatorAddr`
-- if there are no more `Shares` in the delegation, then the delegation object is removed from the store
- - under this situation if the delegation is the validator's self-delegation then also jail the validator.
+* validator's `DelegatorShares` and the delegation's `Shares` are both reduced by the message `SharesAmount`
+* calculate the token worth of the shares remove that amount tokens held within the validator
+* with those removed tokens, if the validator is:
+ * `Bonded` - add them to an entry in `UnbondingDelegation` (create `UnbondingDelegation` if it doesn't exist) with a completion time a full unbonding period from the current time. Update pool shares to reduce BondedTokens and increase NotBondedTokens by token worth of the shares.
+ * `Unbonding` - add them to an entry in `UnbondingDelegation` (create `UnbondingDelegation` if it doesn't exist) with the same completion time as the validator (`UnbondingMinTime`).
+ * `Unbonded` - then send the coins the message `DelegatorAddr`
+* if there are no more `Shares` in the delegation, then the delegation object is removed from the store
+ * under this situation if the delegation is the validator's self-delegation then also jail the validator.
![Unbond sequence](../../../docs/uml/svg/unbond_sequence.svg)
+## MsgCancelUnbondingDelegation
+
+The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbondingDelegation` entry and deleagate back to a previous validator.
+
++++ hhttps://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L36-L40
+
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L146-L165
+
+This message is expected to fail if:
+
+* the `unbondingDelegation` entry is already processed.
+* the `cancel unbonding delegation` amount is greater than the `unbondingDelegation` entry balance.
+* the `cancel unbonding delegation` height doesn't exists in the `unbondingDelegationQueue` of the delegator.
+
+When this message is processed the following actions occur:
+
+* if the `unbondingDelegation` Entry balance is zero
+ * in this condition `unbondingDelegation` entry will be removed from `unbondingDelegationQueue`.
+ * otherwise `unbondingDelegationQueue` will be updated with new `unbondingDelegation` entry balance and initial balance
+* the validator's `DelegatorShares` and the delegation's `Shares` are both increased by the message `Amount`.
+
## MsgBeginRedelegate
The redelegation command allows delegators to instantly switch validators. Once
the unbonding period has passed, the redelegation is automatically completed in
the EndBlocker.
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L26-L28
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L28-L30
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L109-L121
This message returns a response containing the completion time of the redelegation:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L107-L110
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L123-L126
This message is expected to fail if:
-- the delegation doesn't exist
-- the source or destination validators don't exist
-- the delegation has less shares than the ones worth of `Amount`
-- the source validator has a receiving redelegation which is not matured (aka. the redelegation may be transitive)
-- existing `Redelegation` has maximum entries as defined by `params.MaxEntries`
-- the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom`
+* the delegation doesn't exist
+* the source or destination validators don't exist
+* the delegation has less shares than the ones worth of `Amount`
+* the source validator has a receiving redelegation which is not matured (aka. the redelegation may be transitive)
+* existing `Redelegation` has maximum entries as defined by `params.MaxEntries`
+* the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom`
When this message is processed the following actions occur:
-- the source validator's `DelegatorShares` and the delegations `Shares` are both reduced by the message `SharesAmount`
-- calculate the token worth of the shares remove that amount tokens held within the source validator.
-- if the source validator is:
- - `Bonded` - add an entry to the `Redelegation` (create `Redelegation` if it doesn't exist) with a completion time a full unbonding period from the current time. Update pool shares to reduce BondedTokens and increase NotBondedTokens by token worth of the shares (this may be effectively reversed in the next step however).
- - `Unbonding` - add an entry to the `Redelegation` (create `Redelegation` if it doesn't exist) with the same completion time as the validator (`UnbondingMinTime`).
- - `Unbonded` - no action required in this step
-- Delegate the token worth to the destination validator, possibly moving tokens back to the bonded state.
-- if there are no more `Shares` in the source delegation, then the source delegation object is removed from the store
- - under this situation if the delegation is the validator's self-delegation then also jail the validator.
+* the source validator's `DelegatorShares` and the delegations `Shares` are both reduced by the message `SharesAmount`
+* calculate the token worth of the shares remove that amount tokens held within the source validator.
+* if the source validator is:
+ * `Bonded` - add an entry to the `Redelegation` (create `Redelegation` if it doesn't exist) with a completion time a full unbonding period from the current time. Update pool shares to reduce BondedTokens and increase NotBondedTokens by token worth of the shares (this may be effectively reversed in the next step however).
+ * `Unbonding` - add an entry to the `Redelegation` (create `Redelegation` if it doesn't exist) with the same completion time as the validator (`UnbondingMinTime`).
+ * `Unbonded` - no action required in this step
+* Delegate the token worth to the destination validator, possibly moving tokens back to the bonded state.
+* if there are no more `Shares` in the source delegation, then the source delegation object is removed from the store
+ * under this situation if the delegation is the validator's self-delegation then also jail the validator.
![Begin redelegation sequence](../../../docs/uml/svg/begin_redelegation_sequence.svg)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/05_end_block.md ../pstake-native/x/lsnative/staking/spec/05_end_block.md
--- x/staking/spec/05_end_block.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/05_end_block.md 2023-03-10 17:35:24
@@ -1,5 +1,5 @@
<!--
-order: 4
+order: 5
-->
# End-Block
@@ -15,12 +15,12 @@
validator set which is responsible for validating Tendermint messages at the
consensus layer. Operations are as following:
-- the new validator set is taken as the top `params.MaxValidators` number of
+* the new validator set is taken as the top `params.MaxValidators` number of
validators retrieved from the `ValidatorsByPower` index
-- the previous validator set is compared with the new validator set:
- - missing validators begin unbonding and their `Tokens` are transferred from the
+* the previous validator set is compared with the new validator set:
+ * missing validators begin unbonding and their `Tokens` are transferred from the
`BondedPool` to the `NotBondedPool` `ModuleAccount`
- - new validators are instantly bonded and their `Tokens` are transferred from the
+ * new validators are instantly bonded and their `Tokens` are transferred from the
`NotBondedPool` to the `BondedPool` `ModuleAccount`
In all cases, any validators leaving or entering the bonded validator set or
@@ -62,9 +62,9 @@
Complete the unbonding of all mature `UnbondingDelegations.Entries` within the
`UnbondingDelegations` queue with the following procedure:
-- transfer the balance coins to the delegator's wallet address
-- remove the mature entry from `UnbondingDelegation.Entries`
-- remove the `UnbondingDelegation` object from the store if there are no
+* transfer the balance coins to the delegator's wallet address
+* remove the mature entry from `UnbondingDelegation.Entries`
+* remove the `UnbondingDelegation` object from the store if there are no
remaining entries.
### Redelegations
@@ -72,6 +72,6 @@
Complete the unbonding of all mature `Redelegation.Entries` within the
`Redelegations` queue with the following procedure:
-- remove the mature entry from `Redelegation.Entries`
-- remove the `Redelegation` object from the store if there are no
+* remove the mature entry from `Redelegation.Entries`
+* remove the `Redelegation` object from the store if there are no
remaining entries.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/06_hooks.md ../pstake-native/x/lsnative/staking/spec/06_hooks.md
--- x/staking/spec/06_hooks.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/06_hooks.md 2023-03-10 17:35:24
@@ -1,5 +1,5 @@
<!--
-order: 5
+order: 6
-->
# Hooks
@@ -9,19 +9,19 @@
right `Before` or `After` the staking event (as per the hook name). The
following hooks can registered with staking:
-- `AfterValidatorCreated(Context, ValAddress)`
- - called when a validator is created
-- `BeforeValidatorModified(Context, ValAddress)`
- - called when a validator's state is changed
-- `AfterValidatorRemoved(Context, ConsAddress, ValAddress)`
- - called when a validator is deleted
-- `AfterValidatorBonded(Context, ConsAddress, ValAddress)`
- - called when a validator is bonded
-- `AfterValidatorBeginUnbonding(Context, ConsAddress, ValAddress)`
- - called when a validator begins unbonding
-- `BeforeDelegationCreated(Context, AccAddress, ValAddress)`
- - called when a delegation is created
-- `BeforeDelegationSharesModified(Context, AccAddress, ValAddress)`
- - called when a delegation's shares are modified
-- `BeforeDelegationRemoved(Context, AccAddress, ValAddress)`
- - called when a delegation is removed
+* `AfterValidatorCreated(Context, ValAddress) error`
+ * called when a validator is created
+* `BeforeValidatorModified(Context, ValAddress) error`
+ * called when a validator's state is changed
+* `AfterValidatorRemoved(Context, ConsAddress, ValAddress) error`
+ * called when a validator is deleted
+* `AfterValidatorBonded(Context, ConsAddress, ValAddress) error`
+ * called when a validator is bonded
+* `AfterValidatorBeginUnbonding(Context, ConsAddress, ValAddress) error`
+ * called when a validator begins unbonding
+* `BeforeDelegationCreated(Context, AccAddress, ValAddress) error`
+ * called when a delegation is created
+* `BeforeDelegationSharesModified(Context, AccAddress, ValAddress) error`
+ * called when a delegation's shares are modified
+* `BeforeDelegationRemoved(Context, AccAddress, ValAddress) error`
+ * called when a delegation is removed
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/07_events.md ../pstake-native/x/lsnative/staking/spec/07_events.md
--- x/staking/spec/07_events.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/07_events.md 2023-03-10 17:39:45
@@ -1,5 +1,5 @@
<!--
-order: 6
+order: 7
-->
# Events
@@ -32,12 +32,12 @@
### MsgEditValidator
-| Type | Attribute Key | Attribute Value |
-| -------------- | --------------- | ---------------- |
-| edit_validator | commission_rate | {commissionRate} |
-| message | module | staking |
-| message | action | edit_validator |
-| message | sender | {senderAddress} |
+| Type | Attribute Key | Attribute Value |
+| -------------- | ------------------- | ------------------- |
+| edit_validator | commission_rate | {commissionRate} |
+| message | module | staking |
+| message | action | edit_validator |
+| message | sender | {senderAddress} |
### MsgDelegate
@@ -60,8 +60,20 @@
| message | action | begin_unbonding |
| message | sender | {senderAddress} |
-- [0] Time is formatted in the RFC3339 standard
+* [0] Time is formatted in the RFC3339 standard
+### MsgCancelUnbondingDelegation
+
+| Type | Attribute Key | Attribute Value |
+| ----------------------------- | ------------------ | ------------------------------------|
+| cancel_unbonding_delegation | validator | {validatorAddress} |
+| cancel_unbonding_delegation | delegator | {delegatorAddress} |
+| cancel_unbonding_delegation | amount | {cancelUnbondingDelegationAmount} |
+| cancel_unbonding_delegation | creation_height | {unbondingCreationHeight} |
+| message | module | staking |
+| message | action | cancel_unbond |
+| message | sender | {senderAddress} |
+
### MsgBeginRedelegate
| Type | Attribute Key | Attribute Value |
@@ -74,4 +86,4 @@
| message | action | begin_redelegate |
| message | sender | {senderAddress} |
-- [0] Time is formatted in the RFC3339 standard
+* [0] Time is formatted in the RFC3339 standard
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/08_params.md ../pstake-native/x/lsnative/staking/spec/08_params.md
--- x/staking/spec/08_params.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/08_params.md 2023-03-10 17:39:45
@@ -7,7 +7,7 @@
The staking module contains the following parameters:
| Key | Type | Example |
-| ----------------- | ---------------- | ---------------------- |
+|-------------------|------------------|------------------------|
| UnbondingTime | string (time ns) | "259200000000000" |
| MaxValidators | uint16 | 100 |
| KeyMaxEntries | uint16 | 7 |
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/09_client.md ../pstake-native/x/lsnative/staking/spec/09_client.md
--- x/staking/spec/09_client.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/09_client.md 2023-03-10 17:39:45
@@ -708,6 +708,19 @@
```bash
simd tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey
```
+#### cancel unbond
+The command `cancel-unbond` allow users to cancel the unbonding delegation entry and delegate back to the original validator.
+
+Usage:
+```bash
+simd tx staking cancel-unbond [validator-addr] [amount] [creation-height]
+```
+
+Example:
+```bash
+simd tx staking cancel-unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 123123 --from mykey
+```
+
## gRPC
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/spec/README.md ../pstake-native/x/lsnative/staking/spec/README.md
--- x/staking/spec/README.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/spec/README.md 2023-03-10 17:39:45
@@ -9,16 +9,16 @@
## Abstract
-This paper specifies the Staking module of the Cosmos-SDK, which was first
+This paper specifies the Staking module of the Cosmos SDK that was first
described in the [Cosmos Whitepaper](https://cosmos.network/about/whitepaper)
in June 2016.
-The module enables Cosmos-SDK based blockchain to support an advanced
-Proof-of-Stake system. In this system, holders of the native staking token of
+The module enables Cosmos SDK-based blockchain to support an advanced
+Proof-of-Stake (PoS) system. In this system, holders of the native staking token of
the chain can become validators and can delegate tokens to validators,
ultimately determining the effective validator set for the system.
-This module will be used in the Cosmos Hub, the first Hub in the Cosmos
+This module is used in the Cosmos Hub, the first Hub in the Cosmos
network.
This module has been extended with a liquid staking implementation to enable the creation of nonfungible tokenized staking shares to be used to be synthetic staked assets. The governing philosphy of this design is that it optimizes for allowing a smooth upgrade path from the existing cosmos staking module at the expense of the usability of the native staking token. It is anticipated that DAOs will form that accept these assets and issue a more usable underlying asset.
@@ -28,39 +28,38 @@
## Contents
1. **[State](01_state.md)**
- - [Pool](01_state.md#pool)
- - [LastTotalPower](01_state.md#lasttotalpower)
- - [Params](01_state.md#params)
- - [Validator](01_state.md#validator)
- - [Delegation](01_state.md#delegation)
- - [UnbondingDelegation](01_state.md#unbondingdelegation)
- - [Redelegation](01_state.md#redelegation)
- - [Queues](01_state.md#queues)
- - [HistoricalInfo](01_state.md#historicalinfo)
- - [TokenizeShareRecord](01_state.md#tokenizesharerecord)
+ * [Pool](01_state.md#pool)
+ * [LastTotalPower](01_state.md#lasttotalpower)
+ * [Params](01_state.md#params)
+ * [Validator](01_state.md#validator)
+ * [Delegation](01_state.md#delegation)
+ * [UnbondingDelegation](01_state.md#unbondingdelegation)
+ * [Redelegation](01_state.md#redelegation)
+ * [Queues](01_state.md#queues)
+ * [HistoricalInfo](01_state.md#historicalinfo)
+ * [TokenizeShareRecord](01_state.md#tokenizesharerecord)
2. **[State Transitions](02_state_transitions.md)**
- - [Validators](02_state_transitions.md#validators)
- - [Delegations](02_state_transitions.md#delegations)
- - [Slashing](02_state_transitions.md#slashing)
- - [Tokenizing](02_state_transitions.md#tokenizing)
+ * [Validators](02_state_transitions.md#validators)
+ * [Delegations](02_state_transitions.md#delegations)
+ * [Slashing](02_state_transitions.md#slashing)
+ * [Tokenizing](02_state_transitions.md#tokenizing)
3. **[Messages](03_messages.md)**
-
- - [MsgCreateValidator](03_messages.md#msgcreatevalidator)
- - [MsgEditValidator](03_messages.md#msgeditvalidator)
- - [MsgDelegate](03_messages.md#msgdelegate)
- - [MsgUndelegate](03_messages.md#msgundelegate)
- - [MsgBeginRedelegate](03_messages.md#msgbeginredelegate)
- - [MsgTokenizeShares](03_messages.md#msgtokenizeshares)
- - [MsgRedeemTokensforShares](03_messages.md#msgredeemtokensforshares)
- - [MsgTransferTokenizeShareRecord](03_messages.md#msgtransfertokenizesharerecord)
-
+ * [MsgCreateValidator](03_messages.md#msgcreatevalidator)
+ * [MsgEditValidator](03_messages.md#msgeditvalidator)
+ * [MsgDelegate](03_messages.md#msgdelegate)
+ * [MsgUndelegate](03_messages.md#msgundelegate)
+ * [MsgCancelUnbondingDelegation](03_messages.md#msgcancelunbondingdelegation)
+ * [MsgBeginRedelegate](03_messages.md#msgbeginredelegate)
+ * [MsgTokenizeShares](03_messages.md#msgtokenizeshares)
+ * [MsgRedeemTokensforShares](03_messages.md#msgredeemtokensforshares)
+ * [MsgTransferTokenizeShareRecord](03_messages.md#msgtransfertokenizesharerecord)
4. **[Begin-Block](04_begin_block.md)**
- - [Historical Info Tracking](04_begin_block.md#historical-info-tracking)
+ * [Historical Info Tracking](04_begin_block.md#historical-info-tracking)
5. **[End-Block](05_end_block.md)**
- - [Validator Set Changes](05_end_block.md#validator-set-changes)
- - [Queues](05_end_block.md#queues-)
+ * [Validator Set Changes](05_end_block.md#validator-set-changes)
+ * [Queues](05_end_block.md#queues-)
6. **[Hooks](06_hooks.md)**
7. **[Events](07_events.md)**
- - [EndBlocker](07_events.md#endblocker)
- - [Msg's](07_events.md#msg's)
+ * [EndBlocker](07_events.md#endblocker)
+ * [Msg's](07_events.md#msg's)
8. **[Parameters](08_params.md)**
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/teststaking/helper.go ../pstake-native/x/lsnative/staking/teststaking/helper.go
--- x/staking/teststaking/helper.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/staking/teststaking/helper.go 2023-03-10 17:39:45
@@ -5,6 +5,7 @@
"testing"
"time"
+ "cosmossdk.io/math"
"github.com/stretchr/testify/require"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@@ -34,14 +35,14 @@
}
// CreateValidator calls staking module `MsgServer/CreateValidator` to create a new validator
-func (sh *Helper) CreateValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount sdk.Int, ok bool) {
+func (sh *Helper) CreateValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount math.Int, ok bool) {
coin := sdk.NewCoin(sh.Denom, stakeAmount)
sh.createValidator(addr, pk, coin, ok)
}
// CreateValidatorWithValPower calls staking module `MsgServer/CreateValidator` to create a new validator with zero
// commission
-func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk cryptotypes.PubKey, valPower int64, ok bool) sdk.Int {
+func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk cryptotypes.PubKey, valPower int64, ok bool) math.Int {
amount := sh.k.TokensFromConsensusPower(sh.Ctx, valPower)
coin := sdk.NewCoin(sh.Denom, amount)
sh.createValidator(addr, pk, coin, ok)
@@ -49,7 +50,7 @@
}
// CreateValidatorMsg returns a message used to create validator in this service.
-func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount sdk.Int) *stakingtypes.MsgCreateValidator {
+func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount math.Int) *stakingtypes.MsgCreateValidator {
coin := sdk.NewCoin(sh.Denom, stakeAmount)
msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission)
require.NoError(sh.t, err)
@@ -75,7 +76,7 @@
}
// Delegate calls staking module staking module `MsgServer/Delegate` to delegate stake for a validator
-func (sh *Helper) Delegate(delegator sdk.AccAddress, val sdk.ValAddress, amount sdk.Int) {
+func (sh *Helper) Delegate(delegator sdk.AccAddress, val sdk.ValAddress, amount math.Int) {
coin := sdk.NewCoin(sh.Denom, amount)
msg := stakingtypes.NewMsgDelegate(delegator, val, coin)
res, err := sh.msgSrvr.Delegate(sdk.WrapSDKContext(sh.Ctx), msg)
@@ -93,7 +94,7 @@
}
// Undelegate calls staking module `MsgServer/Undelegate` to unbound some stake from a validator.
-func (sh *Helper) Undelegate(delegator sdk.AccAddress, val sdk.ValAddress, amount sdk.Int, ok bool) {
+func (sh *Helper) Undelegate(delegator sdk.AccAddress, val sdk.ValAddress, amount math.Int, ok bool) {
unbondAmt := sdk.NewCoin(sh.Denom, amount)
msg := stakingtypes.NewMsgUndelegate(delegator, val, unbondAmt)
res, err := sh.msgSrvr.Undelegate(sdk.WrapSDKContext(sh.Ctx), msg)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/teststaking/tm.go ../pstake-native/x/lsnative/staking/teststaking/tm.go
--- x/staking/teststaking/tm.go 2023-03-08 16:57:01
+++ ../pstake-native/x/lsnative/staking/teststaking/tm.go 2023-03-10 17:39:45
@@ -1,11 +1,11 @@
package teststaking
import (
+ "cosmossdk.io/math"
tmcrypto "github.com/tendermint/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types"
)
@@ -20,7 +20,7 @@
}
// ToTmValidator casts an SDK validator to a tendermint type Validator.
-func ToTmValidator(v types.Validator, r sdk.Int) (*tmtypes.Validator, error) {
+func ToTmValidator(v types.Validator, r math.Int) (*tmtypes.Validator, error) {
tmPk, err := GetTmConsPubKey(v)
if err != nil {
return nil, err
@@ -30,7 +30,7 @@
}
// ToTmValidators casts all validators to the corresponding tendermint type.
-func ToTmValidators(v types.Validators, r sdk.Int) ([]*tmtypes.Validator, error) {
+func ToTmValidators(v types.Validators, r math.Int) ([]*tmtypes.Validator, error) {
validators := make([]*tmtypes.Validator, len(v))
var err error
for i, val := range v {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/authz.go ../pstake-native/x/lsnative/staking/types/authz.go
--- x/staking/types/authz.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/authz.go 2023-03-10 17:35:24
@@ -10,14 +10,11 @@
// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072
const gasCostPerIteration = uint64(10)
-// Normalized Msg type URLs
-var (
- _ authz.Authorization = &StakeAuthorization{}
-)
+var _ authz.Authorization = &StakeAuthorization{}
// NewStakeAuthorization creates a new StakeAuthorization object.
func NewStakeAuthorization(allowed []sdk.ValAddress, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) {
- allowedValidators, deniedValidators, err := validateAndBech32fy(allowed, denied)
+ allowedValidators, deniedValidators, err := validateAllowAndDenyValidators(allowed, denied)
if err != nil {
return nil, err
}
@@ -48,10 +45,10 @@
func (a StakeAuthorization) ValidateBasic() error {
if a.MaxTokens != nil && a.MaxTokens.IsNegative() {
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "negative coin amount: %v", a.MaxTokens)
+ return sdkerrors.Wrapf(authz.ErrNegativeMaxTokens, "negative coin amount: %v", a.MaxTokens)
}
if a.AuthorizationType == AuthorizationType_AUTHORIZATION_TYPE_UNSPECIFIED {
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "unknown authorization type")
+ return authz.ErrUnknownAuthorizationType
}
return nil
@@ -90,28 +87,35 @@
for _, validator := range denyList {
ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization")
if validator == validatorAddress {
- return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf(" cannot delegate/undelegate to %s validator", validator)
+ return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validator)
}
}
- if !isValidatorExists {
+ if len(allowedList) > 0 && !isValidatorExists {
return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validatorAddress)
}
if a.MaxTokens == nil {
- return authz.AcceptResponse{Accept: true, Delete: false,
- Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType()}}, nil
+ return authz.AcceptResponse{
+ Accept: true, Delete: false,
+ Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType()},
+ }, nil
}
- limitLeft := a.MaxTokens.Sub(amount)
+ limitLeft, err := a.MaxTokens.SafeSub(amount)
+ if err != nil {
+ return authz.AcceptResponse{}, err
+ }
if limitLeft.IsZero() {
return authz.AcceptResponse{Accept: true, Delete: true}, nil
}
- return authz.AcceptResponse{Accept: true, Delete: false,
- Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType(), MaxTokens: &limitLeft}}, nil
+ return authz.AcceptResponse{
+ Accept: true, Delete: false,
+ Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType(), MaxTokens: &limitLeft},
+ }, nil
}
-func validateAndBech32fy(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) {
+func validateAllowAndDenyValidators(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) {
if len(allowed) == 0 && len(denied) == 0 {
return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty")
}
@@ -136,6 +140,7 @@
return nil, deniedValidators, nil
}
+// Normalized Msg type URLs
func normalizeAuthzType(authzType AuthorizationType) (string, error) {
switch authzType {
case AuthorizationType_AUTHORIZATION_TYPE_DELEGATE:
@@ -145,6 +150,6 @@
case AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE:
return sdk.MsgTypeURL(&MsgBeginRedelegate{}), nil
default:
- return "", sdkerrors.ErrInvalidType.Wrapf("unknown authorization type %T", authzType)
+ return "", sdkerrors.Wrapf(authz.ErrUnknownAuthorizationType, "cannot normalize authz type with %T", authzType)
}
}
Only in ../pstake-native/x/lsnative/staking/types: authz.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/codec.go ../pstake-native/x/lsnative/staking/types/codec.go
--- x/staking/types/codec.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/codec.go 2023-03-10 17:39:45
@@ -4,22 +4,25 @@
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/x/authz"
+ authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- // cdc.RegisterConcrete(&MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil)
- // cdc.RegisterConcrete(&MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil)
- // cdc.RegisterConcrete(&MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil)
- // cdc.RegisterConcrete(&MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil)
- // cdc.RegisterConcrete(&MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil)
- cdc.RegisterConcrete(&MsgTokenizeShares{}, "cosmos-sdk/MsgTokenizeShares", nil)
- cdc.RegisterConcrete(&MsgRedeemTokensforShares{}, "cosmos-sdk/MsgRedeemTokensforShares", nil)
- cdc.RegisterConcrete(&MsgTransferTokenizeShareRecord{}, "cosmos-sdk/MsgTransferTokenizeShareRecord", nil)
+ // legacy.RegisterAminoMsg(cdc, &MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator")
+ // legacy.RegisterAminoMsg(cdc, &MsgEditValidator{}, "cosmos-sdk/MsgEditValidator")
+ // legacy.RegisterAminoMsg(cdc, &MsgDelegate{}, "cosmos-sdk/MsgDelegate")
+ // legacy.RegisterAminoMsg(cdc, &MsgUndelegate{}, "cosmos-sdk/MsgUndelegate")
+ // legacy.RegisterAminoMsg(cdc, &MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate")
+ // legacy.RegisterAminoMsg(cdc, &MsgCancelUnbondingDelegation{}, "cosmos-sdk/MsgCancelUnbondingDelegation")
+ legacy.RegisterAminoMsg(cdc, &MsgTokenizeShares{}, "cosmos-sdk/MsgTokenizeShares")
+ legacy.RegisterAminoMsg(cdc, &MsgRedeemTokensforShares{}, "cosmos-sdk/MsgRedeemTokensforShares")
+ legacy.RegisterAminoMsg(cdc, &MsgTransferTokenizeShareRecord{}, "cosmos-sdk/MsgTransferTokenizeShareRecord")
// cdc.RegisterInterface((*isStakeAuthorization_Validators)(nil), nil)
// cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList", nil)
@@ -48,6 +51,17 @@
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
+var (
+ amino = codec.NewLegacyAmino()
+ ModuleCdc = codec.NewAminoCodec(amino)
+)
+
func init() {
- RegisterLegacyAminoCodec(legacy.Cdc)
+ RegisterLegacyAminoCodec(amino)
+ cryptocodec.RegisterCrypto(amino)
+ sdk.RegisterLegacyAminoCodec(amino)
+
+ // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
+ // used to properly serialize MsgGrant and MsgExec instances
+ RegisterLegacyAminoCodec(authzcodec.Amino)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/delegation.go ../pstake-native/x/lsnative/staking/types/delegation.go
--- x/staking/types/delegation.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/delegation.go 2023-03-10 17:39:45
@@ -6,6 +6,7 @@
"strings"
"time"
+ "cosmossdk.io/math"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec"
@@ -29,6 +30,7 @@
}
// NewDelegation creates a new delegation object
+//
//nolint:interfacer
func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, shares sdk.Dec, exempt bool) Delegation {
return Delegation{
@@ -62,12 +64,11 @@
}
func (d Delegation) GetDelegatorAddr() sdk.AccAddress {
- delAddr, err := sdk.AccAddressFromBech32(d.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delAddr := sdk.MustAccAddressFromBech32(d.DelegatorAddress)
+
return delAddr
}
+
func (d Delegation) GetValidatorAddr() sdk.ValAddress {
addr, err := sdk.ValAddressFromBech32(d.ValidatorAddress)
if err != nil {
@@ -94,7 +95,7 @@
return strings.TrimSpace(out)
}
-func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int) UnbondingDelegationEntry {
+func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, balance math.Int) UnbondingDelegationEntry {
return UnbondingDelegationEntry{
CreationHeight: creationHeight,
CompletionTime: completionTime,
@@ -115,10 +116,11 @@
}
// NewUnbondingDelegation - create a new unbonding delegation object
+//
//nolint:interfacer
func NewUnbondingDelegation(
delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress,
- creationHeight int64, minTime time.Time, balance sdk.Int,
+ creationHeight int64, minTime time.Time, balance math.Int,
) UnbondingDelegation {
return UnbondingDelegation{
DelegatorAddress: delegatorAddr.String(),
@@ -130,7 +132,7 @@
}
// AddEntry - append entry to the unbonding delegation
-func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int) {
+func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance math.Int) {
entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance)
ubd.Entries = append(ubd.Entries, entry)
}
@@ -189,7 +191,7 @@
return strings.TrimSpace(out)
}
-func NewRedelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int, sharesDst sdk.Dec) RedelegationEntry {
+func NewRedelegationEntry(creationHeight int64, completionTime time.Time, balance math.Int, sharesDst sdk.Dec) RedelegationEntry {
return RedelegationEntry{
CreationHeight: creationHeight,
CompletionTime: completionTime,
@@ -212,7 +214,7 @@
//nolint:interfacer
func NewRedelegation(
delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress,
- creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec,
+ creationHeight int64, minTime time.Time, balance math.Int, sharesDst sdk.Dec,
) Redelegation {
return Redelegation{
DelegatorAddress: delegatorAddr.String(),
@@ -225,7 +227,7 @@
}
// AddEntry - append entry to the unbonding delegation
-func (red *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec) {
+func (red *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance math.Int, sharesDst sdk.Dec) {
entry := NewRedelegationEntry(creationHeight, minTime, balance, sharesDst)
red.Entries = append(red.Entries, entry)
}
@@ -336,6 +338,7 @@
}
// NewRedelegationResponse crates a new RedelegationEntryResponse instance.
+//
//nolint:interfacer
func NewRedelegationResponse(
delegatorAddr sdk.AccAddress, validatorSrc, validatorDst sdk.ValAddress, entries []RedelegationEntryResponse,
@@ -352,7 +355,8 @@
// NewRedelegationEntryResponse creates a new RedelegationEntryResponse instance.
func NewRedelegationEntryResponse(
- creationHeight int64, completionTime time.Time, sharesDst sdk.Dec, initialBalance, balance sdk.Int) RedelegationEntryResponse {
+ creationHeight int64, completionTime time.Time, sharesDst sdk.Dec, initialBalance, balance math.Int,
+) RedelegationEntryResponse {
return RedelegationEntryResponse{
RedelegationEntry: NewRedelegationEntry(creationHeight, completionTime, initialBalance, sharesDst),
Balance: balance,
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/errors.go ../pstake-native/x/lsnative/staking/types/errors.go
--- x/staking/types/errors.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/errors.go 2023-03-10 17:39:45
@@ -50,6 +50,7 @@
// ErrNoHistoricalInfo = sdkerrors.Register(ModuleName, 38, "no historical info found")
// ErrEmptyValidatorPubKey = sdkerrors.Register(ModuleName, 39, "empty validator public key")
// ErrCommissionLTMinRate = sdkerrors.Register(ModuleName, 40, "commission cannot be less than min rate")
+
ErrNotEnoughBalance = sdkerrors.Register(ModuleName, 41, "not enough balance")
ErrTokenizeShareRecordNotExists = sdkerrors.Register(ModuleName, 42, "tokenize share record not exists")
ErrTokenizeShareRecordAlreadyExists = sdkerrors.Register(ModuleName, 43, "tokenize share record already exists")
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/expected_keepers.go ../pstake-native/x/lsnative/staking/types/expected_keepers.go
--- x/staking/types/expected_keepers.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/expected_keepers.go 2023-03-10 17:39:45
@@ -1,6 +1,7 @@
package types
import (
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -60,11 +61,11 @@
Validator(sdk.Context, sdk.ValAddress) sdkstaking.ValidatorI // get a particular validator by operator address
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) sdkstaking.ValidatorI // get a particular validator by consensus address
- TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set
- StakingTokenSupply(sdk.Context) sdk.Int // total staking token supply
+ TotalBondedTokens(sdk.Context) math.Int // total bonded tokens within the validator set
+ StakingTokenSupply(sdk.Context) math.Int // total staking token supply
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
- Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) sdk.Int
+ Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/exported.go ../pstake-native/x/lsnative/staking/types/exported.go
--- x/staking/types/exported.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/exported.go 2023-03-10 17:39:45
@@ -1,6 +1,7 @@
package types
import (
+ "cosmossdk.io/math"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@@ -17,24 +18,25 @@
// ValidatorI expected validator functions
type ValidatorI interface {
- IsJailed() bool // whether the validator is jailed
- GetMoniker() string // moniker of the validator
- GetStatus() sdkstaking.BondStatus // status of the validator
- IsBonded() bool // check if has a bonded status
- IsUnbonded() bool // check if has status unbonded
- IsUnbonding() bool // check if has status unbonding
- GetOperator() sdk.ValAddress // operator address to receive/return validators coins
- ConsPubKey() (cryptotypes.PubKey, error) // validation consensus pubkey (cryptotypes.PubKey)
- TmConsPublicKey() (tmprotocrypto.PublicKey, error) // validation consensus pubkey (Tendermint)
- GetConsAddr() (sdk.ConsAddress, error) // validation consensus address
- GetTokens() sdk.Int // validation tokens
- GetBondedTokens() sdk.Int // validator bonded tokens
- GetConsensusPower(sdk.Int) int64 // validation power in tendermint
- GetCommission() sdk.Dec // validator commission rate
- GetDelegatorShares() sdk.Dec // total outstanding delegator shares
- TokensFromShares(sdk.Dec) sdk.Dec // token worth of provided delegator shares
- TokensFromSharesTruncated(sdk.Dec) sdk.Dec // token worth of provided delegator shares, truncated
- TokensFromSharesRoundUp(sdk.Dec) sdk.Dec // token worth of provided delegator shares, rounded up
- SharesFromTokens(amt sdk.Int) (sdk.Dec, error) // shares worth of delegator's bond
- SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error) // truncated shares worth of delegator's bond
+ IsJailed() bool // whether the validator is jailed
+ GetMoniker() string // moniker of the validator
+ GetStatus() sdkstaking.BondStatus // status of the validator
+ IsBonded() bool // check if has a bonded status
+ IsUnbonded() bool // check if has status unbonded
+ IsUnbonding() bool // check if has status unbonding
+ GetOperator() sdk.ValAddress // operator address to receive/return validators coins
+ ConsPubKey() (cryptotypes.PubKey, error) // validation consensus pubkey (cryptotypes.PubKey)
+ TmConsPublicKey() (tmprotocrypto.PublicKey, error) // validation consensus pubkey (Tendermint)
+ GetConsAddr() (sdk.ConsAddress, error) // validation consensus address
+ GetTokens() math.Int // validation tokens
+ GetBondedTokens() math.Int // validator bonded tokens
+ GetConsensusPower(math.Int) int64 // validation power in tendermint
+ GetCommission() sdk.Dec // validator commission rate
+ GetMinSelfDelegation() math.Int // validator minimum self delegation
+ GetDelegatorShares() sdk.Dec // total outstanding delegator shares
+ TokensFromShares(sdk.Dec) sdk.Dec // token worth of provided delegator shares
+ TokensFromSharesTruncated(sdk.Dec) sdk.Dec // token worth of provided delegator shares, truncated
+ TokensFromSharesRoundUp(sdk.Dec) sdk.Dec // token worth of provided delegator shares, rounded up
+ SharesFromTokens(amt math.Int) (sdk.Dec, error) // shares worth of delegator's bond
+ SharesFromTokensTruncated(amt math.Int) (sdk.Dec, error) // truncated shares worth of delegator's bond
}
Only in ../pstake-native/x/lsnative/staking/types: genesis.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/historical_info.go ../pstake-native/x/lsnative/staking/types/historical_info.go
--- x/staking/types/historical_info.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/historical_info.go 2023-03-10 17:39:45
@@ -3,19 +3,19 @@
import (
"sort"
+ "cosmossdk.io/math"
"github.com/gogo/protobuf/proto"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// NewHistoricalInfo will create a historical information struct from header and valset
// it will first sort valset before inclusion into historical info
-func NewHistoricalInfo(header tmproto.Header, valSet Validators, powerReduction sdk.Int) HistoricalInfo {
+func NewHistoricalInfo(header tmproto.Header, valSet Validators, powerReduction math.Int) HistoricalInfo {
// Must sort in the same way that tendermint does
sort.SliceStable(valSet, func(i, j int) bool {
return ValidatorsByVotingPower(valSet).Less(i, j, powerReduction)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/hooks.go ../pstake-native/x/lsnative/staking/types/hooks.go
--- x/staking/types/hooks.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/hooks.go 2023-03-10 17:39:45
@@ -22,6 +22,7 @@
return nil
}
+
func (h MultiStakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].BeforeValidatorModified(ctx, valAddr); err != nil {
@@ -30,6 +31,7 @@
}
return nil
}
+
func (h MultiStakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].AfterValidatorRemoved(ctx, consAddr, valAddr); err != nil {
@@ -56,6 +58,7 @@
}
return nil
}
+
func (h MultiStakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].AfterValidatorBeginUnbonding(ctx, consAddr, valAddr); err != nil {
@@ -64,6 +67,7 @@
}
return nil
}
+
func (h MultiStakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil {
@@ -72,6 +76,7 @@
}
return nil
}
+
func (h MultiStakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].BeforeDelegationSharesModified(ctx, delAddr, valAddr); err != nil {
@@ -80,6 +85,7 @@
}
return nil
}
+
func (h MultiStakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].BeforeDelegationRemoved(ctx, delAddr, valAddr); err != nil {
@@ -88,6 +94,7 @@
}
return nil
}
+
func (h MultiStakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].AfterDelegationModified(ctx, delAddr, valAddr); err != nil {
@@ -96,6 +103,7 @@
}
return nil
}
+
func (h MultiStakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error {
for i := range h {
if err := h[i].BeforeValidatorSlashed(ctx, valAddr, fraction); err != nil {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/keys.go ../pstake-native/x/lsnative/staking/types/keys.go
--- x/staking/types/keys.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/keys.go 2023-03-10 17:39:45
@@ -7,6 +7,7 @@
"strconv"
"time"
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/kv"
@@ -83,7 +84,7 @@
// Power index is the key used in the power-store, and represents the relative
// power ranking of the validator.
// VALUE: validator operator address ([]byte)
-func GetValidatorsByPowerIndexKey(validator Validator, powerReduction sdk.Int) []byte {
+func GetValidatorsByPowerIndexKey(validator Validator, powerReduction math.Int) []byte {
// NOTE the address doesn't need to be stored because counter bytes must always be different
// NOTE the larger values are of higher value
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/msg.go ../pstake-native/x/lsnative/staking/types/msg.go
--- x/staking/types/msg.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/msg.go 2023-03-10 17:39:45
@@ -1,7 +1,6 @@
package types
import (
- "github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -12,12 +11,12 @@
// staking message types
const (
TypeMsgUndelegate = "begin_unbonding"
- TypeMsgUnbondValidator = "unbond_validator"
TypeMsgEditValidator = "edit_validator"
TypeMsgCreateValidator = "create_validator"
TypeMsgDelegate = "delegate"
TypeMsgBeginRedelegate = "begin_redelegate"
TypeMsgCancelUnbondingDelegation = "cancel_unbond"
+ TypeMsgUnbondValidator = "unbond_validator"
TypeMsgTokenizeShares = "tokenize_shares"
TypeMsgRedeemTokensforShares = "redeem_tokens_for_shares"
TypeMsgTransferTokenizeShareRecord = "transfer_tokenize_share_record"
@@ -31,12 +30,12 @@
_ sdk.Msg = &MsgEditValidator{}
_ sdk.Msg = &MsgDelegate{}
_ sdk.Msg = &MsgUndelegate{}
- _ sdk.Msg = &MsgUnbondValidator{}
_ sdk.Msg = &MsgBeginRedelegate{}
+ _ sdk.Msg = &MsgCancelUnbondingDelegation{}
+ _ sdk.Msg = &MsgUnbondValidator{}
_ sdk.Msg = &MsgTokenizeShares{}
_ sdk.Msg = &MsgRedeemTokensforShares{}
_ sdk.Msg = &MsgTransferTokenizeShareRecord{}
- _ sdk.Msg = &MsgCancelUnbondingDelegation{}
)
// NewMsgCreateValidator creates a new MsgCreateValidator instance.
@@ -88,7 +87,7 @@
// GetSignBytes returns the message bytes to sign over.
func (msg MsgCreateValidator) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -137,6 +136,7 @@
}
// NewMsgEditValidator creates a new MsgEditValidator instance
+//
//nolint:interfacer
func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec) *MsgEditValidator {
return &MsgEditValidator{
@@ -160,7 +160,7 @@
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgEditValidator) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -184,6 +184,7 @@
}
// NewMsgDelegate creates a new MsgDelegate instance.
+//
//nolint:interfacer
func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgDelegate {
return &MsgDelegate{
@@ -201,16 +202,13 @@
// GetSigners implements the sdk.Msg interface.
func (msg MsgDelegate) GetSigners() []sdk.AccAddress {
- delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress)
return []sdk.AccAddress{delegator}
}
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgDelegate) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -234,6 +232,7 @@
}
// NewMsgBeginRedelegate creates a new MsgBeginRedelegate instance.
+//
//nolint:interfacer
func NewMsgBeginRedelegate(
delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount sdk.Coin,
@@ -254,16 +253,13 @@
// GetSigners implements the sdk.Msg interface
func (msg MsgBeginRedelegate) GetSigners() []sdk.AccAddress {
- delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress)
return []sdk.AccAddress{delegator}
}
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgBeginRedelegate) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -290,6 +286,7 @@
}
// NewMsgUndelegate creates a new MsgUndelegate instance.
+//
//nolint:interfacer
func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgUndelegate {
return &MsgUndelegate{
@@ -307,16 +304,13 @@
// GetSigners implements the sdk.Msg interface.
func (msg MsgUndelegate) GetSigners() []sdk.AccAddress {
- delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress)
return []sdk.AccAddress{delegator}
}
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgUndelegate) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -340,6 +334,7 @@
}
// NewMsgUnbondValidator creates a new MsgUnbondValidator instance.
+//
//nolint:interfacer
func NewMsgUnbondValidator(valAddr sdk.ValAddress) *MsgUnbondValidator {
return &MsgUnbondValidator{
@@ -364,7 +359,7 @@
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgUnbondValidator) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -389,7 +384,7 @@
}
func (msg MsgTokenizeShares) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -426,7 +421,7 @@
}
func (msg MsgRedeemTokensforShares) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -457,7 +452,7 @@
}
func (msg MsgTransferTokenizeShareRecord) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -473,6 +468,7 @@
}
// NewMsgCancelUnbondingDelegation creates a new MsgCancelUnbondingDelegation instance.
+//
//nolint:interfacer
func NewMsgCancelUnbondingDelegation(delAddr sdk.AccAddress, valAddr sdk.ValAddress, creationHeight int64, amount sdk.Coin) *MsgCancelUnbondingDelegation {
return &MsgCancelUnbondingDelegation{
@@ -497,7 +493,7 @@
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgCancelUnbondingDelegation) GetSignBytes() []byte {
- return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
+ return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// ValidateBasic implements the sdk.Msg interface.
@@ -527,6 +523,7 @@
}
// NewMsgExemptDelegation creates a new MsgExemptDelegation instance.
+//
//nolint:interfacer
func NewMsgExemptDelegation(delAddr sdk.AccAddress, valAddr sdk.ValAddress) *MsgExemptDelegation {
return &MsgExemptDelegation{
@@ -552,7 +549,7 @@
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgExemptDelegation) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/params.go ../pstake-native/x/lsnative/staking/types/params.go
--- x/staking/types/params.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/params.go 2023-03-10 17:39:45
@@ -6,6 +6,7 @@
"strings"
"time"
+ "cosmossdk.io/math"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec"
@@ -216,7 +217,7 @@
}
func ValidatePowerReduction(i interface{}) error {
- v, ok := i.(sdk.Int)
+ v, ok := i.(math.Int)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/pool.go ../pstake-native/x/lsnative/staking/types/pool.go
--- x/staking/types/pool.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/pool.go 2023-03-10 17:35:24
@@ -1,8 +1,6 @@
package types
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
+import "cosmossdk.io/math"
// names used as root for pool module accounts:
//
@@ -15,7 +13,7 @@
)
// NewPool creates a new Pool instance used for queries
-func NewPool(notBonded, bonded sdk.Int) Pool {
+func NewPool(notBonded, bonded math.Int) Pool {
return Pool{
NotBondedTokens: notBonded,
BondedTokens: bonded,
Only in ../pstake-native/x/lsnative/staking/types: query.pb.go
Only in ../pstake-native/x/lsnative/staking/types: query.pb.gw.go
Only in ../pstake-native/x/lsnative/staking/types: staking.pb.go
Only in ../pstake-native/x/lsnative/staking/types: tx.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/staking/types/validator.go ../pstake-native/x/lsnative/staking/types/validator.go
--- x/staking/types/validator.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/staking/types/validator.go 2023-03-10 17:39:45
@@ -7,6 +7,7 @@
"strings"
"time"
+ "cosmossdk.io/math"
abci "github.com/tendermint/tendermint/abci/types"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
"sigs.k8s.io/yaml"
@@ -39,6 +40,7 @@
var _ sdkstaking.ValidatorI = Validator{}
// NewValidator constructs a new Validator
+//
//nolint:interfacer
func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, description Description) (Validator, error) {
pkAny, err := codectypes.NewAnyWithValue(pubKey)
@@ -88,6 +90,15 @@
return strings.TrimSpace(out)
}
+// ToSDKValidators - convenience function convert []sdkstaking.Validator to []sdk.ValidatorI
+func (v Validators) ToSDKValidators() (validators []sdkstaking.ValidatorI) {
+ for _, val := range v {
+ validators = append(validators, val)
+ }
+
+ return validators
+}
+
// Sort Validators sorts validator array in ascending operator address order
func (v Validators) Sort() {
sort.Sort(v)
@@ -116,7 +127,7 @@
func (valz ValidatorsByVotingPower) Len() int { return len(valz) }
-func (valz ValidatorsByVotingPower) Less(i, j int, r sdk.Int) bool {
+func (valz ValidatorsByVotingPower) Less(i, j int, r math.Int) bool {
if valz[i].ConsensusPower(r) == valz[j].ConsensusPower(r) {
addrI, errI := valz[i].GetConsAddr()
addrJ, errJ := valz[j].GetConsAddr()
@@ -257,7 +268,7 @@
// ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type
// with the full validator power
-func (v Validator) ABCIValidatorUpdate(r sdk.Int) abci.ValidatorUpdate {
+func (v Validator) ABCIValidatorUpdate(r math.Int) abci.ValidatorUpdate {
tmProtoPk, err := v.TmConsPublicKey()
if err != nil {
panic(err)
@@ -320,7 +331,7 @@
// SharesFromTokens returns the shares of a delegation given a bond amount. It
// returns an error if the validator has no tokens.
-func (v Validator) SharesFromTokens(amt sdk.Int) (sdk.Dec, error) {
+func (v Validator) SharesFromTokens(amt math.Int) (sdk.Dec, error) {
if v.Tokens.IsZero() {
return sdk.ZeroDec(), sdkstaking.ErrInsufficientShares
}
@@ -330,7 +341,7 @@
// SharesFromTokensTruncated returns the truncated shares of a delegation given
// a bond amount. It returns an error if the validator has no tokens.
-func (v Validator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error) {
+func (v Validator) SharesFromTokensTruncated(amt math.Int) (sdk.Dec, error) {
if v.Tokens.IsZero() {
return sdk.ZeroDec(), sdkstaking.ErrInsufficientShares
}
@@ -339,7 +350,7 @@
}
// get the bonded tokens which the validator holds
-func (v Validator) BondedTokens() sdk.Int {
+func (v Validator) BondedTokens() math.Int {
if v.IsBonded() {
return v.Tokens
}
@@ -349,7 +360,7 @@
// ConsensusPower gets the consensus-engine power. Aa reduction of 10^6 from
// validator tokens is applied
-func (v Validator) ConsensusPower(r sdk.Int) int64 {
+func (v Validator) ConsensusPower(r math.Int) int64 {
if v.IsBonded() {
return v.PotentialConsensusPower(r)
}
@@ -358,7 +369,7 @@
}
// PotentialConsensusPower returns the potential consensus-engine power.
-func (v Validator) PotentialConsensusPower(r sdk.Int) int64 {
+func (v Validator) PotentialConsensusPower(r math.Int) int64 {
return sdk.TokensToConsensusPower(v.Tokens, r)
}
@@ -370,7 +381,7 @@
}
// AddTokensFromDel adds tokens to a validator
-func (v Validator) AddTokensFromDel(amount sdk.Int) (Validator, sdk.Dec) {
+func (v Validator) AddTokensFromDel(amount math.Int) (Validator, sdk.Dec) {
// calculate the shares to issue
var issuedShares sdk.Dec
if v.DelegatorShares.IsZero() {
@@ -392,7 +403,7 @@
}
// RemoveTokens removes tokens from a validator
-func (v Validator) RemoveTokens(tokens sdk.Int) Validator {
+func (v Validator) RemoveTokens(tokens math.Int) Validator {
if tokens.IsNegative() {
panic(fmt.Sprintf("should not happen: trying to remove negative tokens %v", tokens))
}
@@ -408,15 +419,16 @@
// RemoveDelShares removes delegator shares from a validator.
// NOTE: because token fractions are left in the valiadator,
-// the exchange rate of future shares of this validator can increase.
-func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) {
+//
+// the exchange rate of future shares of this validator can increase.
+func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, math.Int) {
remainingShares := v.DelegatorShares.Sub(delShares)
- var issuedTokens sdk.Int
+ var issuedTokens math.Int
if remainingShares.IsZero() {
// last delegation share gets any trimmings
issuedTokens = v.Tokens
- v.Tokens = sdk.ZeroInt()
+ v.Tokens = math.ZeroInt()
} else {
// leave excess tokens in the validator
// however fully use all the delegator shares
@@ -444,7 +456,6 @@
v.Commission.Equal(other.Commission) &&
v.Jailed == other.Jailed &&
v.ConsensusPubkey.Equal(other.ConsensusPubkey)
-
}
// Equal checks if the receiver equals the parameter
@@ -476,7 +487,6 @@
}
return pk, nil
-
}
// TmConsPublicKey casts Validator.ConsensusPubkey to tmprotocrypto.PubKey.
@@ -504,15 +514,14 @@
return sdk.ConsAddress(pk.Address()), nil
}
-func (v Validator) GetTokens() sdk.Int { return v.Tokens }
-func (v Validator) GetBondedTokens() sdk.Int { return v.BondedTokens() }
-func (v Validator) GetConsensusPower(r sdk.Int) int64 {
+func (v Validator) GetTokens() math.Int { return v.Tokens }
+func (v Validator) GetBondedTokens() math.Int { return v.BondedTokens() }
+func (v Validator) GetConsensusPower(r math.Int) int64 {
return v.ConsensusPower(r)
}
-func (v Validator) GetCommission() sdk.Dec { return v.Commission.Rate }
-func (v Validator) GetDelegatorShares() sdk.Dec { return v.DelegatorShares }
-
-func (v Validator) GetMinSelfDelegation() sdk.Int { return sdk.ZeroInt() }
+func (v Validator) GetCommission() sdk.Dec { return v.Commission.Rate }
+func (v Validator) GetMinSelfDelegation() math.Int { return math.Int{} }
+func (v Validator) GetDelegatorShares() sdk.Dec { return v.DelegatorShares }
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/client/cli/query.go ../pstake-native/x/lsnative/slashing/client/cli/query.go
--- x/slashing/client/cli/query.go 2023-03-08 16:56:58
+++ ../pstake-native/x/lsnative/slashing/client/cli/query.go 2023-03-10 17:39:45
@@ -30,7 +30,6 @@
)
return slashingQueryCmd
-
}
// GetCmdQuerySigningInfo implements the command to query signing info.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/client/cli/tx.go ../pstake-native/x/lsnative/slashing/client/cli/tx.go
--- x/slashing/client/cli/tx.go 2023-03-08 16:56:58
+++ ../pstake-native/x/lsnative/slashing/client/cli/tx.go 2023-03-10 17:39:45
@@ -24,6 +24,7 @@
return slashingTxCmd
}
+// NewUnjailTxCmd returns a CLI command handler for creating a MsgUnjail transaction.
func NewUnjailTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "unjail",
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/keeper/migrations.go ../pstake-native/x/lsnative/slashing/keeper/migrations.go
--- x/slashing/keeper/migrations.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/keeper/migrations.go 2023-03-10 17:35:24
@@ -2,6 +2,7 @@
import (
sdk "github.com/cosmos/cosmos-sdk/types"
+ v043 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v043"
)
// Migrator is a struct for handling in-place store migrations.
@@ -16,5 +17,5 @@
// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
- return nil
+ return v043.MigrateStore(ctx, m.keeper.storeKey)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/module.go ../pstake-native/x/lsnative/slashing/module.go
--- x/slashing/module.go 2023-03-08 16:56:57
+++ ../pstake-native/x/lsnative/slashing/module.go 2023-03-10 17:39:45
@@ -6,7 +6,6 @@
"fmt"
"math/rand"
- "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
@@ -68,11 +67,6 @@
return types.ValidateGenesis(data)
}
-// RegisterRESTRoutes registers the REST routes for the slashing module.
-// Deprecated: RegisterRESTRoutes is deprecated. `x/slashing` legacy REST implementation
-// has been removed from the SDK.
-func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {}
-
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the slashig module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
@@ -140,10 +134,7 @@
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
m := keeper.NewMigrator(am.keeper)
- err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
- if err != nil {
- panic(err)
- }
+ cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
}
// InitGenesis performs genesis initialization for the slashing module. It returns
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/simulation/operations.go ../pstake-native/x/lsnative/slashing/simulation/operations.go
--- x/slashing/simulation/operations.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/slashing/simulation/operations.go 2023-03-10 17:39:45
@@ -18,7 +18,7 @@
// Simulation operation weights constants
const (
- OpWeightMsgUnjail = "op_weight_msg_unjail"
+ OpWeightMsgUnjail = "op_weight_msg_unjail" //nolint:gosec
)
// WeightedOperations returns all the operations from the module with their respective weights
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/spec/01_concepts.md ../pstake-native/x/lsnative/slashing/spec/01_concepts.md
--- x/slashing/spec/01_concepts.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/spec/01_concepts.md 2023-03-10 17:35:24
@@ -43,16 +43,14 @@
### Single Double Sign Infraction
-<----------------->
-[----------C<sub>1</sub>----D<sub>1</sub>,V<sub>u</sub>-----]
+\[----------C<sub>1</sub>----D<sub>1</sub>,V<sub>u</sub>-----\]
A single infraction is committed then later discovered, at which point the
validator is unbonded and slashed at the full amount for the infraction.
### Multiple Double Sign Infractions
-<--------------------------->
-[----------C<sub>1</sub>--C<sub>2</sub>---C<sub>3</sub>---D<sub>1</sub>,D<sub>2</sub>,D<sub>3</sub>V<sub>u</sub>-----]
+\[----------C<sub>1</sub>--C<sub>2</sub>---C<sub>3</sub>---D<sub>1</sub>,D<sub>2</sub>,D<sub>3</sub>V<sub>u</sub>-----\]
Multiple infractions are committed and then later discovered, at which point the
validator is jailed and slashed for only one infraction. Because the validator
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/spec/02_state.md ../pstake-native/x/lsnative/slashing/spec/02_state.md
--- x/slashing/spec/02_state.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/spec/02_state.md 2023-03-10 17:35:24
@@ -48,4 +48,4 @@
The information stored for tracking validator liveness is as follows:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/slashing/v1beta1/slashing.proto#L11-L33
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/slashing/v1beta1/slashing.proto#L12-L33
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/spec/05_hooks.md ../pstake-native/x/lsnative/slashing/spec/05_hooks.md
--- x/slashing/spec/05_hooks.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/spec/05_hooks.md 2023-03-10 17:35:24
@@ -21,6 +21,8 @@
Upon successful first-time bonding of a new validator, we create a new `ValidatorSigningInfo` structure for the
now-bonded validator, which `StartHeight` of the current block.
+If the validator was out of the validator set and gets bonded again, its new bonded height is set.
+
```go
onValidatorBonded(address sdk.ValAddress)
@@ -32,7 +34,10 @@
JailedUntil : time.Unix(0, 0),
Tombstone : false,
MissedBloskCounter : 0
+ } else {
+ signingInfo.StartHeight = CurrentHeight
}
+
setValidatorSigningInfo(signingInfo)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/codec.go ../pstake-native/x/lsnative/slashing/types/codec.go
--- x/slashing/types/codec.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/codec.go 2023-03-10 17:39:45
@@ -2,15 +2,16 @@
import (
"github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
+ authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- // cdc.RegisterConcrete(&MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil)
+ // legacy.RegisterAminoMsg(cdc, &MsgUnjail{}, "cosmos-sdk/MsgUnjail")
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
@@ -21,6 +22,17 @@
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
+var (
+ amino = codec.NewLegacyAmino()
+ ModuleCdc = codec.NewAminoCodec(amino)
+)
+
func init() {
- RegisterLegacyAminoCodec(legacy.Cdc)
+ RegisterLegacyAminoCodec(amino)
+ cryptocodec.RegisterCrypto(amino)
+ sdk.RegisterLegacyAminoCodec(amino)
+
+ // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
+ // used to properly serialize MsgGrant and MsgExec instances
+ RegisterLegacyAminoCodec(authzcodec.Amino)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/expected_keepers.go ../pstake-native/x/lsnative/slashing/types/expected_keepers.go
--- x/slashing/types/expected_keepers.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/expected_keepers.go 2023-03-10 17:39:45
@@ -3,6 +3,7 @@
package types
import (
+ "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
@@ -42,7 +43,7 @@
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) sdkstaking.ValidatorI // get a particular validator by consensus address
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
- Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) sdk.Int
+ Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/genesis.go ../pstake-native/x/lsnative/slashing/types/genesis.go
--- x/slashing/types/genesis.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/genesis.go 2023-03-10 17:35:24
@@ -11,7 +11,6 @@
func NewGenesisState(
params Params, signingInfos []SigningInfo, missedBlocks []ValidatorMissedBlocks,
) *GenesisState {
-
return &GenesisState{
Params: params,
SigningInfos: signingInfos,
Only in ../pstake-native/x/lsnative/slashing/types: genesis.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/msg.go ../pstake-native/x/lsnative/slashing/types/msg.go
--- x/slashing/types/msg.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/msg.go 2023-03-10 17:35:24
@@ -1,7 +1,6 @@
package types
import (
- "github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@@ -15,6 +14,7 @@
var _ sdk.Msg = &MsgUnjail{}
// NewMsgUnjail creates a new MsgUnjail instance
+//
//nolint:interfacer
func NewMsgUnjail(validatorAddr sdk.ValAddress) *MsgUnjail {
return &MsgUnjail{
@@ -31,11 +31,11 @@
// GetSignBytes gets the bytes for the message signer to sign on
func (msg MsgUnjail) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
-// ValidateBasic validity check for the AnteHandler
+// ValidateBasic does a sanity check on the provided message
func (msg MsgUnjail) ValidateBasic() error {
if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddr); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("validator input address: %s", err)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/params.go ../pstake-native/x/lsnative/slashing/types/params.go
--- x/slashing/types/params.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/params.go 2023-03-10 17:35:24
@@ -39,7 +39,6 @@
signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration,
slashFractionDoubleSign, slashFractionDowntime sdk.Dec,
) Params {
-
return Params{
SignedBlocksWindow: signedBlocksWindow,
MinSignedPerWindow: minSignedPerWindow,
Only in ../pstake-native/x/lsnative/slashing/types: query.pb.go
Only in ../pstake-native/x/lsnative/slashing/types: query.pb.gw.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/slashing/types/signing_info.go ../pstake-native/x/lsnative/slashing/types/signing_info.go
--- x/slashing/types/signing_info.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/slashing/types/signing_info.go 2023-03-10 17:35:24
@@ -9,12 +9,12 @@
)
// NewValidatorSigningInfo creates a new ValidatorSigningInfo instance
+//
//nolint:interfacer
func NewValidatorSigningInfo(
condAddr sdk.ConsAddress, startHeight, indexOffset int64,
jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64,
) ValidatorSigningInfo {
-
return ValidatorSigningInfo{
Address: condAddr.String(),
StartHeight: startHeight,
Only in ../pstake-native/x/lsnative/slashing/types: slashing.pb.go
Only in ../pstake-native/x/lsnative/slashing/types: tx.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/client/cli/tx.go ../pstake-native/x/lsnative/distribution/client/cli/tx.go
--- x/distribution/client/cli/tx.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/distribution/client/cli/tx.go 2023-03-10 17:39:45
@@ -13,7 +13,7 @@
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
+ govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types"
)
@@ -55,7 +55,6 @@
genOrBroadcastFn newGenerateOrBroadcastFunc, clientCtx client.Context,
fs *pflag.FlagSet, msgs []sdk.Msg, chunkSize int,
) error {
-
if chunkSize == 0 {
return genOrBroadcastFn(clientCtx, fs, msgs...)
}
@@ -78,6 +77,7 @@
return nil
}
+// NewWithdrawRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction.
func NewWithdrawRewardsCmd() *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()
@@ -113,12 +113,6 @@
msgs = append(msgs, types.NewMsgWithdrawValidatorCommission(valAddr))
}
- for _, msg := range msgs {
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
- }
-
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...)
},
}
@@ -129,6 +123,7 @@
return cmd
}
+// NewWithdrawAllRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction.
func NewWithdrawAllRewardsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-all-rewards",
@@ -192,6 +187,7 @@
return cmd
}
+// NewSetWithdrawAddrCmd returns a CLI command handler for creating a MsgSetWithdrawAddress transaction.
func NewSetWithdrawAddrCmd() *cobra.Command {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()
@@ -230,6 +226,7 @@
return cmd
}
+// NewFundCommunityPoolCmd returns a CLI command handler for creating a MsgFundCommunityPool transaction.
func NewFundCommunityPoolCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "fund-community-pool [amount]",
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/client/proposal_handler.go ../pstake-native/x/lsnative/distribution/client/proposal_handler.go
--- x/distribution/client/proposal_handler.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/distribution/client/proposal_handler.go 2023-03-10 17:39:45
@@ -7,5 +7,5 @@
// ProposalHandler is the community spend proposal handler.
var (
- ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, nil)
+ ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal)
)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/handler.go ../pstake-native/x/lsnative/distribution/handler.go
--- x/distribution/handler.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/distribution/handler.go 2023-03-10 17:39:45
@@ -3,44 +3,10 @@
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
+ govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/keeper"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types"
)
-
-func NewHandler(k keeper.Keeper) sdk.Handler {
- msgServer := keeper.NewMsgServerImpl(k)
-
- return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
- ctx = ctx.WithEventManager(sdk.NewEventManager())
-
- switch msg := msg.(type) {
- case *types.MsgSetWithdrawAddress:
- res, err := msgServer.SetWithdrawAddress(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
-
- case *types.MsgWithdrawDelegatorReward:
- res, err := msgServer.WithdrawDelegatorReward(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
-
- case *types.MsgWithdrawValidatorCommission:
- res, err := msgServer.WithdrawValidatorCommission(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
-
- case *types.MsgFundCommunityPool:
- res, err := msgServer.FundCommunityPool(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
- case *types.MsgWithdrawTokenizeShareRecordReward:
- res, err := msgServer.WithdrawTokenizeShareRecordReward(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
- case *types.MsgWithdrawAllTokenizeShareRecordReward:
- res, err := msgServer.WithdrawAllTokenizeShareRecordReward(sdk.WrapSDKContext(ctx), msg)
- return sdk.WrapServiceResult(ctx, res, err)
- default:
- return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized distribution message type: %T", msg)
- }
- }
-}
func NewCommunityPoolSpendProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/allocation.go ../pstake-native/x/lsnative/distribution/keeper/allocation.go
--- x/distribution/keeper/allocation.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/keeper/allocation.go 2023-03-10 17:39:45
@@ -81,16 +81,22 @@
// calculate fraction allocated to validators
communityTax := k.GetCommunityTax(ctx)
voteMultiplier := sdk.OneDec().Sub(proposerMultiplier).Sub(communityTax)
+ feeMultiplier := feesCollected.MulDecTruncate(voteMultiplier)
// allocate tokens proportionally to voting power
- // TODO consider parallelizing later, ref https://github.com/cosmos/cosmos-sdk/pull/3099#discussion_r246276376
+ //
+ // TODO: Consider parallelizing later
+ //
+ // Ref: https://github.com/cosmos/cosmos-sdk/pull/3099#discussion_r246276376
for _, vote := range bondedVotes {
validator := k.stakingKeeper.ValidatorByConsAddr(ctx, vote.Validator.Address)
- // TODO consider microslashing for missing votes.
- // ref https://github.com/cosmos/cosmos-sdk/issues/2525#issuecomment-430838701
+ // TODO: Consider micro-slashing for missing votes.
+ //
+ // Ref: https://github.com/cosmos/cosmos-sdk/issues/2525#issuecomment-430838701
powerFraction := sdk.NewDec(vote.Validator.Power).QuoTruncate(sdk.NewDec(totalPreviousPower))
- reward := feesCollected.MulDecTruncate(voteMultiplier).MulDecTruncate(powerFraction)
+ reward := feeMultiplier.MulDecTruncate(powerFraction)
+
k.AllocateTokensToValidator(ctx, validator, reward)
remaining = remaining.Sub(reward)
}
@@ -100,7 +106,8 @@
k.SetFeePool(ctx, feePool)
}
-// AllocateTokensToValidator allocate tokens to a particular validator, splitting according to commission
+// AllocateTokensToValidator allocate tokens to a particular validator,
+// splitting according to commission.
func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val sdkstaking.ValidatorI, tokens sdk.DecCoins) {
// split tokens between validator and delegators according to commission
commission := tokens.MulDec(val.GetCommission())
@@ -131,6 +138,7 @@
sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()),
),
)
+
outstanding := k.GetValidatorOutstandingRewards(ctx, val.GetOperator())
outstanding.Rewards = outstanding.Rewards.Add(tokens...)
k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), outstanding)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/delegation.go ../pstake-native/x/lsnative/distribution/keeper/delegation.go
--- x/distribution/keeper/delegation.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/keeper/delegation.go 2023-03-10 17:39:45
@@ -4,7 +4,6 @@
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
-
sdkdistr "github.com/cosmos/cosmos-sdk/x/distribution/types"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types"
@@ -163,13 +162,13 @@
)
}
- // truncate coins, return remainder to community pool
- coins, remainder := rewards.TruncateDecimal()
+ // truncate reward dec coins, return remainder to community pool
+ finalRewards, remainder := rewards.TruncateDecimal()
// add coins to user account
- if !coins.IsZero() {
+ if !finalRewards.IsZero() {
withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, del.GetDelegatorAddr())
- err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, withdrawAddr, coins)
+ err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, withdrawAddr, finalRewards)
if err != nil {
return nil, err
}
@@ -190,5 +189,25 @@
// remove delegator starting info
k.DeleteDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr())
- return coins, nil
+ emittedRewards := finalRewards
+ if finalRewards.IsZero() {
+ baseDenom, _ := sdk.GetBaseDenom()
+ if baseDenom == "" {
+ baseDenom = sdk.DefaultBondDenom
+ }
+
+ // Note, we do not call the NewCoins constructor as we do not want the zero
+ // coin removed.
+ emittedRewards = sdk.Coins{sdk.NewCoin(baseDenom, sdk.ZeroInt())}
+ }
+
+ ctx.EventManager().EmitEvent(
+ sdk.NewEvent(
+ types.EventTypeWithdrawRewards,
+ sdk.NewAttribute(sdk.AttributeKeyAmount, emittedRewards.String()),
+ sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()),
+ ),
+ )
+
+ return finalRewards, nil
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/grpc_query.go ../pstake-native/x/lsnative/distribution/keeper/grpc_query.go
--- x/distribution/keeper/grpc_query.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/distribution/keeper/grpc_query.go 2023-03-10 17:39:45
@@ -83,7 +83,6 @@
}
ctx := sdk.UnwrapSDKContext(c)
- events := make([]types.ValidatorSlashEvent, 0)
store := ctx.KVStore(k.storeKey)
valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddress)
if err != nil {
@@ -91,29 +90,25 @@
}
slashesStore := prefix.NewStore(store, types.GetValidatorSlashEventPrefix(valAddr))
- pageRes, err := query.FilteredPaginate(slashesStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
- var result types.ValidatorSlashEvent
- err := k.cdc.Unmarshal(value, &result)
-
- if err != nil {
- return false, err
- }
-
+ events, pageRes, err := query.GenericFilteredPaginate(k.cdc, slashesStore, req.Pagination, func(key []byte, result *types.ValidatorSlashEvent) (*types.ValidatorSlashEvent, error) {
if result.ValidatorPeriod < req.StartingHeight || result.ValidatorPeriod > req.EndingHeight {
- return false, nil
+ return nil, nil
}
- if accumulate {
- events = append(events, result)
- }
- return true, nil
+ return result, nil
+ }, func() *types.ValidatorSlashEvent {
+ return &types.ValidatorSlashEvent{}
})
-
if err != nil {
return nil, err
}
- return &types.QueryValidatorSlashesResponse{Slashes: events, Pagination: pageRes}, nil
+ slashes := []types.ValidatorSlashEvent{}
+ for _, event := range events {
+ slashes = append(slashes, *event)
+ }
+
+ return &types.QueryValidatorSlashesResponse{Slashes: slashes, Pagination: pageRes}, nil
}
// DelegationRewards the total rewards accrued by a delegation
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/invariants.go ../pstake-native/x/lsnative/distribution/keeper/invariants.go
--- x/distribution/keeper/invariants.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/keeper/invariants.go 2023-03-10 17:39:45
@@ -64,7 +64,6 @@
// CanWithdrawInvariant checks that current rewards can be completely withdrawn
func CanWithdrawInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
-
// cache, we don't want to write changes
ctx, _ = ctx.CacheContext()
@@ -106,7 +105,6 @@
// ReferenceCountInvariant checks that the number of historical rewards records is correct
func ReferenceCountInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
-
valCount := uint64(0)
k.stakingKeeper.IterateValidators(ctx, func(_ int64, val sdkstaking.ValidatorI) (stop bool) {
valCount++
@@ -137,7 +135,6 @@
// is consistent with the sum of validator outstanding rewards
func ModuleAccountInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
-
var expectedCoins sdk.DecCoins
k.IterateValidatorOutstandingRewards(ctx, func(_ sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) {
expectedCoins = expectedCoins.Add(rewards.Rewards...)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/migrations.go ../pstake-native/x/lsnative/distribution/keeper/migrations.go
--- x/distribution/keeper/migrations.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/keeper/migrations.go 2023-03-10 17:35:24
@@ -1 +1,21 @@
package keeper
+
+import (
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ v043 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043"
+)
+
+// Migrator is a struct for handling in-place store migrations.
+type Migrator struct {
+ keeper Keeper
+}
+
+// NewMigrator returns a new Migrator.
+func NewMigrator(keeper Keeper) Migrator {
+ return Migrator{keeper: keeper}
+}
+
+// Migrate1to2 migrates from version 1 to 2.
+func (m Migrator) Migrate1to2(ctx sdk.Context) error {
+ return v043.MigrateStore(ctx, m.keeper.storeKey)
+}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/keeper/msg_server.go ../pstake-native/x/lsnative/distribution/keeper/msg_server.go
--- x/distribution/keeper/msg_server.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/keeper/msg_server.go 2023-03-10 17:39:45
@@ -84,7 +84,7 @@
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
),
)
- return &types.MsgWithdrawDelegatorRewardResponse{}, nil
+ return &types.MsgWithdrawDelegatorRewardResponse{Amount: amount}, nil
}
func (k msgServer) WithdrawValidatorCommission(goCtx context.Context, msg *types.MsgWithdrawValidatorCommission) (*types.MsgWithdrawValidatorCommissionResponse, error) {
@@ -119,7 +119,7 @@
),
)
- return &types.MsgWithdrawValidatorCommissionResponse{}, nil
+ return &types.MsgWithdrawValidatorCommissionResponse{Amount: amount}, nil
}
// WithdrawTokenizeShareRecordReward defines a method to withdraw reward for owning TokenizeShareRecord
@@ -197,11 +197,11 @@
func (k msgServer) FundCommunityPool(goCtx context.Context, msg *types.MsgFundCommunityPool) (*types.MsgFundCommunityPoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
- depositor, err := sdk.AccAddressFromBech32(msg.Depositor)
+ depositer, err := sdk.AccAddressFromBech32(msg.Depositor)
if err != nil {
return nil, err
}
- if err := k.Keeper.FundCommunityPool(ctx, msg.Amount, depositor); err != nil {
+ if err := k.Keeper.FundCommunityPool(ctx, msg.Amount, depositer); err != nil {
return nil, err
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/module.go ../pstake-native/x/lsnative/distribution/module.go
--- x/distribution/module.go 2023-03-08 16:57:02
+++ ../pstake-native/x/lsnative/distribution/module.go 2023-03-10 17:39:45
@@ -6,7 +6,6 @@
"fmt"
"math/rand"
- "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
@@ -61,11 +60,6 @@
return types.ValidateGenesis(&data)
}
-// RegisterRESTRoutes registers the REST routes for the distribution module.
-// Deprecated: RegisterRESTRoutes is deprecated. `x/distribution` legacy REST implementation
-// has been removed from the SDK.
-func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {}
-
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the distribution module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
@@ -141,6 +135,9 @@
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
+
+ m := keeper.NewMigrator(am.keeper)
+ cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
}
// InitGenesis performs genesis initialization for the distribution module. It returns
@@ -165,12 +162,6 @@
// BeginBlock returns the begin blocker for the distribution module.
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
BeginBlocker(ctx, req, am.keeper)
-}
-
-// EndBlock returns the end blocker for the distribution module. It returns no validator
-// updates.
-func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
}
// AppModuleSimulation functions
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/simulation/operations.go ../pstake-native/x/lsnative/distribution/simulation/operations.go
--- x/distribution/simulation/operations.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/simulation/operations.go 2023-03-10 17:39:45
@@ -19,11 +19,11 @@
// Simulation operation weights constants
const (
- OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address"
- OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward"
- OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission"
- OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool"
- OpWeightMsgWithdrawTokenizeShareRecordReward = "op_weight_msg_withdraw_tokenize_share_record_reward"
+ OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec
+ OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec
+ OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" //nolint:gosec
+ OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool" //nolint:gosec
+ OpWeightMsgWithdrawTokenizeShareRecordReward = "op_weight_msg_withdraw_tokenize_share_record_reward" //nolint:gosec
)
// WeightedOperations returns all the operations from the module with their respective weights
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/simulation/proposals.go ../pstake-native/x/lsnative/distribution/simulation/proposals.go
--- x/distribution/simulation/proposals.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/simulation/proposals.go 2023-03-10 17:39:45
@@ -6,9 +6,9 @@
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/keeper"
"github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types"
+ "github.com/cosmos/cosmos-sdk/x/simulation"
)
// OpWeightSubmitCommunitySpendProposal app params key for community spend proposal
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/spec/02_state.md ../pstake-native/x/lsnative/distribution/spec/02_state.md
--- x/distribution/spec/02_state.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/spec/02_state.md 2023-03-10 17:35:24
@@ -15,7 +15,7 @@
When coins are distributed from the pool they are truncated back to
`sdk.Coins` which are non-decimal.
-- FeePool: `0x00 -> ProtocolBuffer(FeePool)`
+* FeePool: `0x00 -> ProtocolBuffer(FeePool)`
```go
// coins with decimal
@@ -27,7 +27,7 @@
}
```
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/distribution.proto#L94-L101
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/distribution/v1beta1/distribution.proto#L92-L96
## Validator Distribution
@@ -38,7 +38,7 @@
3. any delegator withdraws from a validator, or
4. the validator withdraws its commission.
-- ValidatorDistInfo: `0x02 | ValOperatorAddrLen (1 byte) | ValOperatorAddr -> ProtocolBuffer(validatorDistribution)`
+* ValidatorDistInfo: `0x02 | ValOperatorAddrLen (1 byte) | ValOperatorAddr -> ProtocolBuffer(validatorDistribution)`
```go
type ValidatorDistInfo struct {
@@ -56,7 +56,7 @@
and the delegator's _accumulation_ factor can be calculated passively knowing
only the height of the last withdrawal and its current properties.
-- DelegationDistInfo: `0x02 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValOperatorAddrLen (1 byte) | ValOperatorAddr -> ProtocolBuffer(delegatorDist)`
+* DelegationDistInfo: `0x02 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValOperatorAddrLen (1 byte) | ValOperatorAddr -> ProtocolBuffer(delegatorDist)`
```go
type DelegationDistInfo struct {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/spec/04_messages.md ../pstake-native/x/lsnative/distribution/spec/04_messages.md
--- x/distribution/spec/04_messages.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/spec/04_messages.md 2023-03-10 17:39:45
@@ -13,7 +13,7 @@
Response:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/distribution/v1beta1/tx.proto#L31-L41
```go
func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error
@@ -63,7 +63,7 @@
Response:
-+++ https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50
++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/distribution/v1beta1/tx.proto#L46-L56
## WithdrawValidatorCommission
@@ -79,7 +79,7 @@
The middle account (1:1 assigned per tokenize share record) takes the role of a delegator.
While executing the message, handler iterates all the tokenize share records, withdraw delegation reward from each record account and send the rewards to the record owner.
-
+
## FundCommunityPool
This message sends coins directly from the sender to the community pool.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/spec/05_hooks.md ../pstake-native/x/lsnative/distribution/spec/05_hooks.md
--- x/distribution/spec/05_hooks.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/spec/05_hooks.md 2023-03-10 17:35:24
@@ -8,15 +8,15 @@
## Create or modify delegation distribution
-- triggered-by: `staking.MsgDelegate`, `staking.MsgBeginRedelegate`, `staking.MsgUndelegate`
+* triggered-by: `staking.MsgDelegate`, `staking.MsgBeginRedelegate`, `staking.MsgUndelegate`
### Before
-- The delegation rewards are withdrawn to the withdraw address of the delegator.
+* The delegation rewards are withdrawn to the withdraw address of the delegator.
The rewards include the current period and exclude the starting period.
-- The validator period is incremented.
+* The validator period is incremented.
The validator period is incremented because the validator's power and share distribution might have changed.
-- The reference count for the delegator's starting period is decremented.
+* The reference count for the delegator's starting period is decremented.
### After
@@ -25,21 +25,21 @@
## Validator created
-- triggered-by: `staking.MsgCreateValidator`
+* triggered-by: `staking.MsgCreateValidator`
When a validator is created, the following validator variables are initialized:
-- Historical rewards
-- Current accumulated rewards
-- Accumulated commission
-- Total outstanding rewards
-- Period
+* Historical rewards
+* Current accumulated rewards
+* Accumulated commission
+* Total outstanding rewards
+* Period
By default, all values are set to a `0`, except period, which is set to `1`.
## Validator removed
-- triggered-by: `staking.RemoveValidator`
+* triggered-by: `staking.RemoveValidator`
Outstanding commission is sent to the validator's self-delegation withdrawal address.
Remaining delegator rewards get sent to the community fee pool.
@@ -50,10 +50,10 @@
## Validator is slashed
-- triggered-by: `staking.Slash`
+* triggered-by: `staking.Slash`
-- The current validator period reference count is incremented.
+* The current validator period reference count is incremented.
The reference count is incremented because the slash event has created a reference to it.
-- The validator period is incremented.
-- The slash event is stored for later use.
+* The validator period is incremented.
+* The slash event is stored for later use.
The slash event will be referenced when calculating delegator rewards.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/spec/README.md ../pstake-native/x/lsnative/distribution/spec/README.md
--- x/distribution/spec/README.md 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/spec/README.md 2023-03-10 17:39:45
@@ -22,27 +22,27 @@
whenever changes to parameters which affect the rate of reward distribution
occurs, withdrawal of rewards must also occur.
-- Whenever withdrawing, one must withdraw the maximum amount they are entitled
- to, leaving nothing in the pool.
-- Whenever bonding, unbonding, or re-delegating tokens to an existing account, a
- full withdrawal of the rewards must occur (as the rules for lazy accounting
- change).
-- Whenever a validator chooses to change the commission on rewards, all accumulated
- commission rewards must be simultaneously withdrawn.
+* Whenever withdrawing, one must withdraw the maximum amount they are entitled
+ to, leaving nothing in the pool.
+* Whenever bonding, unbonding, or re-delegating tokens to an existing account, a
+ full withdrawal of the rewards must occur (as the rules for lazy accounting
+ change).
+* Whenever a validator chooses to change the commission on rewards, all accumulated
+ commission rewards must be simultaneously withdrawn.
The above scenarios are covered in `hooks.md`.
The distribution mechanism outlined herein is used to lazily distribute the
following rewards between validators and associated delegators:
-- multi-token fees to be socially distributed
-- proposer reward pool
-- inflated atom provisions
-- validator commission on all rewards earned by their delegators stake
+* multi-token fees to be socially distributed
+* proposer reward pool
+* inflated atom provisions
+* validator commission on all rewards earned by their delegators stake
Fees are pooled within a global pool, as well as validator specific
proposer-reward pools. The mechanisms used allow for validators and delegators
-to independently and lazily withdraw their rewards.
+to independently and lazily withdraw their rewards.
## Shortcomings
@@ -50,7 +50,7 @@
specific to each validator which is used to estimate what their approximate
fair portion of tokens held in the global fee pool is owed to them.
-```
+```text
entitlement = delegator-accumulation / all-delegators-accumulation
```
@@ -85,20 +85,23 @@
## Contents
1. **[Concepts](01_concepts.md)**
- - [Reference Counting in F1 Fee Distribution](01_concepts.md#reference-counting-in-f1-fee-distribution)
+ * [Reference Counting in F1 Fee Distribution](01_concepts.md#reference-counting-in-f1-fee-distribution)
2. **[State](02_state.md)**
3. **[Begin Block](03_begin_block.md)**
4. **[Messages](04_messages.md)**
- - [MsgSetWithdrawAddress](04_messages.md#msgsetwithdrawaddress)
- - [MsgWithdrawDelegatorReward](04_messages.md#msgwithdrawdelegatorreward)
- - [Withdraw Validator Rewards All](04_messages.md#withdraw-validator-rewards-all)
- - [MsgWithdrawTokenizeShareRecordReward](04_messages.md#msgwithdrawtokenizesharerecordreward)
- - [Common calculations](04_messages.md#common-calculations-)
+ * [MsgSetWithdrawAddress](04_messages.md#msgsetwithdrawaddress)
+ * [MsgWithdrawDelegatorReward](04_messages.md#msgwithdrawdelegatorreward)
+ * [Withdraw Validator Rewards All](04_messages.md#withdraw-validator-rewards-all)
+ * [MsgWithdrawTokenizeShareRecordReward](04_messages.md#msgwithdrawtokenizesharerecordreward)
+ * [Common calculations](04_messages.md#common-calculations-)
5. **[Hooks](05_hooks.md)**
- - [Create or modify delegation distribution](05_hooks.md#create-or-modify-delegation-distribution)
- - [Commission rate change](05_hooks.md#commission-rate-change)
- - [Change in Validator State](05_hooks.md#change-in-validator-state)
+ * [Create or modify delegation distribution](05_hooks.md#create-or-modify-delegation-distribution)
+ * [Commission rate change](05_hooks.md#commission-rate-change)
+ * [Change in Validator State](05_hooks.md#change-in-validator-state)
6. **[Events](06_events.md)**
- - [BeginBlocker](06_events.md#beginblocker)
- - [Handlers](06_events.md#handlers)
+ * [BeginBlocker](06_events.md#beginblocker)
+ * [Handlers](06_events.md#handlers)
7. **[Parameters](07_params.md)**
+8. **[Parameters](07_params.md)**
+ * [CLI](08_client.md#cli)
+ * [gRPC](08_client.md#grpc)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/codec.go ../pstake-native/x/lsnative/distribution/types/codec.go
--- x/distribution/types/codec.go 2023-02-14 11:40:26
+++ ../pstake-native/x/lsnative/distribution/types/codec.go 2023-03-10 17:39:45
@@ -4,21 +4,24 @@
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
+ authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
+ govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterLegacyAminoCodec registers the necessary x/distribution interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- // cdc.RegisterConcrete(&MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil)
- // cdc.RegisterConcrete(&MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil)
- // cdc.RegisterConcrete(&MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil)
- // cdc.RegisterConcrete(&MsgFundCommunityPool{}, "cosmos-sdk/MsgFundCommunityPool", nil)
+ // legacy.RegisterAminoMsg(cdc, &MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward")
+ // legacy.RegisterAminoMsg(cdc, &MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValCommission")
+ // legacy.RegisterAminoMsg(cdc, &MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress")
+ // legacy.RegisterAminoMsg(cdc, &MsgFundCommunityPool{}, "cosmos-sdk/MsgFundCommunityPool")
// cdc.RegisterConcrete(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil)
- cdc.RegisterConcrete(&MsgWithdrawTokenizeShareRecordReward{}, "cosmos-sdk/MsgWithdrawTokenizeShareRecordReward", nil)
- cdc.RegisterConcrete(&MsgWithdrawAllTokenizeShareRecordReward{}, "cosmos-sdk/MsgWithdrawAllTokenizeShareRecordReward", nil)
+
+ legacy.RegisterAminoMsg(cdc, &MsgWithdrawTokenizeShareRecordReward{}, "cosmos-sdk/MsgWithdrawTokenizeShareRecordReward")
+ legacy.RegisterAminoMsg(cdc, &MsgWithdrawAllTokenizeShareRecordReward{}, "cosmos-sdk/MsgWithdrawAllTokenizeShareRecordReward")
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
@@ -39,6 +42,17 @@
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
+var (
+ amino = codec.NewLegacyAmino()
+ ModuleCdc = codec.NewAminoCodec(amino)
+)
+
func init() {
- RegisterLegacyAminoCodec(legacy.Cdc)
+ RegisterLegacyAminoCodec(amino)
+ cryptocodec.RegisterCrypto(amino)
+ sdk.RegisterLegacyAminoCodec(amino)
+
+ // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
+ // used to properly serialize MsgGrant and MsgExec instances
+ RegisterLegacyAminoCodec(authzcodec.Amino)
}
Only in ../pstake-native/x/lsnative/distribution/types: distribution.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/errors.go ../pstake-native/x/lsnative/distribution/types/errors.go
--- x/distribution/types/errors.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/types/errors.go 2023-03-10 17:39:45
@@ -6,17 +6,17 @@
// x/distribution module sentinel errors
var (
- // ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 2, "delegator address is empty")
- // ErrEmptyWithdrawAddr = sdkerrors.Register(ModuleName, 3, "withdraw address is empty")
- // ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 4, "validator address is empty")
- // ErrEmptyDelegationDistInfo = sdkerrors.Register(ModuleName, 5, "no delegation distribution info")
- // ErrNoValidatorDistInfo = sdkerrors.Register(ModuleName, 6, "no validator distribution info")
- // ErrNoValidatorCommission = sdkerrors.Register(ModuleName, 7, "no validator commission to withdraw")
- // ErrSetWithdrawAddrDisabled = sdkerrors.Register(ModuleName, 8, "set withdraw address disabled")
- // ErrBadDistribution = sdkerrors.Register(ModuleName, 9, "community pool does not have sufficient coins to distribute")
- // ErrInvalidProposalAmount = sdkerrors.Register(ModuleName, 10, "invalid community pool spend proposal amount")
- // ErrEmptyProposalRecipient = sdkerrors.Register(ModuleName, 11, "invalid community pool spend proposal recipient")
- // ErrNoValidatorExists = sdkerrors.Register(ModuleName, 12, "validator does not exist")
- // ErrNoDelegationExists = sdkerrors.Register(ModuleName, 13, "delegation does not exist")
+ // ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 2, "delegator address is empty")
+ // ErrEmptyWithdrawAddr = sdkerrors.Register(ModuleName, 3, "withdraw address is empty")
+ // ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 4, "validator address is empty")
+ // ErrEmptyDelegationDistInfo = sdkerrors.Register(ModuleName, 5, "no delegation distribution info")
+ // ErrNoValidatorDistInfo = sdkerrors.Register(ModuleName, 6, "no validator distribution info")
+ // ErrNoValidatorCommission = sdkerrors.Register(ModuleName, 7, "no validator commission to withdraw")
+ // ErrSetWithdrawAddrDisabled = sdkerrors.Register(ModuleName, 8, "set withdraw address disabled")
+ // ErrBadDistribution = sdkerrors.Register(ModuleName, 9, "community pool does not have sufficient coins to distribute")
+ // ErrInvalidProposalAmount = sdkerrors.Register(ModuleName, 10, "invalid community pool spend proposal amount")
+ // ErrEmptyProposalRecipient = sdkerrors.Register(ModuleName, 11, "invalid community pool spend proposal recipient")
+ // ErrNoValidatorExists = sdkerrors.Register(ModuleName, 12, "validator does not exist")
+ // ErrNoDelegationExists = sdkerrors.Register(ModuleName, 13, "delegation does not exist")
ErrNotTokenizeShareRecordOwner = sdkerrors.Register(ModuleName, 44, "not tokenize share record owner")
)
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/events.go ../pstake-native/x/lsnative/distribution/types/events.go
--- x/distribution/types/events.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/types/events.go 2023-03-10 17:39:45
@@ -7,8 +7,8 @@
EventTypeCommission = "commission"
EventTypeWithdrawRewards = "withdraw_rewards"
EventTypeWithdrawCommission = "withdraw_commission"
- EventTypeWithdrawTokenizeShareReward = "withdraw_tokenize_share_reward"
EventTypeProposerReward = "proposer_reward"
+ EventTypeWithdrawTokenizeShareReward = "withdraw_tokenize_share_reward"
AttributeKeyWithdrawAddress = "withdraw_address"
AttributeKeyValidator = "validator"
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/expected_keepers.go ../pstake-native/x/lsnative/distribution/types/expected_keepers.go
--- x/distribution/types/expected_keepers.go 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/distribution/types/expected_keepers.go 2023-03-10 17:39:45
@@ -21,6 +21,7 @@
// BankKeeper defines the expected interface needed to retrieve account balances.
type BankKeeper interface {
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
+
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/genesis.go ../pstake-native/x/lsnative/distribution/types/genesis.go
--- x/distribution/types/genesis.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/types/genesis.go 2023-03-10 17:35:24
@@ -10,7 +10,6 @@
acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord,
cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord,
) *GenesisState {
-
return &GenesisState{
Params: params,
FeePool: fp,
Only in ../pstake-native/x/lsnative/distribution/types: genesis.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/msg.go ../pstake-native/x/lsnative/distribution/types/msg.go
--- x/distribution/types/msg.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/types/msg.go 2023-03-10 17:39:45
@@ -1,7 +1,6 @@
package types
import (
- "github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@@ -33,16 +32,13 @@
// Return address that must sign over msg.GetSignBytes()
func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress {
- delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress)
return []sdk.AccAddress{delegator}
}
// get the bytes for the message signer to sign on
func (msg MsgSetWithdrawAddress) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -70,16 +66,13 @@
// Return address that must sign over msg.GetSignBytes()
func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress {
- delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress)
- if err != nil {
- panic(err)
- }
+ delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress)
return []sdk.AccAddress{delegator}
}
// get the bytes for the message signer to sign on
func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -111,7 +104,7 @@
// get the bytes for the message signer to sign on
func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -141,17 +134,14 @@
// GetSigners returns the signer addresses that are expected to sign the result
// of GetSignBytes.
func (msg MsgFundCommunityPool) GetSigners() []sdk.AccAddress {
- depositor, err := sdk.AccAddressFromBech32(msg.Depositor)
- if err != nil {
- panic(err)
- }
+ depositor, _ := sdk.AccAddressFromBech32(msg.Depositor)
return []sdk.AccAddress{depositor}
}
// GetSignBytes returns the raw bytes for a MsgFundCommunityPool message that
// the expected signer needs to sign.
func (msg MsgFundCommunityPool) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -189,7 +179,7 @@
// get the bytes for the message signer to sign on
func (msg MsgWithdrawTokenizeShareRecordReward) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@@ -223,7 +213,7 @@
// get the bytes for the message signer to sign on
func (msg MsgWithdrawAllTokenizeShareRecordReward) GetSignBytes() []byte {
- bz := legacy.Cdc.MustMarshalJSON(&msg)
+ bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/proposal.go ../pstake-native/x/lsnative/distribution/types/proposal.go
--- x/distribution/types/proposal.go 2023-02-14 11:40:31
+++ ../pstake-native/x/lsnative/distribution/types/proposal.go 2023-03-10 17:39:45
@@ -6,7 +6,7 @@
sdk "github.com/cosmos/cosmos-sdk/types"
sdkdistr "github.com/cosmos/cosmos-sdk/x/distribution/types"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
+ govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (
@@ -20,7 +20,6 @@
func init() {
// already registered in cosmos
// govtypes.RegisterProposalType(ProposalTypeCommunityPoolSpend)
- // govtypes.RegisterProposalTypeCodec(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal")
}
// NewCommunityPoolSpendProposal creates a new community pool spend proposal.
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/distribution/types/query.go ../pstake-native/x/lsnative/distribution/types/query.go
--- x/distribution/types/query.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/distribution/types/query.go 2023-03-10 17:35:24
@@ -15,8 +15,7 @@
}
// NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse
-func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward,
- total sdk.DecCoins) QueryDelegatorTotalRewardsResponse {
+func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse {
return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total}
}
@@ -33,8 +32,8 @@
}
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
+//
//nolint:interfacer
-func NewDelegationDelegatorReward(valAddr sdk.ValAddress,
- reward sdk.DecCoins) DelegationDelegatorReward {
+func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward {
return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward}
}
Only in ../pstake-native/x/lsnative/distribution/types: query.pb.go
Only in ../pstake-native/x/lsnative/distribution/types: query.pb.gw.go
Only in ../pstake-native/x/lsnative/distribution/types: tx.pb.go
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/genutil/client/cli/gentx.go ../pstake-native/x/lsnative/genutil/client/cli/gentx.go
--- x/genutil/client/cli/gentx.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/genutil/client/cli/gentx.go 2023-03-10 17:39:45
@@ -130,9 +130,7 @@
}
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags())
- if err != nil {
- return errors.Wrap(err, "error creating tx builder")
- }
+
pub, err := key.GetAddress()
if err != nil {
return err
@@ -167,6 +165,10 @@
w := bytes.NewBuffer([]byte{})
clientCtx = clientCtx.WithOutput(w)
+ if err = msg.ValidateBasic(); err != nil {
+ return err
+ }
+
if err = txBldr.PrintUnsignedTx(clientCtx, msg); err != nil {
return errors.Wrap(err, "failed to print unsigned std tx")
}
@@ -216,7 +218,7 @@
func makeOutputFilepath(rootDir, nodeID string) (string, error) {
writePath := filepath.Join(rootDir, "config", "gentx")
- if err := tmos.EnsureDir(writePath, 0700); err != nil {
+ if err := tmos.EnsureDir(writePath, 0o700); err != nil {
return "", err
}
@@ -238,7 +240,7 @@
}
func writeSignedGenTx(clientCtx client.Context, outputDocument string, tx sdk.Tx) error {
- outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
+ outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
if err != nil {
return err
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/genutil/client/cli/migrate.go ../pstake-native/x/lsnative/genutil/client/cli/migrate.go
--- x/genutil/client/cli/migrate.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/genutil/client/cli/migrate.go 2023-03-10 17:35:24
@@ -1 +1,139 @@
package cli
+
+import (
+ "encoding/json"
+ "fmt"
+ "sort"
+ "time"
+
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+ tmjson "github.com/tendermint/tendermint/libs/json"
+
+ "github.com/cosmos/cosmos-sdk/client"
+ "github.com/cosmos/cosmos-sdk/client/flags"
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ "github.com/cosmos/cosmos-sdk/version"
+ v043 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v043"
+ v046 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v046"
+ "github.com/cosmos/cosmos-sdk/x/genutil/types"
+)
+
+const flagGenesisTime = "genesis-time"
+
+// Allow applications to extend and modify the migration process.
+//
+// Ref: https://github.com/cosmos/cosmos-sdk/issues/5041
+var migrationMap = types.MigrationMap{
+ "v0.43": v043.Migrate, // NOTE: v0.43, v0.44 and v0.45 are genesis compatible.
+ "v0.46": v046.Migrate,
+}
+
+// GetMigrationCallback returns a MigrationCallback for a given version.
+func GetMigrationCallback(version string) types.MigrationCallback {
+ return migrationMap[version]
+}
+
+// GetMigrationVersions get all migration version in a sorted slice.
+func GetMigrationVersions() []string {
+ versions := make([]string, len(migrationMap))
+
+ var i int
+
+ for version := range migrationMap {
+ versions[i] = version
+ i++
+ }
+
+ sort.Strings(versions)
+
+ return versions
+}
+
+// MigrateGenesisCmd returns a command to execute genesis state migration.
+func MigrateGenesisCmd() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "migrate [target-version] [genesis-file]",
+ Short: "Migrate genesis to a specified target version",
+ Long: fmt.Sprintf(`Migrate the source genesis into the target version and print to STDOUT.
+
+Example:
+$ %s migrate v0.36 /path/to/genesis.json --chain-id=cosmoshub-3 --genesis-time=2019-04-22T17:00:00Z
+`, version.AppName),
+ Args: cobra.ExactArgs(2),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ clientCtx := client.GetClientContextFromCmd(cmd)
+
+ var err error
+
+ target := args[0]
+ importGenesis := args[1]
+
+ genDoc, err := validateGenDoc(importGenesis)
+ if err != nil {
+ return err
+ }
+
+ // Since some default values are valid values, we just print to
+ // make sure the user didn't forget to update these values.
+ if genDoc.ConsensusParams.Evidence.MaxBytes == 0 {
+ fmt.Printf("Warning: consensus_params.evidence.max_bytes is set to 0. If this is"+
+ " deliberate, feel free to ignore this warning. If not, please have a look at the chain"+
+ " upgrade guide at %s.\n", chainUpgradeGuide)
+ }
+
+ var initialState types.AppMap
+ if err := json.Unmarshal(genDoc.AppState, &initialState); err != nil {
+ return errors.Wrap(err, "failed to JSON unmarshal initial genesis state")
+ }
+
+ migrationFunc := GetMigrationCallback(target)
+ if migrationFunc == nil {
+ return fmt.Errorf("unknown migration function for version: %s", target)
+ }
+
+ // TODO: handler error from migrationFunc call
+ newGenState := migrationFunc(initialState, clientCtx)
+
+ genDoc.AppState, err = json.Marshal(newGenState)
+ if err != nil {
+ return errors.Wrap(err, "failed to JSON marshal migrated genesis state")
+ }
+
+ genesisTime, _ := cmd.Flags().GetString(flagGenesisTime)
+ if genesisTime != "" {
+ var t time.Time
+
+ err := t.UnmarshalText([]byte(genesisTime))
+ if err != nil {
+ return errors.Wrap(err, "failed to unmarshal genesis time")
+ }
+
+ genDoc.GenesisTime = t
+ }
+
+ chainID, _ := cmd.Flags().GetString(flags.FlagChainID)
+ if chainID != "" {
+ genDoc.ChainID = chainID
+ }
+
+ bz, err := tmjson.Marshal(genDoc)
+ if err != nil {
+ return errors.Wrap(err, "failed to marshal genesis doc")
+ }
+
+ sortedBz, err := sdk.SortJSON(bz)
+ if err != nil {
+ return errors.Wrap(err, "failed to sort JSON genesis doc")
+ }
+
+ cmd.Println(string(sortedBz))
+ return nil
+ },
+ }
+
+ cmd.Flags().String(flagGenesisTime, "", "override genesis_time with this flag")
+ cmd.Flags().String(flags.FlagChainID, "", "override chain_id with this flag")
+
+ return cmd
+}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/genutil/client/cli/validate_genesis.go ../pstake-native/x/lsnative/genutil/client/cli/validate_genesis.go
--- x/genutil/client/cli/validate_genesis.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/genutil/client/cli/validate_genesis.go 2023-03-10 17:35:24
@@ -12,7 +12,7 @@
"github.com/cosmos/cosmos-sdk/types/module"
)
-const chainUpgradeGuide = "https://docs.cosmos.network/master/migrations/chain-upgrade-guide-040.html"
+const chainUpgradeGuide = "https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md"
// ValidateGenesisCmd takes a genesis file, and makes sure that it is valid.
func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/genutil/doc.go ../pstake-native/x/lsnative/genutil/doc.go
--- x/genutil/doc.go 2023-02-14 10:35:05
+++ ../pstake-native/x/lsnative/genutil/doc.go 2023-03-10 17:35:24
@@ -1,10 +1,10 @@
/*
Package genutil contains a variety of genesis utility functionality
for usage within a blockchain application. Namely:
- - Genesis transactions related (gentx)
- - commands for collection and creation of gentxs
- - initchain processing of gentxs
- - Genesis file validation
- - Tendermint related initialization
+ - Genesis transactions related (gentx)
+ - commands for collection and creation of gentxs
+ - initchain processing of gentxs
+ - Genesis file validation
+ - Tendermint related initialization
*/
package genutil
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur x/genutil/module.go ../pstake-native/x/lsnative/genutil/module.go
--- x/genutil/module.go 2023-03-08 16:56:59
+++ ../pstake-native/x/lsnative/genutil/module.go 2023-03-10 17:39:45
@@ -4,7 +4,6 @@
"encoding/json"
"fmt"
- "github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
@@ -53,10 +52,6 @@
return types.ValidateGenesis(&data, txEncodingConfig.TxJSONDecoder())
}
-// RegisterRESTRoutes registers the REST routes for the genutil module.
-// Deprecated: RegisterRESTRoutes is deprecated.
-func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
-
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {
}
@@ -82,7 +77,6 @@
stakingKeeper types.StakingKeeper, deliverTx deliverTxfn,
txEncodingConfig client.TxEncodingConfig,
) module.AppModule {
-
return module.NewGenesisOnlyAppModule(AppModule{
AppModuleBasic: AppModuleBasic{},
accountKeeper: accountKeeper,
@@ -97,10 +91,12 @@
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
+
validators, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
if err != nil {
panic(err)
}
+
return validators
}
Only in ../pstake-native/x/lsnative/genutil/types: genesis.pb.go
Only in ../pstake-native/x/lsnative/proto/lsnative: .DS_Store
Only in proto: buf.gen.gogo.yaml
Only in proto: buf.lock
Only in proto: buf.yaml
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/distribution/v1beta1/distribution.proto ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/distribution.proto
--- proto/distribution/v1beta1/distribution.proto 2023-03-08 16:57:04
+++ ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/distribution.proto 2023-03-10 17:41:45
@@ -1,31 +1,32 @@
syntax = "proto3";
-package liquidstaking.distribution.v1beta1;
+package lsnative.distribution.v1beta1;
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types";
option (gogoproto.equal_all) = true;
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
+import "cosmos_proto/cosmos.proto";
// Params defines the set of params for the distribution module.
message Params {
option (gogoproto.goproto_stringer) = false;
string community_tax = 1 [
- (gogoproto.moretags) = "yaml:\"community_tax\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string base_proposer_reward = 2 [
- (gogoproto.moretags) = "yaml:\"base_proposer_reward\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string bonus_proposer_reward = 3 [
- (gogoproto.moretags) = "yaml:\"bonus_proposer_reward\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
- bool withdraw_addr_enabled = 4 [(gogoproto.moretags) = "yaml:\"withdraw_addr_enabled\""];
+ bool withdraw_addr_enabled = 4;
}
// ValidatorHistoricalRewards represents historical rewards for a validator.
@@ -41,12 +42,9 @@
// read that record)
// + one per validator for the zeroeth period, set on initialization
message ValidatorHistoricalRewards {
- repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1 [
- (gogoproto.moretags) = "yaml:\"cumulative_reward_ratio\"",
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
- (gogoproto.nullable) = false
- ];
- uint32 reference_count = 2 [(gogoproto.moretags) = "yaml:\"reference_count\""];
+ repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1
+ [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
+ uint32 reference_count = 2;
}
// ValidatorCurrentRewards represents current rewards and current
@@ -68,11 +66,8 @@
// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards
// for a validator inexpensive to track, allows simple sanity checks.
message ValidatorOutstandingRewards {
- repeated cosmos.base.v1beta1.DecCoin rewards = 1 [
- (gogoproto.moretags) = "yaml:\"rewards\"",
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
- (gogoproto.nullable) = false
- ];
+ repeated cosmos.base.v1beta1.DecCoin rewards = 1
+ [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}
// ValidatorSlashEvent represents a validator slash event.
@@ -80,33 +75,34 @@
// This is needed to calculate appropriate amount of staking tokens
// for delegations which are withdrawn after a slash has occurred.
message ValidatorSlashEvent {
- uint64 validator_period = 1 [(gogoproto.moretags) = "yaml:\"validator_period\""];
- string fraction = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
+ uint64 validator_period = 1;
+ string fraction = 2 [
+ (cosmos_proto.scalar) = "cosmos.Dec",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.nullable) = false
+ ];
}
// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages.
message ValidatorSlashEvents {
option (gogoproto.goproto_stringer) = false;
- repeated ValidatorSlashEvent validator_slash_events = 1
- [(gogoproto.moretags) = "yaml:\"validator_slash_events\"", (gogoproto.nullable) = false];
+ repeated ValidatorSlashEvent validator_slash_events = 1 [(gogoproto.nullable) = false];
}
// FeePool is the global fee pool for distribution.
message FeePool {
- repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
- (gogoproto.moretags) = "yaml:\"community_pool\""
- ];
+ repeated cosmos.base.v1beta1.DecCoin community_pool = 1
+ [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"];
}
// CommunityPoolSpendProposal details a proposal for use of community funds,
// together with how many coins are proposed to be spent, and to which
// recipient account.
message CommunityPoolSpendProposal {
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
- option (gogoproto.goproto_stringer) = false;
+ option (gogoproto.equal) = false;
+ option (gogoproto.goproto_getters) = false;
+ option (gogoproto.goproto_stringer) = false;
+ option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
string title = 1;
string description = 2;
@@ -122,13 +118,13 @@
// the delegators within the validator may be left with less than a full token,
// thus sdk.Dec is used.
message DelegatorStartingInfo {
- uint64 previous_period = 1 [(gogoproto.moretags) = "yaml:\"previous_period\""];
+ uint64 previous_period = 1;
string stake = 2 [
- (gogoproto.moretags) = "yaml:\"stake\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
- uint64 height = 3 [(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"];
+ uint64 height = 3 [(gogoproto.jsontag) = "creation_height"];
}
// DelegationDelegatorReward represents the properties
@@ -137,7 +133,7 @@
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.DecCoin reward = 2
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
@@ -159,12 +155,13 @@
// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal
// with a deposit
message CommunityPoolSpendProposalWithDeposit {
- option (gogoproto.goproto_getters) = false;
- option (gogoproto.goproto_stringer) = true;
+ option (gogoproto.goproto_getters) = false;
+ option (gogoproto.goproto_stringer) = true;
+ option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
- string title = 1 [(gogoproto.moretags) = "yaml:\"title\""];
- string description = 2 [(gogoproto.moretags) = "yaml:\"description\""];
- string recipient = 3 [(gogoproto.moretags) = "yaml:\"recipient\""];
- string amount = 4 [(gogoproto.moretags) = "yaml:\"amount\""];
- string deposit = 5 [(gogoproto.moretags) = "yaml:\"deposit\""];
+ string title = 1;
+ string description = 2;
+ string recipient = 3;
+ string amount = 4;
+ string deposit = 5;
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/distribution/v1beta1/genesis.proto ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/genesis.proto
--- proto/distribution/v1beta1/genesis.proto 2023-03-08 16:57:04
+++ ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/genesis.proto 2023-03-10 17:41:45
@@ -1,5 +1,5 @@
syntax = "proto3";
-package liquidstaking.distribution.v1beta1;
+package lsnative.distribution.v1beta1;
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types";
option (gogoproto.equal_all) = true;
@@ -7,6 +7,7 @@
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "distribution/v1beta1/distribution.proto";
+import "cosmos_proto/cosmos.proto";
// DelegatorWithdrawInfo is the address for where distributions rewards are
// withdrawn to by default this struct is only used at genesis to feed in
@@ -16,10 +17,10 @@
option (gogoproto.goproto_getters) = false;
// delegator_address is the address of the delegator.
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// withdraw_address is the address to withdraw the delegation rewards to.
- string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""];
+ string withdraw_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// ValidatorOutstandingRewardsRecord is used for import/export via genesis json.
@@ -28,14 +29,11 @@
option (gogoproto.goproto_getters) = false;
// validator_address is the address of the validator.
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// outstanding_rewards represents the oustanding rewards of a validator.
- repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2 [
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"outstanding_rewards\""
- ];
+ repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2
+ [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}
// ValidatorAccumulatedCommissionRecord is used for import / export via genesis
@@ -45,11 +43,10 @@
option (gogoproto.goproto_getters) = false;
// validator_address is the address of the validator.
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// accumulated is the accumulated commission of a validator.
- ValidatorAccumulatedCommission accumulated = 2
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"accumulated\""];
+ ValidatorAccumulatedCommission accumulated = 2 [(gogoproto.nullable) = false];
}
// ValidatorHistoricalRewardsRecord is used for import / export via genesis
@@ -59,13 +56,13 @@
option (gogoproto.goproto_getters) = false;
// validator_address is the address of the validator.
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// period defines the period the historical rewards apply to.
uint64 period = 2;
// rewards defines the historical rewards of a validator.
- ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""];
+ ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false];
}
// ValidatorCurrentRewardsRecord is used for import / export via genesis json.
@@ -74,10 +71,10 @@
option (gogoproto.goproto_getters) = false;
// validator_address is the address of the validator.
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// rewards defines the current rewards of a validator.
- ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""];
+ ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false];
}
// DelegatorStartingInfoRecord used for import / export via genesis json.
@@ -86,14 +83,13 @@
option (gogoproto.goproto_getters) = false;
// delegator_address is the address of the delegator.
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_address is the address of the validator.
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// starting_info defines the starting info of a delegator.
- DelegatorStartingInfo starting_info = 3
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"starting_info\""];
+ DelegatorStartingInfo starting_info = 3 [(gogoproto.nullable) = false];
}
// ValidatorSlashEventRecord is used for import / export via genesis json.
@@ -102,13 +98,13 @@
option (gogoproto.goproto_getters) = false;
// validator_address is the address of the validator.
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// height defines the block height at which the slash event occured.
uint64 height = 2;
// period is the period of the slash event.
uint64 period = 3;
// validator_slash_event describes the slash event.
- ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"event\""];
+ ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false];
}
// GenesisState defines the distribution module's genesis state.
@@ -117,39 +113,32 @@
option (gogoproto.goproto_getters) = false;
// params defines all the paramaters of the module.
- Params params = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"params\""];
+ Params params = 1 [(gogoproto.nullable) = false];
// fee_pool defines the fee pool at genesis.
- FeePool fee_pool = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"fee_pool\""];
+ FeePool fee_pool = 2 [(gogoproto.nullable) = false];
// fee_pool defines the delegator withdraw infos at genesis.
- repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_withdraw_infos\""];
+ repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 [(gogoproto.nullable) = false];
// fee_pool defines the previous proposer at genesis.
- string previous_proposer = 4 [(gogoproto.moretags) = "yaml:\"previous_proposer\""];
+ string previous_proposer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// fee_pool defines the outstanding rewards of all validators at genesis.
- repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"outstanding_rewards\""];
+ repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 [(gogoproto.nullable) = false];
// fee_pool defines the accumulated commisions of all validators at genesis.
- repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_accumulated_commissions\""];
+ repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 [(gogoproto.nullable) = false];
// fee_pool defines the historical rewards of all validators at genesis.
- repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_historical_rewards\""];
+ repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 [(gogoproto.nullable) = false];
// fee_pool defines the current rewards of all validators at genesis.
- repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_current_rewards\""];
+ repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 [(gogoproto.nullable) = false];
// fee_pool defines the delegator starting infos at genesis.
- repeated DelegatorStartingInfoRecord delegator_starting_infos = 9
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_starting_infos\""];
+ repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 [(gogoproto.nullable) = false];
// fee_pool defines the validator slash events at genesis.
- repeated ValidatorSlashEventRecord validator_slash_events = 10
- [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_slash_events\""];
+ repeated ValidatorSlashEventRecord validator_slash_events = 10 [(gogoproto.nullable) = false];
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/distribution/v1beta1/query.proto ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/query.proto
--- proto/distribution/v1beta1/query.proto 2023-03-08 16:57:04
+++ ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/query.proto 2023-03-10 17:41:45
@@ -1,5 +1,5 @@
syntax = "proto3";
-package liquidstaking.distribution.v1beta1;
+package lsnative.distribution.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
@@ -7,6 +7,7 @@
import "cosmos/base/v1beta1/coin.proto";
import "distribution/v1beta1/distribution.proto";
import "cosmos/distribution/v1beta1/query.proto";
+import "cosmos_proto/cosmos.proto";
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types";
@@ -20,12 +21,14 @@
// ValidatorOutstandingRewards queries rewards of a validator address.
rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest)
returns (QueryValidatorOutstandingRewardsResponse) {
- option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards";
+ option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/"
+ "{validator_address}/outstanding_rewards";
}
// ValidatorCommission queries accumulated commission for a validator.
rpc ValidatorCommission(QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {
- option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/commission";
+ option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/"
+ "{validator_address}/commission";
}
// ValidatorSlashes queries slash events of a validator.
@@ -35,7 +38,8 @@
// DelegationRewards queries the total rewards accrued by a delegation.
rpc DelegationRewards(cosmos.distribution.v1beta1.QueryDelegationRewardsRequest) returns (cosmos.distribution.v1beta1.QueryDelegationRewardsResponse) {
- option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/{validator_address}";
+ option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/"
+ "{validator_address}";
}
// DelegationTotalRewards queries the total rewards accrued by a each
@@ -46,18 +50,21 @@
// DelegatorValidators queries the validators of a delegator.
rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {
- option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/validators";
+ option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/"
+ "{delegator_address}/validators";
}
// DelegatorWithdrawAddress queries withdraw address of a delegator.
rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {
- option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/withdraw_address";
+ option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/"
+ "{delegator_address}/withdraw_address";
}
// CommunityPool queries the community pool coins.
rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {
option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool";
}
+
// TokenizeShareRecordReward queries the tokenize share record rewards
rpc TokenizeShareRecordReward(QueryTokenizeShareRecordRewardRequest)
returns (QueryTokenizeShareRecordRewardResponse) {
@@ -79,7 +86,7 @@
// Query/ValidatorOutstandingRewards RPC method.
message QueryValidatorOutstandingRewardsRequest {
// validator_address defines the validator address to query for.
- string validator_address = 1;
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryValidatorOutstandingRewardsResponse is the response type for the
@@ -92,7 +99,7 @@
// Query/ValidatorCommission RPC method
message QueryValidatorCommissionRequest {
// validator_address defines the validator address to query for.
- string validator_address = 1;
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryValidatorCommissionResponse is the response type for the
@@ -109,7 +116,7 @@
option (gogoproto.goproto_stringer) = true;
// validator_address defines the validator address to query for.
- string validator_address = 1;
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// starting_height defines the optional starting height to query the slashes.
uint64 starting_height = 2;
// starting_height defines the optional ending height to query the slashes.
@@ -134,7 +141,7 @@
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// delegator_address defines the delegator address to query for.
- string delegator_address = 1;
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegationTotalRewardsResponse is the response type for the
@@ -154,7 +161,7 @@
option (gogoproto.goproto_getters) = false;
// delegator_address defines the delegator address to query for.
- string delegator_address = 1;
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegatorValidatorsResponse is the response type for the
@@ -174,7 +181,7 @@
option (gogoproto.goproto_getters) = false;
// delegator_address defines the delegator address to query for.
- string delegator_address = 1;
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegatorWithdrawAddressResponse is the response type for the
@@ -184,7 +191,7 @@
option (gogoproto.goproto_getters) = false;
// withdraw_address defines the delegator address to query for.
- string withdraw_address = 1;
+ string withdraw_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC
@@ -203,7 +210,7 @@
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string owner_address = 1 [ (gogoproto.moretags) = "yaml:\"owner_address\"" ];
+ string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
message QueryTokenizeShareRecordRewardResponse {
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/distribution/v1beta1/tx.proto ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/tx.proto
--- proto/distribution/v1beta1/tx.proto 2023-03-08 16:57:04
+++ ../pstake-native/x/lsnative/proto/lsnative/distribution/v1beta1/tx.proto 2023-03-10 17:41:45
@@ -1,11 +1,13 @@
syntax = "proto3";
-package liquidstaking.distribution.v1beta1;
+package lsnative.distribution.v1beta1;
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/distribution/types";
option (gogoproto.equal_all) = true;
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
+import "cosmos_proto/cosmos.proto";
+import "cosmos/msg/v1/msg.proto";
// Msg defines the distribution Msg service.
service Msg {
@@ -21,27 +23,29 @@
// full commission to the validator address.
rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse);
+ // FundCommunityPool defines a method to allow an account to directly
+ // fund the community pool.
+ rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse);
+
// WithdrawTokenizeShareRecordReward defines a method to withdraw reward for an owning TokenizeShareRecord
rpc WithdrawTokenizeShareRecordReward(MsgWithdrawTokenizeShareRecordReward)
returns (MsgWithdrawTokenizeShareRecordRewardResponse);
-
+
// WithdrawAllTokenizeShareRecordReward defines a method to withdraw reward for all owning TokenizeShareRecord
rpc WithdrawAllTokenizeShareRecordReward(MsgWithdrawAllTokenizeShareRecordReward)
returns (MsgWithdrawAllTokenizeShareRecordRewardResponse);
-
- // FundCommunityPool defines a method to allow an account to directly
- // fund the community pool.
- rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse);
}
// MsgSetWithdrawAddress sets the withdraw address for
// a delegator (or validator self-delegation).
message MsgSetWithdrawAddress {
+ option (cosmos.msg.v1.signer) = "delegator_address";
+
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string withdraw_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type.
@@ -50,57 +54,72 @@
// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator
// from a single validator.
message MsgWithdrawDelegatorReward {
+ option (cosmos.msg.v1.signer) = "delegator_address";
+
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type.
-message MsgWithdrawDelegatorRewardResponse {}
+message MsgWithdrawDelegatorRewardResponse {
+ // Since: cosmos-sdk 0.46
+ repeated cosmos.base.v1beta1.Coin amount = 1
+ [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
+}
// MsgWithdrawValidatorCommission withdraws the full commission to the validator
// address.
message MsgWithdrawValidatorCommission {
+ option (cosmos.msg.v1.signer) = "validator_address";
+
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type.
-message MsgWithdrawValidatorCommissionResponse {}
+message MsgWithdrawValidatorCommissionResponse {
+ // Since: cosmos-sdk 0.46
+ repeated cosmos.base.v1beta1.Coin amount = 1
+ [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
+}
+// MsgFundCommunityPool allows an account to directly
+// fund the community pool.
+message MsgFundCommunityPool {
+ option (cosmos.msg.v1.signer) = "depositor";
+
+ option (gogoproto.equal) = false;
+ option (gogoproto.goproto_getters) = false;
+
+ repeated cosmos.base.v1beta1.Coin amount = 1
+ [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
+ string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+}
+
+// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type.
+message MsgFundCommunityPoolResponse {}
+
message MsgWithdrawTokenizeShareRecordReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string owner_address = 1 [ (gogoproto.moretags) = "yaml:\"owner_address\"" ];
+ string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 record_id = 2;
-}
-
+ }
+
message MsgWithdrawTokenizeShareRecordRewardResponse {}
message MsgWithdrawAllTokenizeShareRecordReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string owner_address = 1 [ (gogoproto.moretags) = "yaml:\"owner_address\"" ];
+ string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
message MsgWithdrawAllTokenizeShareRecordRewardResponse {}
-// MsgFundCommunityPool allows an account to directly
-// fund the community pool.
-message MsgFundCommunityPool {
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
-
- repeated cosmos.base.v1beta1.Coin amount = 1
- [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
- string depositor = 2;
-}
-
-// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type.
-message MsgFundCommunityPoolResponse {}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/staking/v1beta1/authz.proto ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/authz.proto
--- proto/staking/v1beta1/authz.proto 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/authz.proto 2023-03-10 17:41:45
@@ -1,5 +1,5 @@
syntax = "proto3";
-package liquidstaking.staking.v1beta1;
+package lsnative.staking.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
@@ -8,6 +8,8 @@
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types";
// StakeAuthorization defines authorization for delegate/undelegate/redelegate.
+//
+// Since: cosmos-sdk 0.43
message StakeAuthorization {
option (cosmos_proto.implements_interface) = "Authorization";
@@ -24,13 +26,15 @@
}
// Validators defines list of validator addresses.
message Validators {
- repeated string address = 1;
+ repeated string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// authorization_type defines one of AuthorizationType.
AuthorizationType authorization_type = 4;
}
// AuthorizationType defines the type of staking module authorization type
+//
+// Since: cosmos-sdk 0.43
enum AuthorizationType {
// AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type
AUTHORIZATION_TYPE_UNSPECIFIED = 0;
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/staking/v1beta1/genesis.proto ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/genesis.proto
--- proto/staking/v1beta1/genesis.proto 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/genesis.proto 2023-03-10 17:41:45
@@ -1,10 +1,11 @@
syntax = "proto3";
-package liquidstaking.staking.v1beta1;
+package lsnative.staking.v1beta1;
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types";
import "gogoproto/gogo.proto";
import "staking/v1beta1/staking.proto";
+import "cosmos_proto/cosmos.proto";
// GenesisState defines the staking module's genesis state.
message GenesisState {
@@ -13,16 +14,12 @@
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.
- bytes last_total_power = 2 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
- (gogoproto.moretags) = "yaml:\"last_total_power\"",
- (gogoproto.nullable) = false
- ];
+ bytes last_total_power = 2
+ [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
// last_validator_powers is a special index that provides a historical list
// of the last-block's bonded validators.
- repeated LastValidatorPower last_validator_powers = 3
- [(gogoproto.moretags) = "yaml:\"last_validator_powers\"", (gogoproto.nullable) = false];
+ repeated LastValidatorPower last_validator_powers = 3 [(gogoproto.nullable) = false];
// delegations defines the validator set at genesis.
repeated Validator validators = 4 [(gogoproto.nullable) = false];
@@ -31,8 +28,7 @@
repeated Delegation delegations = 5 [(gogoproto.nullable) = false];
// unbonding_delegations defines the unbonding delegations active at genesis.
- repeated UnbondingDelegation unbonding_delegations = 6
- [(gogoproto.moretags) = "yaml:\"unbonding_delegations\"", (gogoproto.nullable) = false];
+ repeated UnbondingDelegation unbonding_delegations = 6 [(gogoproto.nullable) = false];
// redelegations defines the redelegations active at genesis.
repeated Redelegation redelegations = 7 [(gogoproto.nullable) = false];
@@ -40,9 +36,8 @@
bool exported = 8;
// store tokenize share records to provide reward to record owners
- repeated TokenizeShareRecord tokenize_share_records = 9
- [ (gogoproto.nullable) = false ];
-
+ repeated TokenizeShareRecord tokenize_share_records = 9 [(gogoproto.nullable) = false];
+
// last tokenize share record id, used for next share record id calculation
uint64 last_tokenize_share_record_id = 10;
}
@@ -53,7 +48,7 @@
option (gogoproto.goproto_getters) = false;
// address is the address of the validator.
- string address = 1;
+ string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// power defines the power of the validator.
int64 power = 2;
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/staking/v1beta1/query.proto ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/query.proto
--- proto/staking/v1beta1/query.proto 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/query.proto 2023-03-10 17:41:45
@@ -1,11 +1,12 @@
syntax = "proto3";
-package liquidstaking.staking.v1beta1;
+package lsnative.staking.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "staking/v1beta1/staking.proto";
import "cosmos/base/v1beta1/coin.proto";
+import "cosmos_proto/cosmos.proto";
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types";
@@ -132,12 +133,12 @@
// QueryValidatorRequest is response type for the Query/Validator RPC method
message QueryValidatorRequest {
// validator_addr defines the validator address to query for.
- string validator_addr = 1;
+ string validator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryValidatorResponse is response type for the Query/Validator RPC method
message QueryValidatorResponse {
- // validator defines the the validator info.
+ // validator defines the validator info.
Validator validator = 1 [(gogoproto.nullable) = false];
}
@@ -145,7 +146,7 @@
// Query/ValidatorDelegations RPC method
message QueryValidatorDelegationsRequest {
// validator_addr defines the validator address to query for.
- string validator_addr = 1;
+ string validator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
@@ -165,7 +166,7 @@
// Query/ValidatorUnbondingDelegations RPC method
message QueryValidatorUnbondingDelegationsRequest {
// validator_addr defines the validator address to query for.
- string validator_addr = 1;
+ string validator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
@@ -186,10 +187,10 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_addr defines the validator address to query for.
- string validator_addr = 2;
+ string validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegationResponse is response type for the Query/Delegation RPC method.
@@ -205,10 +206,10 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_addr defines the validator address to query for.
- string validator_addr = 2;
+ string validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegationResponse is response type for the Query/UnbondingDelegation
@@ -225,7 +226,7 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
@@ -248,7 +249,7 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
@@ -270,13 +271,13 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// src_validator_addr defines the validator address to redelegate from.
- string src_validator_addr = 2;
+ string src_validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// dst_validator_addr defines the validator address to redelegate to.
- string dst_validator_addr = 3;
+ string dst_validator_addr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 4;
@@ -298,7 +299,7 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
@@ -307,7 +308,7 @@
// QueryDelegatorValidatorsResponse is response type for the
// Query/DelegatorValidators RPC method.
message QueryDelegatorValidatorsResponse {
- // validators defines the the validators' info of a delegator.
+ // validators defines the validators' info of a delegator.
repeated Validator validators = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
@@ -321,16 +322,16 @@
option (gogoproto.goproto_getters) = false;
// delegator_addr defines the delegator address to query for.
- string delegator_addr = 1;
+ string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_addr defines the validator address to query for.
- string validator_addr = 2;
+ string validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDelegatorValidatorResponse response type for the
// Query/DelegatorValidator RPC method.
message QueryDelegatorValidatorResponse {
- // validator defines the the validator info.
+ // validator defines the validator info.
Validator validator = 1 [(gogoproto.nullable) = false];
}
@@ -370,26 +371,26 @@
uint64 id = 1;
}
message QueryTokenizeShareRecordByIdResponse {
- TokenizeShareRecord record = 1 [ (gogoproto.nullable) = false ];
+ TokenizeShareRecord record = 1 [(gogoproto.nullable) = false];
}
message QueryTokenizeShareRecordByDenomRequest {
string denom = 1;
}
message QueryTokenizeShareRecordByDenomResponse {
- TokenizeShareRecord record = 1 [ (gogoproto.nullable) = false ];
+ TokenizeShareRecord record = 1 [(gogoproto.nullable) = false];
}
message QueryTokenizeShareRecordsOwnedRequest {
string owner = 1;
}
message QueryTokenizeShareRecordsOwnedResponse {
- repeated TokenizeShareRecord records = 1 [ (gogoproto.nullable) = false ];
+ repeated TokenizeShareRecord records = 1 [(gogoproto.nullable) = false];
}
message QueryAllTokenizeShareRecordsRequest {}
message QueryAllTokenizeShareRecordsResponse {
- repeated TokenizeShareRecord records = 1 [ (gogoproto.nullable) = false ];
+ repeated TokenizeShareRecord records = 1 [(gogoproto.nullable) = false];
}
message QueryLastTokenizeShareRecordIdRequest {}
@@ -399,5 +400,5 @@
message QueryTotalTokenizeSharedAssetsRequest {}
message QueryTotalTokenizeSharedAssetsResponse {
- cosmos.base.v1beta1.Coin value = 1 [ (gogoproto.nullable) = false ];
+ cosmos.base.v1beta1.Coin value = 1 [(gogoproto.nullable) = false];
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/staking/v1beta1/staking.proto ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/staking.proto
--- proto/staking/v1beta1/staking.proto 2023-03-08 16:57:04
+++ ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/staking.proto 2023-03-10 17:41:45
@@ -1,5 +1,5 @@
syntax = "proto3";
-package liquidstaking.staking.v1beta1;
+package lsnative.staking.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
@@ -8,6 +8,7 @@
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
+import "cosmos/staking/v1beta1/staking.proto";
import "tendermint/types/types.proto";
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types";
@@ -28,16 +29,20 @@
option (gogoproto.goproto_stringer) = false;
// rate is the commission rate charged to delegators, as a fraction.
- string rate = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
+ string rate = 1 [
+ (cosmos_proto.scalar) = "cosmos.Dec",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.nullable) = false
+ ];
// max_rate defines the maximum commission rate which validator can ever charge, as a fraction.
string max_rate = 2 [
- (gogoproto.moretags) = "yaml:\"max_rate\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// max_change_rate defines the maximum daily increase of the validator commission, as a fraction.
string max_change_rate = 3 [
- (gogoproto.moretags) = "yaml:\"max_change_rate\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
@@ -51,8 +56,7 @@
// commission_rates defines the initial commission rates to be used for creating a validator.
CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
// update_time is the last time the commission rate was changed.
- google.protobuf.Timestamp update_time = 2
- [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\""];
+ google.protobuf.Timestamp update_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// Description defines a validator description.
@@ -67,7 +71,7 @@
// website defines an optional website link.
string website = 3;
// security_contact defines an optional email for security contact.
- string security_contact = 4 [(gogoproto.moretags) = "yaml:\"security_contact\""];
+ string security_contact = 4;
// details define other optional details.
string details = 5;
}
@@ -86,39 +90,41 @@
option (gogoproto.goproto_getters) = false;
// operator_address defines the address of the validator's operator; bech encoded in JSON.
- string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""];
+ string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// consensus_pubkey is the consensus public key of the validator, as a Protobuf Any.
- google.protobuf.Any consensus_pubkey = 2
- [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", (gogoproto.moretags) = "yaml:\"consensus_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 = 3;
// status is the validator status (bonded/unbonding/unbonded).
- BondStatus status = 4;
+ cosmos.staking.v1beta1.BondStatus status = 4;
// tokens define the delegated tokens (incl. self-delegation).
- string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
+ 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 = 6 [
- (gogoproto.moretags) = "yaml:\"delegator_shares\"",
+ (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 = 7 [(gogoproto.nullable) = false];
// unbonding_height defines, if unbonding, the height at which this validator has begun unbonding.
- int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""];
+ int64 unbonding_height = 8;
// unbonding_time defines, if unbonding, the min time for the validator to complete unbonding.
- google.protobuf.Timestamp unbonding_time = 9
- [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""];
+ google.protobuf.Timestamp unbonding_time = 9 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// commission defines the commission parameters.
Commission commission = 10 [(gogoproto.nullable) = false];
// Number of shares marked_exempt_to_this_validator
string total_exempt_shares = 11[
- (gogoproto.moretags) = "yaml:\"total_exempt_shares\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
- ];
+ ];
string total_tokenized_shares = 12[
- (gogoproto.moretags) = "yaml:\"total_tokenized_shares\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
@@ -143,7 +149,7 @@
option (gogoproto.goproto_stringer) = false;
option (gogoproto.stringer) = true;
- repeated string addresses = 1;
+ repeated string addresses = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// DVPair is struct that just has a delegator-validator pair with no other data.
@@ -154,8 +160,8 @@
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// DVPairs defines an array of DVPair objects.
@@ -172,9 +178,9 @@
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""];
- string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// DVVTriplets defines an array of DVVTriplet objects.
@@ -191,11 +197,15 @@
option (gogoproto.goproto_stringer) = false;
// delegator_address is the bech32-encoded address of the delegator.
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_address is the bech32-encoded address of the validator.
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// shares define the delegation shares received.
- string shares = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
+ string shares = 3 [
+ (cosmos_proto.scalar) = "cosmos.Dec",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.nullable) = false
+ ];
// has this delegation been marked as exempt.
bool exempt = 4;
}
@@ -208,9 +218,9 @@
option (gogoproto.goproto_stringer) = false;
// delegator_address is the bech32-encoded address of the delegator.
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_address is the bech32-encoded address of the validator.
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// entries are the unbonding delegation entries.
repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries
}
@@ -221,18 +231,21 @@
option (gogoproto.goproto_stringer) = false;
// creation_height is the height which the unbonding took place.
- int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""];
+ int64 creation_height = 1;
// completion_time is the unix time for unbonding completion.
- google.protobuf.Timestamp completion_time = 2
- [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""];
+ google.protobuf.Timestamp completion_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// initial_balance defines the tokens initially scheduled to receive at completion.
string initial_balance = 3 [
+ (cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"initial_balance\""
+ (gogoproto.nullable) = false
];
// balance defines the tokens to receive at completion.
- string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
+ string balance = 4 [
+ (cosmos_proto.scalar) = "cosmos.Int",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
+ (gogoproto.nullable) = false
+ ];
}
// RedelegationEntry defines a redelegation object with relevant metadata.
@@ -241,19 +254,21 @@
option (gogoproto.goproto_stringer) = false;
// creation_height defines the height which the redelegation took place.
- int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""];
+ int64 creation_height = 1;
// completion_time defines the unix time for redelegation completion.
- google.protobuf.Timestamp completion_time = 2
- [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""];
+ google.protobuf.Timestamp completion_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// initial_balance defines the initial balance when redelegation started.
string initial_balance = 3 [
+ (cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"initial_balance\""
+ (gogoproto.nullable) = false
];
// shares_dst is the amount of destination-validator shares created by redelegation.
- string shares_dst = 4
- [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
+ string shares_dst = 4 [
+ (cosmos_proto.scalar) = "cosmos.Dec",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.nullable) = false
+ ];
}
// Redelegation contains the list of a particular delegator's redelegating bonds
@@ -264,11 +279,11 @@
option (gogoproto.goproto_stringer) = false;
// delegator_address is the bech32-encoded address of the delegator.
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_src_address is the validator redelegation source operator address.
- string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""];
+ string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator_dst_address is the validator redelegation destination operator address.
- string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""];
+ string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// entries are the redelegation entries.
repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries
}
@@ -296,7 +311,7 @@
];
// exemption_factor is required for tokenize share and undelegation check for network safety
string exemption_factor = 7 [
- (gogoproto.moretags) = "yaml:\"exemption_factor\"",
+ (cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
@@ -320,7 +335,11 @@
option (gogoproto.equal) = true;
RedelegationEntry redelegation_entry = 1 [(gogoproto.nullable) = false];
- string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
+ string balance = 4 [
+ (cosmos_proto.scalar) = "cosmos.Int",
+ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
+ (gogoproto.nullable) = false
+ ];
}
// RedelegationResponse is equivalent to a Redelegation except that its entries
@@ -339,15 +358,16 @@
option (gogoproto.description) = true;
option (gogoproto.equal) = true;
string not_bonded_tokens = 1 [
+ (cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
- (gogoproto.jsontag) = "not_bonded_tokens",
- (gogoproto.nullable) = false
+ (gogoproto.nullable) = false,
+ (gogoproto.jsontag) = "not_bonded_tokens"
];
string bonded_tokens = 2 [
- (gogoproto.jsontag) = "bonded_tokens",
+ (cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"bonded_tokens\""
+ (gogoproto.jsontag) = "bonded_tokens"
];
}
@@ -355,7 +375,7 @@
option (gogoproto.equal) = true;
uint64 id = 1;
- string owner = 2;
+ string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string module_account = 3; // module account take the role of delegator
- string validator = 4; // validator delegated to for tokenize share record creation
+ string validator = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // validator delegated to for tokenize share record creation
}
diff -x '*.pb.go' -x '*.pb.gw.go' -x 'third_party' -ur proto/staking/v1beta1/tx.proto ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/tx.proto
--- proto/staking/v1beta1/tx.proto 2023-03-08 16:57:03
+++ ../pstake-native/x/lsnative/proto/lsnative/staking/v1beta1/tx.proto 2023-03-10 17:41:45
@@ -1,5 +1,5 @@
syntax = "proto3";
-package liquidstaking.staking.v1beta1;
+package lsnative.staking.v1beta1;
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
@@ -9,6 +9,8 @@
import "cosmos/base/v1beta1/coin.proto";
import "staking/v1beta1/staking.proto";
+import "cosmos/msg/v1/msg.proto";
+
option go_package = "github.com/persistenceOne/pstake-native/v2/x/lsnative/staking/types";
// Msg defines the staking Msg service.
@@ -31,16 +33,16 @@
// delegate and a validator.
rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse);
- // UnbondValidator defines a method for performing the status transition for a validator
- // from bonded to unbonded
- rpc UnbondValidator(MsgUnbondValidator) returns (MsgUnbondValidatorResponse);
-
// 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);
+ // UnbondValidator defines a method for performing the status transition for a validator
+ // from bonded to unbonded
+ rpc UnbondValidator(MsgUnbondValidator) returns (MsgUnbondValidatorResponse);
+
// TokenizeShares defines a method for tokenizing shares from a validator.
rpc TokenizeShares(MsgTokenizeShares) returns (MsgTokenizeSharesResponse);
@@ -61,13 +63,19 @@
// 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";
+
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Description description = 1 [(gogoproto.nullable) = false];
CommissionRates commission = 2 [(gogoproto.nullable) = false];
- string delegator_address = 3 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 4 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ string delegator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
google.protobuf.Any pubkey = 5 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
cosmos.base.v1beta1.Coin value = 6 [(gogoproto.nullable) = false];
}
@@ -77,20 +85,20 @@
// MsgEditValidator defines a SDK message for editing an existing validator.
message MsgEditValidator {
+ option (cosmos.msg.v1.signer) = "validator_address";
+
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Description description = 1 [(gogoproto.nullable) = false];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"address\""];
+ string validator_address = 2 [(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 = 3 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
- (gogoproto.moretags) = "yaml:\"commission_rate\""
- ];
+ string commission_rate = 3
+ [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"];
}
// MsgEditValidatorResponse defines the Msg/EditValidator response type.
@@ -99,11 +107,12 @@
// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message MsgDelegate {
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
+ option (cosmos.msg.v1.signer) = "delegator_address";
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ option (gogoproto.equal) = false;
+
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
@@ -113,12 +122,13 @@
// MsgBeginRedelegate defines a SDK message for performing a redelegation
// of coins from a delegator and source validator to a destination validator.
message MsgBeginRedelegate {
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
+ option (cosmos.msg.v1.signer) = "delegator_address";
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""];
- string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""];
+ option (gogoproto.equal) = false;
+
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
}
@@ -130,11 +140,12 @@
// MsgUndelegate defines a SDK message for performing an undelegation from a
// delegate and a validator.
message MsgUndelegate {
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
+ option (cosmos.msg.v1.signer) = "delegator_address";
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
+ option (gogoproto.equal) = false;
+
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
@@ -143,24 +154,17 @@
google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
-// MsgUnbondValidator defines a method for performing the status transition for
-// a validator from bonded to unbonded
-message MsgUnbondValidator {
- string validator_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
-}
-message MsgUnbondValidatorResponse {}
-
// MsgCancelUnbondingDelegation defines the SDK message for performing a cancel unbonding delegation for delegator
//
// Since: cosmos-sdk 0.46
-message MsgCancelUnbondingDelegation{
- option (gogoproto.equal) = false;
- option (gogoproto.goproto_getters) = false;
+message MsgCancelUnbondingDelegation {
+ option (cosmos.msg.v1.signer) = "delegator_address";
+ option (gogoproto.equal) = false;
- string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
- string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
- // amount is always less than or equal to unbonding delegation entry balance
- cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ // amount is always less than or equal to unbonding delegation entry balance
+ cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
// creation_height is the height which the unbonding took place.
int64 creation_height = 4;
}
@@ -168,36 +172,39 @@
// MsgCancelUnbondingDelegationResponse
//
// Since: cosmos-sdk 0.46
-message MsgCancelUnbondingDelegationResponse{}
+message MsgCancelUnbondingDelegationResponse {}
+// MsgUnbondValidator defines a method for performing the status transition for
+// a validator from bonded to unbonded
+message MsgUnbondValidator {
+ string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+}
+message MsgUnbondValidatorResponse {}
+
message MsgTokenizeShares {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string delegator_address = 1
- [ (gogoproto.moretags) = "yaml:\"delegator_address\"" ];
- string validator_address = 2
- [ (gogoproto.moretags) = "yaml:\"validator_address\"" ];
- cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false ];
- string tokenized_share_owner = 4
- [ (gogoproto.moretags) = "yaml:\"tokenized_share_owner\"" ];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
+ string tokenized_share_owner = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
message MsgTokenizeSharesResponse {
- cosmos.base.v1beta1.Coin amount = 1 [ (gogoproto.nullable) = false ];
+ cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false];
}
message MsgRedeemTokensforShares {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- string delegator_address = 1
- [ (gogoproto.moretags) = "yaml:\"delegator_address\"" ];
- cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ];
+ string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
+ cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
}
message MsgRedeemTokensforSharesResponse {
- cosmos.base.v1beta1.Coin amount = 1 [ (gogoproto.nullable) = false ];
+ cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false];
}
message MsgTransferTokenizeShareRecord {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment