From f557959c2412374f7f042d2b6220c8e2817636f6 Mon Sep 17 00:00:00 2001 From: Tatiana Nesterenko Date: Sun, 13 Aug 2023 20:15:31 +0100 Subject: [PATCH] rpcsrv: return error on invalid proof from `verifyProof` This change makes code incompatible with C# node, because currently no error is returned on invalid proof. According to proposal: https://github.com/neo-project/proposals/pull/156 Also adding `verifyProof` descpiption in docs/rpc.md. Signed-off-by: Tatiana Nesterenko --- docs/rpc.md | 5 +++++ pkg/services/rpcsrv/server.go | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/rpc.md b/docs/rpc.md index 5b3e687d8..73b5b0a0b 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -196,6 +196,11 @@ enabled in the server's protocol configuration. ##### `getnep11transfers` and `getnep17transfers` `transfernotifyindex` is not tracked by NeoGo, thus this field is always zero. +##### `verifyProof` + +NeoGo can generate an error in response to an invalid proof, unlike +the error-free C# implementation. + ### Unsupported methods Methods listed below are not going to be supported for various reasons diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index cfc5df532..86c4f3dc3 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -1531,9 +1531,10 @@ func (s *Server) verifyProof(ps params.Params) (any, *neorpc.Error) { } vp := new(result.VerifyProof) val, ok := mpt.VerifyProof(root, p.Key, p.Proof) - if ok { - vp.Value = val + if !ok { + return nil, neorpc.ErrInvalidProof } + vp.Value = val return vp, nil }