From e9f496a19fe6a674c29aa0809a864bc8c8bb30ef Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 5 Mar 2025 19:05:26 +0300 Subject: [PATCH 1/3] cli: use context-bound writer to log message Signed-off-by: Anna Shaleva --- cli/util/upload_bin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/util/upload_bin.go b/cli/util/upload_bin.go index e5eb77de6..0e710ac8a 100644 --- a/cli/util/upload_bin.go +++ b/cli/util/upload_bin.go @@ -257,7 +257,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C if err != nil { return fmt.Errorf("failed to upload index file: %w", err) } - fmt.Println("Successfully uploaded index file ", indexFileStart/indexFileSize) + fmt.Fprintln(ctx.App.Writer, "Successfully uploaded index file ", indexFileStart/indexFileSize) } clear(buf) } From 3ec14d2e8f5e0161d945bca20436ff996f474e81 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 5 Mar 2025 19:14:28 +0300 Subject: [PATCH 2/3] *: extend NotaryRequest verification errors This change is compatible with the old protocol. Signed-off-by: Anna Shaleva --- pkg/core/blockchain.go | 2 +- pkg/network/server.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 0c6b897dd..e722d420c 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -2849,7 +2849,7 @@ func (bc *Blockchain) PoolTxWithData(t *transaction.Transaction, data any, mp *m if verificationFunction != nil { err := verificationFunction(t, data) if err != nil { - return err + return fmt.Errorf("data verification failed: %w", err) } } return bc.verifyAndPoolTx(t, mp, feer, data) diff --git a/pkg/network/server.go b/pkg/network/server.go index 848b4f0c7..bc7decb0c 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -1325,7 +1325,11 @@ func (s *Server) RelayP2PNotaryRequest(r *payload.P2PNotaryRequest) error { // verifyAndPoolNotaryRequest verifies NotaryRequest payload and adds it to the payload mempool. func (s *Server) verifyAndPoolNotaryRequest(r *payload.P2PNotaryRequest) error { - return s.chain.PoolTxWithData(r.FallbackTransaction, r, s.notaryRequestPool, s.notaryFeer, s.verifyNotaryRequest) + err := s.chain.PoolTxWithData(r.FallbackTransaction, r, s.notaryRequestPool, s.notaryFeer, s.verifyNotaryRequest) + if err != nil { + return fmt.Errorf("failed to add fallback transaction to the notary pool: %w", err) + } + return nil } // verifyNotaryRequest is a function for state-dependant P2PNotaryRequest payload verification which is executed before ordinary blockchain's verification. From 13b75c9d1af2b84cb1d89c1d0930e1249653c5f5 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 6 Mar 2025 12:18:37 +0300 Subject: [PATCH 3/3] notary: warn if no space left in completed transaction queue No functional changes, just add a warning to the node's logs. Signed-off-by: Anna Shaleva --- pkg/services/notary/notary.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/services/notary/notary.go b/pkg/services/notary/notary.go index 6639acbca..2e5b4d2fe 100644 --- a/pkg/services/notary/notary.go +++ b/pkg/services/notary/notary.go @@ -333,7 +333,7 @@ func (n *Notary) OnNewRequest(payload *payload.P2PNotaryRequest) { } if r.isMainCompleted() && r.minNotValidBefore > n.Config.Chain.BlockHeight() { if err := n.finalize(acc, r.main, payload.MainTransaction.Hash()); err != nil { - n.Config.Log.Error("failed to finalize main transaction", + n.Config.Log.Error("failed to finalize main transaction, waiting for the next block to retry", zap.String("hash", r.main.Hash().StringLE()), zap.Error(err)) } @@ -381,7 +381,9 @@ func (n *Notary) PostPersist() { for h, r := range n.requests { if !r.isSent && r.isMainCompleted() && r.minNotValidBefore > currHeight { if err := n.finalize(acc, r.main, h); err != nil { - n.Config.Log.Error("failed to finalize main transaction", zap.Error(err)) + n.Config.Log.Error("failed to finalize main transaction after PostPersist, waiting for the next block to retry", + zap.String("hash", r.main.Hash().StringLE()), + zap.Error(err)) } continue } @@ -389,7 +391,10 @@ func (n *Notary) PostPersist() { for _, fb := range r.fallbacks { if nvb := fb.GetAttributes(transaction.NotValidBeforeT)[0].Value.(*transaction.NotValidBefore).Height; nvb <= currHeight { // Ignore the error, wait for the next block to resend them - _ = n.finalize(acc, fb, h) + err := n.finalize(acc, fb, h) + n.Config.Log.Error("failed to finalize fallback transaction, waiting for the next block to retry", + zap.String("hash", fb.Hash().StringLE()), + zap.Error(err)) } } } @@ -413,7 +418,10 @@ func (n *Notary) finalize(acc *wallet.Account, tx *transaction.Transaction, h ut return fmt.Errorf("failed to update completed transaction's size: %w", err) } - n.pushNewTx(newTx, h) + err = n.pushNewTx(newTx, h) + if err != nil { + return fmt.Errorf("failed to enqueue completed transaction: %w", err) + } return nil } @@ -423,11 +431,13 @@ type txHashPair struct { mainHash util.Uint256 } -func (n *Notary) pushNewTx(tx *transaction.Transaction, h util.Uint256) { +func (n *Notary) pushNewTx(tx *transaction.Transaction, h util.Uint256) error { select { case n.newTxs <- txHashPair{tx, h}: default: + return errors.New("transaction queue is full") } + return nil } func (n *Notary) newTxCallbackLoop() {