mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
parent
ae6da0583f
commit
5bc363275c
2 changed files with 52 additions and 0 deletions
|
|
@ -1145,6 +1145,9 @@ func (pool *LegacyPool) addRemoteSync(tx *types.Transaction) error {
|
||||||
// If sync is set, the method will block until all internal maintenance related
|
// If sync is set, the method will block until all internal maintenance related
|
||||||
// to the add is finished. Only use this during tests for determinism!
|
// to the add is finished. Only use this during tests for determinism!
|
||||||
func (pool *LegacyPool) Add(txs []*types.Transaction, local, sync bool) []error {
|
func (pool *LegacyPool) Add(txs []*types.Transaction, local, sync bool) []error {
|
||||||
|
// Do not treat as local if local transactions have been disabled
|
||||||
|
local = local && !pool.config.NoLocals
|
||||||
|
|
||||||
// Filter out known ones without obtaining the pool lock or recovering signatures
|
// Filter out known ones without obtaining the pool lock or recovering signatures
|
||||||
var (
|
var (
|
||||||
errs = make([]error, len(txs))
|
errs = make([]error, len(txs))
|
||||||
|
|
|
||||||
|
|
@ -1604,6 +1604,55 @@ func TestRepricing(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMinGasPriceEnforced(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
// Create the pool to test the pricing enforcement with
|
||||||
|
statedb, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||||
|
blockchain := newTestBlockChain(eip1559Config, 10000000, statedb, new(event.Feed))
|
||||||
|
|
||||||
|
txPoolConfig := DefaultConfig
|
||||||
|
txPoolConfig.NoLocals = true
|
||||||
|
pool := New(txPoolConfig, blockchain)
|
||||||
|
pool.Init(txPoolConfig.PriceLimit, blockchain.CurrentBlock(), newReserver())
|
||||||
|
defer pool.Close()
|
||||||
|
|
||||||
|
key, _ := crypto.GenerateKey()
|
||||||
|
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1_000_000_000_000_000_000))
|
||||||
|
|
||||||
|
minGasPrice := common.GetMinGasPrice(blockchain.CurrentBlock().Number)
|
||||||
|
legacyPrice := new(big.Int).Add(minGasPrice, big.NewInt(1))
|
||||||
|
dynamicTip := new(big.Int).Add(minGasPrice, big.NewInt(1))
|
||||||
|
dynamicFeeCap := new(big.Int).Add(minGasPrice, big.NewInt(2))
|
||||||
|
|
||||||
|
tx := pricedTransaction(0, 100000, legacyPrice, key)
|
||||||
|
pool.SetGasTip(new(big.Int).Add(legacyPrice, big.NewInt(1)))
|
||||||
|
|
||||||
|
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
t.Fatalf("Min tip not enforced")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := pool.Add([]*types.Transaction{tx}, true, false)[0]; !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
t.Fatalf("Min tip not enforced")
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = dynamicFeeTx(0, 100000, dynamicFeeCap, dynamicTip, key)
|
||||||
|
pool.SetGasTip(new(big.Int).Add(dynamicTip, big.NewInt(1)))
|
||||||
|
|
||||||
|
if err := pool.addLocal(tx); !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
t.Fatalf("Min tip not enforced")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := pool.Add([]*types.Transaction{tx}, true, false)[0]; !errors.Is(err, txpool.ErrUnderpriced) {
|
||||||
|
t.Fatalf("Min tip not enforced")
|
||||||
|
}
|
||||||
|
// Make sure the tx is accepted if locals are enabled
|
||||||
|
pool.config.NoLocals = false
|
||||||
|
if err := pool.Add([]*types.Transaction{tx}, true, false)[0]; err != nil {
|
||||||
|
t.Fatalf("Min tip enforced with locals enabled, error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that setting the transaction pool gas price to a higher value correctly
|
// Tests that setting the transaction pool gas price to a higher value correctly
|
||||||
// discards everything cheaper (legacy & dynamic fee) than that and moves any
|
// discards everything cheaper (legacy & dynamic fee) than that and moves any
|
||||||
// gapped transactions back from the pending pool to the queue.
|
// gapped transactions back from the pending pool to the queue.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue