From 80b8b50f0275b87aa0f038b76dd308cc67a8e57f Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sun, 17 May 2020 23:31:08 +0300 Subject: [PATCH] core: fix Neo.Blockchain.GetValidators implementation It should return keys, attempting to push []*state.Validator to the stack would probably lead to failure. --- pkg/core/interop_neo.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index 277e06620..052166555 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -236,7 +236,14 @@ func (ic *interopContext) witnessGetVerificationScript(v *vm.VM) error { // bcGetValidators returns validators. func (ic *interopContext) bcGetValidators(v *vm.VM) error { - validators := ic.dao.GetValidators() + valStates := ic.dao.GetValidators() + if len(valStates) > vm.MaxArraySize { + return errors.New("too many validators") + } + validators := make([]vm.StackItem, 0, len(valStates)) + for _, val := range valStates { + validators = append(validators, vm.NewByteArrayItem(val.PublicKey.Bytes())) + } v.Estack().PushVal(validators) return nil }