From a58daf9b115afe0fc9c95c7f6d5549297f7233e9 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:07:21 +0900 Subject: [PATCH] prepare v0.6.2 release (#307) --- app/upgrade.go | 83 +------------------------------------------------- go.mod | 4 +-- go.sum | 8 ++--- 3 files changed, 7 insertions(+), 88 deletions(-) diff --git a/app/upgrade.go b/app/upgrade.go index 70374631..21308195 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -1,100 +1,19 @@ package app import ( - "bytes" "context" - "errors" - "fmt" - "cosmossdk.io/collections" - sdkerrors "cosmossdk.io/errors" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/types/module" - - movetypes "github.com/initia-labs/initia/x/move/types" - vmprecompile "github.com/initia-labs/movevm/precompile" - vmtypes "github.com/initia-labs/movevm/types" ) -const upgradeName = "0.6.0" +const upgradeName = "0.6.2" // RegisterUpgradeHandlers returns upgrade handlers func (app *InitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) { app.UpgradeKeeper.SetUpgradeHandler( upgradeName, func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - - // 1. publish new code module first - codeModuleBz, err := vmprecompile.ReadStdlib("code.mv") - if err != nil { - return nil, err - } - err = app.MoveKeeper.SetModule(ctx, vmtypes.StdAddress, movetypes.MoveModuleNameCode, codeModuleBz[0]) - if err != nil { - return nil, err - } - - // 2. update vm data with new separator and add checksums of each module - - // Previous: - // ModuleSeparator = byte(0) - // ResourceSeparator = byte(1) - // TableEntrySeparator = byte(2) - // TableInfoSeparator = byte(3) - - // Current: - // ModuleSeparator = byte(0) - // ChecksumSeparator = byte(1) - // ResourceSeparator = byte(2) - // TableEntrySeparator = byte(3) - // TableInfoSeparator = byte(4) - - err = app.MoveKeeper.VMStore.Walk(ctx, new(collections.Range[[]byte]).Descending(), func(key, value []byte) (stop bool, err error) { - key = bytes.Clone(key) - - cursor := movetypes.AddressBytesLength - if len(key) <= cursor { - return true, fmt.Errorf("invalid key length: %d", len(key)) - } - - separator := key[cursor] - if separator == movetypes.ModuleSeparator { - checksum := movetypes.ModuleBzToChecksum(value) - value = checksum[:] - } else if separator >= movetypes.TableInfoSeparator { - return true, errors.New("unknown prefix") - } else if err = app.MoveKeeper.VMStore.Remove(ctx, key); err != nil { - return true, err - } - - key[cursor] = key[cursor] + 1 - err = app.MoveKeeper.VMStore.Set(ctx, key, value) - if err != nil { - return true, err - } - - return false, nil - }) - if err != nil { - return nil, err - } - - // 3. update new modules - - codesBz, err := vmprecompile.ReadStdlib("object_code_deployment.mv", "coin.mv", "cosmos.mv", "dex.mv", "json.mv", "bech32.mv", "hash.mv", "collection.mv") - if err != nil { - return nil, err - } - modules := make([]vmtypes.Module, len(codesBz)) - for i, codeBz := range codesBz { - modules[i] = vmtypes.NewModule(codeBz) - } - - err = app.MoveKeeper.PublishModuleBundle(ctx, vmtypes.StdAddress, vmtypes.NewModuleBundle(modules...), movetypes.UpgradePolicy_COMPATIBLE) - if err != nil { - return nil, sdkerrors.Wrap(err, "failed to publish module bundle") - } - return vm, nil }, ) diff --git a/go.mod b/go.mod index 63720f49..bc382e80 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 - github.com/initia-labs/OPinit v0.5.6 + github.com/initia-labs/OPinit v0.6.0 // we also need to update `LIBMOVEVM_VERSION` of Dockerfile#9 github.com/initia-labs/movevm v0.6.1 github.com/noble-assets/forwarding/v2 v2.0.0-20240521090705-86712c4c9e43 @@ -151,7 +151,7 @@ require ( github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/initia-labs/OPinit/api v0.5.1 // indirect + github.com/initia-labs/OPinit/api v0.6.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.9 // indirect diff --git a/go.sum b/go.sum index 6104221b..b5f9d294 100644 --- a/go.sum +++ b/go.sum @@ -724,10 +724,10 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/initia-labs/OPinit v0.5.6 h1:m+RHWD64rWcvEfe4ZEi9IHxBrMmKUq4VQA7KTZpMMSk= -github.com/initia-labs/OPinit v0.5.6/go.mod h1:lx1amLMszculwPu8ln+btJno38UV28fd2nP7XC88ZeE= -github.com/initia-labs/OPinit/api v0.5.1 h1:zwyJf7HtKJCKvLJ1R9PjVfJO1L+d/jKoeFyT7WTLHFI= -github.com/initia-labs/OPinit/api v0.5.1/go.mod h1:gHK6DEWb3/DqQD5LjKirUx9jilAh2UioXanoQdgqVfU= +github.com/initia-labs/OPinit v0.6.0 h1:V9jQf8+PjNctLX31FHMGUsk6fpnygVJO1WYzCmBMzkU= +github.com/initia-labs/OPinit v0.6.0/go.mod h1:gDpCh4Zx94mihwgzP/PLav8eVHLroZBu3dFyzCy8iIs= +github.com/initia-labs/OPinit/api v0.6.0 h1:Q3hDHpTd9EqlDfY/OryCKIwuXYWJxGJdGfJicV1RjL4= +github.com/initia-labs/OPinit/api v0.6.0/go.mod h1:gHK6DEWb3/DqQD5LjKirUx9jilAh2UioXanoQdgqVfU= github.com/initia-labs/cometbft v0.0.0-20241106155049-4698d4a37fe1 h1:Hqxf4a6PfCatz5vCBCovjhn4FwYaooCXIvyv4MM4Wjs= github.com/initia-labs/cometbft v0.0.0-20241106155049-4698d4a37fe1/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= github.com/initia-labs/movevm v0.6.1 h1:g+nUX289tou8HaHkwvZIE7KzhVAi+fykpGORItw8j0E=