From a7fe85a2d89b3bea3ee67f12c24e1496e363faee Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 5 Apr 2022 15:12:40 +0300 Subject: [PATCH] services: fix changing of main tx size of Notary request --- pkg/services/notary/notary.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/services/notary/notary.go b/pkg/services/notary/notary.go index 5f6a8e747..f6537ac5b 100644 --- a/pkg/services/notary/notary.go +++ b/pkg/services/notary/notary.go @@ -218,8 +218,15 @@ func (n *Notary) OnNewRequest(payload *payload.P2PNotaryRequest) { r.minNotValidBefore = nvbFallback } } else { + // Avoid changes in main transaction witnesses got from notary request pool to + // keep the pooled tx valid. We will update its copy => the copy's size will be changed. + cp := *payload.MainTransaction + cp.Scripts = make([]transaction.Witness, len(payload.MainTransaction.Scripts)) + for i, w := range payload.MainTransaction.Scripts { + cp.Scripts[i] = w + } r = &request{ - main: payload.MainTransaction, + main: &cp, minNotValidBefore: nvbFallback, } n.requests[payload.MainTransaction.Hash()] = r @@ -227,6 +234,8 @@ func (n *Notary) OnNewRequest(payload *payload.P2PNotaryRequest) { if r.witnessInfo == nil && validationErr == nil { r.witnessInfo = newInfo } + // Allow modification of fallback transaction got from notary request pool. + // It has dummy Notary witness attached => its size won't be changed. r.fallbacks = append(r.fallbacks, payload.FallbackTransaction) if exists && r.isMainCompleted() || validationErr != nil { return