Skip to content

Commit 5e38f7a

Browse files
committed
cmd, core: add --txpool.nolocals to disable local price exemptions
1 parent 4c1d0b1 commit 5e38f7a

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var (
6666
utils.EthashDatasetDirFlag,
6767
utils.EthashDatasetsInMemoryFlag,
6868
utils.EthashDatasetsOnDiskFlag,
69+
utils.TxPoolNoLocalsFlag,
6970
utils.TxPoolPriceLimitFlag,
7071
utils.TxPoolPriceBumpFlag,
7172
utils.TxPoolAccountSlotsFlag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ var AppHelpFlagGroups = []flagGroup{
9595
{
9696
Name: "TRANSACTION POOL",
9797
Flags: []cli.Flag{
98+
utils.TxPoolNoLocalsFlag,
9899
utils.TxPoolPriceLimitFlag,
99100
utils.TxPoolPriceBumpFlag,
100101
utils.TxPoolAccountSlotsFlag,

cmd/utils/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ var (
209209
Value: eth.DefaultConfig.EthashDatasetsOnDisk,
210210
}
211211
// Transaction pool settings
212+
TxPoolNoLocalsFlag = cli.BoolFlag{
213+
Name: "txpool.nolocals",
214+
Usage: "Disables price exemptions for locally submitted transactions",
215+
}
212216
TxPoolPriceLimitFlag = cli.Uint64Flag{
213217
Name: "txpool.pricelimit",
214218
Usage: "Minimum gas price limit to enforce for acceptance into the pool",
@@ -831,6 +835,9 @@ func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
831835
}
832836

833837
func setTxPool(ctx *cli.Context, cfg *core.TxPoolConfig) {
838+
if ctx.GlobalIsSet(TxPoolNoLocalsFlag.Name) {
839+
cfg.NoLocals = ctx.GlobalBool(TxPoolNoLocalsFlag.Name)
840+
}
834841
if ctx.GlobalIsSet(TxPoolPriceLimitFlag.Name) {
835842
cfg.PriceLimit = ctx.GlobalUint64(TxPoolPriceLimitFlag.Name)
836843
}

core/tx_pool.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ type stateFn func() (*state.StateDB, error)
9999

100100
// TxPoolConfig are the configuration parameters of the transaction pool.
101101
type TxPoolConfig struct {
102+
NoLocals bool // Whether local transaction handling should be disabled
103+
102104
PriceLimit uint64 // Minimum gas price to enforce for acceptance into the pool
103105
PriceBump uint64 // Minimum price bump percentage to replace an already existing transaction (nonce)
104106

@@ -394,7 +396,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
394396
}
395397
// Drop non-local transactions under our own minimal accepted gas price
396398
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
397-
if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
399+
if (!local || pool.config.NoLocals) && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
398400
return ErrUnderpriced
399401
}
400402
// Ensure the transaction adheres to nonce ordering
@@ -480,7 +482,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
480482
if err != nil {
481483
return false, err
482484
}
483-
if local {
485+
if local && !pool.config.NoLocals {
484486
pool.locals.add(from)
485487
}
486488
log.Trace("Pooled new future transaction", "hash", hash, "from", from, "to", tx.To())

0 commit comments

Comments
 (0)