From 7418a1e2b9c212bbd9e1021b38a967c14478a2dc Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 7 Nov 2023 12:47:33 +0000 Subject: [PATCH 1/3] [release-v1.3] webapi: Wait for unknown outputs to propagate. If broadcasting parent transaction of a ticket fails because it references unknown outputs, there is a good chance that waiting a few seconds will resolve the issue because the ancestor transactions will propagate through the network and reach the mempool of the local dcrd instance. --- internal/webapi/middleware.go | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/internal/webapi/middleware.go b/internal/webapi/middleware.go index 4a3af932..8e2a0435 100644 --- a/internal/webapi/middleware.go +++ b/internal/webapi/middleware.go @@ -275,10 +275,37 @@ func (w *WebAPI) broadcastTicket(c *gin.Context) { w.log.Debugf("%s: Broadcasting parent tx %s (ticketHash=%s)", funcName, parentHash, request.TicketHash) err = dcrdClient.SendRawTransaction(request.ParentHex) if err != nil { - w.log.Errorf("%s: dcrd.SendRawTransaction for parent tx failed (ticketHash=%s): %v", - funcName, request.TicketHash, err) - w.sendError(types.ErrCannotBroadcastTicket, c) - return + // Unknown output errors have special handling because they + // could be resolved by waiting for network propagation. Any + // other errors are returned to client immediately. + if !strings.Contains(err.Error(), rpc.ErrUnknownOutputs) { + w.log.Errorf("%s: dcrd.SendRawTransaction for parent tx failed (ticketHash=%s): %v", + funcName, request.TicketHash, err) + w.sendError(types.ErrCannotBroadcastTicket, c) + return + } + + w.log.Debugf("%s: Parent tx references an unknown output, waiting for it in mempool (ticketHash=%s)", + funcName, request.TicketHash) + + txBroadcast := func() bool { + // Wait for 1 second and try again, max 7 attempts. + for i := 0; i < 7; i++ { + time.Sleep(1 * time.Second) + err := dcrdClient.SendRawTransaction(request.ParentHex) + if err == nil { + return true + } + } + return false + }() + + if !txBroadcast { + w.log.Errorf("%s: Failed to broadcast parent tx, waiting didn't help (ticketHash=%s)", + funcName, request.TicketHash) + w.sendError(types.ErrCannotBroadcastTicket, c) + return + } } } else { From 1417829a6ad7770f51cbb58f6460d0c435a067be Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 7 Nov 2023 15:14:10 +0000 Subject: [PATCH 2/3] [release-v1.3] Downgrade dcrwallet dep to v3. This downgrade changes StakePoolTicketFee back to the version which does not consider DCP-0012 activation. This resolves an issue where Decrediton sometimes fails to pay VSP fees, caused by Decrediton and vspd independently calculating the fee amount using different versions of the algorithm. Releasing the new algorithm will need to be more carefully coordinated, potentially requiring both client and server sides to be updated in sync. --- cmd/v3tool/dcrwallet.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/webapi/getfeeaddress.go | 5 ++--- rpc/dcrwallet.go | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/v3tool/dcrwallet.go b/cmd/v3tool/dcrwallet.go index 0edf6377..f9f62259 100644 --- a/cmd/v3tool/dcrwallet.go +++ b/cmd/v3tool/dcrwallet.go @@ -13,7 +13,7 @@ import ( "fmt" "strings" - wallettypes "decred.org/dcrwallet/v4/rpc/jsonrpc/types" + wallettypes "decred.org/dcrwallet/v3/rpc/jsonrpc/types" "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" diff --git a/go.mod b/go.mod index 6c39d8bf..2cfc743c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/decred/vspd go 1.19 require ( - decred.org/dcrwallet/v4 v4.0.0-20230924083701-09bb3c2c5095 + decred.org/dcrwallet/v3 v3.1.0 github.com/decred/dcrd/blockchain/stake/v5 v5.0.0 github.com/decred/dcrd/blockchain/standalone/v2 v2.2.0 github.com/decred/dcrd/chaincfg/chainhash v1.0.4 diff --git a/go.sum b/go.sum index 51ae29d1..0379189c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -decred.org/dcrwallet/v4 v4.0.0-20230924083701-09bb3c2c5095 h1:Eu9ykx3/PwJGuE1Il7D57Eu1o0DdHk5Fc3WGL7l+9k4= -decred.org/dcrwallet/v4 v4.0.0-20230924083701-09bb3c2c5095/go.mod h1:5mW+Jbpea7fDstBqhWHBs0PCOpDB8yX3VbGNhqLqoRQ= +decred.org/dcrwallet/v3 v3.1.0 h1:JCPnF6ENtkeyWLLhyR6d6hzPAFccbbD0u2Fv2E2mA00= +decred.org/dcrwallet/v3 v3.1.0/go.mod h1:KYWzL2R6ghBLSvB7XXU9S29QwgcqnApCvONMDJ6KCR0= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= diff --git a/internal/webapi/getfeeaddress.go b/internal/webapi/getfeeaddress.go index 2d75c783..6ba0e4d6 100644 --- a/internal/webapi/getfeeaddress.go +++ b/internal/webapi/getfeeaddress.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "decred.org/dcrwallet/v4/wallet/txrules" + "decred.org/dcrwallet/v3/wallet/txrules" "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/vspd/database" "github.com/decred/vspd/rpc" @@ -58,10 +58,9 @@ func (w *WebAPI) getCurrentFee(dcrdClient *rpc.DcrdRPC) (dcrutil.Amount, error) height := int64(bestBlock.Height) isDCP0010Active := w.cfg.Network.DCP10Active(height) - isDCP0012Active := w.cfg.Network.DCP12Active(height) fee := txrules.StakePoolTicketFee(sDiff, defaultMinRelayTxFee, int32(bestBlock.Height), - w.cfg.VSPFee, w.cfg.Network.Params, isDCP0010Active, isDCP0012Active) + w.cfg.VSPFee, w.cfg.Network.Params, isDCP0010Active) if err != nil { return 0, err } diff --git a/rpc/dcrwallet.go b/rpc/dcrwallet.go index e2389f0d..d3201886 100644 --- a/rpc/dcrwallet.go +++ b/rpc/dcrwallet.go @@ -8,7 +8,7 @@ import ( "context" "fmt" - wallettypes "decred.org/dcrwallet/v4/rpc/jsonrpc/types" + wallettypes "decred.org/dcrwallet/v3/rpc/jsonrpc/types" "github.com/decred/dcrd/chaincfg/v3" dcrdtypes "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/wire" From be73154ad5d700d7998c4ad7fd2c5417aa393aab Mon Sep 17 00:00:00 2001 From: jholdstock Date: Wed, 8 Nov 2023 09:04:27 +0000 Subject: [PATCH 3/3] [release-v1.3] Release version 1.3.2 --- internal/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version/version.go b/internal/version/version.go index e8ce625a..77abc303 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -19,7 +19,7 @@ const semverAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst const ( major = 1 minor = 3 - patch = 1 + patch = 2 ) // preRelease contains the prerelease name of the application. It is a variable