From 07ea6288bdbc8dc610bc1c5bb1d2c1ba268e0ddd Mon Sep 17 00:00:00 2001 From: bernd-m <43466467+bermuell@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:55:45 +0200 Subject: [PATCH] test: update e2e permissionless tests (#2251) * adding more permissionless tests * fix changelog filename * Adapt e2e tests to new permissionless logic * Revert "fix changelog filename" This reverts commit 636ed040179e1a46815370130cc5bae3d5cec791. * fix filename on changelog * adapt e2e to allow vals opt in on chains with same ChainId * Revert "adding more permissionless tests" This reverts commit cc90e859fba92862e431542e11e5583d660c8a7f. * rename 2171-permissionless-ICS.md.md --- ...s-ICS.md.md => 2171-permissionless-ICS.md} | 0 ...s-ICS.md.md => 2171-permissionless-ICS.md} | 0 tests/e2e/actions.go | 149 ++++++------- tests/e2e/state.go | 2 +- tests/e2e/steps_partial_set_security.go | 195 +++++++++++------- tests/e2e/steps_permissionless_ics.go | 105 +++------- tests/e2e/steps_start_chains.go | 20 +- 7 files changed, 244 insertions(+), 227 deletions(-) rename .changelog/unreleased/api-breaking/provider/{2171-permissionless-ICS.md.md => 2171-permissionless-ICS.md} (100%) rename .changelog/unreleased/features/provider/{2171-permissionless-ICS.md.md => 2171-permissionless-ICS.md} (100%) diff --git a/.changelog/unreleased/api-breaking/provider/2171-permissionless-ICS.md.md b/.changelog/unreleased/api-breaking/provider/2171-permissionless-ICS.md similarity index 100% rename from .changelog/unreleased/api-breaking/provider/2171-permissionless-ICS.md.md rename to .changelog/unreleased/api-breaking/provider/2171-permissionless-ICS.md diff --git a/.changelog/unreleased/features/provider/2171-permissionless-ICS.md.md b/.changelog/unreleased/features/provider/2171-permissionless-ICS.md similarity index 100% rename from .changelog/unreleased/features/provider/2171-permissionless-ICS.md.md rename to .changelog/unreleased/features/provider/2171-permissionless-ICS.md diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 72bdb9b998..ac3bc1ed7a 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -267,79 +267,81 @@ func (tr Chain) submitTextProposal( } type UpdateConsumerChainAction struct { - Chain ChainID - From ValidatorID - ConsumerChain ChainID - NewOwner string + Chain ChainID + From ValidatorID + ConsumerChain ChainID + NewOwner string + InitParams *InitializationParameters + PowerShapingParams *PowerShapingParameters +} + +type InitializationParameters struct { InitialHeight clienttypes.Height SpawnTime uint DistributionChannel string - TopN uint32 - ValidatorsPowerCap uint32 - ValidatorSetCap uint32 - Allowlist []string - Denylist []string - MinStake uint64 - AllowInactiveVals bool +} + +type PowerShapingParameters struct { + TopN uint32 + ValidatorsPowerCap uint32 + ValidatorSetCap uint32 + Allowlist []string + Denylist []string + MinStake uint64 + AllowInactiveVals bool } func (tr Chain) updateConsumerChain(action UpdateConsumerChainAction, verbose bool) { - spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) - params := ccvtypes.DefaultParams() - initParams := types.ConsumerInitializationParameters{ - InitialHeight: action.InitialHeight, - GenesisHash: []byte("gen_hash"), - BinaryHash: []byte("bin_hash"), - SpawnTime: spawnTime, - UnbondingPeriod: params.UnbondingPeriod, - CcvTimeoutPeriod: params.CcvTimeoutPeriod, - TransferTimeoutPeriod: params.TransferTimeoutPeriod, - ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, - BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, - HistoricalEntries: params.HistoricalEntries, - DistributionTransmissionChannel: action.DistributionChannel, + var initParams *types.ConsumerInitializationParameters + if action.InitParams != nil { + spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.InitParams.SpawnTime) * time.Millisecond) + params := ccvtypes.DefaultParams() + initParams = &types.ConsumerInitializationParameters{ + InitialHeight: action.InitParams.InitialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + + UnbondingPeriod: params.UnbondingPeriod, + CcvTimeoutPeriod: params.CcvTimeoutPeriod, + TransferTimeoutPeriod: params.TransferTimeoutPeriod, + ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, + HistoricalEntries: params.HistoricalEntries, + DistributionTransmissionChannel: action.InitParams.DistributionChannel, + } } - powerShapingParams := types.PowerShapingParameters{ - Top_N: action.TopN, - ValidatorsPowerCap: action.ValidatorsPowerCap, - ValidatorSetCap: action.ValidatorSetCap, - Allowlist: action.Allowlist, - Denylist: action.Denylist, - MinStake: action.MinStake, - AllowInactiveVals: action.AllowInactiveVals, + Top_N: action.PowerShapingParams.TopN, + ValidatorsPowerCap: action.PowerShapingParams.ValidatorsPowerCap, + ValidatorSetCap: action.PowerShapingParams.ValidatorSetCap, + Allowlist: action.PowerShapingParams.Allowlist, + Denylist: action.PowerShapingParams.Denylist, + MinStake: action.PowerShapingParams.MinStake, + AllowInactiveVals: action.PowerShapingParams.AllowInactiveVals, } consumerId := tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId msg := types.MsgUpdateConsumer{ ConsumerId: string(consumerId), NewOwnerAddress: action.NewOwner, - InitializationParameters: &initParams, + InitializationParameters: initParams, PowerShapingParameters: &powerShapingParams, } tr.UpdateConsumer(action.Chain, action.From, msg, verbose) } type CreateConsumerChainAction struct { - Chain ChainID - From ValidatorID - ConsumerChain ChainID - InitialHeight clienttypes.Height - SpawnTime uint - DistributionChannel string - TopN uint32 - ValidatorsPowerCap uint32 - ValidatorSetCap uint32 - Allowlist []string - Denylist []string - MinStake uint64 - AllowInactiveVals bool + Chain ChainID + From ValidatorID + ConsumerChain ChainID + InitParams *InitializationParameters + PowerShapingParams *PowerShapingParameters } // createConsumerChain creates and initializes a consumer chain func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bool) { - spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) consumerChainCfg := tr.testConfig.chainConfigs[action.ConsumerChain] providerChainCfg := tr.testConfig.chainConfigs[action.Chain] @@ -347,30 +349,33 @@ func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bo log.Fatalf("consumer chain already created for '%s'", action.ConsumerChain) } - params := ccvtypes.DefaultParams() - initParams := types.ConsumerInitializationParameters{ - InitialHeight: action.InitialHeight, - GenesisHash: []byte("gen_hash"), - BinaryHash: []byte("bin_hash"), - SpawnTime: spawnTime, - - UnbondingPeriod: params.UnbondingPeriod, - CcvTimeoutPeriod: params.CcvTimeoutPeriod, - TransferTimeoutPeriod: params.TransferTimeoutPeriod, - ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, - BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, - HistoricalEntries: params.HistoricalEntries, - DistributionTransmissionChannel: action.DistributionChannel, + var initParams *types.ConsumerInitializationParameters + if action.InitParams != nil { + spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.InitParams.SpawnTime) * time.Millisecond) + params := ccvtypes.DefaultParams() + initParams = &types.ConsumerInitializationParameters{ + InitialHeight: action.InitParams.InitialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + + UnbondingPeriod: params.UnbondingPeriod, + CcvTimeoutPeriod: params.CcvTimeoutPeriod, + TransferTimeoutPeriod: params.TransferTimeoutPeriod, + ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, + HistoricalEntries: params.HistoricalEntries, + DistributionTransmissionChannel: action.InitParams.DistributionChannel, + } } - - powerShapingParams := types.PowerShapingParameters{ - Top_N: action.TopN, - ValidatorsPowerCap: action.ValidatorsPowerCap, - ValidatorSetCap: action.ValidatorSetCap, - Allowlist: action.Allowlist, - Denylist: action.Denylist, - MinStake: action.MinStake, - AllowInactiveVals: action.AllowInactiveVals, + powerShapingParams := &types.PowerShapingParameters{ + Top_N: action.PowerShapingParams.TopN, + ValidatorsPowerCap: action.PowerShapingParams.ValidatorsPowerCap, + ValidatorSetCap: action.PowerShapingParams.ValidatorSetCap, + Allowlist: action.PowerShapingParams.Allowlist, + Denylist: action.PowerShapingParams.Denylist, + MinStake: action.PowerShapingParams.MinStake, + AllowInactiveVals: action.PowerShapingParams.AllowInactiveVals, } metadata := types.ConsumerMetadata{ @@ -380,7 +385,7 @@ func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bo } // create consumer to get a consumer-id - consumerId := tr.CreateConsumer(providerChainCfg.ChainId, consumerChainCfg.ChainId, action.From, metadata, &initParams, &powerShapingParams) + consumerId := tr.CreateConsumer(providerChainCfg.ChainId, consumerChainCfg.ChainId, action.From, metadata, initParams, powerShapingParams) if verbose { fmt.Println("Created consumer chain", string(consumerChainCfg.ChainId), " with consumer-id", string(consumerId)) } diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 7617ab5924..d476551ef5 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -63,7 +63,7 @@ func (tr Chain) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) { return } if time.Since(start) > timeout { - panic(fmt.Sprintf("\n\n\nwaitBlocks method has timed out after: %s\n\n", timeout)) + panic(fmt.Sprintf("\n\n\nwaitBlocks method on chain '%s' has timed out after: %s\n\n", chain, timeout)) } time.Sleep(time.Second) } diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go index dbe32fc26d..6b23d675c2 100644 --- a/tests/e2e/steps_partial_set_security.go +++ b/tests/e2e/steps_partial_set_security.go @@ -46,9 +46,13 @@ func stepsOptInChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{ ChainID("provi"): ChainState{ @@ -119,9 +123,13 @@ func stepsOptInChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }, @@ -1031,13 +1039,17 @@ func stepsValidatorSetCappedChain() []Step { }, { Action: CreateConsumerChainAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - ConsumerChain: ChainID("consu"), - SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - ValidatorSetCap: 2, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + ValidatorSetCap: 2, + }, }, State: State{ ChainID("provi"): ChainState{ @@ -1108,13 +1120,17 @@ func stepsValidatorSetCappedChain() []Step { { // Update with SpawnTime 0 will trigger launch of consumer chain Action: UpdateConsumerChainAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - ConsumerChain: ChainID("consu"), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - ValidatorSetCap: 2, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + ValidatorSetCap: 2, + }, }, State: State{}, }, @@ -1472,9 +1488,13 @@ func stepsValidatorsAllowlistedChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{ ChainID("provi"): ChainState{ @@ -1547,13 +1567,17 @@ func stepsValidatorsAllowlistedChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - // only "alice" and "bob" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Allowlist: []string{ - "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + // only "alice" and "bob" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) + Allowlist: []string{ + "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + }, }, }, State: State{}, @@ -1652,13 +1676,17 @@ func stepsValidatorsDenylistedChain() []Step { }, { Action: CreateConsumerChainAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - ConsumerChain: ChainID("consu"), - SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - ValidatorSetCap: 2, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + ValidatorSetCap: 2, + }, }, State: State{ ChainID("provi"): ChainState{ @@ -1731,10 +1759,14 @@ func stepsValidatorsDenylistedChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - Denylist: []string{"cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"}, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + Denylist: []string{"cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"}, + }, }, State: State{}, }, @@ -1836,9 +1868,13 @@ func stepsModifyChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{ ChainID("provi"): ChainState{ @@ -1911,9 +1947,13 @@ func stepsModifyChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }, @@ -1992,13 +2032,14 @@ func stepsModifyChain() []Step { // 1. set `ValidatorsPowerCap` to 40% { Action: UpdateConsumerChainAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - ValidatorsPowerCap: 40, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + InitParams: nil, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + ValidatorsPowerCap: 40, + }, }, State: State{}, }, @@ -2031,13 +2072,14 @@ func stepsModifyChain() []Step { // 2. set the `ValidatorSetCap` to a maximum of 2 validators { Action: UpdateConsumerChainAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - ValidatorSetCap: 2, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + InitParams: nil, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + ValidatorSetCap: 2, + }, }, State: State{}, }, @@ -2073,12 +2115,13 @@ func stepsModifyChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - Allowlist: []string{ - "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + InitParams: nil, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + Allowlist: []string{ + "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + }, }, }, State: State{}, @@ -2113,11 +2156,12 @@ func stepsModifyChain() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - // only "alice" is denylisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Denylist: []string{"cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq"}, + InitParams: nil, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + // only "alice" is denylisted (see `getDefaultValidators` in `tests/e2e/config.go`) + Denylist: []string{"cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq"}, + }, }, State: State{}, }, @@ -2153,9 +2197,10 @@ func stepsModifyChain() []Step { From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), NewOwner: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: nil, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }, diff --git a/tests/e2e/steps_permissionless_ics.go b/tests/e2e/steps_permissionless_ics.go index 1da18cb2e0..1abefb2234 100644 --- a/tests/e2e/steps_permissionless_ics.go +++ b/tests/e2e/steps_permissionless_ics.go @@ -9,7 +9,7 @@ import ( // stepsPermissionlessICS tests // - starting multiple permissionless consumer chains with the same chain ID -// - that a validator CANNOT opt-in on two different chains with the same chain ID +// - that a validator CAN opt-in on two different chains with the same chain ID // - taking ownership of a consumer chain func stepsPermissionlessICS() []Step { s := concatSteps( @@ -44,9 +44,13 @@ func stepsPermissionlessICS() []Step { Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("cons2"), // test chain "cons2" is configured with ChainID "consu" - SpawnTime: uint(time.Minute * 3), - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 3), + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }, @@ -67,11 +71,12 @@ func stepsPermissionlessICS() []Step { }, }, // Start another permissionless chain with ChainID `consu` - // test chain "cons1" is configured with ChainID "consu" + // - runs chain "cons1" which is configured with ChainID "consu" + // - test that validator 'alice' can opt-in on two chain with same chain ID stepsStartPermissionlessChain( "cons1", "consu", - []string{"consu", "consu"}, // show up both consumer chains "consu" as proposed chains - []ValidatorID{ValidatorID("bob")}, 0), + []string{"consu", "consu"}, // show up both consumer chains "consu" as proposed chains + []ValidatorID{ValidatorID("bob"), ValidatorID("alice")}, 0), // alice already validating 'cons2' []Step{ { @@ -84,68 +89,14 @@ func stepsPermissionlessICS() []Step { State: State{ ChainID("cons1"): ChainState{ ValPowers: &map[ValidatorID]uint{ - ValidatorID("alice"): 0, - ValidatorID("bob"): 200, - ValidatorID("carol"): 0, - }, - }, - ChainID("provi"): e2e.ChainState{ - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {"consu"}, - ValidatorID("carol"): {}, - }, - }, - }, - }, - }, - - // Test that a validator CANNOT opt-in on a chain with the same ChainID it is already validating - []Step{ - { - Action: OptInAction{ - Chain: ChainID("cons2"), - Validator: ValidatorID("alice"), - ExpectError: true, - ExpectedError: "already opted in to a chain with the same chain id", - }, - State: State{ - ChainID("provi"): ChainState{ - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {"consu"}, - ValidatorID("carol"): {}, - }, - }, - ChainID("cons1"): ChainState{ - ValPowers: &map[ValidatorID]uint{ - ValidatorID("alice"): 0, // alice refused to opt in - ValidatorID("bob"): 200, - ValidatorID("carol"): 0, - }, - }, - }, - }, - }, - []Step{ - { - Action: RelayPacketsAction{ - ChainA: ChainID("provi"), - ChainB: ChainID("cons1"), - Port: "provider", - Channel: 0, - }, - State: State{ - ChainID("cons1"): ChainState{ - ValPowers: &map[ValidatorID]uint{ - ValidatorID("alice"): 0, + ValidatorID("alice"): 100, ValidatorID("bob"): 200, ValidatorID("carol"): 0, }, }, ChainID("provi"): e2e.ChainState{ HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, + ValidatorID("alice"): {"consu"}, ValidatorID("bob"): {"consu"}, ValidatorID("carol"): {}, }, @@ -162,9 +113,13 @@ func stepsPermissionlessICS() []Step { From: ValidatorID("bob"), ConsumerChain: ChainID("cons1"), NewOwner: getDefaultValidators()[ValidatorID("carol")].ValconsAddress, - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }, @@ -173,11 +128,15 @@ func stepsPermissionlessICS() []Step { Chain: ChainID("provi"), From: ValidatorID("carol"), ConsumerChain: ChainID("cons1"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - Allowlist: []string{getDefaultValidators()[ValidatorID("carol")].ValconsAddress}, - Denylist: []string{getDefaultValidators()[ValidatorID("bob")].ValconsAddress}, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + Allowlist: []string{getDefaultValidators()[ValidatorID("carol")].ValconsAddress}, + Denylist: []string{getDefaultValidators()[ValidatorID("bob")].ValconsAddress}, + }, }, State: State{}, }, @@ -191,14 +150,14 @@ func stepsPermissionlessICS() []Step { State: State{ ChainID("cons1"): ChainState{ ValPowers: &map[ValidatorID]uint{ - ValidatorID("alice"): 0, + ValidatorID("alice"): 100, ValidatorID("bob"): 200, // bob is not 'denylisted' ValidatorID("carol"): 0, }, }, ChainID("provi"): e2e.ChainState{ HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, + ValidatorID("alice"): {"consu"}, ValidatorID("bob"): {"consu"}, // bob is still a validator on consu chain ValidatorID("carol"): {}, }, diff --git a/tests/e2e/steps_start_chains.go b/tests/e2e/steps_start_chains.go index 7f84d5fa37..6bdc962014 100644 --- a/tests/e2e/steps_start_chains.go +++ b/tests/e2e/steps_start_chains.go @@ -39,9 +39,13 @@ func stepsStartPermissionlessChain(consumerName, consumerChainId string, propose Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID(consumerName), - SpawnTime: uint(time.Minute * 3), - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: uint(time.Minute * 3), + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{ ChainID("provi"): e2e.ChainState{ @@ -102,9 +106,13 @@ func stepsStartPermissionlessChain(consumerName, consumerChainId string, propose Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID(consumerName), - SpawnTime: 0, // launch now - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + InitParams: &InitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + SpawnTime: 0, // launch now + }, + PowerShapingParams: &PowerShapingParameters{ + TopN: 0, + }, }, State: State{}, }