core: make txpool reject too sudden changes (#23095)

* core: make txpool reject too sudden changes

* core: add some metrics to txpool
This commit is contained in:
Martin Holst Swende
2021-08-24 20:48:36 +02:00
committed by GitHub
parent 5cee33eb72
commit d705f5a554
2 changed files with 33 additions and 7 deletions

View File

@ -1946,20 +1946,20 @@ func TestDualHeapEviction(t *testing.T) {
}
add := func(urgent bool) {
txs := make([]*types.Transaction, 20)
for i := range txs {
for i := 0; i < 20; i++ {
var tx *types.Transaction
// Create a test accounts and fund it
key, _ := crypto.GenerateKey()
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1000000000000))
if urgent {
txs[i] = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
highTip = txs[i]
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
highTip = tx
} else {
txs[i] = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), big.NewInt(1), key)
highCap = txs[i]
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), big.NewInt(1), key)
highCap = tx
}
pool.AddRemotesSync([]*types.Transaction{tx})
}
pool.AddRemotes(txs)
pending, queued := pool.Stats()
if pending+queued != 20 {
t.Fatalf("transaction count mismatch: have %d, want %d", pending+queued, 10)