diff --git a/go.mod b/go.mod index 6fd0f70305..e9ec34b40a 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,10 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) -require cosmossdk.io/errors v1.0.0-beta.7 +require ( + cosmossdk.io/errors v1.0.0-beta.7 + github.com/cosmos/interchain-security v1.0.0 +) require ( cosmossdk.io/api v0.2.6 // indirect @@ -85,7 +88,6 @@ require ( github.com/golang/glog v1.0.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -94,7 +96,6 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect @@ -115,8 +116,7 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/onsi/ginkgo v1.16.4 // indirect - github.com/onsi/gomega v1.20.0 // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect diff --git a/go.sum b/go.sum index 43b9f519c0..df6ac230f6 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,8 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= -github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= @@ -242,6 +242,8 @@ github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go/v4 v4.4.0 h1:OEsSLBP1yoLzONQ/1Tf44ateEgS2YHyhTkecvuenk7k= github.com/cosmos/ibc-go/v4 v4.4.0/go.mod h1:FYZ7ublN6jMojaRND1ST0bTfLKfQnlaxqJbUn7WhzvU= +github.com/cosmos/interchain-security v1.0.0 h1:xNQjjigqH3mzEKSGQhAhKy8I0TA8XR2z5rRTxRBKK3o= +github.com/cosmos/interchain-security v1.0.0/go.mod h1:J9SbXUJT1GSe+mZy+MDCxtuAfbhwCKBEJRYnfjXsE8Q= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -381,7 +383,6 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -462,9 +463,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -535,9 +535,8 @@ github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -776,15 +775,13 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= -github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= @@ -1266,7 +1263,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1371,7 +1367,6 @@ golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1384,6 +1379,7 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 37099e4385..54c1cd5577 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -92,6 +92,8 @@ func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { k.standaloneStakingKeeper = sk } +// SetParamSpace sets the param space for the consumer keeper. +// Note: this is only used for testing! func (k *Keeper) SetParamSpace(ctx sdk.Context, ps paramtypes.Subspace) { k.paramStore = ps } diff --git a/x/ccv/consumer/keeper/migration.go b/x/ccv/consumer/keeper/migration.go index 8e7ad1e8d5..be22cbe4b8 100644 --- a/x/ccv/consumer/keeper/migration.go +++ b/x/ccv/consumer/keeper/migration.go @@ -5,8 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" + v2consumertypes "github.com/cosmos/interchain-security/v2/x/ccv/consumer/types" + v1consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" + v1ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" ) // Migrator is a struct for handling in-place store migrations. @@ -32,27 +33,27 @@ func (m Migrator) Migratev1p0To1p3(ctx sdk.Context) error { func MigrateParamsv1p0To1p3(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { // Get old params var enabled bool - paramsSubspace.Get(ctx, consumertypes.KeyEnabled, &enabled) + paramsSubspace.Get(ctx, v1consumertypes.KeyEnabled, &enabled) var blocksPerDistributionTransmission int64 - paramsSubspace.Get(ctx, consumertypes.KeyBlocksPerDistributionTransmission, &blocksPerDistributionTransmission) + paramsSubspace.Get(ctx, v1consumertypes.KeyBlocksPerDistributionTransmission, &blocksPerDistributionTransmission) var distributionTransmissionChannel string - paramsSubspace.Get(ctx, consumertypes.KeyDistributionTransmissionChannel, &distributionTransmissionChannel) + paramsSubspace.Get(ctx, v1consumertypes.KeyDistributionTransmissionChannel, &distributionTransmissionChannel) var providerFeePoolAddrStr string - paramsSubspace.Get(ctx, consumertypes.KeyProviderFeePoolAddrStr, &providerFeePoolAddrStr) + paramsSubspace.Get(ctx, v1consumertypes.KeyProviderFeePoolAddrStr, &providerFeePoolAddrStr) var ccvTimeoutPeriod time.Duration - paramsSubspace.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &ccvTimeoutPeriod) + paramsSubspace.Get(ctx, v1ccvtypes.KeyCCVTimeoutPeriod, &ccvTimeoutPeriod) var transferTimeoutPeriod time.Duration - paramsSubspace.Get(ctx, consumertypes.KeyTransferTimeoutPeriod, &transferTimeoutPeriod) + paramsSubspace.Get(ctx, v1consumertypes.KeyTransferTimeoutPeriod, &transferTimeoutPeriod) var consumerRedistributionFrac string - paramsSubspace.Get(ctx, consumertypes.KeyConsumerRedistributionFrac, &consumerRedistributionFrac) + paramsSubspace.Get(ctx, v1consumertypes.KeyConsumerRedistributionFrac, &consumerRedistributionFrac) var historicalEntries int64 - paramsSubspace.Get(ctx, consumertypes.KeyHistoricalEntries, &historicalEntries) + paramsSubspace.Get(ctx, v1consumertypes.KeyHistoricalEntries, &historicalEntries) var unbondingPeriod time.Duration - paramsSubspace.Get(ctx, consumertypes.KeyConsumerUnbondingPeriod, &unbondingPeriod) + paramsSubspace.Get(ctx, v1consumertypes.KeyConsumerUnbondingPeriod, &unbondingPeriod) // Recycle old params, set new params to default values - defaultParams := consumertypes.DefaultParams() - newParams := consumertypes.NewParams( + defaultParams := v2consumertypes.DefaultParams() + newParams := v2consumertypes.NewParams( enabled, blocksPerDistributionTransmission, distributionTransmissionChannel, diff --git a/x/ccv/consumer/keeper/migration_test.go b/x/ccv/consumer/keeper/migration_test.go index c2c3f1d5bd..75b814e255 100644 --- a/x/ccv/consumer/keeper/migration_test.go +++ b/x/ccv/consumer/keeper/migration_test.go @@ -10,9 +10,10 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" + v2consumerkeeper "github.com/cosmos/interchain-security/v2/x/ccv/consumer/keeper" + v2consumertypes "github.com/cosmos/interchain-security/v2/x/ccv/consumer/types" + v1consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" + v1ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -42,28 +43,28 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { ) // Note that new param key table is set in keeper constructor - subspace = subspace.WithKeyTable(v1p0p0KeyTable()) + subspace = subspace.WithKeyTable(v1consumertypes.ParamKeyTable()) // Set 9 params from v1.0.0 - subspace.Set(ctx, consumertypes.KeyEnabled, true) - subspace.Set(ctx, consumertypes.KeyBlocksPerDistributionTransmission, int64(10)) - subspace.Set(ctx, consumertypes.KeyDistributionTransmissionChannel, "channel-0") - subspace.Set(ctx, consumertypes.KeyProviderFeePoolAddrStr, "cosmos17p3erf5gv2436fd4vyjwmudakts563a497syuz") - subspace.Set(ctx, ccvtypes.KeyCCVTimeoutPeriod, time.Hour) - subspace.Set(ctx, consumertypes.KeyTransferTimeoutPeriod, time.Hour) - subspace.Set(ctx, consumertypes.KeyConsumerRedistributionFrac, "0.5") - subspace.Set(ctx, consumertypes.KeyHistoricalEntries, int64(10)) - subspace.Set(ctx, consumertypes.KeyConsumerUnbondingPeriod, time.Hour) + subspace.Set(ctx, v1consumertypes.KeyEnabled, true) + subspace.Set(ctx, v1consumertypes.KeyBlocksPerDistributionTransmission, int64(10)) + subspace.Set(ctx, v1consumertypes.KeyDistributionTransmissionChannel, "channel-0") + subspace.Set(ctx, v1consumertypes.KeyProviderFeePoolAddrStr, "cosmos17p3erf5gv2436fd4vyjwmudakts563a497syuz") + subspace.Set(ctx, v1ccvtypes.KeyCCVTimeoutPeriod, time.Hour) + subspace.Set(ctx, v1consumertypes.KeyTransferTimeoutPeriod, time.Hour) + subspace.Set(ctx, v1consumertypes.KeyConsumerRedistributionFrac, "0.5") + subspace.Set(ctx, v1consumertypes.KeyHistoricalEntries, int64(10)) + subspace.Set(ctx, v1consumertypes.KeyConsumerUnbondingPeriod, time.Hour) // Confirm 3 new params cannot be set with old key table require.Panics(t, func() { - subspace.Set(ctx, consumertypes.KeySoftOptOutThreshold, "0.05") + subspace.Set(ctx, v2consumertypes.KeySoftOptOutThreshold, "0.05") }) require.Panics(t, func() { - subspace.Set(ctx, consumertypes.KeyRewardDenoms, []string{"untrn"}) + subspace.Set(ctx, v2consumertypes.KeyRewardDenoms, []string{"untrn"}) }) require.Panics(t, func() { - subspace.Set(ctx, consumertypes.KeyProviderRewardDenoms, []string{"uatom"}) + subspace.Set(ctx, v2consumertypes.KeyProviderRewardDenoms, []string{"uatom"}) }) // Now create new subspace, mocking an upgrade where app initialization happens again @@ -72,13 +73,13 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { storeKey, memStoreKey, paramtypes.ModuleName, - ).WithKeyTable(consumertypes.ParamKeyTable()) // Use new key table, this would be set in keeper constructor + ).WithKeyTable(v2consumertypes.ParamKeyTable()) // Use v2 key table, this would be set in keeper constructor upon app init // Run migration - consumerkeeper.MigrateParamsv1p0To1p3(ctx, subspace) + v2consumerkeeper.MigrateParamsv1p0To1p3(ctx, subspace) - // Use keeper to confirm params are set correctly - keeper := consumerkeeper.Keeper{} + // Use v2 keeper to confirm params are set correctly + keeper := v2consumerkeeper.Keeper{} keeper.SetParamSpace(ctx, subspace) params := keeper.GetParams(ctx) @@ -106,49 +107,3 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { require.Equal(t, []string{"untrn"}, keeper.GetRewardDenoms(ctx)) require.Equal(t, []string{"uatom"}, keeper.GetProviderRewardDenoms(ctx)) } - -// -// Note: the following methods and struct could be removed if v1.3.0 is actually defined as v2.0.0 -// and we bump the go.mod package name accordingly -// - -// v1p0p0Params is a copy of the ParamKeyTable method from v1.0.0 -func v1p0p0KeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&v1p0p0Params{}) -} - -// ParamSetPairs implements params.ParamSet for v1p0p0Params -func (p *v1p0p0Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(consumertypes.KeyEnabled, p.Enabled, ccvtypes.ValidateBool), - paramtypes.NewParamSetPair(consumertypes.KeyBlocksPerDistributionTransmission, - p.BlocksPerDistributionTransmission, ccvtypes.ValidatePositiveInt64), - paramtypes.NewParamSetPair(consumertypes.KeyDistributionTransmissionChannel, - p.DistributionTransmissionChannel, consumertypes.ValidateDistributionTransmissionChannel), - paramtypes.NewParamSetPair(consumertypes.KeyProviderFeePoolAddrStr, - p.ProviderFeePoolAddrStr, consumertypes.ValidateProviderFeePoolAddrStr), - paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, - p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(consumertypes.KeyTransferTimeoutPeriod, - p.TransferTimeoutPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(consumertypes.KeyConsumerRedistributionFrac, - p.ConsumerRedistributionFraction, ccvtypes.ValidateStringFraction), - paramtypes.NewParamSetPair(consumertypes.KeyHistoricalEntries, - p.HistoricalEntries, ccvtypes.ValidatePositiveInt64), - paramtypes.NewParamSetPair(consumertypes.KeyConsumerUnbondingPeriod, - p.UnbondingPeriod, ccvtypes.ValidateDuration), - } -} - -// v1p0p0Params is a copy of the Params struct from v1.0.0 -type v1p0p0Params struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - BlocksPerDistributionTransmission int64 `protobuf:"varint,2,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` - 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"` - CcvTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` - TransferTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"` - ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` - HistoricalEntries int64 `protobuf:"varint,8,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` - UnbondingPeriod time.Duration `protobuf:"bytes,9,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` -} diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index b0bd2a1464..cc0013d7dc 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -82,6 +82,8 @@ func NewKeeper( return k } +// SetParamSpace sets the param space for the provider keeper. +// Note: this is only used for testing! func (k *Keeper) SetParamSpace(ctx sdk.Context, ps paramtypes.Subspace) { k.paramSpace = ps } diff --git a/x/ccv/provider/keeper/migration.go b/x/ccv/provider/keeper/migration.go index 3cd45600b9..9b83478cdf 100644 --- a/x/ccv/provider/keeper/migration.go +++ b/x/ccv/provider/keeper/migration.go @@ -6,19 +6,21 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ibctmtypes "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types" - providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" + v2providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types" + v1ccvtypes "github.com/cosmos/interchain-security/v2/x/ccv/types" + v2ccvtypes "github.com/cosmos/interchain-security/v2/x/ccv/types" + v1providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ) // Migrator is a struct for handling in-place store migrations. type Migrator struct { ccvProviderKeeper Keeper - stakingKeeper ccvtypes.StakingKeeper + stakingKeeper v2ccvtypes.StakingKeeper ccvProviderParamSpace paramtypes.Subspace } // NewMigrator returns a new Migrator. -func NewMigrator(ccvProviderKeeper Keeper, stakingKeeper ccvtypes.StakingKeeper, +func NewMigrator(ccvProviderKeeper Keeper, stakingKeeper v2ccvtypes.StakingKeeper, ccvProviderParamSpace paramtypes.Subspace) Migrator { return Migrator{ccvProviderKeeper: ccvProviderKeeper, ccvProviderParamSpace: ccvProviderParamSpace} } @@ -41,24 +43,24 @@ func (m Migrator) Migratev1p0To1p3(ctx sdk.Context) error { func MigrateParamsv1p0To1p3(ctx sdk.Context, paramsSubspace paramtypes.Subspace, consumerRewardDenomRegistrationFee sdk.Coin) { // Get old params var templateClient ibctmtypes.ClientState - paramsSubspace.Get(ctx, providertypes.KeyTemplateClient, &templateClient) + paramsSubspace.Get(ctx, v1providertypes.KeyTemplateClient, &templateClient) var trustingPeriodFraction string - paramsSubspace.Get(ctx, providertypes.KeyTrustingPeriodFraction, &trustingPeriodFraction) + paramsSubspace.Get(ctx, v1providertypes.KeyTrustingPeriodFraction, &trustingPeriodFraction) var ccvTimeoutPeriod time.Duration - paramsSubspace.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &ccvTimeoutPeriod) + paramsSubspace.Get(ctx, v1ccvtypes.KeyCCVTimeoutPeriod, &ccvTimeoutPeriod) var initTimeoutPeriod time.Duration - paramsSubspace.Get(ctx, providertypes.KeyInitTimeoutPeriod, &initTimeoutPeriod) + paramsSubspace.Get(ctx, v1providertypes.KeyInitTimeoutPeriod, &initTimeoutPeriod) var vscTimeoutPeriod time.Duration - paramsSubspace.Get(ctx, providertypes.KeyVscTimeoutPeriod, &vscTimeoutPeriod) + paramsSubspace.Get(ctx, v1providertypes.KeyVscTimeoutPeriod, &vscTimeoutPeriod) var slashMeterReplenishPeriod time.Duration - paramsSubspace.Get(ctx, providertypes.KeySlashMeterReplenishPeriod, &slashMeterReplenishPeriod) + paramsSubspace.Get(ctx, v1providertypes.KeySlashMeterReplenishPeriod, &slashMeterReplenishPeriod) var slashMeterReplenishFraction string - paramsSubspace.Get(ctx, providertypes.KeySlashMeterReplenishFraction, &slashMeterReplenishFraction) + paramsSubspace.Get(ctx, v1providertypes.KeySlashMeterReplenishFraction, &slashMeterReplenishFraction) var maxThrottledPackets int64 - paramsSubspace.Get(ctx, providertypes.KeyMaxThrottledPackets, &maxThrottledPackets) + paramsSubspace.Get(ctx, v1providertypes.KeyMaxThrottledPackets, &maxThrottledPackets) // Recycle old params, set new param to input value - newParams := providertypes.NewParams( + newParams := v2providertypes.NewParams( &templateClient, trustingPeriodFraction, ccvTimeoutPeriod, diff --git a/x/ccv/provider/keeper/migration_test.go b/x/ccv/provider/keeper/migration_test.go index 1180e36052..66f238d6ad 100644 --- a/x/ccv/provider/keeper/migration_test.go +++ b/x/ccv/provider/keeper/migration_test.go @@ -10,10 +10,10 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - types2 "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types" - providerkeeper "github.com/cosmos/interchain-security/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" + v2providerkeeper "github.com/cosmos/interchain-security/v2/x/ccv/provider/keeper" + v2providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types" + v1providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" + v1ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -43,21 +43,21 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { ) // Note that new param key table is set in keeper constructor - subspace = subspace.WithKeyTable(v1p0p0KeyTable()) + subspace = subspace.WithKeyTable(v1providertypes.ParamKeyTable()) // Set 8 params from v1.0.0 - subspace.Set(ctx, providertypes.KeyTemplateClient, providertypes.DefaultParams().TemplateClient) - subspace.Set(ctx, providertypes.KeyTrustingPeriodFraction, "0.75") - subspace.Set(ctx, ccvtypes.KeyCCVTimeoutPeriod, time.Hour) - subspace.Set(ctx, providertypes.KeyInitTimeoutPeriod, time.Hour) - subspace.Set(ctx, providertypes.KeyVscTimeoutPeriod, time.Hour) - subspace.Set(ctx, providertypes.KeySlashMeterReplenishPeriod, time.Hour) - subspace.Set(ctx, providertypes.KeySlashMeterReplenishFraction, "0.5") - subspace.Set(ctx, providertypes.KeyMaxThrottledPackets, int64(10)) + subspace.Set(ctx, v1providertypes.KeyTemplateClient, v1providertypes.DefaultParams().TemplateClient) + subspace.Set(ctx, v1providertypes.KeyTrustingPeriodFraction, "0.75") + subspace.Set(ctx, v1ccvtypes.KeyCCVTimeoutPeriod, time.Hour) + subspace.Set(ctx, v1providertypes.KeyInitTimeoutPeriod, time.Hour) + subspace.Set(ctx, v1providertypes.KeyVscTimeoutPeriod, time.Hour) + subspace.Set(ctx, v1providertypes.KeySlashMeterReplenishPeriod, time.Hour) + subspace.Set(ctx, v1providertypes.KeySlashMeterReplenishFraction, "0.5") + subspace.Set(ctx, v1providertypes.KeyMaxThrottledPackets, int64(10)) // Confirm new param cannot be set with old key table require.Panics(t, func() { - subspace.Set(ctx, providertypes.KeyConsumerRewardDenomRegistrationFee, sdk.NewInt64Coin("uatom", 100)) + subspace.Set(ctx, v2providertypes.KeyConsumerRewardDenomRegistrationFee, sdk.NewInt64Coin("uatom", 100)) }) // Now create new subspace, mocking an upgrade where app initialization happens again @@ -66,17 +66,17 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { storeKey, memStoreKey, paramtypes.ModuleName, - ).WithKeyTable(providertypes.ParamKeyTable()) // Use new key table, this would be set in keeper constructor + ).WithKeyTable(v2providertypes.ParamKeyTable()) // Use v2 key table, this would be set in keeper constructor upon app init // Run migration - providerkeeper.MigrateParamsv1p0To1p3(ctx, subspace, sdk.NewCoin("uatom", sdk.NewInt(100000))) + v2providerkeeper.MigrateParamsv1p0To1p3(ctx, subspace, sdk.NewCoin("uatom", sdk.NewInt(100000))) // Use keeper to confirm params are set correctly - keeper := providerkeeper.Keeper{} + keeper := v2providerkeeper.Keeper{} keeper.SetParamSpace(ctx, subspace) params := keeper.GetParams(ctx) - require.Equal(t, providertypes.DefaultParams().TemplateClient, params.TemplateClient) + require.Equal(t, v2providertypes.DefaultParams().TemplateClient, params.TemplateClient) require.Equal(t, "0.75", params.TrustingPeriodFraction) require.Equal(t, time.Hour, params.CcvTimeoutPeriod) require.Equal(t, time.Hour, params.InitTimeoutPeriod) @@ -87,44 +87,8 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) { // New param should be set require.Equal(t, sdk.NewCoin("uatom", sdk.NewInt(100000)), params.ConsumerRewardDenomRegistrationFee) - // Set new params to other values + // Set new param to other values params.ConsumerRewardDenomRegistrationFee = sdk.NewCoin("uatom", sdk.NewInt(1000000000)) keeper.SetParams(ctx, params) require.Equal(t, sdk.NewCoin("uatom", sdk.NewInt(1000000000)), keeper.GetParams(ctx).ConsumerRewardDenomRegistrationFee) } - -// -// Note: the following methods and struct could be removed if v1.3.0 is actually defined as v2.0.0 -// and we bump the go.mod package name accordingly -// - -// v1p0p0Params is a copy of the ParamKeyTable method from v1.0.0 -func v1p0p0KeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&v1p0p0Params{}) -} - -// ParamSetPairs implements params.ParamSet for v1p0p0Params -func (p *v1p0p0Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(providertypes.KeyTemplateClient, p.TemplateClient, providertypes.ValidateTemplateClient), - paramtypes.NewParamSetPair(providertypes.KeyTrustingPeriodFraction, p.TrustingPeriodFraction, ccvtypes.ValidateStringFraction), - paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(providertypes.KeyInitTimeoutPeriod, p.InitTimeoutPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(providertypes.KeyVscTimeoutPeriod, p.VscTimeoutPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(providertypes.KeySlashMeterReplenishPeriod, p.SlashMeterReplenishPeriod, ccvtypes.ValidateDuration), - paramtypes.NewParamSetPair(providertypes.KeySlashMeterReplenishFraction, p.SlashMeterReplenishFraction, ccvtypes.ValidateStringFraction), - paramtypes.NewParamSetPair(providertypes.KeyMaxThrottledPackets, p.MaxThrottledPackets, ccvtypes.ValidatePositiveInt64), - } -} - -// v1p0p0Params is a copy of the Params struct from v1.0.0 -type v1p0p0Params struct { - TemplateClient *types2.ClientState `protobuf:"bytes,1,opt,name=template_client,json=templateClient,proto3" json:"template_client,omitempty"` - TrustingPeriodFraction string `protobuf:"bytes,2,opt,name=trusting_period_fraction,json=trustingPeriodFraction,proto3" json:"trusting_period_fraction,omitempty"` - CcvTimeoutPeriod time.Duration `protobuf:"bytes,3,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` - InitTimeoutPeriod time.Duration `protobuf:"bytes,4,opt,name=init_timeout_period,json=initTimeoutPeriod,proto3,stdduration" json:"init_timeout_period"` - VscTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=vsc_timeout_period,json=vscTimeoutPeriod,proto3,stdduration" json:"vsc_timeout_period"` - SlashMeterReplenishPeriod time.Duration `protobuf:"bytes,6,opt,name=slash_meter_replenish_period,json=slashMeterReplenishPeriod,proto3,stdduration" json:"slash_meter_replenish_period"` - SlashMeterReplenishFraction string `protobuf:"bytes,7,opt,name=slash_meter_replenish_fraction,json=slashMeterReplenishFraction,proto3" json:"slash_meter_replenish_fraction,omitempty"` - MaxThrottledPackets int64 `protobuf:"varint,8,opt,name=max_throttled_packets,json=maxThrottledPackets,proto3" json:"max_throttled_packets,omitempty"` -}