From cdf6e12957390f09c2828242ca111b76dcf9f84a Mon Sep 17 00:00:00 2001 From: ptrus Date: Fri, 28 Oct 2022 09:23:37 +0200 Subject: [PATCH 1/2] go/runtime/txpool: bump maxRepublishTxs to 128 --- go/runtime/txpool/txpool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/runtime/txpool/txpool.go b/go/runtime/txpool/txpool.go index b9b3b0b91c5..8b6a97a38d2 100644 --- a/go/runtime/txpool/txpool.go +++ b/go/runtime/txpool/txpool.go @@ -32,7 +32,7 @@ const ( // abortTimeout is the maximum time the runtime can spend aborting. abortTimeout = 5 * time.Second // maxRepublishTxs is the maximum amount of transactions to republish. - maxRepublishTxs = 32 + maxRepublishTxs = 128 // newBlockPublishDelay is the time to wait to publish any newly checked transactions after // receiving a new block. It should be roughly the block propagation delay. newBlockPublishDelay = 200 * time.Millisecond From f1906bf4e3424a65c19ec2770da3763d6b62cdb7 Mon Sep 17 00:00:00 2001 From: ptrus Date: Fri, 28 Oct 2022 09:24:53 +0200 Subject: [PATCH 2/2] go/runtime/txpool: republish soon if maxRepublishTxs reached --- .changelog/5003.bugfix.md | 4 ++++ go/runtime/txpool/txpool.go | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changelog/5003.bugfix.md diff --git a/.changelog/5003.bugfix.md b/.changelog/5003.bugfix.md new file mode 100644 index 00000000000..be8f94d8cdf --- /dev/null +++ b/.changelog/5003.bugfix.md @@ -0,0 +1,4 @@ +go/runtime/txpool: republish sooner if republish limit is reached + +This fixes a case where some portion of a batch of transaction would take a +long time to be published if there are no new transactions incoming. diff --git a/go/runtime/txpool/txpool.go b/go/runtime/txpool/txpool.go index 8b6a97a38d2..58ef7c3751e 100644 --- a/go/runtime/txpool/txpool.go +++ b/go/runtime/txpool/txpool.go @@ -36,6 +36,11 @@ const ( // newBlockPublishDelay is the time to wait to publish any newly checked transactions after // receiving a new block. It should be roughly the block propagation delay. newBlockPublishDelay = 200 * time.Millisecond + + // republishLimitReinvokeTimeout is the timeout to the next republish worker invocation in + // case when the maxRepublishTxs limit is reached. This should be much shorter than the + // RepublishInterval. + republishLimitReinvokeTimeout = 1 * time.Second ) // Config is the transaction pool configuration. @@ -806,7 +811,10 @@ func (t *txPool) republishWorker() { _ = t.seenCache.Put(tx.Hash(), time.Now()) republishedCount++ - if republishedCount > maxRepublishTxs { + if republishedCount >= maxRepublishTxs { + // If the limit of max republish transactions has been reached + // republish again sooner. + nextPendingRepublish = republishLimitReinvokeTimeout break } }