From 725e89c2bfd008c292b5a9440370af9e1dbe4bdd Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:52:56 -0700 Subject: [PATCH 01/18] changes --- .../ccv/consumer/v1/consumer.proto | 14 +- .../ccv/provider/v1/provider.proto | 2 + tests/difference/core/driver/setup.go | 3 + tests/e2e/common_test.go | 5 +- tests/e2e/democracy_test.go | 3 +- tests/e2e/distribution_test.go | 3 +- tests/e2e/normal_operations_test.go | 8 +- tests/e2e/setup_test.go | 5 +- x/ccv/consumer/keeper/distribution.go | 14 +- x/ccv/consumer/keeper/genesis_test.go | 21 +- x/ccv/consumer/keeper/params.go | 26 +- x/ccv/consumer/keeper/params_test.go | 15 +- x/ccv/consumer/keeper/validators.go | 2 +- x/ccv/consumer/types/consumer.pb.go | 237 ++++++++++++++---- x/ccv/consumer/types/genesis.go | 3 + x/ccv/consumer/types/keys.go | 3 - x/ccv/consumer/types/params.go | 109 +++++--- x/ccv/provider/keeper/params.go | 9 + x/ccv/provider/keeper/params_test.go | 2 +- x/ccv/provider/keeper/proposal.go | 4 +- x/ccv/provider/keeper/proposal_test.go | 13 +- x/ccv/provider/types/genesis_test.go | 23 +- x/ccv/provider/types/params.go | 33 ++- x/ccv/provider/types/params_test.go | 10 +- x/ccv/provider/types/provider.pb.go | 126 ++++++---- x/ccv/types/shared_params.go | 33 ++- x/ccv/utils/utils.go | 4 - 27 files changed, 549 insertions(+), 181 deletions(-) diff --git a/proto/interchain_security/ccv/consumer/v1/consumer.proto b/proto/interchain_security/ccv/consumer/v1/consumer.proto index dc459cc89c..cdf26277ce 100644 --- a/proto/interchain_security/ccv/consumer/v1/consumer.proto +++ b/proto/interchain_security/ccv/consumer/v1/consumer.proto @@ -30,9 +30,21 @@ message Params { // provider handshake procedure. string distribution_transmission_channel = 3; string provider_fee_pool_addr_str = 4; - // Sent IBC packets will timeout after this duration + // Sent CCV related IBC packets will timeout after this duration google.protobuf.Duration ccv_timeout_period = 5 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + + // Sent transfer related IBC packets will timeout after this duration + google.protobuf.Duration transfer_timeout_period = 6 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + string consumer_redistribution_fraction = 7; + + // The number of historical info entries to persist in store + int64 num_historical_entries = 8; } // LastTransmissionBlockHeight is the last time validator holding diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 25572f47e2..eae0f9701d 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -62,6 +62,8 @@ message Params { // Sent IBC packets will timeout after this duration google.protobuf.Duration ccv_timeout_period = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + // TrustingPeriodFraction is used to compute the provider IBC client's TrustingPeriod + int64 trusting_period_fraction = 3; } message HandshakeMetadata { diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index deb185d599..2bb5d86a62 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -477,6 +477,9 @@ func (b *Builder) createConsumerGenesis(tmConfig *ibctesting.TendermintConfig) * "", // ignore distribution "", // ignore distribution ccv.DefaultCCVTimeoutPeriod, + consumertypes.DefaultTransferTimeoutPeriod, + consumertypes.DefaultConsumerRedistributeFrac, + consumertypes.DefaultNumHistoricalEntries, ) return consumertypes.NewInitialGenesisState(providerClient, providerConsState, valUpdates, consumertypes.SlashRequests{}, params) } diff --git a/tests/e2e/common_test.go b/tests/e2e/common_test.go index c329f877d2..0a3784d5e1 100644 --- a/tests/e2e/common_test.go +++ b/tests/e2e/common_test.go @@ -8,6 +8,7 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/cosmos/interchain-security/x/ccv/utils" "github.com/stretchr/testify/require" @@ -334,7 +335,7 @@ func incrementTimeBy(s *CCVTestSuite, jumpPeriod time.Duration) { consumerUnbondingPeriod, found := s.consumerChain.App.(*appConsumer.App).ConsumerKeeper.GetUnbondingTime(s.consumerChain.GetContext()) s.Require().True(found) split := 1 - if jumpPeriod > consumerUnbondingPeriod/utils.TrustingPeriodFraction { + if jumpPeriod > consumerUnbondingPeriod/providertypes.DefaultTrustingPeriodFraction { // Make sure the clients do not expire split = 4 jumpPeriod = jumpPeriod / 4 @@ -365,7 +366,7 @@ func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unb tmConfig, ok := endpoint.ClientConfig.(*ibctesting.TendermintConfig) require.True(endpoint.Chain.T, ok) tmConfig.UnbondingPeriod = unbondingPeriod - tmConfig.TrustingPeriod = unbondingPeriod / utils.TrustingPeriodFraction + tmConfig.TrustingPeriod = unbondingPeriod / providertypes.DefaultTrustingPeriodFraction height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height) UpgradePath := []string{"upgrade", "upgradedIBCState"} diff --git a/tests/e2e/democracy_test.go b/tests/e2e/democracy_test.go index 1b5d6d8f66..f3de830cf1 100644 --- a/tests/e2e/democracy_test.go +++ b/tests/e2e/democracy_test.go @@ -19,13 +19,12 @@ import ( proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" appConsumer "github.com/cosmos/interchain-security/app/consumer-democracy" "github.com/cosmos/interchain-security/testutil/simapp" - consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" "github.com/stretchr/testify/suite" ) -var consumerFraction, _ = sdk.NewDecFromStr(consumerkeeper.ConsumerRedistributeFrac) +var consumerFraction, _ = sdk.NewDecFromStr(consumertypes.DefaultConsumerRedistributeFrac) type ConsumerDemocracyTestSuite struct { suite.Suite diff --git a/tests/e2e/distribution_test.go b/tests/e2e/distribution_test.go index 5eb7b12b77..36313df2fe 100644 --- a/tests/e2e/distribution_test.go +++ b/tests/e2e/distribution_test.go @@ -8,7 +8,6 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" app "github.com/cosmos/interchain-security/app/consumer" providerApp "github.com/cosmos/interchain-security/app/provider" - consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" ) @@ -45,7 +44,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { s.Require().Equal(sdk.NewInt(100).Add(feePoolTokensOld.AmountOf(sdk.DefaultBondDenom)), feePoolTokens.AmountOf(sdk.DefaultBondDenom)) //calculate the reward for consumer and provider chain. Consumer will receive ConsumerRedistributeFrac, the rest is going to provider - frac, err := sdk.NewDecFromStr(consumerkeeper.ConsumerRedistributeFrac) + frac, err := sdk.NewDecFromStr(consumertypes.DefaultConsumerRedistributeFrac) s.Require().NoError(err) consumerExpectedRewards, _ := sdk.NewDecCoinsFromCoins(feePoolTokens...).MulDec(frac).TruncateDecimal() providerExpectedRewards := feePoolTokens.Sub(consumerExpectedRewards) diff --git a/tests/e2e/normal_operations_test.go b/tests/e2e/normal_operations_test.go index 1c90efaf50..9e7501a7b4 100644 --- a/tests/e2e/normal_operations_test.go +++ b/tests/e2e/normal_operations_test.go @@ -3,7 +3,7 @@ package e2e_test import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" appConsumer "github.com/cosmos/interchain-security/app/consumer" - "github.com/cosmos/interchain-security/x/ccv/consumer/types" + consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -22,7 +22,7 @@ func (k CCVTestSuite) TestTrackHistoricalInfo() { createVal := func(k CCVTestSuite) { // add new validator to consumer states pk := ed25519.GenPrivKey().PubKey() - cVal, err := types.NewCCValidator(pk.Address(), int64(1), pk) + cVal, err := consumertypes.NewCCValidator(pk.Address(), int64(1), pk) k.Require().NoError(err) consumerKeeper.SetCCValidator(k.consumerChain.GetContext(), cVal) @@ -39,7 +39,7 @@ func (k CCVTestSuite) TestTrackHistoricalInfo() { createVal, createVal, func(k CCVTestSuite) { - newHeight := k.consumerChain.GetContext().BlockHeight() + int64(types.HistoricalEntries) + newHeight := k.consumerChain.GetContext().BlockHeight() + int64(consumertypes.DefaultNumHistoricalEntries) header := tmproto.Header{ ChainID: "HelloChain", Height: newHeight, @@ -71,7 +71,7 @@ func (k CCVTestSuite) TestTrackHistoricalInfo() { expLen: 0, }, { - height: initHeight + int64(types.HistoricalEntries) + 2, + height: initHeight + int64(consumertypes.DefaultNumHistoricalEntries) + 2, found: true, expLen: initValsetLen + 2, }, diff --git a/tests/e2e/setup_test.go b/tests/e2e/setup_test.go index 3fd0522729..44c0c33a11 100644 --- a/tests/e2e/setup_test.go +++ b/tests/e2e/setup_test.go @@ -6,6 +6,7 @@ import ( "bytes" "testing" + providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/cosmos/interchain-security/x/ccv/utils" @@ -95,10 +96,10 @@ func (suite *CCVTestSuite) SetupTest() { // - client config providerUnbondingPeriod := suite.providerChain.App.(*appProvider.App).GetStakingKeeper().UnbondingTime(suite.providerCtx()) suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = providerUnbondingPeriod - suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = providerUnbondingPeriod / utils.TrustingPeriodFraction + suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = providerUnbondingPeriod / providertypes.DefaultTrustingPeriodFraction consumerUnbondingPeriod := utils.ComputeConsumerUnbondingPeriod(providerUnbondingPeriod) suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriod - suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = consumerUnbondingPeriod / utils.TrustingPeriodFraction + suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = consumerUnbondingPeriod / providertypes.DefaultTrustingPeriodFraction // - channel config suite.path.EndpointA.ChannelConfig.PortID = ccv.ConsumerPortID suite.path.EndpointB.ChannelConfig.PortID = ccv.ProviderPortID diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index 1e17ed178d..a118402c77 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -1,8 +1,6 @@ package keeper import ( - "time" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -14,13 +12,6 @@ import ( ccv "github.com/cosmos/interchain-security/x/ccv/types" ) -const TransferTimeDelay = 1 * 7 * 24 * time.Hour // 1 weeks - -// The fraction of tokens allocated to the consumer redistribution address -// during distribution events. The fraction is a string representing a -// decimal number. For example "0.75" would represent 75%. -const ConsumerRedistributeFrac = "0.75" - // Simple model, send tokens to the fee pool of the provider validator set // reference: cosmos/ibc-go/v3/modules/apps/transfer/keeper/msg_server.go func (k Keeper) DistributeToProviderValidatorSet(ctx sdk.Context) error { @@ -34,7 +25,7 @@ func (k Keeper) DistributeToProviderValidatorSet(ctx sdk.Context) error { fpTokens := k.bankKeeper.GetAllBalances(ctx, consumerFeePoolAddr) // split the fee pool, send the consumer's fraction to the consumer redistribution address - frac, err := sdk.NewDecFromStr(ConsumerRedistributeFrac) + frac, err := sdk.NewDecFromStr(k.GetConsumerRedistributionFrac(ctx)) if err != nil { return err } @@ -76,7 +67,8 @@ func (k Keeper) DistributeToProviderValidatorSet(ctx sdk.Context) error { tstProviderTokens := k.bankKeeper.GetAllBalances(ctx, tstProviderAddr) providerAddr := k.GetProviderFeePoolAddrStr(ctx) timeoutHeight := clienttypes.ZeroHeight() - timeoutTimestamp := uint64(ctx.BlockTime().Add(TransferTimeDelay).UnixNano()) + transferTimeoutPeriod := k.GetTransferTimeoutPeriod(ctx) + timeoutTimestamp := uint64(ctx.BlockTime().Add(transferTimeoutPeriod).UnixNano()) for _, token := range tstProviderTokens { err := k.ibcTransferKeeper.SendTransfer(ctx, transfertypes.PortID, diff --git a/x/ccv/consumer/keeper/genesis_test.go b/x/ccv/consumer/keeper/genesis_test.go index 94b7b81e01..1286f51911 100644 --- a/x/ccv/consumer/keeper/genesis_test.go +++ b/x/ccv/consumer/keeper/genesis_test.go @@ -50,7 +50,15 @@ func TestInitGenesis(t *testing.T) { } // create parameters for a new chain - params := types.NewParams(true, types.DefaultBlocksPerDistributionTransmission, "", "", ccv.DefaultCCVTimeoutPeriod) + params := types.NewParams(true, + types.DefaultBlocksPerDistributionTransmission, + "", + "", + ccv.DefaultCCVTimeoutPeriod, + consumertypes.DefaultTransferTimeoutPeriod, + consumertypes.DefaultConsumerRedistributeFrac, + consumertypes.DefaultNumHistoricalEntries, + ) testCases := []struct { name string @@ -152,7 +160,16 @@ func TestExportGenesis(t *testing.T) { MaturityTime: uint64(time.Now().UnixNano()), } - params := types.NewParams(true, types.DefaultBlocksPerDistributionTransmission, "", "", ccv.DefaultCCVTimeoutPeriod) + params := types.NewParams( + true, + types.DefaultBlocksPerDistributionTransmission, + "", + "", + ccv.DefaultCCVTimeoutPeriod, + consumertypes.DefaultTransferTimeoutPeriod, + consumertypes.DefaultConsumerRedistributeFrac, + consumertypes.DefaultNumHistoricalEntries, + ) // create a single validator pubKey := ed25519.GenPrivKey().PubKey() diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index c30bac4a35..ae9ec86f0f 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -9,7 +9,7 @@ import ( ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" ) -// GetParams returns the paramset for the consumer module +// GetParams returns the params for the consumer ccv module func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.GetEnabled(ctx), @@ -17,6 +17,9 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.GetDistributionTransmissionChannel(ctx), k.GetProviderFeePoolAddrStr(ctx), k.GetCCVTimeoutPeriod(ctx), + k.GetTransferTimeoutPeriod(ctx), + k.GetConsumerRedistributionFrac(ctx), + k.GetNumHistoricalEntries(ctx), ) } @@ -62,9 +65,28 @@ func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string) { k.paramStore.Set(ctx, types.KeyProviderFeePoolAddrStr, addr) } -// GetCCVTimeoutPeriod returns the timeout period for sent ibc packets +// GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { var p time.Duration k.paramStore.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) return p } + +// GetTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets +func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { + var p time.Duration + k.paramStore.Get(ctx, types.KeyTransferTimeoutPeriod, &p) + return p +} + +func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { + var str string + k.paramStore.Get(ctx, types.KeyConsumerRedistributionFrac, &str) + return str +} + +func (k Keeper) GetNumHistoricalEntries(ctx sdk.Context) int64 { + var n int64 + k.paramStore.Get(ctx, types.KeyNumHistoricalEntries, &n) + return n +} diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 7a9b0dcd94..722e592495 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -6,6 +6,7 @@ import ( testkeeper "github.com/cosmos/interchain-security/testutil/keeper" "github.com/cosmos/interchain-security/x/ccv/consumer/types" + consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/stretchr/testify/require" ) @@ -16,12 +17,22 @@ func TestParams(t *testing.T) { defer ctrl.Finish() consumerKeeper.SetParams(ctx, types.DefaultParams()) - expParams := types.NewParams(false, 1000, "", "", ccv.DefaultCCVTimeoutPeriod) // these are the default params, IBC suite independently sets enabled=true + expParams := types.NewParams( + false, + 1000, + "", + "", + ccv.DefaultCCVTimeoutPeriod, + consumertypes.DefaultTransferTimeoutPeriod, + consumertypes.DefaultConsumerRedistributeFrac, + consumertypes.DefaultNumHistoricalEntries, + ) // these are the default params, IBC suite independently sets enabled=true params := consumerKeeper.GetParams(ctx) require.Equal(t, expParams, params) - newParams := types.NewParams(false, 1000, "abc", "def", 7*24*time.Hour) + newParams := types.NewParams( + false, 1000, "abc", "def", 7*24*time.Hour, 25*time.Hour, "0.5", 500) consumerKeeper.SetParams(ctx, newParams) params = consumerKeeper.GetParams(ctx) require.Equal(t, newParams, params) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index eeb94d5c93..71c67b16a6 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -154,7 +154,7 @@ func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { // heights that are below pruning height func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { - entryNum := types.HistoricalEntries + entryNum := types.DefaultNumHistoricalEntries // Prune store to ensure we only have parameter-defined historical entries. // In most cases, this will involve removing a single historical entry. diff --git a/x/ccv/consumer/types/consumer.pb.go b/x/ccv/consumer/types/consumer.pb.go index f08bf379cc..0a4ed8a365 100644 --- a/x/ccv/consumer/types/consumer.pb.go +++ b/x/ccv/consumer/types/consumer.pb.go @@ -48,8 +48,16 @@ type Params struct { // provider handshake procedure. DistributionTransmissionChannel string `protobuf:"bytes,3,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"` ProviderFeePoolAddrStr string `protobuf:"bytes,4,opt,name=provider_fee_pool_addr_str,json=providerFeePoolAddrStr,proto3" json:"provider_fee_pool_addr_str,omitempty"` - // Sent IBC packets will timeout after this duration + // Sent CCV related IBC packets will timeout after this duration CcvTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` + // Sent transfer related IBC packets will timeout after this duration + TransferTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"` + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` + // The number of historical info entries to persist in store + NumHistoricalEntries int64 `protobuf:"varint,8,opt,name=num_historical_entries,json=numHistoricalEntries,proto3" json:"num_historical_entries,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -120,6 +128,27 @@ func (m *Params) GetCcvTimeoutPeriod() time.Duration { return 0 } +func (m *Params) GetTransferTimeoutPeriod() time.Duration { + if m != nil { + return m.TransferTimeoutPeriod + } + return 0 +} + +func (m *Params) GetConsumerRedistributionFraction() string { + if m != nil { + return m.ConsumerRedistributionFraction + } + return "" +} + +func (m *Params) GetNumHistoricalEntries() int64 { + if m != nil { + return m.NumHistoricalEntries + } + return 0 +} + // LastTransmissionBlockHeight is the last time validator holding // pools were transmitted to the provider chain type LastTransmissionBlockHeight struct { @@ -339,49 +368,54 @@ func init() { } var fileDescriptor_5b27a82b276e7f93 = []byte{ - // 671 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0x9b,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, 0x8a, 0xba, 0xf9, 0x65, 0x05, 0x34, - 0xc6, 0x48, 0xa0, 0x50, 0xea, 0x6d, 0x70, 0x8d, 0x30, 0xe4, 0x06, 0xc4, 0x6b, 0x6b, 0x5d, 0xad, - 0xb7, 0x6e, 0x57, 0xa9, 0xfe, 0x1c, 0xec, 0xba, 0x01, 0xc7, 0x33, 0xe9, 0x44, 0x44, 0x38, 0x1e, - 0x95, 0x4a, 0x50, 0x37, 0xce, 0x54, 0x1c, 0x25, 0x10, 0x93, 0x21, 0x95, 0x92, 0x72, 0xd6, 0x5e, - 0xe9, 0x6a, 0xbd, 0xba, 0xbd, 0x53, 0x60, 0xc7, 0x44, 0x1c, 0x2d, 0x20, 0x27, 0x0b, 0x40, 0xfd, - 0x09, 0xd8, 0x59, 0xaa, 0xe2, 0xe0, 0x29, 0x62, 0x8c, 0x04, 0xed, 0x7a, 0x57, 0xeb, 0x5d, 0xb7, - 0x3b, 0xde, 0x12, 0x91, 0x51, 0x01, 0xd3, 0x0f, 0xc0, 0x76, 0x24, 0x78, 0x42, 0x3d, 0x22, 0x9c, - 0x53, 0x42, 0x9c, 0x88, 0xf3, 0xc0, 0x41, 0x9e, 0x27, 0x1c, 0xa9, 0x44, 0x7b, 0x35, 0x17, 0xd9, - 0xac, 0x10, 0xc7, 0x84, 0x8c, 0x39, 0x0f, 0x0e, 0x3d, 0x4f, 0x9c, 0x28, 0xa1, 0xbf, 0x00, 0x3a, - 0xc6, 0x89, 0xa3, 0x68, 0x48, 0x78, 0xac, 0xb2, 0xee, 0x28, 0xf7, 0xda, 0x6b, 0x5d, 0xad, 0xd7, - 0x1c, 0x6c, 0xc1, 0xc2, 0x3a, 0x58, 0x59, 0x07, 0x8f, 0x4a, 0xeb, 0x86, 0xeb, 0x67, 0x17, 0x9d, - 0xda, 0xfb, 0x6f, 0x1d, 0xcd, 0xbe, 0x85, 0x71, 0x32, 0x29, 0xd8, 0xe3, 0x9c, 0x6c, 0x3e, 0x04, - 0x77, 0x9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62, 0x2f, 0x30, 0x4d, 0x0f, 0xdc, 0x58, 0xbc, - 0x9c, 0xd4, 0x4f, 0xc0, 0xba, 0x28, 0xe3, 0xb6, 0xd6, 0xad, 0xf7, 0x9a, 0x83, 0x3e, 0xfc, 0x8f, - 0x8d, 0x86, 0x8b, 0x2a, 0xc3, 0xd5, 0xec, 0xc5, 0xed, 0xb9, 0xd0, 0x70, 0x72, 0x76, 0x69, 0x68, - 0xe7, 0x97, 0x86, 0xf6, 0xfd, 0xd2, 0xd0, 0xde, 0x5d, 0x19, 0xb5, 0xf3, 0x2b, 0xa3, 0xf6, 0xf5, - 0xca, 0xa8, 0xbd, 0x3a, 0xf0, 0xa9, 0x9a, 0xc6, 0x2e, 0xc4, 0x3c, 0x2c, 0x37, 0xd1, 0xfa, 0x75, - 0xda, 0xde, 0xfc, 0x6b, 0x78, 0xfb, 0xfb, 0xaf, 0xa3, 0xd2, 0x88, 0x48, 0xb7, 0x91, 0x3f, 0xd2, - 0xfe, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x68, 0x54, 0x2f, 0x73, 0xa6, 0x04, 0x00, 0x00, + // 747 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, + 0x14, 0x8e, 0x6f, 0xda, 0x34, 0x77, 0xd2, 0x7b, 0x75, 0xe5, 0x1b, 0x5a, 0xb7, 0x48, 0x4e, 0x1a, + 0x2a, 0x14, 0x09, 0xd5, 0x56, 0x52, 0xd8, 0x74, 0xd7, 0xa4, 0x54, 0xe5, 0x47, 0x22, 0xb8, 0x11, + 0x0b, 0x58, 0x58, 0xe3, 0xf1, 0x24, 0x19, 0xc5, 0x9e, 0x31, 0x33, 0x63, 0x83, 0xdf, 0x82, 0x25, + 0x12, 0x2f, 0x80, 0xc4, 0x96, 0x87, 0xa8, 0x58, 0x75, 0xc9, 0xaa, 0xa0, 0xf6, 0x0d, 0x78, 0x02, + 0xe4, 0xbf, 0x90, 0x14, 0x22, 0x75, 0x77, 0x8e, 0xce, 0xf7, 0x7d, 0x33, 0xe7, 0x17, 0x74, 0x09, + 0x95, 0x98, 0xa3, 0x09, 0x24, 0xd4, 0x16, 0x18, 0x85, 0x9c, 0xc8, 0xd8, 0x44, 0x28, 0x32, 0x11, + 0xa3, 0x22, 0xf4, 0x31, 0x37, 0xa3, 0xce, 0xcc, 0x36, 0x02, 0xce, 0x24, 0x53, 0xef, 0xfc, 0x81, + 0x63, 0x20, 0x14, 0x19, 0x33, 0x5c, 0xd4, 0xd9, 0xde, 0x5d, 0x26, 0x9c, 0xe8, 0xa1, 0x28, 0x93, + 0xda, 0xde, 0x1a, 0x33, 0x36, 0xf6, 0xb0, 0x99, 0x7a, 0x4e, 0x38, 0x32, 0x21, 0x8d, 0xf3, 0xd0, + 0x2e, 0x62, 0xc2, 0x67, 0xc2, 0x14, 0x12, 0x4e, 0x09, 0x1d, 0x9b, 0x51, 0xc7, 0xc1, 0x12, 0x76, + 0x0a, 0x3f, 0x47, 0xd5, 0xc7, 0x6c, 0xcc, 0x52, 0xd3, 0x4c, 0xac, 0x42, 0x36, 0xe3, 0xda, 0x59, + 0x20, 0x73, 0xf2, 0x90, 0x7e, 0xfd, 0x45, 0x37, 0xe4, 0x50, 0x12, 0x46, 0xb3, 0x78, 0xeb, 0xd3, + 0x0a, 0xa8, 0x0c, 0x20, 0x87, 0xbe, 0x50, 0x35, 0xb0, 0x86, 0x29, 0x74, 0x3c, 0xec, 0x6a, 0x4a, + 0x53, 0x69, 0x57, 0xad, 0xc2, 0x55, 0x9f, 0x81, 0x5d, 0xc7, 0x63, 0x68, 0x2a, 0xec, 0x00, 0x73, + 0xdb, 0x25, 0x42, 0x72, 0xe2, 0x84, 0x89, 0x8a, 0x2d, 0x39, 0xa4, 0xc2, 0x27, 0x42, 0x10, 0x46, + 0xb5, 0xbf, 0x9a, 0x4a, 0xbb, 0x6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, 0xd0, 0xaa, 0x69, 0x13, + 0xeb, 0x34, 0xf4, 0x4f, 0x66, 0xc1, 0x87, 0x59, 0xac, 0xf5, 0x00, 0xdc, 0x7e, 0x0a, 0x85, 0x9c, + 0x6f, 0x43, 0x2f, 0x69, 0xf6, 0x09, 0x26, 0xe3, 0x89, 0x54, 0x37, 0x40, 0x65, 0x92, 0x5a, 0xe9, + 0x00, 0x95, 0xad, 0xdc, 0x6b, 0x7d, 0x54, 0xc0, 0xff, 0x7d, 0xce, 0x84, 0xe8, 0x27, 0xfb, 0xf1, + 0x02, 0x7a, 0xc4, 0x85, 0x92, 0xf1, 0x64, 0xe2, 0x92, 0x46, 0x61, 0x21, 0x52, 0xc2, 0xba, 0x55, + 0xb8, 0x6a, 0x1d, 0xac, 0x06, 0xec, 0x0d, 0xe6, 0xf9, 0x48, 0x65, 0x8e, 0x0a, 0x41, 0x25, 0x08, + 0x9d, 0x29, 0x8e, 0xd3, 0xd9, 0xa8, 0x75, 0xeb, 0xbf, 0x95, 0xf2, 0x90, 0xc6, 0xbd, 0xfd, 0x1f, + 0x17, 0x8d, 0xcd, 0x18, 0xfa, 0xde, 0x41, 0x2b, 0x29, 0x02, 0xa6, 0x22, 0x14, 0x76, 0xc6, 0x6b, + 0x7d, 0xf9, 0xbc, 0x57, 0xcf, 0xf7, 0x03, 0xf1, 0x38, 0x90, 0xcc, 0x18, 0x84, 0xce, 0x13, 0x1c, + 0x5b, 0xb9, 0x70, 0xeb, 0x83, 0x02, 0xd6, 0x4f, 0x3d, 0x28, 0x26, 0x16, 0x7e, 0x1d, 0x62, 0x21, + 0xd5, 0x3e, 0xa8, 0x04, 0x10, 0x4d, 0x71, 0x96, 0x53, 0xad, 0x7b, 0xcf, 0x58, 0x76, 0x0e, 0xa2, + 0x8e, 0x91, 0x32, 0x07, 0x29, 0xfc, 0x08, 0x4a, 0x68, 0xe5, 0x54, 0xf5, 0x18, 0x00, 0x42, 0x67, + 0x1d, 0x4a, 0x72, 0xfa, 0xb7, 0x7b, 0xd7, 0xc8, 0x3f, 0x52, 0x6c, 0x78, 0xbe, 0xf1, 0xc6, 0xa3, + 0x19, 0x72, 0x18, 0x07, 0xd8, 0x9a, 0x63, 0xb6, 0x5c, 0xf0, 0xcf, 0xfc, 0xe7, 0x84, 0x7a, 0x0a, + 0xaa, 0x3c, 0xb7, 0x35, 0xa5, 0x59, 0x6e, 0xd7, 0xba, 0x1d, 0xe3, 0x06, 0xe7, 0xca, 0x98, 0x57, + 0xe9, 0xad, 0x24, 0x63, 0x67, 0xcd, 0x84, 0x7a, 0xc3, 0xb3, 0x4b, 0x5d, 0x39, 0xbf, 0xd4, 0x95, + 0xef, 0x97, 0xba, 0xf2, 0xee, 0x4a, 0x2f, 0x9d, 0x5f, 0xe9, 0xa5, 0xaf, 0x57, 0x7a, 0xe9, 0xe5, + 0xc1, 0x98, 0xc8, 0x49, 0xe8, 0x18, 0x88, 0xf9, 0xf9, 0x99, 0x31, 0x7f, 0xbd, 0xb6, 0x37, 0xbb, + 0x7b, 0x6f, 0x17, 0x4f, 0xaa, 0x8c, 0x03, 0x2c, 0x9c, 0x4a, 0xda, 0xa4, 0xfd, 0x9f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x28, 0xec, 0xa0, 0xf9, 0x83, 0x05, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -404,13 +438,33 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if m.NumHistoricalEntries != 0 { + i = encodeVarintConsumer(dAtA, i, uint64(m.NumHistoricalEntries)) + i-- + dAtA[i] = 0x40 + } + if len(m.ConsumerRedistributionFraction) > 0 { + i -= len(m.ConsumerRedistributionFraction) + copy(dAtA[i:], m.ConsumerRedistributionFraction) + i = encodeVarintConsumer(dAtA, i, uint64(len(m.ConsumerRedistributionFraction))) + i-- + dAtA[i] = 0x3a + } + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) if err1 != nil { return 0, err1 } i -= n1 i = encodeVarintConsumer(dAtA, i, uint64(n1)) i-- + dAtA[i] = 0x32 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintConsumer(dAtA, i, uint64(n2)) + i-- dAtA[i] = 0x2a if len(m.ProviderFeePoolAddrStr) > 0 { i -= len(m.ProviderFeePoolAddrStr) @@ -629,6 +683,15 @@ func (m *Params) Size() (n int) { } l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod) n += 1 + l + sovConsumer(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.TransferTimeoutPeriod) + n += 1 + l + sovConsumer(uint64(l)) + l = len(m.ConsumerRedistributionFraction) + if l > 0 { + n += 1 + l + sovConsumer(uint64(l)) + } + if m.NumHistoricalEntries != 0 { + n += 1 + sovConsumer(uint64(m.NumHistoricalEntries)) + } return n } @@ -866,6 +929,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 TransferTimeoutPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.TransferTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRedistributionFraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsumer + } + 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 ErrInvalidLengthConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumHistoricalEntries", wireType) + } + m.NumHistoricalEntries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumHistoricalEntries |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipConsumer(dAtA[iNdEx:]) diff --git a/x/ccv/consumer/types/genesis.go b/x/ccv/consumer/types/genesis.go index 0e2a0b2557..a2fdbe38a9 100644 --- a/x/ccv/consumer/types/genesis.go +++ b/x/ccv/consumer/types/genesis.go @@ -62,6 +62,9 @@ func (gs GenesisState) Validate() error { if len(gs.InitialValSet) == 0 { return sdkerrors.Wrap(ccv.ErrInvalidGenesis, "initial validator set is empty") } + if err := gs.Params.Validate(); err != nil { + return err + } if gs.NewChain { if gs.ProviderClientState == nil { diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index a94006840a..422cbd1528 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -19,9 +19,6 @@ const ( // QuerierRoute is the querier route for IBC consumer QuerierRoute = ModuleName - // HistoricalEntries is set to 10000 like the staking module parameter DefaultHistoricalEntries - HistoricalEntries uint32 = 10000 - // ConsumerRedistributeName the root string for the consumer-redistribution account address ConsumerRedistributeName = "cons_redistribute" diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index dc5d7d5432..13a808cb13 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -1,9 +1,10 @@ package types import ( - "fmt" + fmt "fmt" "time" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" ) @@ -11,6 +12,17 @@ import ( const ( // about 2 hr at 7.6 seconds per blocks DefaultBlocksPerDistributionTransmission = 1000 + + // 1 week + DefaultTransferTimeoutPeriod = 1 * 7 * 24 * time.Hour + + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + DefaultConsumerRedistributeFrac = "0.75" + + // Default number of historical info entries to persist in store + DefaultNumHistoricalEntries = 10000 ) // Reflection based keys for params subspace @@ -19,6 +31,9 @@ var ( KeyBlocksPerDistributionTransmission = []byte("BlocksPerDistributionTransmission") KeyDistributionTransmissionChannel = []byte("DistributionTransmissionChannel") KeyProviderFeePoolAddrStr = []byte("ProviderFeePoolAddrStr") + KeyTransferTimeoutPeriod = []byte("TransferTimeoutPeriod") + KeyConsumerRedistributionFrac = []byte("ConsumerRedistributionFraction") + KeyNumHistoricalEntries = []byte("NumHistoricalEntries") ) // ParamKeyTable type declaration for parameters @@ -29,13 +44,18 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates new consumer parameters with provided arguments func NewParams(enabled bool, blocksPerDistributionTransmission int64, distributionTransmissionChannel, providerFeePoolAddrStr string, - ccvTimeoutPeriod time.Duration) Params { + ccvTimeoutPeriod time.Duration, transferTimeoutPeriod time.Duration, + consumerRedistributionFraction string, numHistoricalEntries int64) Params { return Params{ Enabled: enabled, BlocksPerDistributionTransmission: blocksPerDistributionTransmission, DistributionTransmissionChannel: distributionTransmissionChannel, ProviderFeePoolAddrStr: providerFeePoolAddrStr, CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, + // TODO: Find a way to make sure fraction is valid, or don't do that here? + ConsumerRedistributionFraction: consumerRedistributionFraction, + NumHistoricalEntries: numHistoricalEntries, } } @@ -47,46 +67,79 @@ func DefaultParams() Params { "", "", ccvtypes.DefaultCCVTimeoutPeriod, + DefaultTransferTimeoutPeriod, + DefaultConsumerRedistributeFrac, + DefaultNumHistoricalEntries, ) } // Validate all ccv-consumer module parameters +// TODO: Unit tests similar to provider func (p Params) Validate() error { - return nil -} - -// ParamSetPairs implements params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyEnabled, p.Enabled, validateBool), - paramtypes.NewParamSetPair(KeyBlocksPerDistributionTransmission, - p.BlocksPerDistributionTransmission, validateInt64), - paramtypes.NewParamSetPair(KeyDistributionTransmissionChannel, - p.DistributionTransmissionChannel, validateString), - paramtypes.NewParamSetPair(KeyProviderFeePoolAddrStr, - p.ProviderFeePoolAddrStr, validateString), - paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, - p.CcvTimeoutPeriod, ccvtypes.ValidateCCVTimeoutPeriod), + if err := ccvtypes.ValidateBool(p.Enabled); err != nil { + return err } -} - -func validateBool(i interface{}) error { - if _, ok := i.(bool); !ok { - return fmt.Errorf("invalid parameter type: %T", i) + if err := ccvtypes.ValidatePositiveInt64(p.BlocksPerDistributionTransmission); err != nil { + return err + } + // TODO: Is it acceptable if string is empty? Defaults say yes + if err := ccvtypes.ValidateString(p.DistributionTransmissionChannel); err != nil { + return err + } + // TODO: Is it acceptable if string is empty? Defaults say yes + if err := ccvtypes.ValidateString(p.ProviderFeePoolAddrStr); err != nil { + return err + } + if err := ccvtypes.ValidateDuration(p.CcvTimeoutPeriod); err != nil { + return err + } + if err := ccvtypes.ValidateDuration(p.TransferTimeoutPeriod); err != nil { + return err + } + if err := validateConsumerRedistributionFraction(p.ConsumerRedistributionFraction); err != nil { + return err + } + if err := ccvtypes.ValidatePositiveInt64(p.NumHistoricalEntries); err != nil { + return err } return nil } -func validateInt64(i interface{}) error { - if _, ok := i.(int64); !ok { +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.IsPositive() { + return fmt.Errorf("consumer redistribution fraction is not positive") + } + if dec.Sub(sdk.NewDec(1)).IsPositive() { + return fmt.Errorf("consumer redistribution fraction cannot be above 1.0") + } return nil } -func validateString(i interface{}) error { - if _, ok := i.(string); !ok { - return fmt.Errorf("invalid parameter type: %T", i) +// ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyEnabled, p.Enabled, ccvtypes.ValidateBool), + paramtypes.NewParamSetPair(KeyBlocksPerDistributionTransmission, + p.BlocksPerDistributionTransmission, ccvtypes.ValidatePositiveInt64), + paramtypes.NewParamSetPair(KeyDistributionTransmissionChannel, + p.DistributionTransmissionChannel, ccvtypes.ValidateString), + paramtypes.NewParamSetPair(KeyProviderFeePoolAddrStr, + p.ProviderFeePoolAddrStr, ccvtypes.ValidateString), + paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, + p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeyTransferTimeoutPeriod, + p.TransferTimeoutPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeyConsumerRedistributionFrac, + p.ConsumerRedistributionFraction, validateConsumerRedistributionFraction), + paramtypes.NewParamSetPair(KeyNumHistoricalEntries, + p.NumHistoricalEntries, ccvtypes.ValidatePositiveInt64), } - return nil } diff --git a/x/ccv/provider/keeper/params.go b/x/ccv/provider/keeper/params.go index 0d822e3cef..f3d04cb7e4 100644 --- a/x/ccv/provider/keeper/params.go +++ b/x/ccv/provider/keeper/params.go @@ -25,11 +25,20 @@ func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { return p } +// GetTrustingPeriodFraction returns a TrustingPeriodFraction +// used to compute the provider IBC client's TrustingPeriod as UnbondingPeriod / TrustingPeriodFraction +func (k Keeper) GetTrustingPeriodFraction(ctx sdk.Context) int64 { + var i int64 + k.paramSpace.Get(ctx, types.KeyTrustingPeriodFraction, &i) + return i +} + // GetParams returns the paramset for the provider module func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.GetTemplateClient(ctx), k.GetCCVTimeoutPeriod(ctx), + k.GetTrustingPeriodFraction(ctx), ) } diff --git a/x/ccv/provider/keeper/params_test.go b/x/ccv/provider/keeper/params_test.go index 232cd3c878..a16d1c1366 100644 --- a/x/ccv/provider/keeper/params_test.go +++ b/x/ccv/provider/keeper/params_test.go @@ -28,7 +28,7 @@ func TestParams(t *testing.T) { newParams := types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), - ccvtypes.DefaultCCVTimeoutPeriod) + ccvtypes.DefaultCCVTimeoutPeriod, types.DefaultTrustingPeriodFraction) providerKeeper.SetParams(ctx, newParams) params = providerKeeper.GetParams(ctx) require.Equal(t, newParams, params) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index d9b346e968..b66aa47812 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -60,7 +60,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, chainID string, initialHei clientState := k.GetTemplateClient(ctx) clientState.ChainId = chainID clientState.LatestHeight = initialHeight - clientState.TrustingPeriod = unbondingPeriod / utils.TrustingPeriodFraction + clientState.TrustingPeriod = unbondingPeriod / time.Duration(k.GetTrustingPeriodFraction(ctx)) clientState.UnbondingPeriod = unbondingPeriod // TODO: Allow for current validators to set different keys @@ -196,7 +196,7 @@ func (k Keeper) MakeConsumerGenesis(ctx sdk.Context) (gen consumertypes.GenesisS clientState := k.GetTemplateClient(ctx) clientState.ChainId = ctx.ChainID() clientState.LatestHeight = height //(+-1???) - clientState.TrustingPeriod = unbondingTime / utils.TrustingPeriodFraction + clientState.TrustingPeriod = unbondingTime / time.Duration(k.GetTrustingPeriodFraction(ctx)) clientState.UnbondingPeriod = unbondingTime consState, err := k.clientKeeper.GetSelfConsensusState(ctx, height) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 7580e1670a..c6a4a03eda 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -571,9 +571,9 @@ func TestPendingConsumerRemovalPropOrder(t *testing.T) { } } -// TestMakeConsumerGenesis tests the MakeConsumerGenesis keeper method -// -// Note: the initial intention of this test wasn't very clear, it was migrated with best effort +// TestMakeConsumerGenesis tests the MakeConsumerGenesis keeper method. +// An expected genesis state is hardcoded in json, unmarshaled, and compared +// against an actual consumer genesis state constructed by a provider keeper. func TestMakeConsumerGenesis(t *testing.T) { keeperParams := testkeeper.NewInMemKeeperParams(t) @@ -623,7 +623,10 @@ func TestMakeConsumerGenesis(t *testing.T) { AllowUpdateAfterExpiry: true, AllowUpdateAfterMisbehaviour: true, }, - CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, + // 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. + CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, + TrustingPeriodFraction: providertypes.DefaultTrustingPeriodFraction, } providerKeeper.SetParams(ctx, moduleParams) defer ctrl.Finish() @@ -638,7 +641,7 @@ func TestMakeConsumerGenesis(t *testing.T) { actualGenesis, err := providerKeeper.MakeConsumerGenesis(ctx) require.NoError(t, err) - jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` + jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 604800000000000, "consumer_redistribution_fraction":"0.75", "num_historical_entries":10000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` var expectedGenesis consumertypes.GenesisState err = json.Unmarshal([]byte(jsonString), &expectedGenesis) diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index fdda7e5668..9960d89409 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -8,6 +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" "github.com/cosmos/interchain-security/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/stretchr/testify/require" @@ -79,7 +80,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), - 2*7*24*time.Hour), + 2*7*24*time.Hour, 3), ), true, }, @@ -95,7 +96,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false), - ccv.DefaultCCVTimeoutPeriod), + ccv.DefaultCCVTimeoutPeriod, providertypes.DefaultTrustingPeriodFraction), ), false, }, @@ -111,7 +112,23 @@ 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), - 0), + 0, providertypes.DefaultTrustingPeriodFraction), + ), + false, + }, + { + "invalid params, zero trusted period 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), + 2*7*24*time.Hour, 0), ), false, }, diff --git a/x/ccv/provider/types/params.go b/x/ccv/provider/types/params.go index 0058a2cbe4..6e958088f2 100644 --- a/x/ccv/provider/types/params.go +++ b/x/ccv/provider/types/params.go @@ -21,11 +21,16 @@ const ( // DefaultMaxClockDrift defines how much new (untrusted) header's Time can drift into the future. DefaultMaxClockDrift = 10 * time.Second + + // DefaultTrustingPeriodFraction is the default fraction used to compute TrustingPeriod + // as UnbondingPeriod / TrustingPeriodFraction + DefaultTrustingPeriodFraction = 2 ) // Reflection based keys for params subspace var ( - KeyTemplateClient = []byte("TemplateClient") + KeyTemplateClient = []byte("TemplateClient") + KeyTrustingPeriodFraction = []byte("TrustingPeriodFraction") ) // ParamKeyTable returns a key table with the necessary registered provider params @@ -34,10 +39,12 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates new provider parameters with provided arguments -func NewParams(cs *ibctmtypes.ClientState, ccvTimeoutPeriod time.Duration) Params { +func NewParams(cs *ibctmtypes.ClientState, ccvTimeoutPeriod time.Duration, + trustingPeriodFraction int64) Params { return Params{ - TemplateClient: cs, - CcvTimeoutPeriod: ccvTimeoutPeriod, + TemplateClient: cs, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TrustingPeriodFraction: trustingPeriodFraction, } } @@ -49,6 +56,7 @@ func DefaultParams() Params { ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, DefaultMaxClockDrift, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"upgrade", "upgradedIBCState"}, true, true), ccvtypes.DefaultCCVTimeoutPeriod, + DefaultTrustingPeriodFraction, ) } @@ -57,24 +65,31 @@ func (p Params) Validate() error { if p.TemplateClient == nil { return fmt.Errorf("template client is nil") } - if ccvtypes.ValidateCCVTimeoutPeriod(p.CcvTimeoutPeriod) != nil { - return fmt.Errorf("ccv timeout period is invalid") + if err := validateTemplateClient(*p.TemplateClient); err != nil { + return err + } + if err := ccvtypes.ValidateDuration(p.CcvTimeoutPeriod); err != nil { + return err } - return validateTemplateClient(*p.TemplateClient) + if err := ccvtypes.ValidatePositiveInt64(p.TrustingPeriodFraction); err != nil { + return err + } + return nil } // ParamSetPairs implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyTemplateClient, p.TemplateClient, validateTemplateClient), - paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, p.CcvTimeoutPeriod, ccvtypes.ValidateCCVTimeoutPeriod), + paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeyTrustingPeriodFraction, p.TrustingPeriodFraction, ccvtypes.ValidatePositiveInt64), } } func validateTemplateClient(i interface{}) error { cs, ok := i.(ibctmtypes.ClientState) if !ok { - return fmt.Errorf("invalid parameter type: %T", i) + return fmt.Errorf("invalid parameter type: %T, expected: %T", i, ibctmtypes.ClientState{}) } // copy clientstate to prevent changing original pointer diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index 898c2de6b8..385f835567 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -22,16 +22,16 @@ 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), - 2*7*24*time.Hour), true}, + 2*7*24*time.Hour, 2), true}, {"custom invalid params", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}, true, false), - 2*7*24*time.Hour), false}, + 2*7*24*time.Hour, 2), false}, {"blank client", types.NewParams(&ibctmtypes.ClientState{}, - 2*7*24*time.Hour), false}, - {"nil client", types.NewParams(nil, 2*7*24*time.Hour), false}, + 2*7*24*time.Hour, 2), false}, + {"nil client", types.NewParams(nil, 2*7*24*time.Hour, 2), 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), - 0), false}, + 0, 2), false}, } for _, tc := range testCases { diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 155504d60d..444f31d909 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -169,6 +169,8 @@ type Params struct { TemplateClient *types1.ClientState `protobuf:"bytes,1,opt,name=template_client,json=templateClient,proto3" json:"template_client,omitempty"` // Sent IBC packets will timeout after this duration CcvTimeoutPeriod time.Duration `protobuf:"bytes,2,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` + // TrustingPeriodFraction is used to compute the provider IBC client's TrustingPeriod + TrustingPeriodFraction int64 `protobuf:"varint,3,opt,name=trusting_period_fraction,json=trustingPeriodFraction,proto3" json:"trusting_period_fraction,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -218,6 +220,13 @@ func (m *Params) GetCcvTimeoutPeriod() time.Duration { return 0 } +func (m *Params) GetTrustingPeriodFraction() int64 { + if m != nil { + return m.TrustingPeriodFraction + } + 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"` @@ -329,50 +338,52 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 688 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x3d, 0x73, 0xd4, 0x48, - 0x10, 0x5d, 0x9d, 0xbf, 0x76, 0x67, 0x7d, 0xbe, 0x3b, 0x9d, 0xcb, 0x27, 0xbb, 0xae, 0x76, 0x97, - 0x25, 0x59, 0x8a, 0x42, 0xaa, 0x5d, 0x47, 0x38, 0x5b, 0x9b, 0x02, 0x13, 0x50, 0x2c, 0xb2, 0x49, - 0x48, 0x54, 0xa3, 0x99, 0xb6, 0x34, 0x65, 0x49, 0xa3, 0x9a, 0x19, 0x09, 0x9c, 0x13, 0x10, 0x3a, - 0x74, 0xe8, 0x7f, 0x40, 0xf1, 0x2f, 0x1c, 0x3a, 0x24, 0x02, 0xca, 0xfe, 0x23, 0x94, 0x66, 0x24, - 0xaf, 0xf9, 0x48, 0x08, 0xc8, 0xa6, 0xbb, 0xdf, 0x6b, 0xbd, 0xee, 0xa7, 0x19, 0x34, 0x61, 0x99, - 0x02, 0x41, 0x62, 0xcc, 0xb2, 0x40, 0x02, 0x29, 0x04, 0x53, 0x27, 0x1e, 0x21, 0xa5, 0x97, 0x0b, - 0x5e, 0x32, 0x0a, 0xc2, 0x2b, 0xc7, 0x37, 0x67, 0x37, 0x17, 0x5c, 0x71, 0xfb, 0xee, 0x4f, 0x38, - 0x2e, 0x21, 0xa5, 0x7b, 0x83, 0x2b, 0xc7, 0x5b, 0xeb, 0x11, 0x8f, 0xb8, 0xc6, 0x7b, 0xd5, 0xc9, - 0x50, 0xb7, 0xfa, 0x11, 0xe7, 0x51, 0x02, 0x9e, 0x8e, 0xc2, 0xe2, 0xc8, 0x53, 0x2c, 0x05, 0xa9, - 0x70, 0x9a, 0xd7, 0x80, 0xde, 0xf7, 0x00, 0x5a, 0x08, 0xac, 0x18, 0xcf, 0x9a, 0x06, 0x2c, 0x24, - 0x1e, 0xe1, 0x02, 0x3c, 0x92, 0x30, 0xc8, 0x54, 0x25, 0xcf, 0x9c, 0x6a, 0x80, 0x57, 0x01, 0x12, - 0x16, 0xc5, 0xca, 0xa4, 0xa5, 0xa7, 0x20, 0xa3, 0x20, 0x52, 0x66, 0xc0, 0xf3, 0xc8, 0x10, 0x86, - 0x6f, 0x17, 0x90, 0xb3, 0xc7, 0x33, 0x59, 0xa4, 0x20, 0xa6, 0x94, 0xb2, 0xea, 0x63, 0x33, 0xc1, - 0x73, 0x2e, 0x71, 0x62, 0xaf, 0xa3, 0x25, 0xc5, 0x54, 0x02, 0x8e, 0x35, 0xb0, 0x46, 0x1d, 0xdf, - 0x04, 0xf6, 0x00, 0x75, 0x29, 0x48, 0x22, 0x58, 0x5e, 0x81, 0x9d, 0x3f, 0x74, 0xed, 0x76, 0xca, - 0xde, 0x44, 0x6d, 0xb3, 0x1f, 0x46, 0x9d, 0x05, 0x5d, 0x5e, 0xd1,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9, 0x75, 0xaf, 0x75, 0x79, 0xdd, 0x6b, 0x7d, 0xbc, 0xee, - 0xb5, 0x5e, 0xed, 0x44, 0x4c, 0xc5, 0x45, 0xe8, 0x12, 0x9e, 0x7a, 0x84, 0xcb, 0x94, 0x4b, 0x6f, - 0xfe, 0xea, 0x3c, 0xb8, 0x79, 0xa9, 0xde, 0x7c, 0xfb, 0x56, 0xa9, 0x93, 0x1c, 0x64, 0xb8, 0xac, - 0x77, 0xb2, 0xfd, 0x35, 0x00, 0x00, 0xff, 0xff, 0x94, 0x02, 0x93, 0x09, 0xdc, 0x04, 0x00, 0x00, + // 712 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xbf, 0x73, 0xd3, 0x30, + 0x14, 0x8e, 0x49, 0x7f, 0x24, 0x4a, 0x29, 0x60, 0x7a, 0xc5, 0xed, 0x71, 0x49, 0x08, 0x4b, 0x38, + 0x0e, 0xfb, 0x92, 0x2e, 0xd0, 0x2d, 0x2d, 0x57, 0xca, 0xc0, 0x11, 0xdc, 0xb2, 0xb0, 0xf8, 0x64, + 0x49, 0xb5, 0x75, 0xb5, 0x2d, 0x9f, 0x24, 0x1b, 0xba, 0x33, 0x30, 0x76, 0xec, 0xd8, 0xff, 0x80, + 0x7f, 0xa3, 0x63, 0x47, 0x26, 0xe0, 0xda, 0x91, 0x7f, 0x82, 0x93, 0x64, 0x37, 0xe5, 0xc7, 0xc2, + 0xc0, 0xa6, 0xf7, 0xde, 0xf7, 0x3d, 0x7f, 0xef, 0x7d, 0x96, 0xc0, 0x98, 0x66, 0x92, 0x70, 0x14, + 0x43, 0x9a, 0x05, 0x82, 0xa0, 0x82, 0x53, 0x79, 0xe4, 0x21, 0x54, 0x7a, 0x39, 0x67, 0x25, 0xc5, + 0x84, 0x7b, 0xe5, 0xe8, 0xea, 0xec, 0xe6, 0x9c, 0x49, 0x66, 0x3f, 0xfc, 0x0b, 0xc7, 0x45, 0xa8, + 0x74, 0xaf, 0x70, 0xe5, 0x68, 0x7d, 0x25, 0x62, 0x11, 0xd3, 0x78, 0x4f, 0x9d, 0x0c, 0x75, 0xbd, + 0x17, 0x31, 0x16, 0x25, 0xc4, 0xd3, 0x51, 0x58, 0x1c, 0x78, 0x92, 0xa6, 0x44, 0x48, 0x98, 0xe6, + 0x15, 0xa0, 0xfb, 0x3b, 0x00, 0x17, 0x1c, 0x4a, 0xca, 0xb2, 0xba, 0x01, 0x0d, 0x91, 0x87, 0x18, + 0x27, 0x1e, 0x4a, 0x28, 0xc9, 0xa4, 0x92, 0x67, 0x4e, 0x15, 0xc0, 0x53, 0x80, 0x84, 0x46, 0xb1, + 0x34, 0x69, 0xe1, 0x49, 0x92, 0x61, 0xc2, 0x53, 0x6a, 0xc0, 0xb3, 0xc8, 0x10, 0x06, 0x1f, 0x9b, + 0xc0, 0xd9, 0x66, 0x99, 0x28, 0x52, 0xc2, 0x27, 0x18, 0x53, 0xf5, 0xb1, 0x29, 0x67, 0x39, 0x13, + 0x30, 0xb1, 0x57, 0xc0, 0xbc, 0xa4, 0x32, 0x21, 0x8e, 0xd5, 0xb7, 0x86, 0x6d, 0xdf, 0x04, 0x76, + 0x1f, 0x74, 0x30, 0x11, 0x88, 0xd3, 0x5c, 0x81, 0x9d, 0x1b, 0xba, 0x76, 0x3d, 0x65, 0xaf, 0x81, + 0x96, 0xd9, 0x0f, 0xc5, 0x4e, 0x53, 0x97, 0x17, 0x75, 0xfc, 0x12, 0xdb, 0x2f, 0xc0, 0x32, 0xcd, + 0xa8, 0xa4, 0x30, 0x09, 0x62, 0xa2, 0x74, 0x3a, 0x73, 0x7d, 0x6b, 0xd8, 0x19, 0xaf, 0xbb, 0x34, + 0x44, 0xae, 0x1a, 0xcd, 0xad, 0x06, 0x2a, 0x47, 0xee, 0xae, 0x46, 0x6c, 0xcd, 0x9d, 0x7d, 0xed, + 0x35, 0xfc, 0x9b, 0x15, 0xcf, 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xa4, 0x4c, 0x78, 0xb3, 0xf7, 0xea, 0xc9, 0xd5, 0x1b, 0xf7, 0xe1, 0xd7, + 0x57, 0x4e, 0x1e, 0xe5, 0x44, 0x84, 0x0b, 0x7a, 0x9b, 0x1b, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, + 0xb7, 0x64, 0x3e, 0xb7, 0x16, 0x05, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -533,6 +544,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TrustingPeriodFraction != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.TrustingPeriodFraction)) + i-- + dAtA[i] = 0x18 + } n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) if err4 != nil { return 0, err4 @@ -707,6 +723,9 @@ func (m *Params) Size() (n int) { } l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod) n += 1 + l + sovProvider(uint64(l)) + if m.TrustingPeriodFraction != 0 { + n += 1 + sovProvider(uint64(m.TrustingPeriodFraction)) + } return n } @@ -1325,6 +1344,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TrustingPeriodFraction", wireType) + } + m.TrustingPeriodFraction = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TrustingPeriodFraction |= 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 5cd02e0c25..f687f8a334 100644 --- a/x/ccv/types/shared_params.go +++ b/x/ccv/types/shared_params.go @@ -14,7 +14,7 @@ var ( KeyCCVTimeoutPeriod = []byte("CcvTimeoutPeriod") ) -func ValidateCCVTimeoutPeriod(i interface{}) error { +func ValidateDuration(i interface{}) error { period, ok := i.(time.Duration) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -24,3 +24,34 @@ func ValidateCCVTimeoutPeriod(i interface{}) error { } return nil } + +func ValidateBool(i interface{}) error { + if _, ok := i.(bool); !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} + +func ValidateInt64(i interface{}) error { + if _, ok := i.(int64); !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} + +func ValidatePositiveInt64(i interface{}) error { + if err := ValidateInt64(i); err != nil { + return err + } + if i.(int64) <= int64(0) { + return fmt.Errorf("int must be positive") + } + return nil +} + +func ValidateString(i interface{}) error { + if _, ok := i.(string); !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} diff --git a/x/ccv/utils/utils.go b/x/ccv/utils/utils.go index c6b1fa000a..54a1845e96 100644 --- a/x/ccv/utils/utils.go +++ b/x/ccv/utils/utils.go @@ -13,10 +13,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// TrustingPeriodFraction is used to compute the IBC clients TrustingPeriod -// as UnbondingPeriod / TrustingPeriodFraction -const TrustingPeriodFraction = 2 - func AccumulateChanges(currentChanges, newChanges []abci.ValidatorUpdate) []abci.ValidatorUpdate { m := make(map[string]abci.ValidatorUpdate) From 33c15c9c3fb704d09de34b4ed02c59ab625a9d49 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 13 Oct 2022 12:34:14 -0700 Subject: [PATCH 02/18] edits --- x/ccv/consumer/keeper/params.go | 4 +++ x/ccv/consumer/keeper/params_test.go | 2 ++ x/ccv/consumer/keeper/validators.go | 6 ++-- x/ccv/consumer/types/genesis_test.go | 30 +++++++++++++++++++ x/ccv/consumer/types/params.go | 10 ++----- x/ccv/consumer/types/params_test.go | 45 ++++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 x/ccv/consumer/types/params_test.go diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index ae9ec86f0f..e6b9fac4bb 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -79,12 +79,16 @@ func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { return p } +// GetConsumerRedistributionFrac returns the fraction of tokens allocated to the consumer redistribution +// address during distribution events. The fraction is a string representing a +// decimal number. For example "0.75" would represent 75%. func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { var str string k.paramStore.Get(ctx, types.KeyConsumerRedistributionFrac, &str) return str } +// GetNumHistoricalEntries returns the number of historical info entries to persist in store func (k Keeper) GetNumHistoricalEntries(ctx sdk.Context) int64 { var n int64 k.paramStore.Get(ctx, types.KeyNumHistoricalEntries, &n) diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 722e592495..40c1ef0757 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -50,3 +50,5 @@ func TestParams(t *testing.T) { GetProviderFeePoolAddrStr(ctx) require.Equal(t, gotAddr, "foobar") } + +// TODO: Test invalid params diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 71c67b16a6..07b9c55640 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -154,7 +154,7 @@ func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { // heights that are below pruning height func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { - entryNum := types.DefaultNumHistoricalEntries + numHistoricalEntries := k.GetNumHistoricalEntries(ctx) // Prune store to ensure we only have parameter-defined historical entries. // In most cases, this will involve removing a single historical entry. @@ -163,7 +163,7 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { // Since the entries to be deleted are always in a continuous range, we can iterate // over the historical entries starting from the most recent version to be pruned // and then return at the first empty entry. - for i := ctx.BlockHeight() - int64(entryNum); i >= 0; i-- { + for i := ctx.BlockHeight() - int64(numHistoricalEntries); i >= 0; i-- { _, found := k.GetHistoricalInfo(ctx, i) if found { k.DeleteHistoricalInfo(ctx, i) @@ -173,7 +173,7 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { } // if there is no need to persist historicalInfo, return - if entryNum == 0 { + if numHistoricalEntries == 0 { return } diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index 3408c81ccb..021e7561a0 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -144,6 +144,21 @@ func TestValidateInitialGenesisState(t *testing.T) { valUpdates, types.SlashRequests{}, params), true, }, + { + "invalid new consumer genesis state: invalid params", + types.NewInitialGenesisState(cs, consensusState, valUpdates, types.SlashRequests{}, + types.NewParams( + true, + types.DefaultBlocksPerDistributionTransmission, + "", + "", + 0, // CCV timeout period cannot be 0 + types.DefaultTransferTimeoutPeriod, + types.DefaultConsumerRedistributeFrac, + types.DefaultNumHistoricalEntries, + )), + true, + }, } for _, c := range cases { @@ -257,6 +272,21 @@ func TestValidateRestartGenesisState(t *testing.T) { types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, nil, nil, nil, params), true, }, + { + "invalid restart consumer genesis state: invalid params", + types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, valUpdates, nil, nil, + types.NewParams( + true, + types.DefaultBlocksPerDistributionTransmission, + "", + "", + 0, // CCV timeout period cannot be 0 + types.DefaultTransferTimeoutPeriod, + types.DefaultConsumerRedistributeFrac, + types.DefaultNumHistoricalEntries, + )), + true, + }, } for _, c := range cases { diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 13a808cb13..33fd19b4ef 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -16,7 +16,7 @@ const ( // 1 week DefaultTransferTimeoutPeriod = 1 * 7 * 24 * time.Hour - // The fraction of tokens allocated to the consumer redistribution address + // The default fraction of tokens allocated to the consumer redistribution address // during distribution events. The fraction is a string representing a // decimal number. For example "0.75" would represent 75%. DefaultConsumerRedistributeFrac = "0.75" @@ -53,9 +53,8 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, ProviderFeePoolAddrStr: providerFeePoolAddrStr, CcvTimeoutPeriod: ccvTimeoutPeriod, TransferTimeoutPeriod: transferTimeoutPeriod, - // TODO: Find a way to make sure fraction is valid, or don't do that here? - ConsumerRedistributionFraction: consumerRedistributionFraction, - NumHistoricalEntries: numHistoricalEntries, + ConsumerRedistributionFraction: consumerRedistributionFraction, + NumHistoricalEntries: numHistoricalEntries, } } @@ -74,7 +73,6 @@ func DefaultParams() Params { } // Validate all ccv-consumer module parameters -// TODO: Unit tests similar to provider func (p Params) Validate() error { if err := ccvtypes.ValidateBool(p.Enabled); err != nil { return err @@ -82,11 +80,9 @@ func (p Params) Validate() error { if err := ccvtypes.ValidatePositiveInt64(p.BlocksPerDistributionTransmission); err != nil { return err } - // TODO: Is it acceptable if string is empty? Defaults say yes if err := ccvtypes.ValidateString(p.DistributionTransmissionChannel); err != nil { return err } - // TODO: Is it acceptable if string is empty? Defaults say yes if err := ccvtypes.ValidateString(p.ProviderFeePoolAddrStr); err != nil { return err } diff --git a/x/ccv/consumer/types/params_test.go b/x/ccv/consumer/types/params_test.go new file mode 100644 index 0000000000..2e3c55d01d --- /dev/null +++ b/x/ccv/consumer/types/params_test.go @@ -0,0 +1,45 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" +) + +// Tests the validation of consumer params that happens at genesis +func TestValidateParams(t *testing.T) { + + testCases := []struct { + name string + params consumertypes.Params + expPass bool + }{ + {"default params", consumertypes.DefaultParams(), true}, + {"custom valid params", consumertypes.NewParams(true, 5, "", "", 1004, 1005, "0.5", 1000), true}, + {"custom invalid params, block per dist transmission", + consumertypes.NewParams(true, -5, "", "", 1004, 1005, "0.5", 1000), false}, + {"custom invalid params, ccv timeout", + consumertypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000), false}, + {"custom invalid params, transfer timeout", + consumertypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000), false}, + {"custom invalid params, consumer redist fraction is negative", + consumertypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000), false}, + {"custom invalid params, consumer redist fraction is over 1", + consumertypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000), false}, + {"custom invalid params, consumer redist fraction rubbish", + consumertypes.NewParams(true, 5, "", "", 5, 1005, "rubbish", 1000), false}, + {"custom invalid params, negative num historical entries", + consumertypes.NewParams(true, 5, "", "", 5, 1005, "rubbish", -100), false}, + } + + for _, tc := range testCases { + err := tc.params.Validate() + if tc.expPass { + require.Nil(t, err, "expected error to be nil for test case: %s", tc.name) + } else { + require.NotNil(t, err, "expected error but got nil for test case: %s", tc.name) + } + } +} From fa02d6d241937e76a93416f72a49b91522bae12f Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 13 Oct 2022 13:37:38 -0700 Subject: [PATCH 03/18] Update params_test.go --- x/ccv/consumer/keeper/params_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 40c1ef0757..722e592495 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -50,5 +50,3 @@ func TestParams(t *testing.T) { GetProviderFeePoolAddrStr(ctx) require.Equal(t, gotAddr, "foobar") } - -// TODO: Test invalid params From 6338a6670125bb82ec02732f0d9bfd6e9567f9a5 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 18 Oct 2022 08:45:24 -0700 Subject: [PATCH 04/18] small --- x/ccv/consumer/types/params.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index cec08ebcf2..04f379067d 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -108,9 +108,9 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyBlocksPerDistributionTransmission, p.BlocksPerDistributionTransmission, ccvtypes.ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyDistributionTransmissionChannel, - p.DistributionTransmissionChannel, ccvtypes.ValidateString), + p.DistributionTransmissionChannel, validateDistributionTransmissionChannel), paramtypes.NewParamSetPair(KeyProviderFeePoolAddrStr, - p.ProviderFeePoolAddrStr, ccvtypes.ValidateString), + p.ProviderFeePoolAddrStr, validateProviderFeePoolAddrStr), paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeyTransferTimeoutPeriod, From 3afb7c4500446ffde81f4afa8d31893009b0cd37 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 18 Oct 2022 08:56:30 -0700 Subject: [PATCH 05/18] Update genesis_test.go --- x/ccv/provider/types/genesis_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index 9960d89409..ddc1218d7a 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -112,12 +112,13 @@ 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), - 0, providertypes.DefaultTrustingPeriodFraction), + 0, // 0 ccv timeout here + providertypes.DefaultTrustingPeriodFraction), ), false, }, { - "invalid params, zero trusted period fraction", + "invalid params, zero trusting period fraction", types.NewGenesisState( 0, nil, @@ -128,7 +129,8 @@ 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), - 2*7*24*time.Hour, 0), + 2*7*24*time.Hour, + 0), // 0 trusting period fraction here ), false, }, From fe2f938d7556f3ee3417fadd5c275b464d035042 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:31:47 -0700 Subject: [PATCH 06/18] remove "num" from historical entries param --- .../ccv/consumer/v1/consumer.proto | 6 +- x/ccv/consumer/keeper/params.go | 8 +- x/ccv/consumer/keeper/validators.go | 2 +- x/ccv/consumer/types/consumer.pb.go | 120 +++++++++--------- x/ccv/consumer/types/params.go | 12 +- x/ccv/provider/keeper/proposal_test.go | 2 +- 6 files changed, 77 insertions(+), 73 deletions(-) diff --git a/proto/interchain_security/ccv/consumer/v1/consumer.proto b/proto/interchain_security/ccv/consumer/v1/consumer.proto index cdf26277ce..056e155ea3 100644 --- a/proto/interchain_security/ccv/consumer/v1/consumer.proto +++ b/proto/interchain_security/ccv/consumer/v1/consumer.proto @@ -43,8 +43,10 @@ message Params { // decimal number. For example "0.75" would represent 75%. string consumer_redistribution_fraction = 7; - // The number of historical info entries to persist in store - int64 num_historical_entries = 8; + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + int64 historical_entries = 8; } // LastTransmissionBlockHeight is the last time validator holding diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index e6b9fac4bb..4b78629389 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -19,7 +19,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.GetCCVTimeoutPeriod(ctx), k.GetTransferTimeoutPeriod(ctx), k.GetConsumerRedistributionFrac(ctx), - k.GetNumHistoricalEntries(ctx), + k.GetHistoricalEntries(ctx), ) } @@ -88,9 +88,9 @@ func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { return str } -// GetNumHistoricalEntries returns the number of historical info entries to persist in store -func (k Keeper) GetNumHistoricalEntries(ctx sdk.Context) int64 { +// GetHistoricalEntries returns the number of historical info entries to persist in store +func (k Keeper) GetHistoricalEntries(ctx sdk.Context) int64 { var n int64 - k.paramStore.Get(ctx, types.KeyNumHistoricalEntries, &n) + k.paramStore.Get(ctx, types.KeyHistoricalEntries, &n) return n } diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 07b9c55640..3c3362750c 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -154,7 +154,7 @@ func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { // heights that are below pruning height func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { - numHistoricalEntries := k.GetNumHistoricalEntries(ctx) + numHistoricalEntries := k.GetHistoricalEntries(ctx) // Prune store to ensure we only have parameter-defined historical entries. // In most cases, this will involve removing a single historical entry. diff --git a/x/ccv/consumer/types/consumer.pb.go b/x/ccv/consumer/types/consumer.pb.go index 0a4ed8a365..5f57533fa6 100644 --- a/x/ccv/consumer/types/consumer.pb.go +++ b/x/ccv/consumer/types/consumer.pb.go @@ -56,8 +56,10 @@ type Params struct { // during distribution events. The fraction is a string representing a // decimal number. For example "0.75" would represent 75%. ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` - // The number of historical info entries to persist in store - NumHistoricalEntries int64 `protobuf:"varint,8,opt,name=num_historical_entries,json=numHistoricalEntries,proto3" json:"num_historical_entries,omitempty"` + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + HistoricalEntries int64 `protobuf:"varint,8,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -142,9 +144,9 @@ func (m *Params) GetConsumerRedistributionFraction() string { return "" } -func (m *Params) GetNumHistoricalEntries() int64 { +func (m *Params) GetHistoricalEntries() int64 { if m != nil { - return m.NumHistoricalEntries + return m.HistoricalEntries } return 0 } @@ -368,54 +370,54 @@ func init() { } var fileDescriptor_5b27a82b276e7f93 = []byte{ - // 747 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x8e, 0x6f, 0xda, 0x34, 0x77, 0xd2, 0x7b, 0x75, 0xe5, 0x1b, 0x5a, 0xb7, 0x48, 0x4e, 0x1a, - 0x2a, 0x14, 0x09, 0xd5, 0x56, 0x52, 0xd8, 0x74, 0xd7, 0xa4, 0x54, 0xe5, 0x47, 0x22, 0xb8, 0x11, - 0x0b, 0x58, 0x58, 0xe3, 0xf1, 0x24, 0x19, 0xc5, 0x9e, 0x31, 0x33, 0x63, 0x83, 0xdf, 0x82, 0x25, - 0x12, 0x2f, 0x80, 0xc4, 0x96, 0x87, 0xa8, 0x58, 0x75, 0xc9, 0xaa, 0xa0, 0xf6, 0x0d, 0x78, 0x02, - 0xe4, 0xbf, 0x90, 0x14, 0x22, 0x75, 0x77, 0x8e, 0xce, 0xf7, 0x7d, 0x33, 0xe7, 0x17, 0x74, 0x09, - 0x95, 0x98, 0xa3, 0x09, 0x24, 0xd4, 0x16, 0x18, 0x85, 0x9c, 0xc8, 0xd8, 0x44, 0x28, 0x32, 0x11, - 0xa3, 0x22, 0xf4, 0x31, 0x37, 0xa3, 0xce, 0xcc, 0x36, 0x02, 0xce, 0x24, 0x53, 0xef, 0xfc, 0x81, - 0x63, 0x20, 0x14, 0x19, 0x33, 0x5c, 0xd4, 0xd9, 0xde, 0x5d, 0x26, 0x9c, 0xe8, 0xa1, 0x28, 0x93, - 0xda, 0xde, 0x1a, 0x33, 0x36, 0xf6, 0xb0, 0x99, 0x7a, 0x4e, 0x38, 0x32, 0x21, 0x8d, 0xf3, 0xd0, - 0x2e, 0x62, 0xc2, 0x67, 0xc2, 0x14, 0x12, 0x4e, 0x09, 0x1d, 0x9b, 0x51, 0xc7, 0xc1, 0x12, 0x76, - 0x0a, 0x3f, 0x47, 0xd5, 0xc7, 0x6c, 0xcc, 0x52, 0xd3, 0x4c, 0xac, 0x42, 0x36, 0xe3, 0xda, 0x59, - 0x20, 0x73, 0xf2, 0x90, 0x7e, 0xfd, 0x45, 0x37, 0xe4, 0x50, 0x12, 0x46, 0xb3, 0x78, 0xeb, 0xd3, - 0x0a, 0xa8, 0x0c, 0x20, 0x87, 0xbe, 0x50, 0x35, 0xb0, 0x86, 0x29, 0x74, 0x3c, 0xec, 0x6a, 0x4a, - 0x53, 0x69, 0x57, 0xad, 0xc2, 0x55, 0x9f, 0x81, 0x5d, 0xc7, 0x63, 0x68, 0x2a, 0xec, 0x00, 0x73, - 0xdb, 0x25, 0x42, 0x72, 0xe2, 0x84, 0x89, 0x8a, 0x2d, 0x39, 0xa4, 0xc2, 0x27, 0x42, 0x10, 0x46, - 0xb5, 0xbf, 0x9a, 0x4a, 0xbb, 0x6c, 0xed, 0x64, 0xd8, 0x01, 0xe6, 0x47, 0x73, 0xc8, 0xe1, 0x1c, - 0x50, 0x7d, 0x0c, 0x76, 0x96, 0xaa, 0xd8, 0x68, 0x02, 0x29, 0xc5, 0x9e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43, 0x2f, 0x69, 0xf6, 0x09, 0x26, 0xe3, 0x89, 0x54, 0x37, 0x40, 0x65, 0x92, 0x5a, 0xe9, - 0x00, 0x95, 0xad, 0xdc, 0x6b, 0x7d, 0x54, 0xc0, 0xff, 0x7d, 0xce, 0x84, 0xe8, 0x27, 0xfb, 0xf1, - 0x02, 0x7a, 0xc4, 0x85, 0x92, 0xf1, 0x64, 0xe2, 0x92, 0x46, 0x61, 0x21, 0x52, 0xc2, 0xba, 0x55, - 0xb8, 0x6a, 0x1d, 0xac, 0x06, 0xec, 0x0d, 0xe6, 0xf9, 0x48, 0x65, 0x8e, 0x0a, 0x41, 0x25, 0x08, - 0x9d, 0x29, 0x8e, 0xd3, 0xd9, 0xa8, 0x75, 0xeb, 0xbf, 0x95, 0xf2, 0x90, 0xc6, 0xbd, 0xfd, 0x1f, - 0x17, 0x8d, 0xcd, 0x18, 0xfa, 0xde, 0x41, 0x2b, 0x29, 0x02, 0xa6, 0x22, 0x14, 0x76, 0xc6, 0x6b, - 0x7d, 0xf9, 0xbc, 0x57, 0xcf, 0xf7, 0x03, 0xf1, 0x38, 0x90, 0xcc, 0x18, 0x84, 0xce, 0x13, 0x1c, - 0x5b, 0xb9, 0x70, 0xeb, 0x83, 0x02, 0xd6, 0x4f, 0x3d, 0x28, 0x26, 0x16, 0x7e, 0x1d, 0x62, 0x21, - 0xd5, 0x3e, 0xa8, 0x04, 0x10, 0x4d, 0x71, 0x96, 0x53, 0xad, 0x7b, 0xcf, 0x58, 0x76, 0x0e, 0xa2, - 0x8e, 0x91, 0x32, 0x07, 0x29, 0xfc, 0x08, 0x4a, 0x68, 0xe5, 0x54, 0xf5, 0x18, 0x00, 0x42, 0x67, - 0x1d, 0x4a, 0x72, 0xfa, 0xb7, 0x7b, 0xd7, 0xc8, 0x3f, 0x52, 0x6c, 0x78, 0xbe, 0xf1, 0xc6, 0xa3, - 0x19, 0x72, 0x18, 0x07, 0xd8, 0x9a, 0x63, 0xb6, 0x5c, 0xf0, 0xcf, 0xfc, 0xe7, 0x84, 0x7a, 0x0a, - 0xaa, 0x3c, 0xb7, 0x35, 0xa5, 0x59, 0x6e, 0xd7, 0xba, 0x1d, 0xe3, 0x06, 0xe7, 0xca, 0x98, 0x57, - 0xe9, 0xad, 0x24, 0x63, 0x67, 0xcd, 0x84, 0x7a, 0xc3, 0xb3, 0x4b, 0x5d, 0x39, 0xbf, 0xd4, 0x95, - 0xef, 0x97, 0xba, 0xf2, 0xee, 0x4a, 0x2f, 0x9d, 0x5f, 0xe9, 0xa5, 0xaf, 0x57, 0x7a, 0xe9, 0xe5, - 0xc1, 0x98, 0xc8, 0x49, 0xe8, 0x18, 0x88, 0xf9, 0xf9, 0x99, 0x31, 0x7f, 0xbd, 0xb6, 0x37, 0xbb, - 0x7b, 0x6f, 0x17, 0x4f, 0xaa, 0x8c, 0x03, 0x2c, 0x9c, 0x4a, 0xda, 0xa4, 0xfd, 0x9f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x28, 0xec, 0xa0, 0xf9, 0x83, 0x05, 0x00, 0x00, + // 738 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x49, 0x9b, 0x86, 0x49, 0x41, 0x30, 0x84, 0xd6, 0x2d, 0x92, 0x93, 0x86, 0x0a, 0x45, + 0x42, 0xb5, 0x95, 0x54, 0x6c, 0xba, 0x6b, 0x52, 0xaa, 0xf2, 0x90, 0x08, 0x6e, 0xc4, 0x02, 0x16, + 0xd6, 0x78, 0x3c, 0x49, 0x46, 0x71, 0x3c, 0x66, 0x66, 0x6c, 0xf0, 0x5f, 0xb0, 0x44, 0x62, 0xcb, + 0x82, 0x0f, 0xe0, 0x23, 0x2a, 0x56, 0x5d, 0xb2, 0x2a, 0xa8, 0xfd, 0x03, 0xbe, 0x00, 0xf9, 0x95, + 0x26, 0x85, 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, 0xc8, 0x7e, 0xe4, 0x13, 0x73, 0x86, 0xd9, 0x70, + 0xc0, 0xad, 0xd9, 0xcf, 0x09, 0x78, 0x0c, 0xca, 0x3c, 0xb3, 0x55, 0xa5, 0x5e, 0x6c, 0x56, 0xda, + 0x2d, 0xfd, 0x1a, 0x77, 0x4a, 0x9f, 0x55, 0xe9, 0x2c, 0xc5, 0xf3, 0x66, 0x4e, 0x85, 0x3a, 0xfd, + 0x93, 0x73, 0x4d, 0x39, 0x3d, 0xd7, 0x94, 0xdf, 0xe7, 0x9a, 0xf2, 0xe9, 0x42, 0x2b, 0x9c, 0x5e, + 0x68, 0x85, 0x9f, 0x17, 0x5a, 0xe1, 0xed, 0xde, 0x90, 0xca, 0x51, 0x60, 0xeb, 0x98, 0x4d, 0xb2, + 0xfb, 0x62, 0x5c, 0xbe, 0xb6, 0x33, 0x3d, 0x78, 0x1f, 0xe7, 0x6f, 0xa9, 0x8c, 0x7c, 0x22, 0xec, + 0x52, 0xd2, 0xa4, 0xdd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x10, 0x1c, 0x1b, 0x8c, 0x7c, 0x05, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -438,8 +440,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NumHistoricalEntries != 0 { - i = encodeVarintConsumer(dAtA, i, uint64(m.NumHistoricalEntries)) + if m.HistoricalEntries != 0 { + i = encodeVarintConsumer(dAtA, i, uint64(m.HistoricalEntries)) i-- dAtA[i] = 0x40 } @@ -689,8 +691,8 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovConsumer(uint64(l)) } - if m.NumHistoricalEntries != 0 { - n += 1 + sovConsumer(uint64(m.NumHistoricalEntries)) + if m.HistoricalEntries != 0 { + n += 1 + sovConsumer(uint64(m.HistoricalEntries)) } return n } @@ -996,9 +998,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 8: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumHistoricalEntries", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) } - m.NumHistoricalEntries = 0 + m.HistoricalEntries = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConsumer @@ -1008,7 +1010,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumHistoricalEntries |= int64(b&0x7F) << shift + m.HistoricalEntries |= int64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 04f379067d..6e7d3e3f10 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -33,7 +33,7 @@ var ( KeyProviderFeePoolAddrStr = []byte("ProviderFeePoolAddrStr") KeyTransferTimeoutPeriod = []byte("TransferTimeoutPeriod") KeyConsumerRedistributionFrac = []byte("ConsumerRedistributionFraction") - KeyNumHistoricalEntries = []byte("NumHistoricalEntries") + KeyHistoricalEntries = []byte("HistoricalEntries") ) // ParamKeyTable type declaration for parameters @@ -45,7 +45,7 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams(enabled bool, blocksPerDistributionTransmission int64, distributionTransmissionChannel, providerFeePoolAddrStr string, ccvTimeoutPeriod time.Duration, transferTimeoutPeriod time.Duration, - consumerRedistributionFraction string, numHistoricalEntries int64) Params { + consumerRedistributionFraction string, historicalEntries int64) Params { return Params{ Enabled: enabled, BlocksPerDistributionTransmission: blocksPerDistributionTransmission, @@ -54,7 +54,7 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, CcvTimeoutPeriod: ccvTimeoutPeriod, TransferTimeoutPeriod: transferTimeoutPeriod, ConsumerRedistributionFraction: consumerRedistributionFraction, - NumHistoricalEntries: numHistoricalEntries, + HistoricalEntries: historicalEntries, } } @@ -95,7 +95,7 @@ func (p Params) Validate() error { if err := validateConsumerRedistributionFraction(p.ConsumerRedistributionFraction); err != nil { return err } - if err := ccvtypes.ValidatePositiveInt64(p.NumHistoricalEntries); err != nil { + if err := ccvtypes.ValidatePositiveInt64(p.HistoricalEntries); err != nil { return err } return nil @@ -117,8 +117,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { p.TransferTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeyConsumerRedistributionFrac, p.ConsumerRedistributionFraction, validateConsumerRedistributionFraction), - paramtypes.NewParamSetPair(KeyNumHistoricalEntries, - p.NumHistoricalEntries, ccvtypes.ValidatePositiveInt64), + paramtypes.NewParamSetPair(KeyHistoricalEntries, + p.HistoricalEntries, ccvtypes.ValidatePositiveInt64), } } diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index c6a4a03eda..fc991e11f4 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -641,7 +641,7 @@ func TestMakeConsumerGenesis(t *testing.T) { actualGenesis, err := providerKeeper.MakeConsumerGenesis(ctx) require.NoError(t, err) - jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 604800000000000, "consumer_redistribution_fraction":"0.75", "num_historical_entries":10000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` + jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 604800000000000, "consumer_redistribution_fraction":"0.75", "historical_entries":10000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` var expectedGenesis consumertypes.GenesisState err = json.Unmarshal([]byte(jsonString), &expectedGenesis) From 04e831dd9cd721cea67441a24c051e9c066b7308 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:33:35 -0700 Subject: [PATCH 07/18] comment --- proto/interchain_security/ccv/provider/v1/provider.proto | 2 +- x/ccv/provider/types/provider.pb.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index eae0f9701d..cf72e150ea 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -62,7 +62,7 @@ message Params { // Sent IBC packets will timeout after this duration google.protobuf.Duration ccv_timeout_period = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - // TrustingPeriodFraction is used to compute the provider IBC client's TrustingPeriod + // TrustingPeriodFraction is used to compute the consumer and provider IBC client's TrustingPeriod int64 trusting_period_fraction = 3; } diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 444f31d909..93464a51f1 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -169,7 +169,7 @@ type Params struct { TemplateClient *types1.ClientState `protobuf:"bytes,1,opt,name=template_client,json=templateClient,proto3" json:"template_client,omitempty"` // Sent IBC packets will timeout after this duration CcvTimeoutPeriod time.Duration `protobuf:"bytes,2,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` - // TrustingPeriodFraction is used to compute the provider IBC client's TrustingPeriod + // TrustingPeriodFraction is used to compute the consumer and provider IBC client's TrustingPeriod TrustingPeriodFraction int64 `protobuf:"varint,3,opt,name=trusting_period_fraction,json=trustingPeriodFraction,proto3" json:"trusting_period_fraction,omitempty"` } From 03178ef3f61b5d6f86a6a71dc68b9e96d7875880 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:45:41 -0700 Subject: [PATCH 08/18] use params p1 --- tests/e2e/common.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/common.go b/tests/e2e/common.go index a1a6fd4bb8..0eb3ce8b9e 100644 --- a/tests/e2e/common.go +++ b/tests/e2e/common.go @@ -333,7 +333,8 @@ func incrementTimeBy(s *CCVTestSuite, jumpPeriod time.Duration) { consumerUnbondingPeriod, found := s.consumerApp.GetConsumerKeeper().GetUnbondingTime(s.consumerChain.GetContext()) s.Require().True(found) split := 1 - if jumpPeriod > consumerUnbondingPeriod/providertypes.DefaultTrustingPeriodFraction { + trustingPeriodFraction := s.providerApp.GetProviderKeeper().GetTrustingPeriodFraction(s.providerCtx()) + if jumpPeriod > consumerUnbondingPeriod/time.Duration(trustingPeriodFraction) { // Make sure the clients do not expire split = 4 jumpPeriod = jumpPeriod / 4 From 1ddaf6dd8489ec7d6c7082c5a09d0fa9eeab1789 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:47:55 -0700 Subject: [PATCH 09/18] use params p2 --- tests/e2e/democracy.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/e2e/democracy.go b/tests/e2e/democracy.go index dc074ef91d..8b4dfda7f9 100644 --- a/tests/e2e/democracy.go +++ b/tests/e2e/democracy.go @@ -20,8 +20,6 @@ import ( "github.com/stretchr/testify/suite" ) -var consumerFraction, _ = sdk.NewDecFromStr(consumertypes.DefaultConsumerRedistributeFrac) - type ConsumerDemocracyTestSuite struct { suite.Suite coordinator *ibctesting.Coordinator @@ -107,14 +105,21 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() { consumerRedistributeDifference = consumerRedistributeDifference.Add(representativeDifference[key]) } + consumerRedistributionFraction := sdk.MustNewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) + //confirm that the total amount given to the community pool plus all representatives is equal to the total amount taken out of distribution s.Require().Equal(distrModuleDifference, consumerRedistributeDifference) //confirm that the percentage given to the community pool is equal to the configured community tax percentage. - s.Require().Equal(communityPoolDifference.Quo(consumerRedistributeDifference), distrKeeper.GetCommunityTax(s.consumerCtx())) + s.Require().Equal(communityPoolDifference.Quo(consumerRedistributeDifference), + distrKeeper.GetCommunityTax(s.consumerCtx())) //check that the fraction actually kept by the consumer is the correct fraction. using InEpsilon because the math code uses truncations - s.Require().InEpsilon(distrModuleDifference.Quo(providerDifference.Add(distrModuleDifference)).MustFloat64(), consumerFraction.MustFloat64(), float64(0.0001)) + s.Require().InEpsilon(distrModuleDifference.Quo( + providerDifference.Add(distrModuleDifference)).MustFloat64(), + consumerRedistributionFraction.MustFloat64(), float64(0.0001)) //check that the fraction actually kept by the provider is the correct fraction. using InEpsilon because the math code uses truncations - s.Require().InEpsilon(providerDifference.Quo(providerDifference.Add(distrModuleDifference)).MustFloat64(), sdk.NewDec(1).Sub(consumerFraction).MustFloat64(), float64(0.0001)) + s.Require().InEpsilon(providerDifference.Quo( + providerDifference.Add(distrModuleDifference)).MustFloat64(), + sdk.NewDec(1).Sub(consumerRedistributionFraction).MustFloat64(), float64(0.0001)) totalRepresentativePower := stakingKeeper.GetValidatorSet().TotalBondedTokens(s.consumerCtx()) From cd9fbfc27c2a8b94b88c678f9279caeb4bfd1b79 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:54:12 -0700 Subject: [PATCH 10/18] use params p3 --- tests/e2e/normal_operations.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/normal_operations.go b/tests/e2e/normal_operations.go index 3e6ffc456a..92ea5bac16 100644 --- a/tests/e2e/normal_operations.go +++ b/tests/e2e/normal_operations.go @@ -38,7 +38,8 @@ func (k CCVTestSuite) TestHistoricalInfo() { createVal, createVal, func(k CCVTestSuite) { - newHeight := k.consumerChain.GetContext().BlockHeight() + int64(consumertypes.DefaultNumHistoricalEntries) + historicalEntries := k.consumerApp.GetConsumerKeeper().GetHistoricalEntries(k.consumerCtx()) + newHeight := k.consumerChain.GetContext().BlockHeight() + historicalEntries header := tmproto.Header{ ChainID: "HelloChain", Height: newHeight, From c7a5068668f0fdb45aa8d6324071ebcb22f4fd43 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:56:48 -0700 Subject: [PATCH 11/18] p4 --- tests/e2e/setup.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/e2e/setup.go b/tests/e2e/setup.go index 7f0995317e..a1eac9182a 100644 --- a/tests/e2e/setup.go +++ b/tests/e2e/setup.go @@ -1,13 +1,14 @@ package e2e import ( + "time" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" "bytes" "testing" e2e "github.com/cosmos/interchain-security/testutil/e2e" - providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/cosmos/interchain-security/x/ccv/utils" @@ -120,12 +121,13 @@ func (suite *CCVTestSuite) SetupTest() { suite.path.EndpointA.ClientID = providerClient // - client config + trustingPeriodFraction := suite.providerApp.GetProviderKeeper().GetTrustingPeriodFraction(suite.providerCtx()) providerUnbondingPeriod := suite.providerApp.GetStakingKeeper().UnbondingTime(suite.providerCtx()) suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = providerUnbondingPeriod - suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = providerUnbondingPeriod / providertypes.DefaultTrustingPeriodFraction + suite.path.EndpointB.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = providerUnbondingPeriod / time.Duration(trustingPeriodFraction) consumerUnbondingPeriod := utils.ComputeConsumerUnbondingPeriod(providerUnbondingPeriod) suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).UnbondingPeriod = consumerUnbondingPeriod - suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = consumerUnbondingPeriod / providertypes.DefaultTrustingPeriodFraction + suite.path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod = consumerUnbondingPeriod / time.Duration(trustingPeriodFraction) // - channel config suite.path.EndpointA.ChannelConfig.PortID = ccv.ConsumerPortID suite.path.EndpointB.ChannelConfig.PortID = ccv.ProviderPortID From 502ef976808c40381f8b9963d331c7937a25019d Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:37:28 -0700 Subject: [PATCH 12/18] change default transfer timeout period --- x/ccv/consumer/types/params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 6e7d3e3f10..37a73fc01a 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -14,7 +14,7 @@ const ( DefaultBlocksPerDistributionTransmission = 1000 // 1 week - DefaultTransferTimeoutPeriod = 1 * 7 * 24 * time.Hour + DefaultTransferTimeoutPeriod = time.Hour // The default fraction of tokens allocated to the consumer redistribution address // during distribution events. The fraction is a string representing a From 29a97593d575670741842ad766d817c8ae75e9d0 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:56:47 -0700 Subject: [PATCH 13/18] Update proposal_test.go --- x/ccv/provider/keeper/proposal_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index fc991e11f4..278f81e43b 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -641,7 +641,7 @@ func TestMakeConsumerGenesis(t *testing.T) { actualGenesis, err := providerKeeper.MakeConsumerGenesis(ctx) require.NoError(t, err) - jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 604800000000000, "consumer_redistribution_fraction":"0.75", "historical_entries":10000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` + jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 3600000000000, "consumer_redistribution_fraction":"0.75", "historical_entries":10000},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":907200000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}` var expectedGenesis consumertypes.GenesisState err = json.Unmarshal([]byte(jsonString), &expectedGenesis) From 6df90f9b505509f231baf570bb00666c318252c5 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:57:36 -0700 Subject: [PATCH 14/18] default historical entries --- tests/difference/core/driver/setup.go | 2 +- tests/e2e/normal_operations.go | 2 +- x/ccv/consumer/keeper/genesis_test.go | 4 ++-- x/ccv/consumer/keeper/params_test.go | 2 +- x/ccv/consumer/types/genesis_test.go | 4 ++-- x/ccv/consumer/types/params.go | 10 +++++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 2bb5d86a62..a4d3e7d1a0 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -479,7 +479,7 @@ func (b *Builder) createConsumerGenesis(tmConfig *ibctesting.TendermintConfig) * ccv.DefaultCCVTimeoutPeriod, consumertypes.DefaultTransferTimeoutPeriod, consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultNumHistoricalEntries, + consumertypes.DefaultHistoricalEntries, ) return consumertypes.NewInitialGenesisState(providerClient, providerConsState, valUpdates, consumertypes.SlashRequests{}, params) } diff --git a/tests/e2e/normal_operations.go b/tests/e2e/normal_operations.go index 92ea5bac16..5fc6689467 100644 --- a/tests/e2e/normal_operations.go +++ b/tests/e2e/normal_operations.go @@ -71,7 +71,7 @@ func (k CCVTestSuite) TestHistoricalInfo() { expLen: 0, }, { - height: initHeight + int64(consumertypes.DefaultNumHistoricalEntries) + 2, + height: initHeight + int64(consumertypes.DefaultHistoricalEntries) + 2, found: true, expLen: initValsetLen + 2, }, diff --git a/x/ccv/consumer/keeper/genesis_test.go b/x/ccv/consumer/keeper/genesis_test.go index 1286f51911..1818fa129e 100644 --- a/x/ccv/consumer/keeper/genesis_test.go +++ b/x/ccv/consumer/keeper/genesis_test.go @@ -57,7 +57,7 @@ func TestInitGenesis(t *testing.T) { ccv.DefaultCCVTimeoutPeriod, consumertypes.DefaultTransferTimeoutPeriod, consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultNumHistoricalEntries, + consumertypes.DefaultHistoricalEntries, ) testCases := []struct { @@ -168,7 +168,7 @@ func TestExportGenesis(t *testing.T) { ccv.DefaultCCVTimeoutPeriod, consumertypes.DefaultTransferTimeoutPeriod, consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultNumHistoricalEntries, + consumertypes.DefaultHistoricalEntries, ) // create a single validator diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 8280aec303..d7d9ba0fcb 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -25,7 +25,7 @@ func TestParams(t *testing.T) { ccv.DefaultCCVTimeoutPeriod, consumertypes.DefaultTransferTimeoutPeriod, consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultNumHistoricalEntries, + consumertypes.DefaultHistoricalEntries, ) // these are the default params, IBC suite independently sets enabled=true params := consumerKeeper.GetParams(ctx) diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index 021e7561a0..700024ad77 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -155,7 +155,7 @@ func TestValidateInitialGenesisState(t *testing.T) { 0, // CCV timeout period cannot be 0 types.DefaultTransferTimeoutPeriod, types.DefaultConsumerRedistributeFrac, - types.DefaultNumHistoricalEntries, + types.DefaultHistoricalEntries, )), true, }, @@ -283,7 +283,7 @@ func TestValidateRestartGenesisState(t *testing.T) { 0, // CCV timeout period cannot be 0 types.DefaultTransferTimeoutPeriod, types.DefaultConsumerRedistributeFrac, - types.DefaultNumHistoricalEntries, + types.DefaultHistoricalEntries, )), true, }, diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 37a73fc01a..406acf99af 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -6,6 +6,7 @@ import ( 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" ) @@ -21,8 +22,11 @@ const ( // decimal number. For example "0.75" would represent 75%. DefaultConsumerRedistributeFrac = "0.75" - // Default number of historical info entries to persist in store - DefaultNumHistoricalEntries = 10000 + // Default number of historical info entries to persist in store. + // We use the same default as the staking module, but use a signed integer + // so that negative values can be caught during parameter validation in a readable way, + // (and for consistency with other protobuf schemas defined for ccv). + DefaultHistoricalEntries = int64(stakingtypes.DefaultHistoricalEntries) ) // Reflection based keys for params subspace @@ -68,7 +72,7 @@ func DefaultParams() Params { ccvtypes.DefaultCCVTimeoutPeriod, DefaultTransferTimeoutPeriod, DefaultConsumerRedistributeFrac, - DefaultNumHistoricalEntries, + DefaultHistoricalEntries, ) } From b6568259690aae283bf5fa4b0567550d14886b6b Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:00:13 -0700 Subject: [PATCH 15/18] is negative --- x/ccv/consumer/types/params.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 406acf99af..62d0d7a081 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -153,8 +153,8 @@ func validateConsumerRedistributionFraction(i interface{}) error { if err != nil { return err } - if !dec.IsPositive() { - return fmt.Errorf("consumer redistribution fraction is not positive") + 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") From 3be7f3760e8e18f1633379bef042677b9cd7ca20 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:03:15 -0700 Subject: [PATCH 16/18] add test case --- x/ccv/provider/types/params_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index 385f835567..d1366e2c33 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -32,6 +32,9 @@ func TestValidateParams(t *testing.T) { {"0 ccv timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}, true, false), 0, 2), 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), + 10000, 0), false}, } for _, tc := range testCases { From 5cdd7a84d5bfd24859b705df95c51da53eebb149 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:09:16 -0700 Subject: [PATCH 17/18] forgot one --- tests/e2e/distribution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/distribution.go b/tests/e2e/distribution.go index 6613159b68..403268cee5 100644 --- a/tests/e2e/distribution.go +++ b/tests/e2e/distribution.go @@ -42,7 +42,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { s.Require().Equal(sdk.NewInt(100).Add(feePoolTokensOld.AmountOf(sdk.DefaultBondDenom)), feePoolTokens.AmountOf(sdk.DefaultBondDenom)) //calculate the reward for consumer and provider chain. Consumer will receive ConsumerRedistributeFrac, the rest is going to provider - frac, err := sdk.NewDecFromStr(consumertypes.DefaultConsumerRedistributeFrac) + frac, err := sdk.NewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) s.Require().NoError(err) consumerExpectedRewards, _ := sdk.NewDecCoinsFromCoins(feePoolTokens...).MulDec(frac).TruncateDecimal() providerExpectedRewards := feePoolTokens.Sub(consumerExpectedRewards) From 05d30bb6ead42de4f61f62bbfdbd10c474606f1c Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:16:01 -0700 Subject: [PATCH 18/18] comment --- x/ccv/consumer/types/params.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/ccv/consumer/types/params.go b/x/ccv/consumer/types/params.go index 62d0d7a081..ac63cf1260 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/consumer/types/params.go @@ -14,7 +14,12 @@ const ( // about 2 hr at 7.6 seconds per blocks DefaultBlocksPerDistributionTransmission = 1000 - // 1 week + // Default transfer timeout period is 1 hour, less than the default blocks + // per dist transmission * average block time. + // Since IBC token transfers do not have to be in order, it could be easier + // to reason about the distribution protocol if the previous reward times out + // before sending the next one. Note that on timeout, the transferred funds are + // added back to the pool, so the next transfer will include them as well. DefaultTransferTimeoutPeriod = time.Hour // The default fraction of tokens allocated to the consumer redistribution address