From bad6717720180c9b661e61f37994424c96a48110 Mon Sep 17 00:00:00 2001 From: Juan Palacios Date: Wed, 1 Nov 2023 13:12:44 +1100 Subject: [PATCH] Revert "Addressing PR feedback. Now setting local = false when NoLocals is set" This reverts commit 75d4098bf2cff119ce424840e7786a1592170c52. The local flag doesn't propagate to validation logic, only opts.MinTip --- core/txpool/legacypool/legacypool.go | 8 ++++++-- core/txpool/legacypool/legacypool_test.go | 8 -------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index f97dae2785..88957d6c14 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -152,6 +152,10 @@ var DefaultConfig = Config{ Lifetime: 3 * time.Hour, } +func (config *Config) PrioritizeLocals() bool { + return !config.NoLocals +} + // sanitize checks the provided user configurations and changes anything that's // unreasonable or unworkable. func (config *Config) sanitize() Config { @@ -596,8 +600,8 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro MaxSize: txMaxSize, MinTip: pool.gasTip.Load(), } - if local && pool.config.NoLocals { - local = false + if local && pool.config.PrioritizeLocals() { + opts.MinTip = new(big.Int) } if err := txpool.ValidateTransaction(tx, pool.currentHead.Load(), pool.signer, opts); err != nil { return err diff --git a/core/txpool/legacypool/legacypool_test.go b/core/txpool/legacypool/legacypool_test.go index fed3ba0225..a3d5cb5ac1 100644 --- a/core/txpool/legacypool/legacypool_test.go +++ b/core/txpool/legacypool/legacypool_test.go @@ -1515,20 +1515,12 @@ func TestMinGasPriceEnforced(t *testing.T) { t.Fatalf("Min tip not enforced") } - if err := pool.Add([]*txpool.Transaction{{Tx: tx}}, true, false)[0]; !errors.Is(err, txpool.ErrUnderpriced) { - t.Fatalf("Min tip not enforced") - } - tx = dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), key) pool.SetGasTip(big.NewInt(tx.GasTipCap().Int64() + 1)) if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) { t.Fatalf("Min tip not enforced") } - - if err := pool.Add([]*txpool.Transaction{{Tx: tx}}, true, false)[0]; !errors.Is(err, txpool.ErrUnderpriced) { - t.Fatalf("Min tip not enforced") - } } // Tests that setting the transaction pool gas price to a higher value correctly