From 6db764c7d328cf17e2ddd1aa1188c2268f3502f3 Mon Sep 17 00:00:00 2001 From: ssd04 Date: Fri, 8 Dec 2023 14:59:49 +0200 Subject: [PATCH 1/2] adapt migrate code leaf in accounts adapter --- config/gasSchedule.go | 1 + go.mod | 4 ++-- go.sum | 4 ++++ mock/world/worldAccountsAdapter.go | 5 +++++ scenarioexec/gasSchedules/gasScheduleEmbedGenerated.go | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config/gasSchedule.go b/config/gasSchedule.go index 8c660a928..266ab8926 100644 --- a/config/gasSchedule.go +++ b/config/gasSchedule.go @@ -236,6 +236,7 @@ func FillGasMapBuiltInCosts(value uint64) map[string]uint64 { gasMap["UnGuardAccount"] = value gasMap["TrieLoadPerNode"] = value gasMap["TrieStorePerNode"] = value + gasMap["MigrateCodeLeaf"] = value return gasMap } diff --git a/go.mod b/go.mod index 0a6a3a623..a98ad6d61 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,12 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 github.com/gogo/protobuf v1.3.2 github.com/mitchellh/mapstructure v1.5.0 - github.com/multiversx/mx-chain-core-go v1.2.19-0.20231129100534-356aa234f4ff + github.com/multiversx/mx-chain-core-go v1.2.19-0.20231207131555-bec3579d08d3 github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231129101537-ef355850e34b github.com/multiversx/mx-chain-logger-go v1.0.14-0.20231129101244-c44fa1c79b03 github.com/multiversx/mx-chain-scenario-go v1.2.2-0.20231129113427-ad3056f45296 github.com/multiversx/mx-chain-storage-go v1.0.14-0.20231129103407-a506e0debdd4 - github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231129110322-d07a35163513 + github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231207131737-758c1e47240e github.com/multiversx/mx-components-big-int v1.0.0 github.com/pelletier/go-toml v1.9.3 github.com/stretchr/testify v1.8.1 diff --git a/go.sum b/go.sum index c5dedc444..1c4763dc3 100644 --- a/go.sum +++ b/go.sum @@ -83,6 +83,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiversx/mx-chain-core-go v1.2.19-0.20231129100534-356aa234f4ff h1:Iss44e+2C4vGtQ5sU3lOqDQ+dxvwlO+Z3mSbC8T1J64= github.com/multiversx/mx-chain-core-go v1.2.19-0.20231129100534-356aa234f4ff/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= +github.com/multiversx/mx-chain-core-go v1.2.19-0.20231207131555-bec3579d08d3 h1:aRKyuOCTYyCAdMQHXd33Ob5Ze5gKmh5UqaMf0GbkpBs= +github.com/multiversx/mx-chain-core-go v1.2.19-0.20231207131555-bec3579d08d3/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231129101537-ef355850e34b h1:TIE6it719ZIW0E1bFgPAgE+U3zPSkPfAloFYEIeOL3U= github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231129101537-ef355850e34b/go.mod h1:Ap6p7QZFtwPlb++OvCG+85BfuZ+bLP/JtQp6EwjWJsI= github.com/multiversx/mx-chain-logger-go v1.0.14-0.20231129101244-c44fa1c79b03 h1:krjJTyN9jrFTK0goMGFdgvJGy6bYSqe8EtI/HCceUmU= @@ -93,6 +95,8 @@ github.com/multiversx/mx-chain-storage-go v1.0.14-0.20231129103407-a506e0debdd4 github.com/multiversx/mx-chain-storage-go v1.0.14-0.20231129103407-a506e0debdd4/go.mod h1:ioCT2oHQ+TyHQYpgjxzlUdy7dCdv56+w5HnBg9z96eY= github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231129110322-d07a35163513 h1:3Hm3MVIpiu4+j+aHiDOYBJBiQC62nF/rHHRJ8YIFOL4= github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231129110322-d07a35163513/go.mod h1:vgmpc/YegaUMAImR+WZ+kpJgv9qYF31oL12vVx/46i4= +github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231207131737-758c1e47240e h1:6O1sVZt0M8kGOOObkLvziZzGk2N9ogJtE0jxpOYazgY= +github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231207131737-758c1e47240e/go.mod h1:kd+f708v/b5L1VVxaoYYEh1Z4poAfGOD+wRVKxLxasE= github.com/multiversx/mx-components-big-int v1.0.0 h1:Wkr8lSzK2nDqixOrrBa47VNuqdhV1m/aJhaP1EMaiS8= github.com/multiversx/mx-components-big-int v1.0.0/go.mod h1:maIEMgHlNE2u78JaDD0oLzri+ShgU4okHfzP3LWGdQM= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/mock/world/worldAccountsAdapter.go b/mock/world/worldAccountsAdapter.go index 548f16e8a..f2990c774 100644 --- a/mock/world/worldAccountsAdapter.go +++ b/mock/world/worldAccountsAdapter.go @@ -145,6 +145,11 @@ func (m *MockAccountsAdapter) IsPruningEnabled() bool { return false } +// MigrateCodeLeaf - +func (m *MockAccountsAdapter) MigrateCodeLeaf(_ vmcommon.AccountHandler) error { + return nil +} + // IsInterfaceNil - func (m *MockAccountsAdapter) IsInterfaceNil() bool { return m == nil diff --git a/scenarioexec/gasSchedules/gasScheduleEmbedGenerated.go b/scenarioexec/gasSchedules/gasScheduleEmbedGenerated.go index 6612c9946..3aa29f0e1 100644 --- a/scenarioexec/gasSchedules/gasScheduleEmbedGenerated.go +++ b/scenarioexec/gasSchedules/gasScheduleEmbedGenerated.go @@ -32,6 +32,7 @@ const ( UnGuardAccount = 250000 TrieLoadPerNode = 20000 TrieStorePerNode = 50000 + MigrateCodeLeaf = 100000 [MetaChainSystemSCsCost] Stake = 5000000 @@ -852,6 +853,7 @@ const ( UnGuardAccount = 250000 TrieLoadPerNode = 20000 TrieStorePerNode = 50000 + MigrateCodeLeaf = 100000 [MetaChainSystemSCsCost] Stake = 5000000 From 3d6ffbd07a22207717ef71eb70e5344a6804a9f7 Mon Sep 17 00:00:00 2001 From: ssd04 Date: Mon, 11 Dec 2023 20:37:42 +0200 Subject: [PATCH 2/2] coverage unit test --- config/gasSchedule_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/gasSchedule_test.go b/config/gasSchedule_test.go index 822dad5ed..e8a42f433 100644 --- a/config/gasSchedule_test.go +++ b/config/gasSchedule_test.go @@ -7,6 +7,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/multiversx/mx-chain-vm-go/executor" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type operations struct { @@ -172,3 +173,10 @@ func Test_isDynamicGasComputationFuncCorrectlyDefined(t *testing.T) { assert.True(t, ok) }) } + +func TestMakeGasMap(t *testing.T) { + t.Parallel() + + gasMap := MakeGasMapForTests() + require.NotNil(t, gasMap) +}