From 6910e18e7f12ebd2ec95334b947d4a8a45354369 Mon Sep 17 00:00:00 2001 From: ledgerwatch <akhounov@gmail.com> Date: Fri, 26 Nov 2021 14:39:26 +0000 Subject: [PATCH] [txpool] Introduce PriceBump, change tx replacement logic, add test (#3039) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> --- cmd/txpool/main.go | 3 +++ cmd/utils/flags.go | 3 ++- eth/backend.go | 1 + go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/txpool/main.go b/cmd/txpool/main.go index cf71f9d903..d06d7e13e4 100644 --- a/cmd/txpool/main.go +++ b/cmd/txpool/main.go @@ -40,6 +40,7 @@ var ( queuedPoolLimit int priceLimit uint64 + priceBump uint64 ) func init() { @@ -60,6 +61,7 @@ func init() { rootCmd.PersistentFlags().IntVar(&queuedPoolLimit, "txpool.globalqueue", txpool.DefaultConfig.QueuedSubPoolLimit, "Maximum number of non-executable transaction slots for all accounts") rootCmd.PersistentFlags().Uint64Var(&priceLimit, "txpool.pricelimit", txpool.DefaultConfig.MinFeeCap, "Minimum gas price (fee cap) limit to enforce for acceptance into the pool") rootCmd.PersistentFlags().Uint64Var(&priceLimit, "txpool.accountslots", txpool.DefaultConfig.AccountSlots, "Minimum number of executable transaction slots guaranteed per account") + rootCmd.PersistentFlags().Uint64Var(&priceBump, "txpool.pricebump", txpool.DefaultConfig.PriceBump, "Price bump percentage to replace an already existing transaction") } var rootCmd = &cobra.Command{ @@ -112,6 +114,7 @@ var rootCmd = &cobra.Command{ cfg.BaseFeeSubPoolLimit = baseFeePoolLimit cfg.QueuedSubPoolLimit = queuedPoolLimit cfg.MinFeeCap = priceLimit + cfg.PriceBump = priceBump cacheConfig := kvcache.DefaultCoherentConfig cacheConfig.MetricsLabel = "txpool" diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 5a9ab1bb08..973cbc6972 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -31,6 +31,7 @@ import ( "text/template" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/txpool" "github.com/ledgerwatch/erigon/eth/protocols/eth" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -181,7 +182,7 @@ var ( TxPoolPriceBumpFlag = cli.Uint64Flag{ Name: "txpool.pricebump", Usage: "Price bump percentage to replace an already existing transaction", - Value: ethconfig.Defaults.TxPool.PriceBump, + Value: txpool.DefaultConfig.PriceBump, } TxPoolAccountSlotsFlag = cli.Uint64Flag{ Name: "txpool.accountslots", diff --git a/eth/backend.go b/eth/backend.go index 9e4144d3ee..a9c3c66209 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -309,6 +309,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere cfg.PendingSubPoolLimit = int(config.TxPool.GlobalSlots) cfg.BaseFeeSubPoolLimit = int(config.TxPool.GlobalBaseFeeQueue) cfg.QueuedSubPoolLimit = int(config.TxPool.GlobalQueue) + cfg.PriceBump = config.TxPool.PriceBump cfg.MinFeeCap = config.TxPool.PriceLimit cfg.AccountSlots = config.TxPool.AccountSlots cfg.LogEvery = 1 * time.Minute diff --git a/go.mod b/go.mod index b74ac96047..fbc58aaa6f 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20211124065323-9b501d57799a + github.com/ledgerwatch/erigon-lib v0.0.0-20211126135558-040474414670 github.com/ledgerwatch/log/v3 v3.4.0 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/logrusorgru/aurora/v3 v3.0.0 diff --git a/go.sum b/go.sum index 3964b22260..2f47d6a25a 100644 --- a/go.sum +++ b/go.sum @@ -596,8 +596,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20211124065323-9b501d57799a h1:dml/Mwe0ReKdFy2rSu0OJ6KNFMOfXKMZUKU67dc5xuQ= -github.com/ledgerwatch/erigon-lib v0.0.0-20211124065323-9b501d57799a/go.mod h1:lyGP3i0x4CeabdKZ4beycD5xZfHWZwJsAX+70OfGj4Y= +github.com/ledgerwatch/erigon-lib v0.0.0-20211126135558-040474414670 h1:j9BsLxZXywwIfFIsdzC6AwfRyEaIbupUyW1dPkjIYI8= +github.com/ledgerwatch/erigon-lib v0.0.0-20211126135558-040474414670/go.mod h1:lyGP3i0x4CeabdKZ4beycD5xZfHWZwJsAX+70OfGj4Y= github.com/ledgerwatch/log/v3 v3.4.0 h1:SEIOcv5a2zkG3PmoT5jeTU9m/0nEUv0BJS5bzsjwKCI= github.com/ledgerwatch/log/v3 v3.4.0/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= -- GitLab