core: fix Neo.Blockchain.GetValidators implementation

It should return keys, attempting to push []*state.Validator to the stack
would probably lead to failure.
This commit is contained in:
Roman Khimov 2020-05-17 23:31:08 +03:00
parent 9e94895bb0
commit 80b8b50f02

View file

@ -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
}