From f6155d31c804e265530d2bb8ba73d6bccc6726dd Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 3 Oct 2024 16:54:14 +0100 Subject: [PATCH 1/5] update upgrade test --- app/upgrades.go | 2 +- integration_tests/upgrade_ibc_test.go | 84 +++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 8378bcf7..6ff8bab1 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -const UpgradeName = "v12" +const UpgradeName = "v13" func (app *WasmApp) RegisterUpgradeHandlers() { app.WrapSetUpgradeHandler(UpgradeName) diff --git a/integration_tests/upgrade_ibc_test.go b/integration_tests/upgrade_ibc_test.go index 7ca79f41..a92973c2 100644 --- a/integration_tests/upgrade_ibc_test.go +++ b/integration_tests/upgrade_ibc_test.go @@ -2,6 +2,10 @@ package integration_tests import ( "context" + "encoding/json" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "os" + "path" "strconv" "testing" "time" @@ -21,11 +25,11 @@ import ( ) const ( - xionImageFrom = "ghcr.io/burnt-labs/xion/heighliner" - xionVersionFrom = "9.0.1-rc2" - xionImageTo = "ghcr.io/burnt-labs/xion/heighliner" - xionVersionTo = "sha-7bba345" - xionUpgradeName = "v12" + xionImageFrom = "xion" + xionVersionFrom = "current" + xionImageTo = "xion" + xionVersionTo = "local" + xionUpgradeName = "v13" osmosisImage = "ghcr.io/strangelove-ventures/heighliner/osmosis" osmosisVersion = "v25.2.1" @@ -91,7 +95,7 @@ func TestXionUpgradeIBC(t *testing.T) { chain, counterpartyChain := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain) const ( - path = "ibc-upgrade-test-path" + testPath = "ibc-upgrade-test-testPath" relayerName = "relayer" ) @@ -112,7 +116,7 @@ func TestXionUpgradeIBC(t *testing.T) { Chain1: chain, Chain2: counterpartyChain, Relayer: r, - Path: path, + Path: testPath, }) ctx := context.Background() @@ -134,8 +138,68 @@ func TestXionUpgradeIBC(t *testing.T) { users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) chainUser := users[0] + // deploy the account contract, and pin it + fp, err := os.Getwd() + require.NoError(t, err) + codeIDStr, err := chain.StoreContract(ctx, chainUser.FormattedAddress(), + path.Join(fp, "integration_tests", "testdata", "contracts", "account_updatable-aarch64.wasm")) + require.NoError(t, err) + + authority, err := chain.UpgradeQueryAuthority(ctx) + require.NoError(t, err) + codeID, err := strconv.Atoi(codeIDStr) + require.NoError(t, err) + + pinCodeMsg := wasmtypes.MsgPinCodes{ + Authority: authority, + CodeIDs: []uint64{uint64(codeID)}, + } + msg, err := chain.Config().EncodingConfig.Codec.MarshalInterfaceJSON(&pinCodeMsg) + require.NoError(t, err) + + pinCodeTx, err := chain.SubmitProposal(ctx, chainUser.KeyName(), cosmos.TxProposalv1{ + Messages: []json.RawMessage{msg}, + Metadata: "", + Deposit: "100uxion", + Title: "Pin AA Contract Code", + Summary: "To verify that the wasm cache doesn't move or change during upgrade", + }) + require.NoError(t, err) + + proposalID, err := strconv.Atoi(pinCodeTx.ProposalID) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := chain.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusVotingPeriod { + return true + } + t.Logf("Waiting for proposal to enter voting status VOTING, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status VOTING after 11s") + + err = chain.VoteOnProposalAllValidators(ctx, uint64(proposalID), cosmos.ProposalVoteYes) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := chain.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusPassed { + return true + } + t.Logf("Waiting for proposal to enter voting status PASSED, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status PASSED after 11s") + // test IBC conformance before chain upgrade - conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, path) + conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, testPath) height, err := chain.Height(ctx) require.NoError(t, err, "error fetching height before submit upgrade proposal") @@ -196,6 +260,6 @@ func TestXionUpgradeIBC(t *testing.T) { err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), chain) require.NoError(t, err, "chain did not produce blocks after upgrade") - // test IBC conformance after chain upgrade on same path - conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, path) + // test IBC conformance after chain upgrade on same testPath + conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, testPath) } From 4fb39d3ae542299c7bfe40130c0cc16f67b8c667 Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 3 Oct 2024 17:37:20 +0100 Subject: [PATCH 2/5] directory fix for wasmvm --- app/app.go | 4 +- integration_tests/go.mod | 1 + integration_tests/upgrade_ibc_test.go | 69 ++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 6f8744fd..7ed1eeac 100644 --- a/app/app.go +++ b/app/app.go @@ -714,8 +714,10 @@ func NewWasmApp( wasmOpts = append(wasmOpts, tokenFactoryOpts...) // instantiate the Wasm VM with the chosen parameters + // we need to create this double wasm dir because the wasmd Keeper appends an extra `wasm/` to the value you give it + doubleWasmDir := filepath.Join(wasmDir, "wasm") wasmVM, err := wasmvm.NewVM( - wasmDir, + doubleWasmDir, availableCapabilities, WasmContractMemoryLimit, // default of 32 wasmConfig.ContractDebugMode, diff --git a/integration_tests/go.mod b/integration_tests/go.mod index b2fed9a0..0ffc7731 100644 --- a/integration_tests/go.mod +++ b/integration_tests/go.mod @@ -13,6 +13,7 @@ require ( github.com/cosmos/cosmos-sdk v0.50.10 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/modules/capability v1.0.1 + github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72 github.com/cosmos/ibc-go/v8 v8.5.1 github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74 github.com/docker/docker v24.0.9+incompatible diff --git a/integration_tests/upgrade_ibc_test.go b/integration_tests/upgrade_ibc_test.go index a92973c2..3221d8d8 100644 --- a/integration_tests/upgrade_ibc_test.go +++ b/integration_tests/upgrade_ibc_test.go @@ -2,8 +2,37 @@ package integration_tests import ( "context" + "cosmossdk.io/x/upgrade" "encoding/json" + "github.com/CosmWasm/wasmd/x/wasm" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/burnt-labs/xion/x/jwk" + "github.com/burnt-labs/xion/x/mint" + "github.com/burnt-labs/xion/x/xion" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/auth" + authz "github.com/cosmos/cosmos-sdk/x/authz/module" + "github.com/cosmos/cosmos-sdk/x/bank" + "github.com/cosmos/cosmos-sdk/x/consensus" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + "github.com/cosmos/cosmos-sdk/x/params" + paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" + "github.com/cosmos/cosmos-sdk/x/slashing" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/ibc-go/modules/capability" + ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibccore "github.com/cosmos/ibc-go/v8/modules/core" + ibcsolomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibclocalhost "github.com/cosmos/ibc-go/v8/modules/light-clients/09-localhost" + ccvprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider" + aa "github.com/larry0x/abstract-account/x/abstractaccount" + "github.com/strangelove-ventures/tokenfactory/x/tokenfactory" "os" "path" "strconv" @@ -65,7 +94,45 @@ func TestXionUpgradeIBC(t *testing.T) { Bech32Prefix: "xion", Denom: "uxion", TrustingPeriod: ibcClientTrustingPeriod, - ModifyGenesis: ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}}), + EncodingConfig: func() *moduletestutil.TestEncodingConfig { + cfg := moduletestutil.MakeTestEncodingConfig( + auth.AppModuleBasic{}, + genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + }, + ), + params.AppModuleBasic{}, + slashing.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + consensus.AppModuleBasic{}, + transfer.AppModuleBasic{}, + ibccore.AppModuleBasic{}, + ibctm.AppModuleBasic{}, + ibcwasm.AppModuleBasic{}, + ccvprovider.AppModuleBasic{}, + ibcsolomachine.AppModuleBasic{}, + + // custom + wasm.AppModuleBasic{}, + authz.AppModuleBasic{}, + tokenfactory.AppModuleBasic{}, + xion.AppModuleBasic{}, + jwk.AppModuleBasic{}, + aa.AppModuleBasic{}, + ) + // TODO: add encoding types here for the modules you want to use + ibclocalhost.RegisterInterfaces(cfg.InterfaceRegistry) + return &cfg + }(), + + ModifyGenesis: ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}}), }, }, { From 8481f201011f818b548be9479d75fe3e4f2b7bdb Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 3 Oct 2024 17:57:10 +0100 Subject: [PATCH 3/5] linting --- benchmarks/app_test.go | 2 +- integration_tests/upgrade_ibc_test.go | 14 ++++++++------ x/mint/common_test.go | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 9239f93b..4b7a7c01 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -219,7 +219,7 @@ func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo { Label: "Demo contract", Msg: initBz, } - gasWanted := 500000 + 10000*uint64(numAccounts) + gasWanted := 500000 + 10000*uint64(numAccounts) // nolint:gosec initTx, err := simtestutil.GenSignedMockTx(r, txGen, []sdk.Msg{&initMsg}, nil, gasWanted, "", []uint64{0}, []uint64{1}, minter) require.NoError(b, err) _, res, err := wasmApp.SimDeliver(txGen.TxEncoder(), initTx) diff --git a/integration_tests/upgrade_ibc_test.go b/integration_tests/upgrade_ibc_test.go index 49755256..7ed6aa87 100644 --- a/integration_tests/upgrade_ibc_test.go +++ b/integration_tests/upgrade_ibc_test.go @@ -2,8 +2,15 @@ package integration_tests import ( "context" - "cosmossdk.io/x/upgrade" "encoding/json" + "os" + "path" + "strconv" + "testing" + "time" + + "cosmossdk.io/x/upgrade" + "github.com/CosmWasm/wasmd/x/wasm" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/burnt-labs/xion/x/jwk" @@ -33,11 +40,6 @@ import ( ccvprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider" aa "github.com/larry0x/abstract-account/x/abstractaccount" "github.com/strangelove-ventures/tokenfactory/x/tokenfactory" - "os" - "path" - "strconv" - "testing" - "time" "cosmossdk.io/math" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" diff --git a/x/mint/common_test.go b/x/mint/common_test.go index 4d7417f1..31d7117f 100644 --- a/x/mint/common_test.go +++ b/x/mint/common_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + // banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" From 4a5b3e8c30955ec5afcbb1bbf99095d5729691f6 Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 3 Oct 2024 17:57:54 +0100 Subject: [PATCH 4/5] nit --- integration_tests/upgrade_ibc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/upgrade_ibc_test.go b/integration_tests/upgrade_ibc_test.go index 7ed6aa87..65a7359f 100644 --- a/integration_tests/upgrade_ibc_test.go +++ b/integration_tests/upgrade_ibc_test.go @@ -329,6 +329,6 @@ func TestXionUpgradeIBC(t *testing.T) { err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), chain) require.NoError(t, err, "chain did not produce blocks after upgrade") - // test IBC conformance after chain upgrade on same testPath + // test IBC conformance after chain upgrade on same path conformance.TestChainPair(t, ctx, client, network, chain, counterpartyChain, rf, rep, r, testPath) } From 54cfbc78031eb5dc7329984cc131463861617d1e Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 3 Oct 2024 18:50:31 +0100 Subject: [PATCH 5/5] go mod tidy --- integration_tests/go.sum | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration_tests/go.sum b/integration_tests/go.sum index aa1ac463..2654286a 100644 --- a/integration_tests/go.sum +++ b/integration_tests/go.sum @@ -404,6 +404,8 @@ github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0 github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd/go.mod h1:JWfpWVKJKiKtd53/KbRoKfxWl8FsT2GPcNezTOk0o5Q= 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/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72 h1:QjCi4bJoy9AXLL1e4jqi+4rHYN0gGZAQxf937cdWhw4= +github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.4.2-0.20240730185033-ccd4dc278e72/go.mod h1:yiulzyQAZ+Ci802z/kVQqTA3lGiSJOmDpTq7kZxOUNE= 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=