From fd2774ea91b1ace97afeda75f40ec2ba1bf4c0d9 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Sep 2023 19:24:45 +0300 Subject: [PATCH] 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 --- pkg/services/rpcsrv/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index f973d0489..34872a5a4 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -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) }