rpcsrv: return core.ErrVerificationFailed from calculatenetworkfee

We can ignore core.ErrInvalidSignature (which means that the script has
executed, but returned false), but we shouldn't ignore other errors which
likely mean that the script is incorrect (or hits some resource limits).

Use neorpc.ErrInvalidSignature as a return to separate this case from
contract-based verification.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2023-09-27 19:24:45 +03:00
parent 3628b824e1
commit fd2774ea91

View file

@ -951,7 +951,10 @@ func (s *Server) calculateNetworkFee(reqParams params.Params) (any, *neorpc.Erro
}
w.InvocationScript = inv.Bytes()
}
gasConsumed, _ := s.chain.VerifyWitness(signer.Account, tx, &w, int64(s.config.MaxGasInvoke))
gasConsumed, err := s.chain.VerifyWitness(signer.Account, tx, &w, int64(s.config.MaxGasInvoke))
if err != nil && !errors.Is(err, core.ErrInvalidSignature) {
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidSignature, err.Error())
}
netFee += gasConsumed
size += io.GetVarSize(w.VerificationScript) + io.GetVarSize(w.InvocationScript)
}