diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 753d1a28e4..a0b17af011 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -72,6 +72,18 @@ message Params { // to timeout VSC packets even when a consumer chain is not live. google.protobuf.Duration vsc_timeout_period = 5 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + + // The period for which the slash meter is replenished + google.protobuf.Duration slash_meter_replenish_period = 6 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + + // The fraction of total voting power that is replenished to the slash meter every replenish period. + // This param also serves as a maximum fraction of total voting power that the slash meter can hold. + string slash_meter_replenish_fraction = 7; + + // The maximum amount of pending slash packets that can be queued for a consumer + // before the provider chain halts. + int64 max_pending_slash_packets = 8; } message HandshakeMetadata { diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 68d586f3c6..7a0a96832e 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -1,10 +1,8 @@ package types import ( - fmt "fmt" time "time" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" @@ -110,7 +108,7 @@ func (p Params) Validate() error { if err := ccvtypes.ValidateDuration(p.TransferTimeoutPeriod); err != nil { return err } - if err := validateConsumerRedistributionFraction(p.ConsumerRedistributionFraction); err != nil { + if err := ccvtypes.ValidateStringFraction(p.ConsumerRedistributionFraction); err != nil { return err } if err := ccvtypes.ValidatePositiveInt64(p.HistoricalEntries); err != nil { @@ -137,7 +135,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyTransferTimeoutPeriod, p.TransferTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeyConsumerRedistributionFrac, - p.ConsumerRedistributionFraction, validateConsumerRedistributionFraction), + p.ConsumerRedistributionFraction, ccvtypes.ValidateStringFraction), paramtypes.NewParamSetPair(KeyHistoricalEntries, p.HistoricalEntries, ccvtypes.ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyConsumerUnbondingPeriod, @@ -162,21 +160,3 @@ func validateProviderFeePoolAddrStr(i interface{}) error { // Otherwise validate as usual for a bech32 address return ccvtypes.ValidateBech32(i) } - -func validateConsumerRedistributionFraction(i interface{}) error { - str, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - dec, err := sdk.NewDecFromStr(str) - if err != nil { - return err - } - if dec.IsNegative() { - return fmt.Errorf("consumer redistribution fraction is negative") - } - if dec.Sub(sdk.NewDec(1)).IsPositive() { - return fmt.Errorf("consumer redistribution fraction cannot be above 1.0") - } - return nil -} diff --git a/x/ccv/provider/keeper/params.go b/x/ccv/provider/keeper/params.go index 9ce00d2f81..ae6d34ce9a 100644 --- a/x/ccv/provider/keeper/params.go +++ b/x/ccv/provider/keeper/params.go @@ -52,6 +52,30 @@ func (k Keeper) SetVscTimeoutPeriod(ctx sdk.Context, period time.Duration) { k.paramSpace.Set(ctx, types.KeyVscTimeoutPeriod, period) } +// GetSlashMeterReplenishPeriod returns the period for which the slash gas meter is replenished. +func (k Keeper) GetSlashMeterReplenishPeriod(ctx sdk.Context) time.Duration { + var p time.Duration + k.paramSpace.Get(ctx, types.KeySlashMeterReplenishPeriod, &p) + return p +} + +// GetSlashMeterReplenishFraction returns the string fraction of total voting power that is replenished +// to the slash meter every replenish period. This param also serves as a maximum fraction of total +// voting power that the slash meter can hold. +func (k Keeper) GetSlashMeterReplenishFraction(ctx sdk.Context) string { + var f string + k.paramSpace.Get(ctx, types.KeySlashMeterReplenishFraction, &f) + return f +} + +// GetMaxPendingSlashingPackets returns the maximum number of pending slash packets that can be queued for a consumer +// before the provider chain halts. +func (k Keeper) GetMaxPendingSlashingPackets(ctx sdk.Context) int64 { + var p int64 + k.paramSpace.Get(ctx, types.KeyMaxPendingSlashPackets, &p) + return p +} + // GetParams returns the paramset for the provider module func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( @@ -60,6 +84,9 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.GetCCVTimeoutPeriod(ctx), k.GetInitTimeoutPeriod(ctx), k.GetVscTimeoutPeriod(ctx), + k.GetSlashMeterReplenishPeriod(ctx), + k.GetSlashMeterReplenishFraction(ctx), + k.GetMaxPendingSlashingPackets(ctx), ) } diff --git a/x/ccv/provider/keeper/params_test.go b/x/ccv/provider/keeper/params_test.go index 02da2aa9de..7fbeb8760f 100644 --- a/x/ccv/provider/keeper/params_test.go +++ b/x/ccv/provider/keeper/params_test.go @@ -8,8 +8,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" testkeeper "github.com/cosmos/interchain-security/testutil/keeper" - "github.com/cosmos/interchain-security/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" + providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" "github.com/stretchr/testify/require" ) @@ -21,14 +20,32 @@ func TestParams(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) defer ctrl.Finish() - defaultParams := types.DefaultParams() + defaultParams := providertypes.DefaultParams() providerKeeper.SetParams(ctx, defaultParams) params := providerKeeper.GetParams(ctx) require.Equal(t, defaultParams, params) - newParams := types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, - time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - types.DefaultTrustingPeriodFraction, ccvtypes.DefaultCCVTimeoutPeriod, types.DefaultInitTimeoutPeriod, types.DefaultVscTimeoutPeriod) + newParams := providertypes.NewParams( + ibctmtypes.NewClientState( + "", + ibctmtypes.DefaultTrustLevel, + 0, + 0, + time.Second*40, + clienttypes.Height{}, + commitmenttypes.GetSDKSpecs(), + []string{"ibc", "upgradedIBCState"}, + true, + false, + ), + 4, + 7*24*time.Hour, + 5*time.Hour, + 10*time.Minute, + time.Hour, + "0.4", + 100, + ) providerKeeper.SetParams(ctx, newParams) params = providerKeeper.GetParams(ctx) require.Equal(t, newParams, params) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 7f6ad1058e..c5f1b68338 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -633,10 +633,13 @@ func TestMakeConsumerGenesis(t *testing.T) { }, // Note these are unused provider parameters for this test, and not actually asserted against // They must be populated with reasonable values to satisfy SetParams though. - TrustingPeriodFraction: providertypes.DefaultTrustingPeriodFraction, - CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, - InitTimeoutPeriod: types.DefaultInitTimeoutPeriod, - VscTimeoutPeriod: types.DefaultVscTimeoutPeriod, + TrustingPeriodFraction: providertypes.DefaultTrustingPeriodFraction, + CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, + InitTimeoutPeriod: types.DefaultInitTimeoutPeriod, + VscTimeoutPeriod: types.DefaultVscTimeoutPeriod, + SlashMeterReplenishPeriod: types.DefaultSlashMeterReplenishPeriod, + SlashMeterReplenishFraction: types.DefaultSlashMeterReplenishFraction, + MaxPendingSlashPackets: types.DefaultMaxPendingSlashPackets, } providerKeeper.SetParams(ctx, moduleParams) defer ctrl.Finish() diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index 87aa1f8ff5..c1613c8277 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -79,7 +79,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 3, time.Hour, time.Hour, time.Hour), + 3, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400), ), true, }, @@ -95,7 +95,13 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false), - types.DefaultTrustingPeriodFraction, ccv.DefaultCCVTimeoutPeriod, types.DefaultInitTimeoutPeriod, types.DefaultVscTimeoutPeriod), + types.DefaultTrustingPeriodFraction, + ccv.DefaultCCVTimeoutPeriod, + types.DefaultInitTimeoutPeriod, + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), ), false, }, @@ -114,7 +120,10 @@ func TestValidateGenesisState(t *testing.T) { 0, // 0 trusting period fraction here ccv.DefaultCCVTimeoutPeriod, types.DefaultInitTimeoutPeriod, - types.DefaultVscTimeoutPeriod), + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), ), false, }, @@ -133,7 +142,10 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultTrustingPeriodFraction, 0, // 0 ccv timeout here types.DefaultInitTimeoutPeriod, - types.DefaultVscTimeoutPeriod), + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), ), false, }, @@ -152,7 +164,10 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultTrustingPeriodFraction, ccv.DefaultCCVTimeoutPeriod, 0, // 0 init timeout here - types.DefaultVscTimeoutPeriod), + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), ), false, }, @@ -171,7 +186,76 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultTrustingPeriodFraction, ccv.DefaultCCVTimeoutPeriod, types.DefaultInitTimeoutPeriod, - 0), // 0 vsc timeout here + 0, // 0 vsc timeout here + types.DefaultSlashMeterReplenishPeriod, + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), + ), + false, + }, + { + "invalid params, zero slash meter replenish period", + types.NewGenesisState( + 0, + nil, + []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid"}}, + nil, + nil, + nil, + nil, + types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + types.DefaultTrustingPeriodFraction, + ccv.DefaultCCVTimeoutPeriod, + types.DefaultInitTimeoutPeriod, + types.DefaultVscTimeoutPeriod, + 0, // 0 slash meter replenish period here + types.DefaultSlashMeterReplenishFraction, + types.DefaultMaxPendingSlashPackets), + ), + false, + }, + { + "invalid params, invalid slash meter replenish fraction", + types.NewGenesisState( + 0, + nil, + []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid"}}, + nil, + nil, + nil, + nil, + types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + types.DefaultTrustingPeriodFraction, + ccv.DefaultCCVTimeoutPeriod, + types.DefaultInitTimeoutPeriod, + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + "1.15", + types.DefaultMaxPendingSlashPackets), + ), + false, + }, + { + "invalid params, invalid max pending slash packets", + types.NewGenesisState( + 0, + nil, + []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid"}}, + nil, + nil, + nil, + nil, + types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + types.DefaultTrustingPeriodFraction, + ccv.DefaultCCVTimeoutPeriod, + types.DefaultInitTimeoutPeriod, + types.DefaultVscTimeoutPeriod, + types.DefaultSlashMeterReplenishPeriod, + "1.15", + -1), ), false, }, diff --git a/x/ccv/provider/types/params.go b/x/ccv/provider/types/params.go index be3281ee06..87e9773557 100644 --- a/x/ccv/provider/types/params.go +++ b/x/ccv/provider/types/params.go @@ -26,14 +26,29 @@ const ( // DefaultVscTimeoutPeriod defines the VSC timeout period DefaultVscTimeoutPeriod = 5 * 7 * 24 * time.Hour + + // DefaultSlashMeterReplenishPeriod defines the default period for which the slash gas meter is replenished + DefaultSlashMeterReplenishPeriod = time.Hour + + // DefaultSlashMeterReplenishFraction defines the default fraction of total voting power + // that is replenished to the slash meter every replenish period. This param also serves as a maximum + // fraction of total voting power that the slash meter can hold. + DefaultSlashMeterReplenishFraction = "0.05" + + // DefaultMaxPendingSlashPackets defines the default maximum amount of pending slash packets that can + // be queued for a consumer before the provider chain halts. + DefaultMaxPendingSlashPackets = 1000 ) // Reflection based keys for params subspace var ( - KeyTemplateClient = []byte("TemplateClient") - KeyTrustingPeriodFraction = []byte("TrustingPeriodFraction") - KeyInitTimeoutPeriod = []byte("InitTimeoutPeriod") - KeyVscTimeoutPeriod = []byte("VscTimeoutPeriod") + KeyTemplateClient = []byte("TemplateClient") + KeyTrustingPeriodFraction = []byte("TrustingPeriodFraction") + KeyInitTimeoutPeriod = []byte("InitTimeoutPeriod") + KeyVscTimeoutPeriod = []byte("VscTimeoutPeriod") + KeySlashMeterReplenishPeriod = []byte("SlashMeterReplenishPeriod") + KeySlashMeterReplenishFraction = []byte("SlashMeterReplenishFraction") + KeyMaxPendingSlashPackets = []byte("MaxPendingSlashPackets") ) // ParamKeyTable returns a key table with the necessary registered provider params @@ -48,13 +63,19 @@ func NewParams( ccvTimeoutPeriod time.Duration, initTimeoutPeriod time.Duration, vscTimeoutPeriod time.Duration, + slashMeterReplenishPeriod time.Duration, + slashMeterReplenishFraction string, + maxPendingSlashPackets int64, ) Params { return Params{ - TemplateClient: cs, - TrustingPeriodFraction: trustingPeriodFraction, - CcvTimeoutPeriod: ccvTimeoutPeriod, - InitTimeoutPeriod: initTimeoutPeriod, - VscTimeoutPeriod: vscTimeoutPeriod, + TemplateClient: cs, + TrustingPeriodFraction: trustingPeriodFraction, + CcvTimeoutPeriod: ccvTimeoutPeriod, + InitTimeoutPeriod: initTimeoutPeriod, + VscTimeoutPeriod: vscTimeoutPeriod, + SlashMeterReplenishPeriod: slashMeterReplenishPeriod, + SlashMeterReplenishFraction: slashMeterReplenishFraction, + MaxPendingSlashPackets: maxPendingSlashPackets, } } @@ -79,6 +100,9 @@ func DefaultParams() Params { ccvtypes.DefaultCCVTimeoutPeriod, DefaultInitTimeoutPeriod, DefaultVscTimeoutPeriod, + DefaultSlashMeterReplenishPeriod, + DefaultSlashMeterReplenishFraction, + DefaultMaxPendingSlashPackets, ) } @@ -102,6 +126,15 @@ func (p Params) Validate() error { if err := ccvtypes.ValidateDuration(p.VscTimeoutPeriod); err != nil { return fmt.Errorf("vsc timeout period is invalid: %s", err) } + if err := ccvtypes.ValidateDuration(p.SlashMeterReplenishPeriod); err != nil { + return fmt.Errorf("slash meter replenish period is invalid: %s", err) + } + if err := ccvtypes.ValidateStringFraction(p.SlashMeterReplenishFraction); err != nil { + return fmt.Errorf("slash meter replenish fraction is invalid: %s", err) + } + if err := ccvtypes.ValidatePositiveInt64(p.MaxPendingSlashPackets); err != nil { + return fmt.Errorf("max pending slash packets is invalid: %s", err) + } return nil } @@ -113,6 +146,9 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeyInitTimeoutPeriod, p.InitTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeyVscTimeoutPeriod, p.VscTimeoutPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeySlashMeterReplenishPeriod, p.SlashMeterReplenishPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeySlashMeterReplenishFraction, p.SlashMeterReplenishFraction, ccvtypes.ValidateStringFraction), + paramtypes.NewParamSetPair(KeyMaxPendingSlashPackets, p.MaxPendingSlashPackets, ccvtypes.ValidatePositiveInt64), } } diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index f4a13a7bd3..1db46449b8 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -22,25 +22,34 @@ func TestValidateParams(t *testing.T) { {"default params", types.DefaultParams(), true}, {"custom valid params", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 3, time.Hour, time.Hour, time.Hour), true}, + 3, time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), true}, {"custom invalid params", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false), - 3, time.Hour, time.Hour, time.Hour), false}, + 3, time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false}, {"blank client", types.NewParams(&ibctmtypes.ClientState{}, - 3, time.Hour, time.Hour, time.Hour), false}, - {"nil client", types.NewParams(nil, 3, time.Hour, time.Hour, time.Hour), false}, + 3, time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false}, + {"nil client", types.NewParams(nil, 3, time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false}, {"0 trusting period fraction (denominator)", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 0, time.Hour, time.Hour, time.Hour), false}, + 0, time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false}, {"0 ccv timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 3, 0, time.Hour, time.Hour), false}, + 3, 0, time.Hour, time.Hour, 30*time.Minute, "0.1", 100), false}, {"0 init timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 3, time.Hour, 0, time.Hour), false}, + 3, time.Hour, 0, time.Hour, 30*time.Minute, "0.1", 100), false}, {"0 vsc timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - 3, time.Hour, time.Hour, 0), false}, + 3, time.Hour, time.Hour, 0, 30*time.Minute, "0.1", 100), false}, + {"0 slash meter replenish period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + 3, time.Hour, time.Hour, 24*time.Hour, 0, "0.1", 100), false}, + {"slash meter replenish fraction over 1", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + 3, time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", 100), false}, + {"negative max pending slash packets", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, + time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), + 3, time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100), false}, } for _, tc := range testCases { diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index b928cb9751..8c36024522 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -178,6 +178,14 @@ type Params struct { // the vsc_timeout_period is a provider-side param that enables the provider // to timeout VSC packets even when a consumer chain is not live. VscTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=vsc_timeout_period,json=vscTimeoutPeriod,proto3,stdduration" json:"vsc_timeout_period"` + // The period for which the slash meter is replenished + SlashMeterReplenishPeriod time.Duration `protobuf:"bytes,6,opt,name=slash_meter_replenish_period,json=slashMeterReplenishPeriod,proto3,stdduration" json:"slash_meter_replenish_period"` + // The fraction of total voting power that is replenished to the slash meter every replenish period. + // This param also serves as a maximum fraction of total voting power that the slash meter can hold. + SlashMeterReplenishFraction string `protobuf:"bytes,7,opt,name=slash_meter_replenish_fraction,json=slashMeterReplenishFraction,proto3" json:"slash_meter_replenish_fraction,omitempty"` + // The maximum amount of pending slash packets that can be queued for a consumer + // before the provider chain halts. + MaxPendingSlashPackets int64 `protobuf:"varint,8,opt,name=max_pending_slash_packets,json=maxPendingSlashPackets,proto3" json:"max_pending_slash_packets,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -248,6 +256,27 @@ func (m *Params) GetVscTimeoutPeriod() time.Duration { return 0 } +func (m *Params) GetSlashMeterReplenishPeriod() time.Duration { + if m != nil { + return m.SlashMeterReplenishPeriod + } + return 0 +} + +func (m *Params) GetSlashMeterReplenishFraction() string { + if m != nil { + return m.SlashMeterReplenishFraction + } + return "" +} + +func (m *Params) GetMaxPendingSlashPackets() int64 { + if m != nil { + return m.MaxPendingSlashPackets + } + return 0 +} + type HandshakeMetadata struct { ProviderFeePoolAddr string `protobuf:"bytes,1,opt,name=provider_fee_pool_addr,json=providerFeePoolAddr,proto3" json:"provider_fee_pool_addr,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` @@ -453,57 +482,62 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0x8e, 0x49, 0xda, 0x24, 0x93, 0x65, 0x61, 0x67, 0x57, 0xc5, 0xa9, 0x50, 0x12, 0xc2, 0x25, - 0x08, 0x61, 0x2b, 0xd9, 0x0b, 0xac, 0xe0, 0x90, 0x16, 0x2d, 0xe5, 0x80, 0xc8, 0xba, 0x05, 0x24, - 0x2e, 0xd6, 0x78, 0x66, 0x6a, 0x8f, 0x6a, 0x7b, 0xac, 0x99, 0xb1, 0xa1, 0x77, 0x0e, 0x1c, 0x57, - 0xe2, 0xb2, 0xc7, 0xfd, 0x07, 0xfc, 0x8d, 0x3d, 0xf6, 0xc8, 0x09, 0x50, 0xfb, 0x47, 0xd0, 0xcc, - 0xd8, 0x49, 0x1b, 0xa8, 0xd4, 0x1e, 0xb8, 0x79, 0xde, 0xfb, 0xbe, 0x6f, 0xde, 0x9b, 0xef, 0xcd, - 0x18, 0x2c, 0x58, 0xae, 0xa8, 0xc0, 0x09, 0x62, 0x79, 0x28, 0x29, 0x2e, 0x05, 0x53, 0xe7, 0x3e, - 0xc6, 0x95, 0x5f, 0x08, 0x5e, 0x31, 0x42, 0x85, 0x5f, 0xcd, 0xd7, 0xdf, 0x5e, 0x21, 0xb8, 0xe2, - 0xf0, 0xc3, 0xff, 0xe0, 0x78, 0x18, 0x57, 0xde, 0x1a, 0x57, 0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xa0, 0x5b, - 0x50, 0x73, 0x23, 0x0c, 0x71, 0xb0, 0xf8, 0xc2, 0xbb, 0xc3, 0xd3, 0xea, 0xdd, 0x26, 0x18, 0x34, - 0x6a, 0x53, 0xb1, 0x79, 0xd2, 0xb6, 0xee, 0x92, 0x84, 0xdf, 0x6f, 0x6f, 0xfa, 0xf9, 0xbd, 0x36, - 0xdd, 0xd2, 0x5b, 0xef, 0x79, 0x70, 0xf2, 0xe6, 0x72, 0xe4, 0x5c, 0x5c, 0x8e, 0x9c, 0xbf, 0x2f, - 0x47, 0xce, 0xcb, 0xab, 0x51, 0xeb, 0xe2, 0x6a, 0xd4, 0xfa, 0xe3, 0x6a, 0xd4, 0xfa, 0xf1, 0x59, - 0xcc, 0x54, 0x52, 0x46, 0x1e, 0xe6, 0x99, 0x8f, 0xb9, 0xcc, 0xb8, 0xf4, 0x37, 0x3b, 0x7e, 0xb2, - 0xfe, 0xeb, 0xfc, 0x7c, 0xf3, 0xbf, 0xa3, 0xce, 0x0b, 0x2a, 0xa3, 0x5d, 0xe3, 0xfe, 0xd3, 0x7f, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x97, 0x79, 0x3f, 0x95, 0xa8, 0x06, 0x00, 0x00, + // 872 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x73, 0xdb, 0x44, + 0x14, 0xb6, 0xb0, 0x13, 0xdb, 0xeb, 0x52, 0xe8, 0xb6, 0x13, 0xe4, 0xd0, 0xb1, 0x8d, 0xb9, 0x98, + 0x61, 0x90, 0x26, 0xee, 0x85, 0x76, 0xe0, 0x90, 0x84, 0x29, 0xe1, 0xd0, 0xc1, 0x55, 0x02, 0xcc, + 0x70, 0xd1, 0xac, 0x57, 0x2f, 0xd6, 0x4e, 0x24, 0xad, 0x66, 0x77, 0x25, 0x92, 0x3b, 0x07, 0x8e, + 0x3d, 0xf6, 0xd8,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f, 0x59, 0x73, + 0xef, 0xe8, 0xed, 0xf9, 0xc0, 0x79, 0x77, 0x3e, 0x70, 0xfe, 0x3e, 0x1f, 0x38, 0xaf, 0x2e, 0x06, + 0x8d, 0x77, 0x17, 0x83, 0xc6, 0x1f, 0x17, 0x83, 0xc6, 0xcf, 0xcf, 0x16, 0x4c, 0xc5, 0xc5, 0xdc, + 0xa3, 0x3c, 0xf5, 0x29, 0x97, 0x29, 0x97, 0xfe, 0xaa, 0xe2, 0x17, 0xcb, 0xb7, 0xf5, 0xf4, 0xea, + 0xeb, 0xaa, 0xce, 0x72, 0x90, 0xf3, 0x4d, 0xb3, 0x0d, 0x9f, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, + 0xf3, 0xd5, 0x5b, 0x4e, 0x8e, 0x07, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -664,29 +698,49 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.VscTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.VscTimeoutPeriod):]) + if m.MaxPendingSlashPackets != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.MaxPendingSlashPackets)) + i-- + dAtA[i] = 0x40 + } + if len(m.SlashMeterReplenishFraction) > 0 { + i -= len(m.SlashMeterReplenishFraction) + copy(dAtA[i:], m.SlashMeterReplenishFraction) + i = encodeVarintProvider(dAtA, i, uint64(len(m.SlashMeterReplenishFraction))) + i-- + dAtA[i] = 0x3a + } + n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.SlashMeterReplenishPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.SlashMeterReplenishPeriod):]) if err4 != nil { return 0, err4 } i -= n4 i = encodeVarintProvider(dAtA, i, uint64(n4)) i-- - dAtA[i] = 0x2a - n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.InitTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.InitTimeoutPeriod):]) + dAtA[i] = 0x32 + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.VscTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.VscTimeoutPeriod):]) if err5 != nil { return 0, err5 } i -= n5 i = encodeVarintProvider(dAtA, i, uint64(n5)) i-- - dAtA[i] = 0x22 - n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + dAtA[i] = 0x2a + n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.InitTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.InitTimeoutPeriod):]) if err6 != nil { return 0, err6 } i -= n6 i = encodeVarintProvider(dAtA, i, uint64(n6)) i-- + dAtA[i] = 0x22 + n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err7 != nil { + return 0, err7 + } + i -= n7 + i = encodeVarintProvider(dAtA, i, uint64(n7)) + i-- dAtA[i] = 0x1a if m.TrustingPeriodFraction != 0 { i = encodeVarintProvider(dAtA, i, uint64(m.TrustingPeriodFraction)) @@ -940,6 +994,15 @@ func (m *Params) Size() (n int) { n += 1 + l + sovProvider(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.VscTimeoutPeriod) n += 1 + l + sovProvider(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.SlashMeterReplenishPeriod) + n += 1 + l + sovProvider(uint64(l)) + l = len(m.SlashMeterReplenishFraction) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + if m.MaxPendingSlashPackets != 0 { + n += 1 + sovProvider(uint64(m.MaxPendingSlashPackets)) + } return n } @@ -1673,6 +1736,90 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.SlashMeterReplenishPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishFraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SlashMeterReplenishFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxPendingSlashPackets", wireType) + } + m.MaxPendingSlashPackets = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxPendingSlashPackets |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipProvider(dAtA[iNdEx:]) diff --git a/x/ccv/types/shared_params.go b/x/ccv/types/shared_params.go index 15e2dd1acb..5d100eab7c 100644 --- a/x/ccv/types/shared_params.go +++ b/x/ccv/types/shared_params.go @@ -75,3 +75,21 @@ func ValidateBech32(i interface{}) error { _, err := sdktypes.AccAddressFromBech32(value) return err } + +func ValidateStringFraction(i interface{}) error { + str, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + dec, err := sdktypes.NewDecFromStr(str) + if err != nil { + return err + } + if dec.IsNegative() { + return fmt.Errorf("consumer redistribution fraction is negative") + } + if dec.Sub(sdktypes.NewDec(1)).IsPositive() { + return fmt.Errorf("consumer redistribution fraction cannot be above 1.0") + } + return nil +}