Skip to content

Commit

Permalink
fix more upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Feb 11, 2025
1 parent ac40f6b commit be0fcd6
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
output=$(go run cmd/build_test_matrix/main.go)
echo "matrix=$output" >> $GITHUB_OUTPUT
env:
TEST_EXCLUSIONS: 'TestUpgradeTestSuite,TestIBCWasmUpgradeTestSuite'
TEST_EXCLUSIONS: 'TestUpgradeTestSuite'

e2e-fork:
env:
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ jobs:
test: "TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade"
upload-logs: true

upgrade-ibcwasm-v8:
uses: ./.github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-wasm-simd
chain-a-tag: v7.3.0-e2e-upgrade
chain-b-tag: v7.3.0-e2e-upgrade
upgrade-plan-name: "ibcwasm-v8"
test-entry-point: "TestIBCWasmUpgradeTestSuite"
test: "TestIBCWasmChainUpgrade"
upload-logs: true

upgrade-v9:
uses: ./.github/workflows/e2e-test-workflow-call.yml
with:
Expand All @@ -102,13 +91,3 @@ jobs:
test: "TestV8ToV9ChainUpgrade_Localhost"
upload-logs: true

upgrade-v9-channel-upgrades:
uses: ./.github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-a-tag: v8.4.0
chain-b-tag: v9.0.0
upgrade-plan-name: "v9"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade"
upload-logs: true
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ jobs:
chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}'
# on regular PRs we won't run upgrade tests.
# NOTE: we are excluding TestTransferTestSuite as we run this full suite instead of each individual test.
test-exclusions: 'TestUpgradeTestSuite,TestIBCWasmUpgradeTestSuite,TestTransferTestSuite,TestAuthzTransferTestSuite,TestTransferTestSuiteSendReceive,TestTransferTestSuiteSendEnabled,TestTransferLocalhostTestSuite,TestConnectionTestSuite,TestInterchainAccountsGovTestSuite,TestIncentivizedTransferTestSuite'
test-exclusions: 'TestUpgradeTestSuite,TestTransferTestSuite,TestAuthzTransferTestSuite,TestTransferTestSuiteSendReceive,TestTransferTestSuiteSendEnabled,TestTransferLocalhostTestSuite,TestConnectionTestSuite,TestInterchainAccountsGovTestSuite,TestIncentivizedTransferTestSuite'
temp-run-full-suite: true
136 changes: 135 additions & 1 deletion e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,17 @@ func newDefaultSimappConfig(cc ChainConfig, name, chainID, denom string, cometCf
// getGenesisModificationFunction returns a genesis modification function that handles the GenesisState type
// correctly depending on if the govv1beta1 gov module is used or if govv1 is being used.
func getGenesisModificationFunction(cc ChainConfig) func(ibc.ChainConfig, []byte) ([]byte, error) {
binary := cc.Binary
version := cc.Tag
return defaultGovv1ModifyGenesis(version)

simdSupportsGovV1Genesis := binary == defaultBinary && testvalues.GovGenesisFeatureReleases.IsSupported(version)

// TODO: Remove after we drop v7 support (this is only needed right now because of v6 -> v7 upgrade tests)
if simdSupportsGovV1Genesis {
return defaultGovv1ModifyGenesis(version)
}

return defaultGovv1Beta1ModifyGenesis(version)
}

// defaultGovv1ModifyGenesis will only modify governance params to ensure the voting period and minimum deposit
Expand Down Expand Up @@ -764,6 +773,108 @@ func defaultGovv1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([]
}
}

// defaultGovv1Beta1ModifyGenesis will only modify governance params to ensure the voting period and minimum deposit
// // are functional for e2e testing purposes.
func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([]byte, error) {
const appStateKey = "app_state"
return func(chainConfig ibc.ChainConfig, genbz []byte) ([]byte, error) {
genesisDocMap := map[string]interface{}{}
err := json.Unmarshal(genbz, &genesisDocMap)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into genesis doc: %w", err)
}

appStateMap, ok := genesisDocMap[appStateKey].(map[string]interface{})
if !ok {
return nil, errors.New("failed to extract to app_state")
}

govModuleBytes, err := json.Marshal(appStateMap[govtypes.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract gov genesis bytes: %s", err)
}

govModuleGenesisBytes, err := modifyGovv1Beta1AppState(chainConfig, govModuleBytes)
if err != nil {
return nil, err
}

govModuleGenesisMap := map[string]interface{}{}
err = json.Unmarshal(govModuleGenesisBytes, &govModuleGenesisMap)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err)
}

if !testvalues.AllowAllClientsWildcardFeatureReleases.IsSupported(version) {
ibcModuleBytes, err := json.Marshal(appStateMap[ibcexported.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract ibc genesis bytes: %s", err)
}

ibcGenesisBytes, err := modifyClientGenesisAppState(ibcModuleBytes)
if err != nil {
return nil, err
}

ibcModuleGenesisMap := map[string]interface{}{}
err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err)
}
appStateMap[ibcexported.ModuleName] = ibcModuleGenesisMap
}

if !testvalues.ChannelParamsFeatureReleases.IsSupported(version) {
ibcModuleBytes, err := json.Marshal(appStateMap[ibcexported.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract ibc genesis bytes: %s", err)
}

ibcGenesisBytes, err := modifyChannelGenesisAppState(ibcModuleBytes)
if err != nil {
return nil, err
}

ibcModuleGenesisMap := map[string]interface{}{}
err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err)
}
appStateMap[ibcexported.ModuleName] = ibcModuleGenesisMap

}

if !testvalues.ChannelsV2FeatureReleases.IsSupported(version) {
ibcModuleBytes, err := json.Marshal(appStateMap[ibcexported.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract ibc genesis bytes: %s", err)
}

ibcGenesisBytes, err := modifyChannelV2GenesisAppState(ibcModuleBytes)
if err != nil {
return nil, err
}

ibcModuleGenesisMap := map[string]interface{}{}
err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err)
}
appStateMap[ibcexported.ModuleName] = ibcModuleGenesisMap
}

appStateMap[govtypes.ModuleName] = govModuleGenesisMap
genesisDocMap[appStateKey] = appStateMap

finalGenesisDocBytes, err := json.MarshalIndent(genesisDocMap, "", " ")
if err != nil {
return nil, err
}

return finalGenesisDocBytes, nil
}
}

// modifyGovV1AppState takes the existing gov app state and marshals it to a govv1 GenesisState.
func modifyGovV1AppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byte, error) {
cfg := testutil.MakeTestEncodingConfig()
Expand Down Expand Up @@ -792,6 +903,29 @@ func modifyGovV1AppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byt
return govGenBz, nil
}

// modifyGovv1Beta1AppState takes the existing gov app state and marshals it to a govv1beta1 GenesisState.
func modifyGovv1Beta1AppState(chainConfig ibc.ChainConfig, govAppState []byte) ([]byte, error) {
cfg := testutil.MakeTestEncodingConfig()

cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)
govv1beta1.RegisterInterfaces(cfg.InterfaceRegistry)

govGenesisState := &govv1beta1.GenesisState{}
if err := cdc.UnmarshalJSON(govAppState, govGenesisState); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into govv1beta1 genesis state: %w", err)
}

govGenesisState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(chainConfig.Denom, govv1beta1.DefaultMinDepositTokens))
govGenesisState.VotingParams.VotingPeriod = testvalues.VotingPeriod

govGenBz, err := cdc.MarshalJSON(govGenesisState)
if err != nil {
return nil, fmt.Errorf("failed to marshal gov genesis state: %w", err)
}

return govGenBz, nil
}

// modifyClientGenesisAppState takes the existing ibc app state and marshals it to an ibc GenesisState.
func modifyClientGenesisAppState(ibcAppState []byte) ([]byte, error) {
cfg := testutil.MakeTestEncodingConfig()
Expand Down

0 comments on commit be0fcd6

Please sign in to comment.