From de7682132edbc47862c4ba5e40e967287b90bb77 Mon Sep 17 00:00:00 2001 From: Jorge Silva Date: Mon, 15 Jul 2024 13:41:53 +0100 Subject: [PATCH] fix: ERC721NFTs code migration --- .../TestDeployNativeContract-root.hex | 2 +- .../testdbhash/TestGetEvents-blocklog.hex | 2 +- ...mint_from_it_as_a_collection1-accounts.hex | 2 +- ...mint_from_it_as_a_collection2-accounts.hex | 2 +- .../testdbhash/TestSelfDestruct-evm.hex | 2 +- .../testdbhash/TestSendBaseTokens-evm.hex | 2 +- .../testdbhash/TestStorageContract-evm.hex | 2 +- .../TestUnprocessableWithPruning-blocklog.hex | 2 +- .../vm/core/migrations/allmigrations/all.go | 2 ++ .../core/migrations/m002/update_iscmagic.go | 14 ++++++------ .../core/migrations/m003/update_iscmagic.go | 22 +++++++++++++++++++ 11 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 packages/vm/core/migrations/m003/update_iscmagic.go diff --git a/packages/testutil/testdbhash/TestDeployNativeContract-root.hex b/packages/testutil/testdbhash/TestDeployNativeContract-root.hex index ca90a02879..08fa8f566e 100644 --- a/packages/testutil/testdbhash/TestDeployNativeContract-root.hex +++ b/packages/testutil/testdbhash/TestDeployNativeContract-root.hex @@ -1 +1 @@ -0x97abe1b6193673f6c561c704ef04565b1211e344ffdf44eae0ca4b93e2b39bb4 +0xaad445a087e088ca60f34f3917c641619677dbbcb6041c997c18d05e091b13f5 diff --git a/packages/testutil/testdbhash/TestGetEvents-blocklog.hex b/packages/testutil/testdbhash/TestGetEvents-blocklog.hex index f38755de38..1637c50c54 100644 --- a/packages/testutil/testdbhash/TestGetEvents-blocklog.hex +++ b/packages/testutil/testdbhash/TestGetEvents-blocklog.hex @@ -1 +1 @@ -0x6d23c7af0d1d75bccf5d2132d94466f685ff7dfcdf568ce9426e24f3f72329b9 +0x6e59e0c0b3388e66ca1106d1d384952899e9ee09db1819f7d4bf39e02e2cab3b diff --git a/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection1-accounts.hex b/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection1-accounts.hex index e2b7161f4e..7aefb3e22b 100644 --- a/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection1-accounts.hex +++ b/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection1-accounts.hex @@ -1 +1 @@ -0x054bc728d6fc6392983981c78cc7f1e37947c378fcd7bb687f633251d7101fc5 +0xcbc6d3ebde280d1c98c454b50483d90fa828b5ae2620a086da6c72f9295927f2 diff --git a/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection2-accounts.hex b/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection2-accounts.hex index 795233e1dc..560230a474 100644 --- a/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection2-accounts.hex +++ b/packages/testutil/testdbhash/TestNFTMint-mint_to_self,_then_mint_from_it_as_a_collection2-accounts.hex @@ -1 +1 @@ -0x93ae0b29d133ce13d27fae2ea08257f2258fe5fab8cb89f9bff0d1592b7d89a6 +0x9d600e1f99cbc893aa43dccb94dd59a03b635890cf7b8574c8605295b33eaa2b diff --git a/packages/testutil/testdbhash/TestSelfDestruct-evm.hex b/packages/testutil/testdbhash/TestSelfDestruct-evm.hex index 60ad5b2a09..9117a7f9df 100644 --- a/packages/testutil/testdbhash/TestSelfDestruct-evm.hex +++ b/packages/testutil/testdbhash/TestSelfDestruct-evm.hex @@ -1 +1 @@ -0x890a1dad1110c96878fd4d91dba3fafccf7bcbd6339aa64a750eda41a284700a +0x6c162882de7133f9192f2eba02fd36a5437a353919e3c3c4842f6b5e5c5f79f4 diff --git a/packages/testutil/testdbhash/TestSendBaseTokens-evm.hex b/packages/testutil/testdbhash/TestSendBaseTokens-evm.hex index 7ac24585cf..491b3a795a 100644 --- a/packages/testutil/testdbhash/TestSendBaseTokens-evm.hex +++ b/packages/testutil/testdbhash/TestSendBaseTokens-evm.hex @@ -1 +1 @@ -0x9ca6247f0595c26d1525ce260d1d1fe686793f1ae2ab79dbff8473be702d22d9 +0xd3a01e44768150fac49f4b76fb069aaf7b22c0fbcac7a6b1c4125bcf24d009dd diff --git a/packages/testutil/testdbhash/TestStorageContract-evm.hex b/packages/testutil/testdbhash/TestStorageContract-evm.hex index 846975483b..07216fe0bc 100644 --- a/packages/testutil/testdbhash/TestStorageContract-evm.hex +++ b/packages/testutil/testdbhash/TestStorageContract-evm.hex @@ -1 +1 @@ -0x5d36d9fd395239fd2bcad1bb313ba3b653ca58a50a85b479ef2fcf5cef24bf7d +0xf947695a32a4a3bd1a33c878a39f37f3db4e8cffb98b60d9c10ac38af1703cf5 diff --git a/packages/testutil/testdbhash/TestUnprocessableWithPruning-blocklog.hex b/packages/testutil/testdbhash/TestUnprocessableWithPruning-blocklog.hex index e2aefd4632..7c2adb03e6 100644 --- a/packages/testutil/testdbhash/TestUnprocessableWithPruning-blocklog.hex +++ b/packages/testutil/testdbhash/TestUnprocessableWithPruning-blocklog.hex @@ -1 +1 @@ -0xff156b18e625b1a3d2ebfa7d749515c6b3ada0aa20fd7bb5ee3d14f4d2f6e18f +0x6aa9785ecccf62b58eb7421c29cb620cf21852e7f999578b19d83ac65c96ccba diff --git a/packages/vm/core/migrations/allmigrations/all.go b/packages/vm/core/migrations/allmigrations/all.go index 737aa83a2e..3cc1cfd50a 100644 --- a/packages/vm/core/migrations/allmigrations/all.go +++ b/packages/vm/core/migrations/allmigrations/all.go @@ -4,6 +4,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/core/migrations" "github.com/iotaledger/wasp/packages/vm/core/migrations/m001" "github.com/iotaledger/wasp/packages/vm/core/migrations/m002" + "github.com/iotaledger/wasp/packages/vm/core/migrations/m003" ) var DefaultScheme = &migrations.MigrationScheme{ @@ -19,5 +20,6 @@ var DefaultScheme = &migrations.MigrationScheme{ Migrations: []migrations.Migration{ m001.AccountDecimals, m002.UpdateEVMISCMagic, + m003.UpdateEVMISCMagicFixed, }, } diff --git a/packages/vm/core/migrations/m002/update_iscmagic.go b/packages/vm/core/migrations/m002/update_iscmagic.go index 958791579b..e6c89d1763 100644 --- a/packages/vm/core/migrations/m002/update_iscmagic.go +++ b/packages/vm/core/migrations/m002/update_iscmagic.go @@ -3,20 +3,20 @@ package m002 import ( "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/subrealm" "github.com/iotaledger/wasp/packages/vm/core/evm" - "github.com/iotaledger/wasp/packages/vm/core/evm/emulator" - "github.com/iotaledger/wasp/packages/vm/core/evm/iscmagic" "github.com/iotaledger/wasp/packages/vm/core/migrations" ) var UpdateEVMISCMagic = migrations.Migration{ Contract: evm.Contract, Apply: func(state kv.KVStore, log *logger.Logger) error { - evmPartition := subrealm.New(state, kv.Key(evm.Contract.Hname().Bytes())) - emulatorState := evm.EmulatorStateSubrealm(evmPartition) - stateDBSubrealm := emulator.StateDBSubrealm(emulatorState) - emulator.SetCode(stateDBSubrealm, iscmagic.ERC721NFTsAddress, iscmagic.ERC721NFTsRuntimeBytecode) + // noop - this migration was executed in the testnet, it had an issue where a bogus key was updated (not problematic) + // keeping the code below if necessary to revisit return nil + // evmPartition := subrealm.New(state, kv.Key(evm.Contract.Hname().Bytes())) // NOTE: this line was unnecessary + // emulatorState := evm.EmulatorStateSubrealm(evmPartition) + // stateDBSubrealm := emulator.StateDBSubrealm(emulatorState) + // emulator.SetCode(stateDBSubrealm, iscmagic.ERC721NFTsAddress, iscmagic.ERC721NFTsRuntimeBytecode) + // return nil }, } diff --git a/packages/vm/core/migrations/m003/update_iscmagic.go b/packages/vm/core/migrations/m003/update_iscmagic.go new file mode 100644 index 0000000000..267c0f487c --- /dev/null +++ b/packages/vm/core/migrations/m003/update_iscmagic.go @@ -0,0 +1,22 @@ +package m003 + +import ( + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/wasp/packages/kv" + "github.com/iotaledger/wasp/packages/vm/core/evm" + "github.com/iotaledger/wasp/packages/vm/core/evm/emulator" + "github.com/iotaledger/wasp/packages/vm/core/evm/iscmagic" + "github.com/iotaledger/wasp/packages/vm/core/migrations" +) + +var UpdateEVMISCMagicFixed = migrations.Migration{ + Contract: evm.Contract, + Apply: func(state kv.KVStore, log *logger.Logger) error { + log.Infof("m003 UpdateEVMISCMagicFixed started") + emulatorState := evm.EmulatorStateSubrealm(state) + stateDBSubrealm := emulator.StateDBSubrealm(emulatorState) + emulator.SetCode(stateDBSubrealm, iscmagic.ERC721NFTsAddress, iscmagic.ERC721NFTsRuntimeBytecode) + log.Infof("m003 UpdateEVMISCMagicFixed finished") + return nil + }, +}