Skip to content

Commit

Permalink
test: update e2e permissionless tests (#2251)
Browse files Browse the repository at this point in the history
* adding more permissionless tests

* fix changelog filename

* Adapt e2e tests to new permissionless logic

* Revert "fix changelog filename"

This reverts commit 636ed04.

* fix filename on changelog

* adapt e2e to allow vals opt in on chains with same ChainId

* Revert "adding more permissionless tests"

This reverts commit cc90e85.

* rename 2171-permissionless-ICS.md.md
  • Loading branch information
bermuell authored Sep 11, 2024
1 parent db9176c commit 07ea628
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 227 deletions.
149 changes: 77 additions & 72 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,110 +267,115 @@ 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]

if consumerChainCfg.ConsumerId != "" {
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{
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading

0 comments on commit 07ea628

Please sign in to comment.