diff --git a/app/upgrade.go b/app/upgrade.go index 1d5d117..fbc11ac 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -2,25 +2,29 @@ package app import ( "context" + "strings" + + "github.com/ethereum/go-ethereum/core/vm" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/types/module" ) -const upgradeName = "0.5.14" +const upgradeName = "0.6.0" // RegisterUpgradeHandlers returns upgrade handlers func (app *MinitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) { app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + func(ctx context.Context, _ upgradetypes.Plan, versionMap module.VersionMap) (module.VersionMap, error) { // deploy and store erc20 wrapper contract address - err := app.EVMKeeper.DeployERC20Wrapper(ctx) - if err != nil { + if err := app.EVMKeeper.DeployERC20Wrapper(ctx); err != nil && + // ignore contract address collision error (contract already deployed) + !strings.Contains(err.Error(), vm.ErrContractAddressCollision.Error()) { return nil, err } - return vm, nil + return versionMap, nil }, ) } diff --git a/go.mod b/go.mod index f6020aa..3d1da42 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/holiman/uint256 v1.3.1 github.com/initia-labs/OPinit v0.5.5 - github.com/initia-labs/initia v0.5.6 + github.com/initia-labs/initia v0.6.0 github.com/initia-labs/kvindexer v0.1.9 github.com/initia-labs/kvindexer/submodules/block v0.1.0 github.com/initia-labs/kvindexer/submodules/evm-tx v0.1.2 diff --git a/go.sum b/go.sum index 9b868b8..aae3b67 100644 --- a/go.sum +++ b/go.sum @@ -1446,8 +1446,8 @@ github.com/initia-labs/evm v0.0.0-20241027024417-b90d6257f9b7 h1:m7ni67mL0+7qQCF github.com/initia-labs/evm v0.0.0-20241027024417-b90d6257f9b7/go.mod h1:Mq0biU2jbdmKSZoqOj29017ygFrMnB5/Rifwp980W4o= github.com/initia-labs/ibc-go/v8 v8.0.0-20240802003717-19c0b4ad450d h1:TLq8lB1PtQ0pjGf+bN8YgGVeLMuytZ26SBGMOs1seKY= github.com/initia-labs/ibc-go/v8 v8.0.0-20240802003717-19c0b4ad450d/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs= -github.com/initia-labs/initia v0.5.6 h1:7Um8tVTFHlYkt2kIpOzv5U6O3Z0izVJOZh+UXTmdFPU= -github.com/initia-labs/initia v0.5.6/go.mod h1:BPtxDrbu3HHnlZ8EGb3AZ5PDR4d+UVR5KMeX0K+oGI8= +github.com/initia-labs/initia v0.6.0 h1:/39ZN26zeixxZZdcfY1sOitiBhfnG3lcbPtpFqd9z7A= +github.com/initia-labs/initia v0.6.0/go.mod h1:nTHzSyI6Ldv8uG98h/A6N+h/qcfrlbALB7UDabWqenY= github.com/initia-labs/kvindexer v0.1.9 h1:rv/zD8VMU0+P7f+rTtYefIG93f3vRy55JqNK+fohQr8= github.com/initia-labs/kvindexer v0.1.9/go.mod h1:OV85HaQ9KVrg+zGPUlxT9RF9nAaM3Yq4/3MoHqGqhWk= github.com/initia-labs/kvindexer/submodules/block v0.1.0 h1:y+EXnksd/I2F96mzIoQA64nZUZON2P+99YrSzeLCLoY= @@ -1458,8 +1458,8 @@ github.com/initia-labs/kvindexer/submodules/pair v0.1.1 h1:o151gA4jIbqEl+pWTOCiz github.com/initia-labs/kvindexer/submodules/pair v0.1.1/go.mod h1:8X1GE1ZLkH7z8TKb5MUh7UClTkcqVFIwXIIRdsqeUZY= github.com/initia-labs/kvindexer/submodules/tx v0.1.0 h1:6kbf6wmzXPN0XCQLasiFgq1AlZHkt5K3/ZG+IWw1nNs= github.com/initia-labs/kvindexer/submodules/tx v0.1.0/go.mod h1:i0XeLbLa6xdgTR01WF8kaAO50vMmwxbeq0fKexwpFHU= -github.com/initia-labs/movevm v0.5.0 h1:dBSxoVyUumSE4x6/ZSOWtvbtZpw+V4W25/NH6qLU0uQ= -github.com/initia-labs/movevm v0.5.0/go.mod h1:aUWdvFZPdULjJ2McQTE+mLnfnG3CLAz0TWJRFzFFUwg= +github.com/initia-labs/movevm v0.6.0 h1:46JjDfOId6hfeoqYqKWTzPeb5ESQzzm8AhhGWYnFOmE= +github.com/initia-labs/movevm v0.6.0/go.mod h1:aUWdvFZPdULjJ2McQTE+mLnfnG3CLAz0TWJRFzFFUwg= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jellydator/ttlcache/v3 v3.3.0 h1:BdoC9cE81qXfrxeb9eoJi9dWrdhSuwXMAnHTbnBm4Wc= diff --git a/x/evm/keeper/context_test.go b/x/evm/keeper/context_test.go index 5f476c4..497e28e 100644 --- a/x/evm/keeper/context_test.go +++ b/x/evm/keeper/context_test.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/holiman/uint256" "golang.org/x/crypto/sha3" @@ -35,6 +36,24 @@ func Test_Create(t *testing.T) { require.Len(t, contractAddr, 20) } +func Test_Create2(t *testing.T) { + ctx, input := createDefaultTestInput(t) + _, _, addr := keyPubAddr() + + counterBz, err := hexutil.Decode(counter.CounterBin) + require.NoError(t, err) + + caller := common.BytesToAddress(addr.Bytes()) + + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate2(ctx, caller, counterBz, nil, 1, nil) + require.NoError(t, err) + require.NotEmpty(t, retBz) + require.Len(t, contractAddr, 20) + + _, _, _, err = input.EVMKeeper.EVMCreate2(ctx, caller, counterBz, nil, 1, nil) + require.ErrorContains(t, err, vm.ErrContractAddressCollision.Error()) +} + func Test_CreateWithValue(t *testing.T) { ctx, input := createDefaultTestInput(t) _, _, addr := keyPubAddr()