Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New higher capacity Txpool #2660

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
dfb046e
txpool: incomplete pool2 and pool3
emailtovamos Jul 16, 2024
e30248b
pool: optimise sending in reorg
emailtovamos Jul 29, 2024
f80ac01
pool: add static info and simplify transfer
emailtovamos Aug 1, 2024
8655d30
pool: remove comments, use queue not pool23
emailtovamos Aug 1, 2024
4538e92
pool: remove unused function
emailtovamos Aug 1, 2024
4369e3d
pool: refactor and bugfix
emailtovamos Aug 1, 2024
d0d6a27
pool: buffer test and size logic
emailtovamos Aug 2, 2024
5faf413
pool: add discarded ones to pool3 by default.
emailtovamos Aug 2, 2024
5bb78b3
pool: minor refactor
emailtovamos Aug 20, 2024
6b4e16b
pool: make slots config
emailtovamos Aug 21, 2024
d03f7e5
pool: initialise pool3 slots
emailtovamos Aug 21, 2024
94a60a9
pool: add underpriced to pool2 or 3
emailtovamos Aug 23, 2024
ed2d1d7
pool: enqueue in pool2 & drop properly
emailtovamos Aug 25, 2024
6daecfb
pool: bugfix:always drop drop and pool2 size
emailtovamos Aug 27, 2024
9d7298f
pool: TestDualHeapEviction passing partly
emailtovamos Aug 27, 2024
a1a25e9
pool: TestDualHeapEviction fully pass
emailtovamos Aug 27, 2024
253d9a5
pool: some cleanups
emailtovamos Aug 27, 2024
0692a99
pool: fix the TestTransactionFutureAttack test
emailtovamos Aug 28, 2024
40dcfcd
pool: cleanup debug logs
emailtovamos Aug 28, 2024
6673f3e
pool: fix TestUnderpricingDynamicFee based on new pool
emailtovamos Aug 28, 2024
ebd8f59
pool: fix all old tests
emailtovamos Aug 28, 2024
bdb4cc2
pool: lint
emailtovamos Aug 29, 2024
e45e7eb
pool: include static in flatten
emailtovamos Aug 29, 2024
069eaf2
pool: proper use of AsyncSendPooledTransactionHashes
emailtovamos Aug 29, 2024
70ece93
pool: flags for pool2 and 3 capacity
emailtovamos Aug 29, 2024
e7d0a16
pool: fix test as now by default pool2 and pool3 aren't empty
emailtovamos Aug 30, 2024
16a2a53
Merge remote-tracking branch 'origin/develop' into txpool-new
emailtovamos Sep 2, 2024
0f8a1b5
pool: test for transfer
emailtovamos Sep 3, 2024
76d157d
pool: set transfer time in config
emailtovamos Sep 3, 2024
aeec0c7
pool: remove unused criticalpathpool
emailtovamos Sep 3, 2024
53042e1
buffer: make private
emailtovamos Sep 3, 2024
8e6833c
pool: bug fix and test fix
emailtovamos Sep 3, 2024
5f398db
pool: pool2 can have 0 size
emailtovamos Sep 3, 2024
706a24e
pool: lint fix
emailtovamos Sep 4, 2024
0e61543
test: requestPromoteExecutables after every enqueue for testing
emailtovamos Sep 6, 2024
0a5dbef
pool: queued goes to 0 locally after this change
emailtovamos Sep 6, 2024
248bb6b
pool: fastcache, interface, metrics modify
emailtovamos Sep 11, 2024
cf10c5c
eth: send to some peers of pool2, not just static
emailtovamos Sep 11, 2024
b818cb7
pool: transfer on block import and simplify it
emailtovamos Sep 12, 2024
774e314
pool: truly discard underpriced, Transfer after lock is over
emailtovamos Sep 18, 2024
629af6d
pool: else ifs instead of ifs
emailtovamos Sep 18, 2024
3e3c56b
pool: address minor issues
emailtovamos Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pool: add underpriced to pool2 or 3
  • Loading branch information
emailtovamos committed Aug 23, 2024
commit 94a60a9006c7334fab9a3807cfd709cb8e0155b0
23 changes: 14 additions & 9 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
// txReannoMaxNum is the maximum number of transactions a reannounce action can include.
txReannoMaxNum = 1024

maxPool2Size = 10000 // todo might have to set it in config // This is in slots and not in no of transactions

Check failure on line 59 in core/txpool/legacypool/legacypool.go

View workflow job for this annotation

GitHub Actions / golang-lint (1.21.x, ubuntu-latest)

const `maxPool2Size` is unused (unused)
maxPool3Size = 50000

Check failure on line 60 in core/txpool/legacypool/legacypool.go

View workflow job for this annotation

GitHub Actions / golang-lint (1.21.x, ubuntu-latest)

const `maxPool3Size` is unused (unused)
)

var (
Expand Down Expand Up @@ -259,7 +259,7 @@
static bool
}

func newQueueTxEventCh() QueueTxEventCh {

Check failure on line 262 in core/txpool/legacypool/legacypool.go

View workflow job for this annotation

GitHub Actions / golang-lint (1.21.x, ubuntu-latest)

func `newQueueTxEventCh` is unused (unused)
return QueueTxEventCh{
tx: new(types.Transaction),
}
Expand Down Expand Up @@ -822,18 +822,23 @@
}

// If the transaction pool is full, discard underpriced transactions
if uint64(pool.all.Slots()+numSlots(tx)) > maxPool1Size { // todo 3 maybe a check here for pool2? // try addToPool2OrPool3() and only if unsuccessful then do the other things!!!
if uint64(pool.all.Slots()+numSlots(tx)) > maxPool1Size {
// todo 3 -> done maybe a check here for pool2? // try addToPool2OrPool3() and only if unsuccessful then do the other things!!!
// Try adding to pool2 or pool3 first
// If the new transaction is underpriced, don't accept it
if true || (!isLocal && pool.priced.Underpriced(tx)) {
// todo 5 actually if underpriced then add to pool2 or 3. Otherwise find out which one will be replaced with and that one will go to pool2 or 3
if !isLocal && pool.priced.Underpriced(tx) {
addedToAnyPool, err := pool.addToPool2OrPool3(tx, from, isLocal, includePool1, includePool2, includePool3)
if !addedToAnyPool {
log.Trace("Discarding underpriced transaction", "hash", hash, "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
underpricedTxMeter.Mark(1)
return false, err
//return false, txpool.ErrUnderpriced
if addedToAnyPool {
return false, nil
}
if err != nil {
log.Error("Error while trying to add to pool2 or pool3", "error", err)
}
return false, nil // since it is not replacing a transaction

log.Trace("Discarding underpriced transaction", "hash", hash, "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
underpricedTxMeter.Mark(1)
return false, txpool.ErrUnderpriced
}

// We're about to replace a transaction. The reorg does a more thorough
Expand Down Expand Up @@ -897,7 +902,7 @@
remainingDrop = append(remainingDrop, tx)
}
}

Check failure on line 905 in core/txpool/legacypool/legacypool.go

View workflow job for this annotation

GitHub Actions / golang-lint (1.21.x, ubuntu-latest)

unnecessary trailing newline (whitespace)
}

// Kick out the underpriced remote transactions.
Expand All @@ -915,7 +920,7 @@
}
}

// Try to replace an existing transaction in the pending pool
// Try to replace an existing transaction in the pending pool // todo 4 why we are replacing a pending tx if the we can put in pool3 or so?
if list := pool.pending[from]; list != nil && list.Contains(tx.Nonce()) {
// Nonce already pending, check if required price bump is met
inserted, old := list.Add(tx, pool.config.PriceBump, includePool2)
Expand Down Expand Up @@ -2189,7 +2194,7 @@
}

// transferTransactions mainly moves from pool 3 to pool 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion-5:
I think pool-3 does not need to transfer to pool-2 specifically. the transactions in pool-3 can just seen as new arrived transaction, there is the workflow:

  • 1.check if it is still valid or not, remove if it is no longer valid
  • 2.try to put it into pool-1, ok => remove it from pool-3
  • 3.try to put it into pool-2, ok => remove it from pool-3
  • 4.if failed to transfer, due to pool-1 and pool-2 are full, stop the transfer procedure.

func (pool *LegacyPool) transferTransactions() {

Check failure on line 2197 in core/txpool/legacypool/legacypool.go

View workflow job for this annotation

GitHub Actions / golang-lint (1.21.x, ubuntu-latest)

unnecessary leading newline (whitespace)

maxPool1Size := pool.config.GlobalSlots + pool.config.GlobalQueue
maxPool2Size := pool.config.Pool2Slots
Expand Down
Loading