diff --git a/cli/server/server.go b/cli/server/server.go index c5f44f1ae..9d47ab47a 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -636,7 +636,7 @@ func initBlockChain(cfg config.Config, log *zap.Logger) (*core.Blockchain, stora errArgs = append(errArgs, closeErr) } - return nil, nil, cli.NewExitError(fmt.Errorf(errText, errArgs), 1) + return nil, nil, cli.NewExitError(fmt.Errorf(errText, errArgs...), 1) } return chain, store, nil } diff --git a/pkg/core/blockchain_neotest_test.go b/pkg/core/blockchain_neotest_test.go index 7ab6c53a2..4cf2f8137 100644 --- a/pkg/core/blockchain_neotest_test.go +++ b/pkg/core/blockchain_neotest_test.go @@ -207,6 +207,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) { require.Error(t, err) require.True(t, strings.Contains(err.Error(), "can't init MPT at height"), err) }) + /* See #2801 t.Run("failed native Management initialisation", func(t *testing.T) { ps = newPS(t) @@ -223,6 +224,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) { require.Error(t, err) require.True(t, strings.Contains(err.Error(), "can't init cache for Management native contract"), err) }) + */ t.Run("invalid native contract deactivation", func(t *testing.T) { ps = newPS(t) _, _, _, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, func(c *config.ProtocolConfiguration) { diff --git a/pkg/core/native/management.go b/pkg/core/native/management.go index 444cf07fd..faa2d4e4a 100644 --- a/pkg/core/native/management.go +++ b/pkg/core/native/management.go @@ -539,19 +539,13 @@ func (m *Management) InitializeCache(d *dao.Simple) error { nep17: make(map[util.Uint160]struct{}), } - var initErr error - d.Seek(m.ID, storage.SeekRange{Prefix: []byte{PrefixContract}}, func(_, v []byte) bool { + d.Seek(m.ID, storage.SeekRange{Prefix: []byte{PrefixContract}}, func(k, v []byte) bool { var cs = new(state.Contract) - initErr = stackitem.DeserializeConvertible(v, cs) - if initErr != nil { - return false + if stackitem.DeserializeConvertible(v, cs) == nil { + updateContractCache(cache, cs) } - updateContractCache(cache, cs) return true }) - if initErr != nil { - return initErr - } d.SetCache(m.ID, cache) return nil } diff --git a/pkg/core/native/management_test.go b/pkg/core/native/management_test.go index 123e67f3a..2b3a71df5 100644 --- a/pkg/core/native/management_test.go +++ b/pkg/core/native/management_test.go @@ -78,12 +78,14 @@ func TestManagement_Initialize(t *testing.T) { mgmt := newManagement() require.NoError(t, mgmt.InitializeCache(d)) }) + /* See #2801 t.Run("invalid contract state", func(t *testing.T) { d := dao.NewSimple(storage.NewMemoryStore(), false, false) mgmt := newManagement() d.PutStorageItem(mgmt.ID, []byte{PrefixContract}, state.StorageItem{0xFF}) require.Error(t, mgmt.InitializeCache(d)) }) + */ } func TestManagement_GetNEP17Contracts(t *testing.T) {