Skip to content

Commit

Permalink
upgrade wasmd deps (#933)
Browse files Browse the repository at this point in the history
* Added new upgrde plan

* write upgrade test

* fix proto breaking
  • Loading branch information
miladz68 authored Aug 27, 2024
1 parent 5e3c62b commit 4250e1b
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 18 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import (
"github.com/CoreumFoundation/coreum/v4/app/openapi"
appupgrade "github.com/CoreumFoundation/coreum/v4/app/upgrade"
appupgradev4 "github.com/CoreumFoundation/coreum/v4/app/upgrade/v4"
appupgradev4patch1 "github.com/CoreumFoundation/coreum/v4/app/upgrade/v4patch1"
"github.com/CoreumFoundation/coreum/v4/docs"
"github.com/CoreumFoundation/coreum/v4/pkg/config"
"github.com/CoreumFoundation/coreum/v4/pkg/config/constant"
Expand Down Expand Up @@ -1119,6 +1120,7 @@ func New(
upgrades := []appupgrade.Upgrade{
appupgradev4.New(appupgradev4.Name, app.ModuleManager, app.configurator, app.ConsensusParamsKeeper),
appupgradev4.New(appupgradev4.NameAlias, app.ModuleManager, app.configurator, app.ConsensusParamsKeeper),
appupgradev4patch1.New(appupgradev4patch1.Name, app.ModuleManager, app.configurator),
}

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down
29 changes: 29 additions & 0 deletions app/upgrade/v4patch1/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v4patch1

import (
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/CoreumFoundation/coreum/v4/app/upgrade"
)

// Name defines the upgrade name.
const (
Name = "v4patch1"
)

// New makes an upgrade handler for v4patch1 upgrade.
func New(name string, mm *module.Manager, configurator module.Configurator,
) upgrade.Upgrade {
return upgrade.Upgrade{
Name: name,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
},
Upgrade: func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
},
}
}
2 changes: 1 addition & 1 deletion build/coreum/generate-proto-breaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func breakingProto(ctx context.Context, deps types.DepsFunc) error {
}
defer os.RemoveAll(masterDir) //nolint:errcheck // error doesn't matter

if err := git.CloneLocalBranch(ctx, masterDir, repoPath, "crust/proto-breaking", "master"); err != nil {
if err := git.CloneLocalBranch(ctx, masterDir, repoPath, "crust/release-v4/proto-breaking", "release-v4"); err != nil {
return err
}
if err := golang.DownloadDependencies(ctx, deps, masterDir); err != nil {
Expand Down
1 change: 1 addition & 0 deletions build/coreum/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func buildCoredDockerImage(ctx context.Context, cfg imageConfig) error {
func ensureReleasedBinaries(ctx context.Context, deps types.DepsFunc) error {
for _, binaryTool := range []tools.Name{
tools.CoredV303,
tools.CoredV401,
} {
if err := tools.Ensure(ctx, binaryTool, tools.TargetPlatformLinuxLocalArchInDocker); err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions build/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ replace (
require (
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240213123712-d7d6a45ddb8f
github.com/CoreumFoundation/crust v0.0.0-20240614103121-cf038db2a87f
github.com/CoreumFoundation/crust v0.0.0-20240826114038-46fc12fae481
github.com/iancoleman/strcase v0.3.0
github.com/pkg/errors v0.9.1
github.com/samber/lo v1.39.0
Expand Down Expand Up @@ -64,8 +64,8 @@ require (
github.com/99designs/keyring v1.2.2 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmd v0.45.0 // indirect
github.com/CosmWasm/wasmvm v1.5.2 // indirect
github.com/CosmWasm/wasmd v0.46.0 // indirect
github.com/CosmWasm/wasmvm v1.5.4 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions build/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,12 @@ github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRr
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68 h1:Tb9avuSQW3smVGrUnDh/Y+ML4eK802UsvJNZHsBgOGg=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/crust v0.0.0-20240614103121-cf038db2a87f h1:2fJOiFtKr9uHRMJh9yAQi4+HKZFdbmu0bvrJznclQdA=
github.com/CoreumFoundation/crust v0.0.0-20240614103121-cf038db2a87f/go.mod h1:+tc+D5f9K7oNNtv8UazzNy8LheAhBG7UDc25JwY803Y=
github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI=
github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944=
github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag=
github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/CoreumFoundation/crust v0.0.0-20240826114038-46fc12fae481 h1:EdgwleYocnP2EGb++I0CDMxVPFmbTbo3MxiZ+JGhaDI=
github.com/CoreumFoundation/crust v0.0.0-20240826114038-46fc12fae481/go.mod h1:+tc+D5f9K7oNNtv8UazzNy8LheAhBG7UDc25JwY803Y=
github.com/CosmWasm/wasmd v0.46.0 h1:78kmiobbVE8JWBcM+ssxiFV2cS+4l9lmZQqPAQ0mA04=
github.com/CosmWasm/wasmd v0.46.0/go.mod h1:BZFz+CFGdLNGomshb3IeccFyD4R+XbnS/mXpytOUyTA=
github.com/CosmWasm/wasmvm v1.5.4 h1:Opqy65ubJ8bMsT08dn85VjRdsLJVPIAgIXif92qOMGc=
github.com/CosmWasm/wasmvm v1.5.4/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
Expand Down
4 changes: 2 additions & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oM
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
github.com/CoreumFoundation/crust v0.0.0-20240531092943-bab690541bbd h1:4nns+B+HSRdWLHSn8KHv1q4Y4/eNMvp8lyg4uA0/2Xg=
github.com/CoreumFoundation/crust v0.0.0-20240531092943-bab690541bbd/go.mod h1:+tc+D5f9K7oNNtv8UazzNy8LheAhBG7UDc25JwY803Y=
github.com/CoreumFoundation/crust v0.0.0-20240826114038-46fc12fae481 h1:EdgwleYocnP2EGb++I0CDMxVPFmbTbo3MxiZ+JGhaDI=
github.com/CoreumFoundation/crust v0.0.0-20240826114038-46fc12fae481/go.mod h1:+tc+D5f9K7oNNtv8UazzNy8LheAhBG7UDc25JwY803Y=
github.com/CosmWasm/wasmd v0.40.0-rc.1/go.mod h1:uacdue6EGn9JA1TqBNHB3iCe4PCIChuFT23AzIl2VME=
github.com/CosmWasm/wasmvm v1.2.3/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc=
Expand Down Expand Up @@ -616,8 +618,6 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vl
github.com/cosmos/cosmos-sdk v0.47.3-0.20230513170018-83d600596f5d/go.mod h1:f3jiGiA4OauW0xaDL5KB09x4FtPP5ilvPGvi+S2dHCY=
github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c=
github.com/cosmos/cosmos-sdk v0.47.8/go.mod h1:VTAtthIsmfplanhFfUTfT6ED4F+kkJxT7nmvmKXRthI=
github.com/cosmos/cosmos-sdk v0.47.12 h1:KOZHAVWrcilHywBN/FabBaXbDFMzoFmtdX0hqy5Ory8=
github.com/cosmos/cosmos-sdk v0.47.12/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0=
github.com/cosmos/cosmos-sdk v0.50.1/go.mod h1:fsLSPGstCwn6MMsFDMAQWGJj8E4sYsN9Gnu1bGE5imA=
github.com/cosmos/cosmos-sdk v0.50.4/go.mod h1:UbShFs6P8Ly29xxJvkNGaNaL/UGj5a686NRtb1Cqra0=
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a h1:2humuGPw3O5riJVFq/E2FRjF57UrO97W1qJcGVmK+6k=
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
cosmossdk.io/math v1.3.0
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab
github.com/CoreumFoundation/coreum/v4 v4.0.0-00010101000000-000000000000
github.com/CosmWasm/wasmd v0.45.0
github.com/CosmWasm/wasmd v0.46.0
github.com/cometbft/cometbft v0.37.5
github.com/cosmos/cosmos-sdk v0.47.12
github.com/cosmos/gogoproto v1.4.10
Expand Down Expand Up @@ -57,7 +57,7 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmvm v1.5.2 // indirect
github.com/CosmWasm/wasmvm v1.5.4 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/avast/retry-go/v4 v4.3.2 // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,10 @@ github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRr
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab h1:XPcSzlQ06tor/py1LkEM9FX70LIeDWB++vLuAO6eAYI=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI=
github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944=
github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag=
github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/CosmWasm/wasmd v0.46.0 h1:78kmiobbVE8JWBcM+ssxiFV2cS+4l9lmZQqPAQ0mA04=
github.com/CosmWasm/wasmd v0.46.0/go.mod h1:BZFz+CFGdLNGomshb3IeccFyD4R+XbnS/mXpytOUyTA=
github.com/CosmWasm/wasmvm v1.5.4 h1:Opqy65ubJ8bMsT08dn85VjRdsLJVPIAgIXif92qOMGc=
github.com/CosmWasm/wasmvm v1.5.4/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
Expand Down
18 changes: 18 additions & 0 deletions integration-tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/CoreumFoundation/coreum-tools/pkg/retry"
appupgradev4 "github.com/CoreumFoundation/coreum/v4/app/upgrade/v4"
appupgradev4patch1 "github.com/CoreumFoundation/coreum/v4/app/upgrade/v4patch1"
integrationtests "github.com/CoreumFoundation/coreum/v4/integration-tests"
"github.com/CoreumFoundation/coreum/v4/testutil/integration"
)
Expand All @@ -45,6 +46,7 @@ func TestUpgrade(t *testing.T) {

if strings.HasPrefix(infoRes.ApplicationVersion.Version, "v3.") {
upgradeV3ToV4(t)
upgradeV4ToV4Patch1(t)
return
}
requireT.Failf("not supported cored version", "version: %s", infoRes.ApplicationVersion.Version)
Expand All @@ -67,6 +69,21 @@ func upgradeV3ToV4(t *testing.T) {
}
}

func upgradeV4ToV4Patch1(t *testing.T) {
tests := []upgradeTest{
&wasmdUpgradeTest{},
}
for _, test := range tests {
test.Before(t)
}

runUpgrade(t, appupgradev4patch1.Name, upgradeDelayInBlocks)

for _, test := range tests {
test.After(t)
}
}

func runUpgrade(
t *testing.T,
upgradeName string,
Expand All @@ -85,6 +102,7 @@ func runUpgrade(
tmQueryClient := tmservice.NewServiceClient(chain.ClientContext)
infoBeforeRes, err := tmQueryClient.GetNodeInfo(ctx, &tmservice.GetNodeInfoRequest{})
requireT.NoError(err)
t.Logf("Old binary version: %s", infoBeforeRes.ApplicationVersion.Version)

latestBlockRes, err := tmQueryClient.GetLatestBlock(ctx, &tmservice.GetLatestBlockRequest{})
requireT.NoError(err)
Expand Down
62 changes: 62 additions & 0 deletions integration-tests/upgrade/wasmd_upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//go:build integrationtests

package upgrade

import (
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/stretchr/testify/require"

integrationtests "github.com/CoreumFoundation/coreum/v4/integration-tests"
)

type wasmdUpgradeTest struct {
}

func (wut *wasmdUpgradeTest) Before(t *testing.T) {
assertDependencyVersion(
t,
"github.com/CosmWasm/wasmd",
"v0.45.",
)
assertDependencyVersion(
t,
"github.com/CosmWasm/wasmvm",
"v1.5.2",
)
}

func (wut *wasmdUpgradeTest) After(t *testing.T) {
assertDependencyVersion(
t,
"github.com/CosmWasm/wasmd",
"v0.46.0",
)
assertDependencyVersion(
t,
"github.com/CosmWasm/wasmvm",
"v1.5.4",
)
}

func assertDependencyVersion(
t *testing.T,
depName string,
versionPrefix string,
) {
ctx, chain := integrationtests.NewCoreumTestingContext(t)
requireT := require.New(t)
cmtClient := tmservice.NewServiceClient(chain.ClientContext)
nodeInfo, err := cmtClient.GetNodeInfo(ctx, &tmservice.GetNodeInfoRequest{})
requireT.NoError(err)
for _, dep := range nodeInfo.ApplicationVersion.BuildDeps {
if dep.Path == depName {
t.Logf("dep %s. version:%s. expected version:%s", dep.Path, dep.Version, versionPrefix)
requireT.True(strings.HasPrefix(dep.Version, versionPrefix))
return
}
}
requireT.Failf("dependency %s not found", depName)
}

0 comments on commit 4250e1b

Please sign in to comment.