*: add broadcast local txs feature#192
Conversation
23223b2 to
edd6b15
Compare
There was a problem hiding this comment.
Here, I followed the approach of Rejournal.
store the config value in legacypool.Config and use it in eth/backend.go for TxTracker
ref.
Line 245 in edd6b15
| } | ||
| eth.localTxTracker = locals.New(config.TxPool.Journal, rejournal, eth.blockchain.Config(), eth.txPool, broadcastPendingLocalTx) | ||
| stack.RegisterLifecycle(eth.localTxTracker) | ||
| eth.txPool.PendingLocalTxsPublisher = eth.localTxTracker |
There was a problem hiding this comment.
Just a note on the main changes in this PR:
The key refactor is in txPool's SubscribePendingLocalTxsEvent:
- Before: txPool called
subPools.SubscribePendingLocalTxsEventwhen executingSubscribePendingLocalTxsEvent. - After: It now calls
PendingLocalTxsPublisher.SubscribePendingLocalTransactions, which is backed bylocalTxTracker.
Since localTxTracker is optional and the handler only has txPool (but not localTxTracker), we had to pass eth.localTxTracker into txPool at L257.
While the data flow feels a bit indirect (handler → txPool → localTxTracker, instead of handler → localTxTracker), I couldn’t immediately think of a cleaner solution without making broader changes.
Overall, I think this approach is fine, so I’ll approve this.
Reference of old customized commit: bf10d46#diff-4d08b06f78070fa573caaaa4b6b56dd5cc7bbeb03b04d1b93cafa167fc5577e5R374
There was a problem hiding this comment.
Thanks for organizing!
The data flow:
- before v1.14.13:
handler ->txPool->LegacyPool(subpool) -> filterpendingbylocals(contains the addresses that submitting local tx before) - after v1.15.0:
handler ->txPool->TxTracker(PendingLocalTxsPublisher) -> query pending txs fromLegacyPooland filter them bybyAddr(contains the addresses that submitting local tx before)
| case <-pendingLocalTxs.C: | ||
| lTxs := types.Transactions{} | ||
| for addr, lazyTxs := range tracker.pool.Pending(txpool.PendingFilter{OnlyPlainTxs: true}) { | ||
| if tracker.byAddr[addr] == nil { |
There was a problem hiding this comment.
check if key exists instead of checking value?
edd6b15 to
07fb79c
Compare
## Why this should be merged Addition of recent, functionality constitutes a bump to the minor version. Doing this on `main` first for consistency and will cut a release candidate after. ## How this works Magic ## How this was tested Super magic
ethereum#30559
The locals-tracking feature has been migrated from pool to TxTracker. As a result, pending local transactions should now be retrieved directly from TxTracker.
Data flow:
handler ->
txPool->LegacyPool(subpool) -> filterpendingbylocals(contains the addresses that submitting local tx before)handler ->
txPool->TxTracker(PendingLocalTxsPublisher) -> query pending txs fromLegacyPooland filter them bybyAddr(contains the addresses that submitting local tx before)