diff --git a/tests/interchain/chainsuite/chain_spec_provider.go b/tests/interchain/chainsuite/chain_spec_provider.go index 38469bcb6c..ac627df8ce 100644 --- a/tests/interchain/chainsuite/chain_spec_provider.go +++ b/tests/interchain/chainsuite/chain_spec_provider.go @@ -48,6 +48,7 @@ func providerModifiedGenesis() []cosmos.GenesisKV { cosmos.NewGenesisKV("app_state.gov.params.min_deposit.0.amount", strconv.Itoa(GovMinDepositAmount)), cosmos.NewGenesisKV("app_state.slashing.params.signed_blocks_window", strconv.Itoa(ProviderSlashingWindow)), cosmos.NewGenesisKV("app_state.slashing.params.downtime_jail_duration", DowntimeJailDuration.String()), + cosmos.NewGenesisKV("app_state.slashing.params.slash_fraction_double_sign", SlashFractionDoubleSign), cosmos.NewGenesisKV("app_state.provider.params.slash_meter_replenish_period", ProviderReplenishPeriod), cosmos.NewGenesisKV("app_state.provider.params.slash_meter_replenish_fraction", ProviderReplenishFraction), cosmos.NewGenesisKV("app_state.provider.params.blocks_per_epoch", "1"), diff --git a/tests/interchain/chainsuite/config.go b/tests/interchain/chainsuite/config.go index df77c86696..c1375e518f 100644 --- a/tests/interchain/chainsuite/config.go +++ b/tests/interchain/chainsuite/config.go @@ -11,13 +11,14 @@ import ( const ( ProviderImageName = "ghcr.io/cosmos/interchain-security" - ProviderImageVersion = "v6.1.0" + ProviderImageVersion = "v6.1.0" //todo: update image version ProviderBin = "interchain-security-pd" ProviderBech32Prefix = "cosmos" ProviderValOperPrefix = "cosmosvaloper" ProviderChainID = "ics-provider" Stake = "stake" DowntimeJailDuration = 10 * time.Second + SlashFractionDoubleSign = "0.05" ProviderSlashingWindow = 10 ProviderUnbondingTime = 10 * time.Second ProviderReplenishPeriod = "2s" @@ -37,7 +38,7 @@ const ( ChainSpawnWait = 155 * time.Second CosmosChainType = "cosmos" GovModuleAddress = "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" - TestWalletsNumber = 15 // Ensure that test accounts are used in a way that maintains the mutual independence of tests + TestWalletsNumber = 20 // Ensure that test accounts are used in a way that maintains the mutual independence of tests ) func DefaultConfigToml() testutil.Toml { diff --git a/tests/interchain/chainsuite/query_types.go b/tests/interchain/chainsuite/query_types.go index 1e7dafe9fd..05efddf405 100644 --- a/tests/interchain/chainsuite/query_types.go +++ b/tests/interchain/chainsuite/query_types.go @@ -44,6 +44,7 @@ type ConsumerResponse struct { OwnerAddress string `json:"owner_address"` Phase string `json:"phase"` PowerShapingParams PowerShapingParams `json:"power_shaping_params"` + InfractionParams InfractionParams `json:"infraction_parameters"` } type InitParams struct { @@ -75,6 +76,16 @@ type PowerShapingParams struct { ValidatorsPowerCap int `json:"validators_power_cap"` } +type InfractionParams struct { + DoubleSign SlashJailParams `json:"double_sign"` + Downtime SlashJailParams `json:"downtime"` +} + +type SlashJailParams struct { + SlashFraction string `json:"slash_fraction"` + JailDuration string `json:"jail_duration"` +} + type Params struct { Enabled bool `json:"enabled"` BlocksPerDistributionTransmission string `json:"blocks_per_distribution_transmission"` diff --git a/tests/interchain/go.mod b/tests/interchain/go.mod index 14027f4217..76845ec12c 100644 --- a/tests/interchain/go.mod +++ b/tests/interchain/go.mod @@ -6,8 +6,9 @@ toolchain go1.22.6 require ( cosmossdk.io/math v1.3.0 + github.com/cometbft/cometbft v0.38.11 github.com/cosmos/cosmos-sdk v0.50.9 - github.com/cosmos/ibc-go/v8 v8.5.0 + github.com/cosmos/ibc-go/v8 v8.5.1 github.com/cosmos/interchain-security/v6 v6.1.0 github.com/docker/docker v24.0.9+incompatible github.com/strangelove-ventures/interchaintest/v8 v8.7.1 @@ -20,7 +21,7 @@ require ( cloud.google.com/go v0.115.0 // indirect cloud.google.com/go/auth v0.6.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect + cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.1.9 // indirect cloud.google.com/go/storage v1.41.0 // indirect cosmossdk.io/api v0.7.5 // indirect @@ -64,7 +65,6 @@ require ( github.com/cockroachdb/pebble v1.1.1 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cometbft/cometbft v0.38.11 // indirect github.com/cometbft/cometbft-db v0.14.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect @@ -111,7 +111,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.3 // indirect - github.com/golang/glog v1.2.1 // indirect + github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -219,7 +219,7 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect @@ -239,9 +239,9 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/mod v0.20.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.23.0 // indirect golang.org/x/text v0.17.0 // indirect @@ -249,9 +249,9 @@ require ( golang.org/x/tools v0.23.0 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect - google.golang.org/grpc v1.66.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect @@ -276,7 +276,10 @@ replace ( github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.3 + // todo:remove this after 3f7df3506d1a is merged to main and update ics version + github.com/cosmos/interchain-security/v6 => github.com/cosmos/interchain-security/v6 v6.0.0-20241128093443-3f7df3506d1a github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/strangelove-ventures/interchaintest/v8 => github.com/stana-miric/interchaintest/v8 v8.0.0-20241022073631-60f2480aacd4 github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 + ) diff --git a/tests/interchain/go.sum b/tests/interchain/go.sum index 1cde4631bf..a894bef412 100644 --- a/tests/interchain/go.sum +++ b/tests/interchain/go.sum @@ -72,8 +72,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= +cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= @@ -390,12 +390,12 @@ github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y= github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM= github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= -github.com/cosmos/ibc-go/v8 v8.5.0 h1:OjaSXz480JT8ZuMrASxGgS7XzloZ2NuuJPwZB/fKDgE= -github.com/cosmos/ibc-go/v8 v8.5.0/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= +github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNBs= +github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/interchain-security/v6 v6.1.0 h1:ycTpT+If90nSEvRVu86ThPJxNtcmnOMjJmFC9ptd/yo= -github.com/cosmos/interchain-security/v6 v6.1.0/go.mod h1:+5zIZEzkL4yNHB/UWXCu75t6GeEgEmWHbz5OnBWiL0o= +github.com/cosmos/interchain-security/v6 v6.0.0-20241128093443-3f7df3506d1a h1:JQfqLMR0XBF40kRkMzqISVDH86frYyZ/X6xAzRwvDbw= +github.com/cosmos/interchain-security/v6 v6.0.0-20241128093443-3f7df3506d1a/go.mod h1:6DSiV2w+DuPkxP1KGFtaxpiwf8Xt2iusj8O53KCx96Q= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -562,8 +562,8 @@ github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6x github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -1154,8 +1154,8 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= @@ -1297,8 +1297,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1358,8 +1358,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1385,8 +1385,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1767,10 +1767,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 h1:6whtk83KtD3FkGrVb2hFXuQ+ZMbCNdakARIn/aHMmG8= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094/go.mod h1:Zs4wYw8z1zr6RNF4cwYb31mvN/EGaKAdQjNCF3DW6K4= -google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg= -google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1812,8 +1812,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= -google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/tests/interchain/provider_test.go b/tests/interchain/provider_test.go index 7a3a7796fb..2d54806c13 100644 --- a/tests/interchain/provider_test.go +++ b/tests/interchain/provider_test.go @@ -34,8 +34,8 @@ func (s *ProviderSuite) TestProviderCreateConsumer() { testAccKey := s.Provider.TestWallets[0].KeyName() // Confirm that a chain can be create with the minimum params (metadata) - chainName := "minParamAddConsumer" - createConsumerMsg := msgCreateConsumer(chainName, nil, nil, testAcc) + chainName := "minParamAddConsumer-1" + createConsumerMsg := msgCreateConsumer(chainName, nil, nil, nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -43,9 +43,9 @@ func (s *ProviderSuite) TestProviderCreateConsumer() { s.Require().Equal(providertypes.CONSUMER_PHASE_REGISTERED.String(), consumerChain.Phase) // Confirm that a chain can be created with initialization parameters that do not contain a spawn time - chainName = "noSpawnTimeAddConsumer" + chainName = "noSpawnTimeAddConsumer-1" powerShapingParams := powerShapingParamsTemplate() - createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(nil), powerShapingParams, testAcc) + createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(nil), powerShapingParams, nil, testAcc) consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -58,9 +58,9 @@ func (s *ProviderSuite) TestProviderCreateConsumer() { powerShapingParams.Allowlist = []string{valConsAddr} powerShapingParams.Denylist = []string{"cosmosvalcons1l9qq4m300z8c5ez86ak2mp8znftewkwgjlxh88"} - chainName = "allParamsFutureSpawnTimeAddConsumer" + chainName = "allParamsFutureSpawnTimeAddConsumer-1" spawnTimeFromNow := time.Now().Add(time.Hour) - createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(&spawnTimeFromNow), powerShapingParams, testAcc) + createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(&spawnTimeFromNow), powerShapingParams, infractionParamsTemplate(), testAcc) consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -68,9 +68,9 @@ func (s *ProviderSuite) TestProviderCreateConsumer() { s.Require().Equal(providertypes.CONSUMER_PHASE_INITIALIZED.String(), consumerChain.Phase) // Confirm that a chain can be created with all params(past spawn time) - chainName = "allParamsPastSpawnTimeAddConsumer" + chainName = "allParamsPastSpawnTimeAddConsumer-1" spawnTimeFromNow = time.Now().Add(-time.Hour) - createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(&spawnTimeFromNow), powerShapingParams, testAcc) + createConsumerMsg = msgCreateConsumer(chainName, consumerInitParamsTemplate(&spawnTimeFromNow), powerShapingParams, infractionParamsTemplate(), testAcc) consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -87,15 +87,15 @@ func (s *ProviderSuite) TestProviderCreateConsumerRejection() { testAcc := s.Provider.TestWallets[1].FormattedAddress() testAccKey := s.Provider.TestWallets[1].KeyName() - chainName := "rejectConsumer" + chainName := "rejectConsumer-1" // Confirm that a chain with TopN > 0 is rejected - createConsumerMsg := msgCreateConsumer(chainName, nil, powerShapingParamsTemplate(), testAcc) + createConsumerMsg := msgCreateConsumer(chainName, nil, powerShapingParamsTemplate(), nil, testAcc) createConsumerMsg.PowerShapingParameters.Top_N = 100 _, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().Error(err) // Confirm that a chain without the minimum params (metadata) is rejected - createConsumerMsg = msgCreateConsumer(chainName, nil, nil, testAcc) + createConsumerMsg = msgCreateConsumer(chainName, nil, nil, nil, testAcc) createConsumerMsg.Metadata = providertypes.ConsumerMetadata{} _, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().Error(err) @@ -110,10 +110,10 @@ func (s *ProviderSuite) TestProviderValidatorOptIn() { testAccKey := s.Provider.TestWallets[2].KeyName() // Scenario 1: Validators opted in, MsgUpdateConsumer called to set spawn time in the past -> chain should start. - chainName := "optInScenario1" + chainName := "optInScenario1-1" spawnTime := time.Now().Add(time.Hour) consumerInitParams := consumerInitParamsTemplate(&spawnTime) - createConsumerMsg := msgCreateConsumer(chainName, consumerInitParams, powerShapingParamsTemplate(), testAcc) + createConsumerMsg := msgCreateConsumer(chainName, consumerInitParams, powerShapingParamsTemplate(), nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -135,10 +135,10 @@ func (s *ProviderSuite) TestProviderValidatorOptIn() { s.Require().Equal(providertypes.CONSUMER_PHASE_LAUNCHED.String(), consumerChain.Phase) // Scenario 2: Validators opted in, spawn time is in the future, the chain should not start before the spawn time. - chainName = "optInScenario2" + chainName = "optInScenario2-1" spawnTime = time.Now().Add(30 * time.Second) consumerInitParams = consumerInitParamsTemplate(&spawnTime) - createConsumerMsg = msgCreateConsumer(chainName, consumerInitParams, powerShapingParamsTemplate(), testAcc) + createConsumerMsg = msgCreateConsumer(chainName, consumerInitParams, powerShapingParamsTemplate(), nil, testAcc) consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -172,8 +172,8 @@ func (s *ProviderSuite) TestProviderValidatorOptInWithKeyAssignment() { s.Require().NoError(err) // create chain and opt-in - chainName := "keyAssignment" - createConsumerMsg := msgCreateConsumer(chainName, nil, powerShapingParamsTemplate(), testAcc) + chainName := "keyAssignment-1" + createConsumerMsg := msgCreateConsumer(chainName, nil, powerShapingParamsTemplate(), nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -230,13 +230,13 @@ func (s *ProviderSuite) TestProviderUpdateConsumer() { testAcc := s.Provider.TestWallets[4].FormattedAddress() testAccKey := s.Provider.TestWallets[4].KeyName() - chainName := "updateConsumer" + chainName := "updateConsumer-1" spawnTime := time.Now().Add(-time.Hour) initParams := consumerInitParamsTemplate(&spawnTime) powerShapingParams := powerShapingParamsTemplate() // create consumer - createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, testAcc) + createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -293,11 +293,11 @@ func (s *ProviderSuite) TestProviderTransformOptInToTopN() { testAccKey := s.Provider.TestWallets[5].KeyName() // Create an opt-in chain, owner is testAcc1 - chainName := "transformOptinToTopNConsumer" + chainName := "transformOptinToTopNConsumer-1" spawnTime := time.Now().Add(time.Hour) initParams := consumerInitParamsTemplate(&spawnTime) powerShapingParams := powerShapingParamsTemplate() - createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, testAcc) + createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -364,12 +364,12 @@ func (s *ProviderSuite) TestProviderTransformOptInToTopN() { func (s *ProviderSuite) TestProviderTransformTopNtoOptIn() { testAcc := s.Provider.TestWallets[6].FormattedAddress() - chainName := "transformTopNtoOptIn" + chainName := "transformTopNtoOptIn-1" // create top N chain spawnTimeFromNow := time.Now().Add(time.Hour) powerShapingParams := powerShapingParamsTemplate() initParams := consumerInitParamsTemplate(&spawnTimeFromNow) - proposalMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, chainsuite.GovModuleAddress) + proposalMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, nil, chainsuite.GovModuleAddress) s.Require().NoError(s.Provider.ExecuteProposalMsg(s.GetContext(), proposalMsg, chainsuite.GovModuleAddress, chainName, cosmos.ProposalVoteYes, govv1.StatusPassed, false)) consumerChain, err := s.Provider.GetConsumerChainByChainId(s.GetContext(), chainName) s.Require().NoError(err) @@ -409,11 +409,11 @@ func (s *ProviderSuite) TestOptOut() { testAccKey := s.Provider.TestWallets[7].KeyName() // Add consume chain - chainName := "TestOptOut" + chainName := "TestOptOut-1" spawnTime := time.Now().Add(time.Hour) consumerInitParams := consumerInitParamsTemplate(&spawnTime) powerShapingParams := powerShapingParamsTemplate() - createConsumerMsg := msgCreateConsumer(chainName, consumerInitParams, powerShapingParams, testAcc) + createConsumerMsg := msgCreateConsumer(chainName, consumerInitParams, powerShapingParams, nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -458,11 +458,11 @@ func (s *ProviderSuite) TestProviderRemoveConsumer() { testAccKey := s.Provider.TestWallets[8].KeyName() // Test removing a chain - chainName := "removeConsumer" + chainName := "removeConsumer-1" spawnTime := time.Now().Add(time.Hour) initParams := consumerInitParamsTemplate(&spawnTime) powerShapingParams := powerShapingParamsTemplate() - createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, testAcc) + createConsumerMsg := msgCreateConsumer(chainName, initParams, powerShapingParams, nil, testAcc) consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) s.Require().NoError(err) consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) @@ -515,8 +515,8 @@ func (s *ProviderSuite) TestProviderOwnerChecks() { testAccKey1 := s.Provider.TestWallets[9].KeyName() testAccKey2 := s.Provider.TestWallets[10].KeyName() // Create an opt-in chain - chainName := "providerOwnerChecks" - createMsg := msgCreateConsumer(chainName, nil, nil, testAcc1) + chainName := "providerOwnerChecks-1" + createMsg := msgCreateConsumer(chainName, nil, nil, nil, testAcc1) // create consumer with owner set to test account 1 consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createMsg, testAccKey1) @@ -612,3 +612,127 @@ func (s *ProviderSuite) TestProviderOwnerChecks() { s.Require().Equal(powerShapingParams.Top_N, uint32(consumerChain.PowerShapingParams.TopN)) s.Require().Equal(chainsuite.GovModuleAddress, consumerChain.OwnerAddress) } + +// Tests adding and updating infraction parameters with MsgCreateConsumer, MsgUpdateConsumer +func (s *ProviderSuite) TestInfractionParameters() { + testAcc := s.Provider.TestWallets[11].FormattedAddress() + testAccKey := s.Provider.TestWallets[11].KeyName() + defaultInfractionParams := defaultInfractionParams() + + // Confirm that a default params are used if infraction params are not set (taken from provider) + chainName := "defaultInfractionParams-1" + createConsumerMsg := msgCreateConsumer(chainName, nil, nil, nil, testAcc) + consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) + s.Require().NoError(err) + consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + s.Require().Equal(providertypes.CONSUMER_PHASE_REGISTERED.String(), consumerChain.Phase) + s.Require().Equal(defaultInfractionParams, convertJsonToInfractionParameters(consumerChain.InfractionParams)) + + // update infraction params for a non launched chain + upgradeMsg := &providertypes.MsgUpdateConsumer{ + Owner: testAcc, + ConsumerId: consumerChain.ConsumerID, + NewOwnerAddress: testAcc, + InfractionParameters: infractionParamsTemplate(), + } + s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + // chain is in pre-launched phase, params are updated immediatelly + s.Require().Equal(infractionParamsTemplate(), convertJsonToInfractionParameters(consumerChain.InfractionParams)) + + // Confirm that a chain can be created with custom infrection parameters set only for double sign + chainName = "doubleSignInfractionParams-1" + infractionParams := infractionParamsTemplate() + infractionParams.Downtime = nil + createConsumerMsg = msgCreateConsumer(chainName, nil, nil, infractionParams, testAcc) + consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) + s.Require().NoError(err) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + response := convertJsonToInfractionParameters(consumerChain.InfractionParams) + s.Require().Equal(infractionParams.DoubleSign, response.DoubleSign) + s.Require().Equal(defaultInfractionParams.Downtime, response.Downtime) + + // Confirm that a chain can be created with custom infrection parameters set only for downtime + chainName = "downtimeInfractionParams-1" + infractionParams = infractionParamsTemplate() + infractionParams.DoubleSign = nil + createConsumerMsg = msgCreateConsumer(chainName, nil, nil, infractionParams, testAcc) + consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) + s.Require().NoError(err) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + response = convertJsonToInfractionParameters(consumerChain.InfractionParams) + s.Require().Equal(infractionParams.Downtime, response.Downtime) + s.Require().Equal(defaultInfractionParams.DoubleSign, response.DoubleSign) + + // Confirm that a chain can be created with custom infrection parameters set for both downtime and doublesign + chainName = "infractionParams-1" + spawnTime := time.Now().Add(time.Hour) + consumerInitParams := consumerInitParamsTemplate(&spawnTime) + infractionParams = infractionParamsTemplate() + createConsumerMsg = msgCreateConsumer(chainName, consumerInitParams, powerShapingParamsTemplate(), infractionParams, testAcc) + consumerId, err = s.Provider.CreateConsumer(s.GetContext(), createConsumerMsg, testAccKey) + s.Require().NoError(err) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + s.Require().NoError(s.Provider.OptIn(s.GetContext(), consumerChain.ConsumerID, 0)) + consumerInitParams.SpawnTime = time.Now() + upgradeMsg = &providertypes.MsgUpdateConsumer{ + Owner: testAcc, + ConsumerId: consumerChain.ConsumerID, + NewOwnerAddress: testAcc, + InitializationParameters: consumerInitParams, + PowerShapingParameters: powerShapingParamsTemplate(), + } + s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + // chain is started + s.Require().Equal(providertypes.CONSUMER_PHASE_LAUNCHED.String(), consumerChain.Phase) + s.Require().Equal(infractionParams, convertJsonToInfractionParameters(consumerChain.InfractionParams)) + + // update infraction params for a launched chain + upgradeMsg = &providertypes.MsgUpdateConsumer{ + Owner: testAcc, + ConsumerId: consumerChain.ConsumerID, + NewOwnerAddress: testAcc, + InfractionParameters: defaultInfractionParams, + } + s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + s.Require().Equal(infractionParamsTemplate(), convertJsonToInfractionParameters(consumerChain.InfractionParams)) + time.Sleep(chainsuite.ProviderUnbondingTime) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + // chain is in launched phase, parameters are queued and updated after provider unbonding time + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + s.Require().Equal(defaultInfractionParams, convertJsonToInfractionParameters(consumerChain.InfractionParams)) + + // test cancelling infraction params update + upgradeMsg = &providertypes.MsgUpdateConsumer{ + Owner: testAcc, + ConsumerId: consumerChain.ConsumerID, + NewOwnerAddress: testAcc, + InfractionParameters: infractionParamsTemplate(), + } + // current value is defaultInfractionParams + // - first MsgUpdateConsumer will queue parameters infractionParamsTemplate to be applied after undonding period + // - second MsgUpdateConsumer is submitted before unbonding period is expired, so the update will be cancelled because the params in the second msg + // are the same as the current infraction params for that chain + s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + upgradeMsg.InfractionParameters = defaultInfractionParams + s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey)) + time.Sleep(chainsuite.ProviderUnbondingTime) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Provider)) + consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId) + s.Require().NoError(err) + s.Require().Equal(defaultInfractionParams, convertJsonToInfractionParameters(consumerChain.InfractionParams)) +} diff --git a/tests/interchain/provider_utils.go b/tests/interchain/provider_utils.go index cc4ebdb5f7..fb372f3cfc 100644 --- a/tests/interchain/provider_utils.go +++ b/tests/interchain/provider_utils.go @@ -1,8 +1,10 @@ package interchain import ( + "cosmos/interchain-security/tests/interchain/chainsuite" "time" + "cosmossdk.io/math" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" providertypes "github.com/cosmos/interchain-security/v6/x/ccv/provider/types" ) @@ -11,6 +13,7 @@ func msgCreateConsumer( chainId string, initParams *providertypes.ConsumerInitializationParameters, powerParams *providertypes.PowerShapingParameters, + infractionParams *providertypes.InfractionParameters, submiter string) *providertypes.MsgCreateConsumer { consumerMetadata := providertypes.ConsumerMetadata{ Name: chainId, @@ -24,12 +27,13 @@ func msgCreateConsumer( Metadata: consumerMetadata, InitializationParameters: initParams, PowerShapingParameters: powerParams, + InfractionParameters: infractionParams, } } func consumerInitParamsTemplate(spawnTime *time.Time) *providertypes.ConsumerInitializationParameters { initParams := &providertypes.ConsumerInitializationParameters{ - InitialHeight: clienttypes.NewHeight(0, 1), + InitialHeight: clienttypes.NewHeight(1, 1), GenesisHash: []byte("gen_hash"), BinaryHash: []byte("bin_hash"), UnbondingPeriod: 10 * time.Second, @@ -59,3 +63,45 @@ func powerShapingParamsTemplate() *providertypes.PowerShapingParameters { AllowInactiveVals: true, } } + +func infractionParamsTemplate() *providertypes.InfractionParameters { + return &providertypes.InfractionParameters{ + DoubleSign: &providertypes.SlashJailParameters{ + JailDuration: 1200 * time.Second, + SlashFraction: math.LegacyNewDecWithPrec(7, 2), // 0.07 + }, + Downtime: &providertypes.SlashJailParameters{ + JailDuration: 2400 * time.Second, + SlashFraction: math.LegacyNewDecWithPrec(8, 2), // 0.08 + }, + } +} + +func defaultInfractionParams() *providertypes.InfractionParameters { + return &providertypes.InfractionParameters{ + DoubleSign: &providertypes.SlashJailParameters{ + JailDuration: time.Duration(1<<63 - 1), // the largest value a time.Duration can hold 9223372036854775807 (approximately 292 years) + SlashFraction: math.LegacyNewDecWithPrec(5, 2), // 0.05 + }, + Downtime: &providertypes.SlashJailParameters{ + JailDuration: chainsuite.DowntimeJailDuration, + SlashFraction: math.LegacyNewDec(0), // no slashing for downtime on the consumer + }, + } +} + +func convertJsonToInfractionParameters(jsonParams chainsuite.InfractionParams) *providertypes.InfractionParameters { + doubleSignJailDuration, _ := time.ParseDuration(jsonParams.DoubleSign.JailDuration) + downtimeJailDuration, _ := time.ParseDuration(jsonParams.Downtime.JailDuration) + + return &providertypes.InfractionParameters{ + DoubleSign: &providertypes.SlashJailParameters{ + SlashFraction: math.LegacyMustNewDecFromStr(jsonParams.DoubleSign.SlashFraction), + JailDuration: doubleSignJailDuration, + }, + Downtime: &providertypes.SlashJailParameters{ + SlashFraction: math.LegacyMustNewDecFromStr(jsonParams.Downtime.SlashFraction), + JailDuration: downtimeJailDuration, + }, + } +}