2015-07-07 02:54:22 +02:00
|
|
|
// Copyright 2014 The go-ethereum Authors
|
2015-07-22 18:48:40 +02:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 02:54:22 +02:00
|
|
|
//
|
2015-07-23 18:35:11 +02:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 02:54:22 +02:00
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2015-07-22 18:48:40 +02:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 02:54:22 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 18:48:40 +02:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 02:54:22 +02:00
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2015-07-22 18:48:40 +02:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 02:54:22 +02:00
|
|
|
|
2014-12-04 10:28:02 +01:00
|
|
|
package core
|
2014-02-14 23:56:09 +01:00
|
|
|
|
|
|
|
import (
|
2015-01-31 17:22:17 +01:00
|
|
|
"errors"
|
2015-11-21 00:40:36 +01:00
|
|
|
"time"
|
2014-07-30 00:31:15 +02:00
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2022-02-07 16:54:20 +07:00
|
|
|
"github.com/ledgerwatch/erigon-lib/txpool"
|
2017-08-18 18:58:36 +08:00
|
|
|
)
|
|
|
|
|
2015-01-31 17:22:17 +01:00
|
|
|
var (
|
2020-01-22 16:39:43 +02:00
|
|
|
// ErrAlreadyKnown is returned if the transactions is already contained
|
|
|
|
// within the pool.
|
|
|
|
ErrAlreadyKnown = errors.New("already known")
|
|
|
|
|
2017-06-22 17:01:49 +03:00
|
|
|
// ErrInvalidSender is returned if the transaction contains an invalid signature.
|
|
|
|
ErrInvalidSender = errors.New("invalid sender")
|
|
|
|
|
|
|
|
// ErrUnderpriced is returned if a transaction's gas price is below the minimum
|
|
|
|
// configured for the transaction pool.
|
|
|
|
ErrUnderpriced = errors.New("transaction underpriced")
|
|
|
|
|
2020-12-11 17:44:57 +08:00
|
|
|
// ErrTxPoolOverflow is returned if the transaction pool is full and can't accpet
|
|
|
|
// another remote transaction.
|
|
|
|
ErrTxPoolOverflow = errors.New("txpool is full")
|
|
|
|
|
2017-06-22 17:01:49 +03:00
|
|
|
// ErrReplaceUnderpriced is returned if a transaction is attempted to be replaced
|
|
|
|
// with a different one without the required price bump.
|
2017-05-16 22:07:27 +03:00
|
|
|
ErrReplaceUnderpriced = errors.New("replacement transaction underpriced")
|
2017-06-22 17:01:49 +03:00
|
|
|
|
|
|
|
// ErrGasLimit is returned if a transaction's requested gas limit exceeds the
|
|
|
|
// maximum allowance of the current block.
|
|
|
|
ErrGasLimit = errors.New("exceeds block gas limit")
|
|
|
|
|
2020-05-25 16:21:28 +08:00
|
|
|
// ErrNegativeValue is a sanity error to ensure no one is able to specify a
|
|
|
|
// transaction with a negative value.
|
|
|
|
ErrNegativeValue = errors.New("negative value")
|
|
|
|
|
2017-06-22 17:01:49 +03:00
|
|
|
// ErrOversizedData is returned if the input data of a transaction is greater
|
|
|
|
// than some meaningful limit a user might use. This is not a consensus error
|
|
|
|
// making the transaction invalid, rather a DOS protection.
|
|
|
|
ErrOversizedData = errors.New("oversized data")
|
2015-01-31 17:22:17 +01:00
|
|
|
)
|
2014-06-23 12:54:10 +01:00
|
|
|
|
2017-05-26 13:40:47 +03:00
|
|
|
// TxPoolConfig are the configuration parameters of the transaction pool.
|
|
|
|
type TxPoolConfig struct {
|
2022-05-26 12:27:44 +07:00
|
|
|
Disable bool
|
2023-01-13 18:12:18 +00:00
|
|
|
Locals []libcommon.Address // Addresses that should be treated by default as local
|
|
|
|
NoLocals bool // Whether local transaction handling should be disabled
|
2017-07-05 17:06:05 +03:00
|
|
|
|
2017-05-26 13:40:47 +03:00
|
|
|
PriceLimit uint64 // Minimum gas price to enforce for acceptance into the pool
|
|
|
|
PriceBump uint64 // Minimum price bump percentage to replace an already existing transaction (nonce)
|
|
|
|
|
2018-07-25 00:44:41 +09:00
|
|
|
AccountSlots uint64 // Number of executable transaction slots guaranteed per account
|
2017-05-26 13:40:47 +03:00
|
|
|
GlobalSlots uint64 // Maximum number of executable transaction slots for all accounts
|
|
|
|
AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account
|
|
|
|
GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts
|
|
|
|
|
2021-09-29 14:48:19 +07:00
|
|
|
GlobalBaseFeeQueue uint64 // Maximum number of non-executable transaction slots for all accounts
|
|
|
|
|
2021-12-14 16:15:54 +00:00
|
|
|
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
|
|
|
|
StartOnInit bool
|
|
|
|
TracedSenders []string // List of senders for which tx pool should print out debugging info
|
2017-05-26 13:40:47 +03:00
|
|
|
}
|
|
|
|
|
2022-05-26 12:27:44 +07:00
|
|
|
// DeprecatedDefaultTxPoolConfig contains the default configurations for the transaction
|
2017-05-26 13:40:47 +03:00
|
|
|
// pool.
|
2022-05-26 12:27:44 +07:00
|
|
|
var DeprecatedDefaultTxPoolConfig = TxPoolConfig{
|
2017-05-26 13:40:47 +03:00
|
|
|
PriceLimit: 1,
|
|
|
|
PriceBump: 10,
|
|
|
|
|
2021-10-16 12:37:43 +07:00
|
|
|
AccountSlots: 16,
|
|
|
|
GlobalSlots: 10_000,
|
2021-11-15 10:16:03 +07:00
|
|
|
GlobalBaseFeeQueue: 30_000,
|
2021-10-16 12:37:43 +07:00
|
|
|
AccountQueue: 64,
|
2021-11-15 10:16:03 +07:00
|
|
|
GlobalQueue: 30_000,
|
2017-05-26 13:40:47 +03:00
|
|
|
|
|
|
|
Lifetime: 3 * time.Hour,
|
|
|
|
}
|
2022-02-07 16:54:20 +07:00
|
|
|
|
|
|
|
var DefaultTxPool2Config = func(pool1Cfg TxPoolConfig) txpool.Config {
|
|
|
|
cfg := txpool.DefaultConfig
|
|
|
|
cfg.PendingSubPoolLimit = int(pool1Cfg.GlobalSlots)
|
|
|
|
cfg.BaseFeeSubPoolLimit = int(pool1Cfg.GlobalBaseFeeQueue)
|
|
|
|
cfg.QueuedSubPoolLimit = int(pool1Cfg.GlobalQueue)
|
|
|
|
cfg.PriceBump = pool1Cfg.PriceBump
|
|
|
|
cfg.MinFeeCap = pool1Cfg.PriceLimit
|
|
|
|
cfg.AccountSlots = pool1Cfg.AccountSlots
|
|
|
|
cfg.LogEvery = 1 * time.Minute
|
|
|
|
cfg.CommitEvery = 5 * time.Minute
|
|
|
|
cfg.TracedSenders = pool1Cfg.TracedSenders
|
2023-01-17 11:07:57 +00:00
|
|
|
|
2022-02-07 16:54:20 +07:00
|
|
|
return cfg
|
|
|
|
}
|