tx_pool_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package core
  17. import (
  18. "crypto/ecdsa"
  19. "math/big"
  20. "testing"
  21. "github.com/ethereum/go-ethereum/common"
  22. "github.com/ethereum/go-ethereum/core/state"
  23. "github.com/ethereum/go-ethereum/core/types"
  24. "github.com/ethereum/go-ethereum/crypto"
  25. "github.com/ethereum/go-ethereum/ethdb"
  26. "github.com/ethereum/go-ethereum/event"
  27. )
  28. func transaction(nonce uint64, gaslimit *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
  29. tx, _ := types.NewTransaction(nonce, common.Address{}, big.NewInt(100), gaslimit, big.NewInt(1), nil).SignECDSA(key)
  30. return tx
  31. }
  32. func setupTxPool() (*TxPool, *ecdsa.PrivateKey) {
  33. db, _ := ethdb.NewMemDatabase()
  34. statedb, _ := state.New(common.Hash{}, db)
  35. var m event.TypeMux
  36. key, _ := crypto.GenerateKey()
  37. newPool := NewTxPool(&m, func() (*state.StateDB, error) { return statedb, nil }, func() *big.Int { return big.NewInt(1000000) })
  38. newPool.resetState()
  39. return newPool, key
  40. }
  41. func TestInvalidTransactions(t *testing.T) {
  42. pool, key := setupTxPool()
  43. tx := transaction(0, big.NewInt(100), key)
  44. if err := pool.Add(tx); err != ErrNonExistentAccount {
  45. t.Error("expected", ErrNonExistentAccount)
  46. }
  47. from, _ := tx.From()
  48. currentState, _ := pool.currentState()
  49. currentState.AddBalance(from, big.NewInt(1))
  50. if err := pool.Add(tx); err != ErrInsufficientFunds {
  51. t.Error("expected", ErrInsufficientFunds)
  52. }
  53. balance := new(big.Int).Add(tx.Value(), new(big.Int).Mul(tx.Gas(), tx.GasPrice()))
  54. currentState.AddBalance(from, balance)
  55. if err := pool.Add(tx); err != ErrIntrinsicGas {
  56. t.Error("expected", ErrIntrinsicGas, "got", err)
  57. }
  58. currentState.SetNonce(from, 1)
  59. currentState.AddBalance(from, big.NewInt(0xffffffffffffff))
  60. tx = transaction(0, big.NewInt(100000), key)
  61. if err := pool.Add(tx); err != ErrNonce {
  62. t.Error("expected", ErrNonce)
  63. }
  64. tx = transaction(1, big.NewInt(100000), key)
  65. pool.minGasPrice = big.NewInt(1000)
  66. if err := pool.Add(tx); err != ErrCheap {
  67. t.Error("expected", ErrCheap, "got", err)
  68. }
  69. pool.SetLocal(tx)
  70. if err := pool.Add(tx); err != nil {
  71. t.Error("expected", nil, "got", err)
  72. }
  73. }
  74. func TestTransactionQueue(t *testing.T) {
  75. pool, key := setupTxPool()
  76. tx := transaction(0, big.NewInt(100), key)
  77. from, _ := tx.From()
  78. currentState, _ := pool.currentState()
  79. currentState.AddBalance(from, big.NewInt(1000))
  80. pool.queueTx(tx.Hash(), tx)
  81. pool.checkQueue()
  82. if len(pool.pending) != 1 {
  83. t.Error("expected valid txs to be 1 is", len(pool.pending))
  84. }
  85. tx = transaction(1, big.NewInt(100), key)
  86. from, _ = tx.From()
  87. currentState.SetNonce(from, 2)
  88. pool.queueTx(tx.Hash(), tx)
  89. pool.checkQueue()
  90. if _, ok := pool.pending[tx.Hash()]; ok {
  91. t.Error("expected transaction to be in tx pool")
  92. }
  93. if len(pool.queue[from]) > 0 {
  94. t.Error("expected transaction queue to be empty. is", len(pool.queue[from]))
  95. }
  96. pool, key = setupTxPool()
  97. tx1 := transaction(0, big.NewInt(100), key)
  98. tx2 := transaction(10, big.NewInt(100), key)
  99. tx3 := transaction(11, big.NewInt(100), key)
  100. from, _ = tx1.From()
  101. currentState, _ = pool.currentState()
  102. currentState.AddBalance(from, big.NewInt(1000))
  103. pool.queueTx(tx1.Hash(), tx1)
  104. pool.queueTx(tx2.Hash(), tx2)
  105. pool.queueTx(tx3.Hash(), tx3)
  106. pool.checkQueue()
  107. if len(pool.pending) != 1 {
  108. t.Error("expected tx pool to be 1, got", len(pool.pending))
  109. }
  110. if len(pool.queue[from]) != 2 {
  111. t.Error("expected len(queue) == 2, got", len(pool.queue[from]))
  112. }
  113. }
  114. func TestRemoveTx(t *testing.T) {
  115. pool, key := setupTxPool()
  116. tx := transaction(0, big.NewInt(100), key)
  117. from, _ := tx.From()
  118. currentState, _ := pool.currentState()
  119. currentState.AddBalance(from, big.NewInt(1))
  120. pool.queueTx(tx.Hash(), tx)
  121. pool.addTx(tx.Hash(), from, tx)
  122. if len(pool.queue) != 1 {
  123. t.Error("expected queue to be 1, got", len(pool.queue))
  124. }
  125. if len(pool.pending) != 1 {
  126. t.Error("expected txs to be 1, got", len(pool.pending))
  127. }
  128. pool.RemoveTx(tx.Hash())
  129. if len(pool.queue) > 0 {
  130. t.Error("expected queue to be 0, got", len(pool.queue))
  131. }
  132. if len(pool.pending) > 0 {
  133. t.Error("expected txs to be 0, got", len(pool.pending))
  134. }
  135. }
  136. func TestNegativeValue(t *testing.T) {
  137. pool, key := setupTxPool()
  138. tx, _ := types.NewTransaction(0, common.Address{}, big.NewInt(-1), big.NewInt(100), big.NewInt(1), nil).SignECDSA(key)
  139. from, _ := tx.From()
  140. currentState, _ := pool.currentState()
  141. currentState.AddBalance(from, big.NewInt(1))
  142. if err := pool.Add(tx); err != ErrNegativeValue {
  143. t.Error("expected", ErrNegativeValue, "got", err)
  144. }
  145. }
  146. func TestTransactionChainFork(t *testing.T) {
  147. pool, key := setupTxPool()
  148. addr := crypto.PubkeyToAddress(key.PublicKey)
  149. resetState := func() {
  150. db, _ := ethdb.NewMemDatabase()
  151. statedb, _ := state.New(common.Hash{}, db)
  152. pool.currentState = func() (*state.StateDB, error) { return statedb, nil }
  153. currentState, _ := pool.currentState()
  154. currentState.AddBalance(addr, big.NewInt(100000000000000))
  155. pool.resetState()
  156. }
  157. resetState()
  158. tx := transaction(0, big.NewInt(100000), key)
  159. if err := pool.add(tx); err != nil {
  160. t.Error("didn't expect error", err)
  161. }
  162. pool.RemoveTransactions([]*types.Transaction{tx})
  163. // reset the pool's internal state
  164. resetState()
  165. if err := pool.add(tx); err != nil {
  166. t.Error("didn't expect error", err)
  167. }
  168. }
  169. func TestTransactionDoubleNonce(t *testing.T) {
  170. pool, key := setupTxPool()
  171. addr := crypto.PubkeyToAddress(key.PublicKey)
  172. resetState := func() {
  173. db, _ := ethdb.NewMemDatabase()
  174. statedb, _ := state.New(common.Hash{}, db)
  175. pool.currentState = func() (*state.StateDB, error) { return statedb, nil }
  176. currentState, _ := pool.currentState()
  177. currentState.AddBalance(addr, big.NewInt(100000000000000))
  178. pool.resetState()
  179. }
  180. resetState()
  181. tx := transaction(0, big.NewInt(100000), key)
  182. tx2 := transaction(0, big.NewInt(1000000), key)
  183. if err := pool.add(tx); err != nil {
  184. t.Error("didn't expect error", err)
  185. }
  186. if err := pool.add(tx2); err != nil {
  187. t.Error("didn't expect error", err)
  188. }
  189. pool.checkQueue()
  190. if len(pool.pending) != 2 {
  191. t.Error("expected 2 pending txs. Got", len(pool.pending))
  192. }
  193. }
  194. func TestMissingNonce(t *testing.T) {
  195. pool, key := setupTxPool()
  196. addr := crypto.PubkeyToAddress(key.PublicKey)
  197. currentState, _ := pool.currentState()
  198. currentState.AddBalance(addr, big.NewInt(100000000000000))
  199. tx := transaction(1, big.NewInt(100000), key)
  200. if err := pool.add(tx); err != nil {
  201. t.Error("didn't expect error", err)
  202. }
  203. if len(pool.pending) != 0 {
  204. t.Error("expected 0 pending transactions, got", len(pool.pending))
  205. }
  206. if len(pool.queue[addr]) != 1 {
  207. t.Error("expected 1 queued transaction, got", len(pool.queue[addr]))
  208. }
  209. }
  210. func TestNonceRecovery(t *testing.T) {
  211. const n = 10
  212. pool, key := setupTxPool()
  213. addr := crypto.PubkeyToAddress(key.PublicKey)
  214. currentState, _ := pool.currentState()
  215. currentState.SetNonce(addr, n)
  216. currentState.AddBalance(addr, big.NewInt(100000000000000))
  217. pool.resetState()
  218. tx := transaction(n, big.NewInt(100000), key)
  219. if err := pool.Add(tx); err != nil {
  220. t.Error(err)
  221. }
  222. // simulate some weird re-order of transactions and missing nonce(s)
  223. currentState.SetNonce(addr, n-1)
  224. pool.resetState()
  225. if fn := pool.pendingState.GetNonce(addr); fn != n+1 {
  226. t.Errorf("expected nonce to be %d, got %d", n+1, fn)
  227. }
  228. }
  229. func TestRemovedTxEvent(t *testing.T) {
  230. pool, key := setupTxPool()
  231. tx := transaction(0, big.NewInt(1000000), key)
  232. from, _ := tx.From()
  233. currentState, _ := pool.currentState()
  234. currentState.AddBalance(from, big.NewInt(1000000000000))
  235. pool.eventMux.Post(RemovedTransactionEvent{types.Transactions{tx}})
  236. pool.eventMux.Post(ChainHeadEvent{nil})
  237. if len(pool.pending) != 1 {
  238. t.Error("expected 1 pending tx, got", len(pool.pending))
  239. }
  240. }
  241. // Tests that if an account runs out of funds, any pending and queued transactions
  242. // are dropped.
  243. func TestTransactionDropping(t *testing.T) {
  244. // Create a test account and fund it
  245. pool, key := setupTxPool()
  246. account, _ := transaction(0, big.NewInt(0), key).From()
  247. state, _ := pool.currentState()
  248. state.AddBalance(account, big.NewInt(1000))
  249. // Add some pending and some queued transactions
  250. var (
  251. tx0 = transaction(0, big.NewInt(100), key)
  252. tx1 = transaction(1, big.NewInt(200), key)
  253. tx10 = transaction(10, big.NewInt(100), key)
  254. tx11 = transaction(11, big.NewInt(200), key)
  255. )
  256. pool.addTx(tx0.Hash(), account, tx0)
  257. pool.addTx(tx1.Hash(), account, tx1)
  258. pool.queueTx(tx10.Hash(), tx10)
  259. pool.queueTx(tx11.Hash(), tx11)
  260. // Check that pre and post validations leave the pool as is
  261. if len(pool.pending) != 2 {
  262. t.Errorf("pending transaction mismatch: have %d, want %d", len(pool.pending), 2)
  263. }
  264. if len(pool.queue[account]) != 2 {
  265. t.Errorf("queued transaction mismatch: have %d, want %d", len(pool.queue), 2)
  266. }
  267. pool.resetState()
  268. if len(pool.pending) != 2 {
  269. t.Errorf("pending transaction mismatch: have %d, want %d", len(pool.pending), 2)
  270. }
  271. if len(pool.queue[account]) != 2 {
  272. t.Errorf("queued transaction mismatch: have %d, want %d", len(pool.queue), 2)
  273. }
  274. // Reduce the balance of the account, and check that invalidated transactions are dropped
  275. state.AddBalance(account, big.NewInt(-750))
  276. pool.resetState()
  277. if _, ok := pool.pending[tx0.Hash()]; !ok {
  278. t.Errorf("funded pending transaction missing: %v", tx0)
  279. }
  280. if _, ok := pool.pending[tx1.Hash()]; ok {
  281. t.Errorf("out-of-fund pending transaction present: %v", tx1)
  282. }
  283. if _, ok := pool.queue[account][tx10.Hash()]; !ok {
  284. t.Errorf("funded queued transaction missing: %v", tx10)
  285. }
  286. if _, ok := pool.queue[account][tx11.Hash()]; ok {
  287. t.Errorf("out-of-fund queued transaction present: %v", tx11)
  288. }
  289. }
  290. // Tests that if a transaction is dropped from the current pending pool (e.g. out
  291. // of fund), all consecutive (still valid, but not executable) transactions are
  292. // postponed back into the future queue to prevent broadcasting them.
  293. func TestTransactionPostponing(t *testing.T) {
  294. // Create a test account and fund it
  295. pool, key := setupTxPool()
  296. account, _ := transaction(0, big.NewInt(0), key).From()
  297. state, _ := pool.currentState()
  298. state.AddBalance(account, big.NewInt(1000))
  299. // Add a batch consecutive pending transactions for validation
  300. txns := []*types.Transaction{}
  301. for i := 0; i < 100; i++ {
  302. var tx *types.Transaction
  303. if i%2 == 0 {
  304. tx = transaction(uint64(i), big.NewInt(100), key)
  305. } else {
  306. tx = transaction(uint64(i), big.NewInt(500), key)
  307. }
  308. pool.addTx(tx.Hash(), account, tx)
  309. txns = append(txns, tx)
  310. }
  311. // Check that pre and post validations leave the pool as is
  312. if len(pool.pending) != len(txns) {
  313. t.Errorf("pending transaction mismatch: have %d, want %d", len(pool.pending), len(txns))
  314. }
  315. if len(pool.queue[account]) != 0 {
  316. t.Errorf("queued transaction mismatch: have %d, want %d", len(pool.queue), 0)
  317. }
  318. pool.resetState()
  319. if len(pool.pending) != len(txns) {
  320. t.Errorf("pending transaction mismatch: have %d, want %d", len(pool.pending), len(txns))
  321. }
  322. if len(pool.queue[account]) != 0 {
  323. t.Errorf("queued transaction mismatch: have %d, want %d", len(pool.queue), 0)
  324. }
  325. // Reduce the balance of the account, and check that transactions are reorganized
  326. state.AddBalance(account, big.NewInt(-750))
  327. pool.resetState()
  328. if _, ok := pool.pending[txns[0].Hash()]; !ok {
  329. t.Errorf("tx %d: valid and funded transaction missing from pending pool: %v", 0, txns[0])
  330. }
  331. if _, ok := pool.queue[account][txns[0].Hash()]; ok {
  332. t.Errorf("tx %d: valid and funded transaction present in future queue: %v", 0, txns[0])
  333. }
  334. for i, tx := range txns[1:] {
  335. if i%2 == 1 {
  336. if _, ok := pool.pending[tx.Hash()]; ok {
  337. t.Errorf("tx %d: valid but future transaction present in pending pool: %v", i+1, tx)
  338. }
  339. if _, ok := pool.queue[account][tx.Hash()]; !ok {
  340. t.Errorf("tx %d: valid but future transaction missing from future queue: %v", i+1, tx)
  341. }
  342. } else {
  343. if _, ok := pool.pending[tx.Hash()]; ok {
  344. t.Errorf("tx %d: out-of-fund transaction present in pending pool: %v", i+1, tx)
  345. }
  346. if _, ok := pool.queue[account][tx.Hash()]; ok {
  347. t.Errorf("tx %d: out-of-fund transaction present in future queue: %v", i+1, tx)
  348. }
  349. }
  350. }
  351. }
  352. // Tests that if the transaction count belonging to a single account goes above
  353. // some threshold, the higher transactions are dropped to prevent DOS attacks.
  354. func TestTransactionQueueLimiting(t *testing.T) {
  355. // Create a test account and fund it
  356. pool, key := setupTxPool()
  357. account, _ := transaction(0, big.NewInt(0), key).From()
  358. state, _ := pool.currentState()
  359. state.AddBalance(account, big.NewInt(1000000))
  360. // Keep queuing up transactions and make sure all above a limit are dropped
  361. for i := uint64(1); i <= maxQueued+5; i++ {
  362. if err := pool.Add(transaction(i, big.NewInt(100000), key)); err != nil {
  363. t.Fatalf("tx %d: failed to add transaction: %v", i, err)
  364. }
  365. if len(pool.pending) != 0 {
  366. t.Errorf("tx %d: pending pool size mismatch: have %d, want %d", i, len(pool.pending), 0)
  367. }
  368. if i <= maxQueued {
  369. if len(pool.queue[account]) != int(i) {
  370. t.Errorf("tx %d: queue size mismatch: have %d, want %d", i, len(pool.queue[account]), i)
  371. }
  372. } else {
  373. if len(pool.queue[account]) != maxQueued {
  374. t.Errorf("tx %d: queue limit mismatch: have %d, want %d", i, len(pool.queue[account]), maxQueued)
  375. }
  376. }
  377. }
  378. }
  379. // Tests that even if the transaction count belonging to a single account goes
  380. // above some threshold, as long as the transactions are executable, they are
  381. // accepted.
  382. func TestTransactionPendingLimiting(t *testing.T) {
  383. // Create a test account and fund it
  384. pool, key := setupTxPool()
  385. account, _ := transaction(0, big.NewInt(0), key).From()
  386. state, _ := pool.currentState()
  387. state.AddBalance(account, big.NewInt(1000000))
  388. // Keep queuing up transactions and make sure all above a limit are dropped
  389. for i := uint64(0); i < maxQueued+5; i++ {
  390. if err := pool.Add(transaction(i, big.NewInt(100000), key)); err != nil {
  391. t.Fatalf("tx %d: failed to add transaction: %v", i, err)
  392. }
  393. if len(pool.pending) != int(i)+1 {
  394. t.Errorf("tx %d: pending pool size mismatch: have %d, want %d", i, len(pool.pending), i+1)
  395. }
  396. if len(pool.queue[account]) != 0 {
  397. t.Errorf("tx %d: queue size mismatch: have %d, want %d", i, len(pool.queue[account]), 0)
  398. }
  399. }
  400. }
  401. // Tests that the transaction limits are enforced the same way irrelevant whether
  402. // the transactions are added one by one or in batches.
  403. func TestTransactionQueueLimitingEquivalency(t *testing.T) { testTransactionLimitingEquivalency(t, 1) }
  404. func TestTransactionPendingLimitingEquivalency(t *testing.T) { testTransactionLimitingEquivalency(t, 0) }
  405. func testTransactionLimitingEquivalency(t *testing.T, origin uint64) {
  406. // Add a batch of transactions to a pool one by one
  407. pool1, key1 := setupTxPool()
  408. account1, _ := transaction(0, big.NewInt(0), key1).From()
  409. state1, _ := pool1.currentState()
  410. state1.AddBalance(account1, big.NewInt(1000000))
  411. for i := uint64(0); i < maxQueued+5; i++ {
  412. if err := pool1.Add(transaction(origin+i, big.NewInt(100000), key1)); err != nil {
  413. t.Fatalf("tx %d: failed to add transaction: %v", i, err)
  414. }
  415. }
  416. // Add a batch of transactions to a pool in one bit batch
  417. pool2, key2 := setupTxPool()
  418. account2, _ := transaction(0, big.NewInt(0), key2).From()
  419. state2, _ := pool2.currentState()
  420. state2.AddBalance(account2, big.NewInt(1000000))
  421. txns := []*types.Transaction{}
  422. for i := uint64(0); i < maxQueued+5; i++ {
  423. txns = append(txns, transaction(origin+i, big.NewInt(100000), key2))
  424. }
  425. pool2.AddTransactions(txns)
  426. // Ensure the batch optimization honors the same pool mechanics
  427. if len(pool1.pending) != len(pool2.pending) {
  428. t.Errorf("pending transaction count mismatch: one-by-one algo: %d, batch algo: %d", len(pool1.pending), len(pool2.pending))
  429. }
  430. if len(pool1.queue[account1]) != len(pool2.queue[account2]) {
  431. t.Errorf("queued transaction count mismatch: one-by-one algo: %d, batch algo: %d", len(pool1.queue[account1]), len(pool2.queue[account2]))
  432. }
  433. }
  434. // Benchmarks the speed of validating the contents of the pending queue of the
  435. // transaction pool.
  436. func BenchmarkValidatePool100(b *testing.B) { benchmarkValidatePool(b, 100) }
  437. func BenchmarkValidatePool1000(b *testing.B) { benchmarkValidatePool(b, 1000) }
  438. func BenchmarkValidatePool10000(b *testing.B) { benchmarkValidatePool(b, 10000) }
  439. func benchmarkValidatePool(b *testing.B, size int) {
  440. // Add a batch of transactions to a pool one by one
  441. pool, key := setupTxPool()
  442. account, _ := transaction(0, big.NewInt(0), key).From()
  443. state, _ := pool.currentState()
  444. state.AddBalance(account, big.NewInt(1000000))
  445. for i := 0; i < size; i++ {
  446. tx := transaction(uint64(i), big.NewInt(100000), key)
  447. pool.addTx(tx.Hash(), account, tx)
  448. }
  449. // Benchmark the speed of pool validation
  450. b.ResetTimer()
  451. for i := 0; i < b.N; i++ {
  452. pool.validatePool()
  453. }
  454. }
  455. // Benchmarks the speed of scheduling the contents of the future queue of the
  456. // transaction pool.
  457. func BenchmarkCheckQueue100(b *testing.B) { benchmarkCheckQueue(b, 100) }
  458. func BenchmarkCheckQueue1000(b *testing.B) { benchmarkCheckQueue(b, 1000) }
  459. func BenchmarkCheckQueue10000(b *testing.B) { benchmarkCheckQueue(b, 10000) }
  460. func benchmarkCheckQueue(b *testing.B, size int) {
  461. // Add a batch of transactions to a pool one by one
  462. pool, key := setupTxPool()
  463. account, _ := transaction(0, big.NewInt(0), key).From()
  464. state, _ := pool.currentState()
  465. state.AddBalance(account, big.NewInt(1000000))
  466. for i := 0; i < size; i++ {
  467. tx := transaction(uint64(1+i), big.NewInt(100000), key)
  468. pool.queueTx(tx.Hash(), tx)
  469. }
  470. // Benchmark the speed of pool validation
  471. b.ResetTimer()
  472. for i := 0; i < b.N; i++ {
  473. pool.checkQueue()
  474. }
  475. }