From e0825e766541d7f222fc2acfe10676ca59478237 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 4 Jun 2024 13:25:21 +0300 Subject: [PATCH] core: introduce D hardfork Signed-off-by: Anna Shaleva --- pkg/config/hardfork.go | 3 +++ pkg/config/hardfork_string.go | 8 ++++++-- pkg/core/blockchain_core_test.go | 4 +++- pkg/core/blockchain_neotest_test.go | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/config/hardfork.go b/pkg/config/hardfork.go index b070f9aa5..c0b2c5ff6 100644 --- a/pkg/config/hardfork.go +++ b/pkg/config/hardfork.go @@ -27,6 +27,9 @@ const ( // https://github.com/neo-project/neo/pull/2925) and #3362 (ported from // https://github.com/neo-project/neo/pull/3154). HFCockatrice // Cockatrice + // HFDomovoi represents hard-fork introduced in #3476 (ported from + // https://github.com/neo-project/neo/pull/3290). + HFDomovoi // Domovoi // hfLast denotes the end of hardforks enum. Consider adding new hardforks // before hfLast. hfLast diff --git a/pkg/config/hardfork_string.go b/pkg/config/hardfork_string.go index 8fc61d7b7..f45f1b3ca 100644 --- a/pkg/config/hardfork_string.go +++ b/pkg/config/hardfork_string.go @@ -12,13 +12,15 @@ func _() { _ = x[HFAspidochelone-1] _ = x[HFBasilisk-2] _ = x[HFCockatrice-4] - _ = x[hfLast-8] + _ = x[HFDomovoi-8] + _ = x[hfLast-16] } const ( _Hardfork_name_0 = "DefaultAspidocheloneBasilisk" _Hardfork_name_1 = "Cockatrice" - _Hardfork_name_2 = "hfLast" + _Hardfork_name_2 = "Domovoi" + _Hardfork_name_3 = "hfLast" ) var ( @@ -33,6 +35,8 @@ func (i Hardfork) String() string { return _Hardfork_name_1 case i == 8: return _Hardfork_name_2 + case i == 16: + return _Hardfork_name_3 default: return "Hardfork(" + strconv.FormatInt(int64(i), 10) + ")" } diff --git a/pkg/core/blockchain_core_test.go b/pkg/core/blockchain_core_test.go index c431d508e..0365338d7 100644 --- a/pkg/core/blockchain_core_test.go +++ b/pkg/core/blockchain_core_test.go @@ -370,6 +370,7 @@ func TestNewBlockchain_InitHardforks(t *testing.T) { config.HFAspidochelone.String(): 0, config.HFBasilisk.String(): 0, config.HFCockatrice.String(): 0, + config.HFDomovoi.String(): 0, }, bc.GetConfig().Hardforks) }) t.Run("empty set", func(t *testing.T) { @@ -400,13 +401,14 @@ func TestNewBlockchain_InitHardforks(t *testing.T) { }) t.Run("all present", func(t *testing.T) { bc := newTestChainWithCustomCfg(t, func(c *config.Config) { - c.ProtocolConfiguration.Hardforks = map[string]uint32{config.HFAspidochelone.String(): 5, config.HFBasilisk.String(): 10, config.HFCockatrice.String(): 15} + c.ProtocolConfiguration.Hardforks = map[string]uint32{config.HFAspidochelone.String(): 5, config.HFBasilisk.String(): 10, config.HFCockatrice.String(): 15, config.HFDomovoi.String(): 20} require.NoError(t, c.ProtocolConfiguration.Validate()) }) require.Equal(t, map[string]uint32{ config.HFAspidochelone.String(): 5, config.HFBasilisk.String(): 10, config.HFCockatrice.String(): 15, + config.HFDomovoi.String(): 20, }, bc.GetConfig().Hardforks) }) } diff --git a/pkg/core/blockchain_neotest_test.go b/pkg/core/blockchain_neotest_test.go index 5f70bdf37..5d0593052 100644 --- a/pkg/core/blockchain_neotest_test.go +++ b/pkg/core/blockchain_neotest_test.go @@ -271,7 +271,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) { _, _, _, err = chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache) require.Error(t, err) - require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch for the latest hardfork Cockatrice (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err) + require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch for the latest hardfork Domovoi (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err) }) t.Run("good", func(t *testing.T) {