Skip to content

Change TxPreEvent to NewTxsEvent#427

Closed
trinhdn2 wants to merge 4 commits intoBuildOnViction:masterfrom
trinhdn2:ft/group_multiple_TxPreEvent
Closed

Change TxPreEvent to NewTxsEvent#427
trinhdn2 wants to merge 4 commits intoBuildOnViction:masterfrom
trinhdn2:ft/group_multiple_TxPreEvent

Conversation

@trinhdn2
Copy link
Copy Markdown

@trinhdn2 trinhdn2 commented Jan 15, 2024

Currently, when a transaction is promoted, a TxPreEvent will be pushed to subscribers immediately.

While when the number of new transactions received is large, there are too many TxPreEvent will be pushed leads to txFeed lock resource contention.

So in this PR, i replace all TxPreEvent to NewTxsEvent. So that we can push a batch of new promoted txs together. It will help in these scenario:

  • Block reorganization (a bunch of transactions will be re-injected to txpool)
  • Improve transaction forwarding efficiency (Send a batch of transactions to peers instead of single one)
  • Relieving pressure on the system from websocket pending transaction subscriptions (Prevent slower socket write speeds from blocking txfeed)

This works around what seems to be a source of contention when event.Feed.Send is called from multiple txpool goroutines at high volume.

goroutine 43158053 [chan receive, 136 minutes]:
github.com/ethereum/go-ethereum/event.(*Feed).Send(0xc420313e38, 0xdef1a0, 0xc4b5ae3320, 0x60c977)
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/event/feed.go:133 +0xcc
created by github.com/ethereum/go-ethereum/core.(*TxPool).promoteTx
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/core/tx_pool.go:750 +0x2ae

goroutine 43750113 [chan receive, 57 minutes]:
github.com/ethereum/go-ethereum/event.(*Feed).Send(0xc420313e38, 0xdef1a0, 0xc5403ca6c0, 0x60c977)
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/event/feed.go:133 +0xcc
created by github.com/ethereum/go-ethereum/core.(*TxPool).promoteTx
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/core/tx_pool.go:750 +0x2ae

goroutine 43016550 [chan receive, 154 minutes]:
github.com/ethereum/go-ethereum/event.(*Feed).Send(0xc420313e38, 0xdef1a0, 0xc4935fddd0, 0x60c977)
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/event/feed.go:133 +0xcc
created by github.com/ethereum/go-ethereum/core.(*TxPool).promoteTx
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/core/tx_pool.go:750 +0x2ae

goroutine 43928769 [chan receive, 35 minutes]:
github.com/ethereum/go-ethereum/event.(*Feed).Send(0xc420313e38, 0xdef1a0, 0xc5059bf710, 0x60c977)
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/event/feed.go:133 +0xcc
created by github.com/ethereum/go-ethereum/core.(*TxPool).promoteTx
  /home/ubuntu/geth/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/core/tx_pool.go:750 +0x2ae

Besides, this PR also fixes a small problem. When we apply new promoted transaction to mining block, it should still abide original gas limit restriction instead of creating a new gas limit.

Reference:

@trinhdn2 trinhdn2 closed this by deleting the head repository Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant