From bbe02ac584375aa227882b0c091be7308e2f1cff Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 29 Jun 2020 10:36:44 +0300 Subject: [PATCH] native: store typed `nil` in validators cache Fix `error encountered at instruction 0 (SYSCALL): sync/atomic: store of nil value into Value"`. --- pkg/core/native/native_neo.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index f42fa4286..677c47266 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -77,6 +77,7 @@ func NewNEO() *NEO { nep5.ContractID = neoContractID n.nep5TokenNative = *nep5 + n.validators.Store(keys.PublicKeys(nil)) onp := n.Methods["onPersist"] onp.Func = getOnPersistWrapper(n.onPersist) @@ -333,7 +334,7 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b return err } } - n.validators.Store(nil) + n.validators.Store(keys.PublicKeys(nil)) return nil } @@ -386,8 +387,8 @@ func (n *NEO) getRegisteredValidatorsCall(ic *interop.Context, _ []stackitem.Ite // GetValidatorsInternal returns a list of current validators. func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error) { - if vals := n.validators.Load(); vals != nil { - return vals.(keys.PublicKeys), nil + if vals := n.validators.Load().(keys.PublicKeys); vals != nil { + return vals, nil } standByValidators := bc.GetStandByValidators() si := d.GetStorageItem(n.ContractID, validatorsCountKey)