test: perform upgrade test from v53 (#24749)

This commit is contained in:
Alex | Interchain Labs 2025-05-16 13:50:29 -04:00 committed by GitHub
parent def657dafa
commit 30eaefc25b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 127 deletions

View File

@ -504,22 +504,22 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes
.PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes
test-system: build-v50 build
test-system: build-v53 build
mkdir -p ./tests/systemtests/binaries/
cp $(BUILDDIR)/simd ./tests/systemtests/binaries/
mkdir -p ./tests/systemtests/binaries/v0.50
mv $(BUILDDIR)/simdv50 ./tests/systemtests/binaries/v0.50/simd
mkdir -p ./tests/systemtests/binaries/v0.53
mv $(BUILDDIR)/simdv53 ./tests/systemtests/binaries/v0.53/simd
$(MAKE) -C tests/systemtests test
.PHONY: test-system
# build-v50 checks out the v0.50.x branch, builds the binary, and renames it to simdv50.
build-v50:
@echo "Starting v50 build process..."
# build-v53 checks out the v0.53.x branch, builds the binary, and renames it to simdv53.
build-v53:
@echo "Starting v53 build process..."
git_status=$$(git status --porcelain) && \
has_changes=false && \
if [ -n "$$git_status" ]; then \
echo "Stashing uncommitted changes..." && \
git stash push -m "Temporary stash for v50 build" && \
git stash push -m "Temporary stash for v53 build" && \
has_changes=true; \
else \
echo "No changes to stash"; \
@ -527,10 +527,10 @@ build-v50:
echo "Saving current reference..." && \
CURRENT_REF=$$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse HEAD) && \
echo "Checking out release branch..." && \
git checkout release/v0.50.x && \
echo "Building v50 binary..." && \
git checkout release/v0.53.x && \
echo "Building v53 binary..." && \
make build && \
mv build/simd build/simdv50 && \
mv build/simd build/simdv53 && \
echo "Returning to original branch..." && \
if [ "$$CURRENT_REF" = "HEAD" ]; then \
git checkout $$(git rev-parse HEAD); \
@ -543,4 +543,4 @@ build-v50:
else \
echo "No changes to reapply"; \
fi
.PHONY: build-v50
.PHONY: build-v53

View File

@ -7,18 +7,16 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
epochstypes "github.com/cosmos/cosmos-sdk/x/epochs/types"
protocolpooltypes "github.com/cosmos/cosmos-sdk/x/protocolpool/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade
// from v050 to v053.
// from v053 to v054.
//
// NOTE: This upgrade defines a reference implementation of what an upgrade
// could look like when an application is migrating from Cosmos SDK version
// v0.50.x to v0.53.x.
const UpgradeName = "v050-to-v053"
// v0.53.x to v0.54.x.
const UpgradeName = "v053-to-v054"
func (app SimApp) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
@ -36,10 +34,7 @@ func (app SimApp) RegisterUpgradeHandlers() {
if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
epochstypes.ModuleName,
protocolpooltypes.ModuleName,
},
Added: []string{},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades

View File

@ -3,7 +3,6 @@
package systemtests
import (
"fmt"
"testing"
"time"
@ -60,65 +59,3 @@ func TestUnorderedTXDuplicate(t *testing.T) {
return cli.QueryBalance(account2Addr, "stake") == 5000
}, 10*systest.Sut.BlockTime(), 200*time.Millisecond, "TX was not executed before timeout")
}
func TestTxBackwardsCompatability(t *testing.T) {
// Scenario:
// A transaction generated from a v0.53 chain without unordered and timeout_timestamp flags set should succeed.
// Conversely, a transaction generated from a v0.53 chain with unordered and timeout_timestamp flags set should fail.
var (
denom = "stake"
transferAmount int64 = 1000
)
systest.Sut.ResetChain(t)
v53CLI := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)
// we just get val addr for an address to send things to.
valAddr := v53CLI.GetKeyAddr("node0")
require.NotEmpty(t, valAddr)
// generate a deterministic account. we'll use this seed again later in the v50 chain.
senderAddr := v53CLI.AddKeyFromSeed("account1", testSeed)
v50CLI, legacySut := createLegacyBinary(t, initAccount{
address: senderAddr,
balance: "10000000000stake",
})
legacySut.StartChain(t)
bankSendCmdArgs := []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct"}
res, ok := v53CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
response, ok := v50CLI.AwaitTxCommitted(res, 15*time.Second)
require.True(t, ok)
code := gjson.Get(response, "code").Int()
require.Equal(t, int64(0), code)
bankSendCmdArgs = []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct", "--unordered", "--timeout-duration=8m"}
res, ok = v53CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
code = gjson.Get(res, "code").Int()
require.Equal(t, int64(2), code)
require.Contains(t, res, "errUnknownField")
legacySut.StopChain()
// Now start a v53 chain, and send a transaction from a v50 client.
// generate a deterministic account. we'll use this seed again later in the v50 chain.
systest.Sut.SetupChain()
systest.Sut.ModifyGenesisCLI(t,
// we need our sender to be account 5 because that's how it was signed in the v53 scenario.
[]string{"genesis", "add-genesis-account", senderAddr, "10000000000stake"},
)
systest.Sut.StartChain(t)
senderAddr = v50CLI.AddKeyFromSeed("account1", testSeed)
bankSendCmdArgs = []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct"}
res, ok = v50CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
response, ok = v53CLI.AwaitTxCommitted(res, 15*time.Second)
require.True(t, ok)
code = gjson.Get(response, "code").Int()
require.Equal(t, int64(0), code)
}

View File

@ -20,50 +20,9 @@ import (
const (
testSeed = "scene learn remember glide apple expand quality spawn property shoe lamp carry upset blossom draft reject aim file trash miss script joy only measure"
upgradeHeight int64 = 22
upgradeName = "v050-to-v053" // must match UpgradeName in simapp/upgrades.go
upgradeName = "v053-to-v054" // must match UpgradeName in simapp/upgrades.go
)
type initAccount struct {
address string
balance string
}
func createLegacyBinary(t *testing.T, extraAccounts ...initAccount) (*systest.CLIWrapper, *systest.SystemUnderTest) {
t.Helper()
legacyBinary := systest.WorkDir + "/binaries/v0.50/simd"
//// Now we're going to switch to a v.50 chain.
t.Logf("+++ legacy binary: %s\n", legacyBinary)
// setup the v50 chain. v53 made some changes to testnet command, so we'll have to adjust here.
// this only uses 1 node.
legacySut := systest.NewSystemUnderTest("simd", systest.Verbose, 1, 1*time.Second)
// we need to explicitly set this here as the constructor infers the exec binary is in the "binaries" directory.
legacySut.SetExecBinary(legacyBinary)
legacySut.SetTestnetInitializer(systest.LegacyInitializerWithBinary(legacyBinary, legacySut))
legacySut.SetupChain()
v50CLI := systest.NewCLIWrapper(t, legacySut, systest.Verbose)
v50CLI.AddKeyFromSeed("account1", testSeed)
// Typically, SystemUnderTest will create a node with 4 validators. In the legacy setup, we create run a single validator network.
// This means we need to add 3 more accounts in order to make further account additions map to the same account number in state
modifications := [][]string{
{"genesis", "add-genesis-account", v50CLI.AddKey("foo"), "10000000000stake"},
{"genesis", "add-genesis-account", v50CLI.AddKey("bar"), "10000000000stake"},
{"genesis", "add-genesis-account", v50CLI.AddKey("baz"), "10000000000stake"},
}
for _, extraAccount := range extraAccounts {
modifications = append(modifications, []string{"genesis", "add-genesis-account", extraAccount.address, extraAccount.balance})
}
legacySut.ModifyGenesisCLI(t,
modifications...,
)
return v50CLI, legacySut
}
func TestChainUpgrade(t *testing.T) {
// Scenario:
// start a legacy chain with some state
@ -74,9 +33,8 @@ func TestChainUpgrade(t *testing.T) {
currentBranchBinary := systest.Sut.ExecBinary()
currentInitializer := systest.Sut.TestnetInitializer()
legacyBinary := systest.WorkDir + "/binaries/v0.50/simd"
legacyBinary := systest.WorkDir + "/binaries/v0.53/simd"
systest.Sut.SetExecBinary(legacyBinary)
systest.Sut.SetTestnetInitializer(systest.NewModifyConfigYamlInitializer(legacyBinary, systest.Sut))
systest.Sut.SetupChain()
votingPeriod := 5 * time.Second // enough time to vote