-
Notifications
You must be signed in to change notification settings - Fork 11
*: add broadcast local txs feature #192
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
Conversation
23223b2 to
edd6b15
Compare
core/txpool/legacypool/legacypool.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| rejournal := config.TxPool.Rejournal |
| } | ||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
core/txpool/locals/tx_tracker.go
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if key exists instead of checking value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
edd6b15 to
07fb79c
Compare
markya0616
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
## 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)