mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
add flag txpool.commit_every (#7062)
Adds flag _--txpool.commit_every_ to control how often transactions should be committed to the storage [Related Issue](https://github.com/ledgerwatch/erigon/issues/7002)
This commit is contained in:
parent
f69f7095bb
commit
4e5dce1365
@ -2,8 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -50,6 +52,8 @@ var (
|
|||||||
priceLimit uint64
|
priceLimit uint64
|
||||||
accountSlots uint64
|
accountSlots uint64
|
||||||
priceBump uint64
|
priceBump uint64
|
||||||
|
|
||||||
|
commitEvery time.Duration
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -71,6 +75,7 @@ func init() {
|
|||||||
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.pricelimit", txpool.DefaultConfig.MinFeeCap, "Minimum gas price (fee cap) limit to enforce for acceptance into the pool")
|
||||||
rootCmd.PersistentFlags().Uint64Var(&accountSlots, "txpool.accountslots", txpool.DefaultConfig.AccountSlots, "Minimum number of executable transaction slots guaranteed per account")
|
rootCmd.PersistentFlags().Uint64Var(&accountSlots, "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")
|
rootCmd.PersistentFlags().Uint64Var(&priceBump, "txpool.pricebump", txpool.DefaultConfig.PriceBump, "Price bump percentage to replace an already existing transaction")
|
||||||
|
rootCmd.PersistentFlags().DurationVar(&commitEvery, utils.TxPoolCommitEveryFlag.Name, utils.TxPoolCommitEveryFlag.Value, utils.TxPoolCommitEveryFlag.Usage)
|
||||||
rootCmd.Flags().StringSliceVar(&traceSenders, utils.TxPoolTraceSendersFlag.Name, []string{}, utils.TxPoolTraceSendersFlag.Usage)
|
rootCmd.Flags().StringSliceVar(&traceSenders, utils.TxPoolTraceSendersFlag.Name, []string{}, utils.TxPoolTraceSendersFlag.Usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +136,12 @@ func doTxpool(ctx context.Context) error {
|
|||||||
dirs := datadir.New(datadirCli)
|
dirs := datadir.New(datadirCli)
|
||||||
|
|
||||||
cfg.DBDir = dirs.TxPool
|
cfg.DBDir = dirs.TxPool
|
||||||
cfg.CommitEvery = 30 * time.Second
|
|
||||||
|
randDuration, err := rand.Int(rand.Reader, big.NewInt(int64(2*time.Second)))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("generating random additional value for --txpool.commit.every: %w", err)
|
||||||
|
}
|
||||||
|
cfg.CommitEvery = commitEvery + time.Duration(randDuration.Int64())
|
||||||
cfg.PendingSubPoolLimit = pendingPoolLimit
|
cfg.PendingSubPoolLimit = pendingPoolLimit
|
||||||
cfg.BaseFeeSubPoolLimit = baseFeePoolLimit
|
cfg.BaseFeeSubPoolLimit = baseFeePoolLimit
|
||||||
cfg.QueuedSubPoolLimit = queuedPoolLimit
|
cfg.QueuedSubPoolLimit = queuedPoolLimit
|
||||||
|
@ -19,12 +19,14 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/c2h5oh/datasize"
|
"github.com/c2h5oh/datasize"
|
||||||
"github.com/ledgerwatch/erigon-lib/chain"
|
"github.com/ledgerwatch/erigon-lib/chain"
|
||||||
@ -193,6 +195,11 @@ var (
|
|||||||
Usage: "Comma separared list of addresses, whoes transactions will traced in transaction pool with debug printing",
|
Usage: "Comma separared list of addresses, whoes transactions will traced in transaction pool with debug printing",
|
||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
|
TxPoolCommitEveryFlag = cli.DurationFlag{
|
||||||
|
Name: "txpool.commit.every",
|
||||||
|
Usage: "How often transactions should be committed to the storage",
|
||||||
|
Value: txpool.DefaultConfig.CommitEvery,
|
||||||
|
}
|
||||||
// Miner settings
|
// Miner settings
|
||||||
MiningEnabledFlag = cli.BoolFlag{
|
MiningEnabledFlag = cli.BoolFlag{
|
||||||
Name: "mine",
|
Name: "mine",
|
||||||
@ -1262,6 +1269,14 @@ func setTxPool(ctx *cli.Context, cfg *core.TxPoolConfig) {
|
|||||||
cfg.TracedSenders[i] = string(sender[:])
|
cfg.TracedSenders[i] = string(sender[:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ctx.IsSet(TxPoolCommitEveryFlag.Name) {
|
||||||
|
cfg.CommitEvery = ctx.Duration(TxPoolCommitEveryFlag.Name)
|
||||||
|
randDuration, err := rand.Int(rand.Reader, big.NewInt(int64(2*time.Second)))
|
||||||
|
if err != nil {
|
||||||
|
Fatalf("Generating random additional value for --txpool.commit.every: %s", err)
|
||||||
|
}
|
||||||
|
cfg.CommitEvery += time.Duration(randDuration.Int64())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setEthash(ctx *cli.Context, datadir string, cfg *ethconfig.Config) {
|
func setEthash(ctx *cli.Context, datadir string, cfg *ethconfig.Config) {
|
||||||
|
@ -77,6 +77,7 @@ type TxPoolConfig struct {
|
|||||||
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
|
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
|
||||||
StartOnInit bool
|
StartOnInit bool
|
||||||
TracedSenders []string // List of senders for which tx pool should print out debugging info
|
TracedSenders []string // List of senders for which tx pool should print out debugging info
|
||||||
|
CommitEvery time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeprecatedDefaultTxPoolConfig contains the default configurations for the transaction
|
// DeprecatedDefaultTxPoolConfig contains the default configurations for the transaction
|
||||||
@ -105,6 +106,7 @@ var DefaultTxPool2Config = func(pool1Cfg TxPoolConfig) txpool.Config {
|
|||||||
cfg.LogEvery = 1 * time.Minute
|
cfg.LogEvery = 1 * time.Minute
|
||||||
cfg.CommitEvery = 5 * time.Minute
|
cfg.CommitEvery = 5 * time.Minute
|
||||||
cfg.TracedSenders = pool1Cfg.TracedSenders
|
cfg.TracedSenders = pool1Cfg.TracedSenders
|
||||||
|
cfg.CommitEvery = pool1Cfg.CommitEvery
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ var DefaultFlags = []cli.Flag{
|
|||||||
&utils.TxPoolGlobalQueueFlag,
|
&utils.TxPoolGlobalQueueFlag,
|
||||||
&utils.TxPoolLifetimeFlag,
|
&utils.TxPoolLifetimeFlag,
|
||||||
&utils.TxPoolTraceSendersFlag,
|
&utils.TxPoolTraceSendersFlag,
|
||||||
|
&utils.TxPoolCommitEveryFlag,
|
||||||
&PruneFlag,
|
&PruneFlag,
|
||||||
&PruneHistoryFlag,
|
&PruneHistoryFlag,
|
||||||
&PruneReceiptFlag,
|
&PruneReceiptFlag,
|
||||||
|
@ -2,6 +2,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/ledgerwatch/erigon-lib/txpool"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -194,6 +195,12 @@ var (
|
|||||||
Usage: "Maximum amount of time to wait for the answer from EVM call.",
|
Usage: "Maximum amount of time to wait for the answer from EVM call.",
|
||||||
Value: rpccfg.DefaultEvmCallTimeout,
|
Value: rpccfg.DefaultEvmCallTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TxPoolCommitEvery = cli.DurationFlag{
|
||||||
|
Name: "txpool.commit.every",
|
||||||
|
Usage: "How often transactions should be committed to the storage",
|
||||||
|
Value: txpool.DefaultConfig.CommitEvery,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config) {
|
func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||||
|
Loading…
Reference in New Issue
Block a user