Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ERC721NFTs code migration #3469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x97abe1b6193673f6c561c704ef04565b1211e344ffdf44eae0ca4b93e2b39bb4
0xaad445a087e088ca60f34f3917c641619677dbbcb6041c997c18d05e091b13f5
2 changes: 1 addition & 1 deletion packages/testutil/testdbhash/TestGetEvents-blocklog.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x6d23c7af0d1d75bccf5d2132d94466f685ff7dfcdf568ce9426e24f3f72329b9
0x6e59e0c0b3388e66ca1106d1d384952899e9ee09db1819f7d4bf39e02e2cab3b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x054bc728d6fc6392983981c78cc7f1e37947c378fcd7bb687f633251d7101fc5
0xcbc6d3ebde280d1c98c454b50483d90fa828b5ae2620a086da6c72f9295927f2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x93ae0b29d133ce13d27fae2ea08257f2258fe5fab8cb89f9bff0d1592b7d89a6
0x9d600e1f99cbc893aa43dccb94dd59a03b635890cf7b8574c8605295b33eaa2b
2 changes: 1 addition & 1 deletion packages/testutil/testdbhash/TestSelfDestruct-evm.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x890a1dad1110c96878fd4d91dba3fafccf7bcbd6339aa64a750eda41a284700a
0x6c162882de7133f9192f2eba02fd36a5437a353919e3c3c4842f6b5e5c5f79f4
2 changes: 1 addition & 1 deletion packages/testutil/testdbhash/TestSendBaseTokens-evm.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x9ca6247f0595c26d1525ce260d1d1fe686793f1ae2ab79dbff8473be702d22d9
0xd3a01e44768150fac49f4b76fb069aaf7b22c0fbcac7a6b1c4125bcf24d009dd
2 changes: 1 addition & 1 deletion packages/testutil/testdbhash/TestStorageContract-evm.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x5d36d9fd395239fd2bcad1bb313ba3b653ca58a50a85b479ef2fcf5cef24bf7d
0xf947695a32a4a3bd1a33c878a39f37f3db4e8cffb98b60d9c10ac38af1703cf5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0xff156b18e625b1a3d2ebfa7d749515c6b3ada0aa20fd7bb5ee3d14f4d2f6e18f
0x6aa9785ecccf62b58eb7421c29cb620cf21852e7f999578b19d83ac65c96ccba
2 changes: 2 additions & 0 deletions packages/vm/core/migrations/allmigrations/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -19,5 +20,6 @@ var DefaultScheme = &migrations.MigrationScheme{
Migrations: []migrations.Migration{
m001.AccountDecimals,
m002.UpdateEVMISCMagic,
m003.UpdateEVMISCMagicFixed,
},
}
14 changes: 7 additions & 7 deletions packages/vm/core/migrations/m002/update_iscmagic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}
22 changes: 22 additions & 0 deletions packages/vm/core/migrations/m003/update_iscmagic.go
Original file line number Diff line number Diff line change
@@ -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
},
}
Loading