MempoolTxsDetector is only fed with mempool txs.#901
MempoolTxsDetector is only fed with mempool txs.#901
Conversation
|
Claude finished @ZanCorDX's task in 1m 15s —— View job PR Review: MempoolTxsDetector refactor
SummaryThe refactoring direction is sound — making Issues found
See inline comments for details. |
| let mempool_txs_detector = MempoolTxsDetector::new(); | ||
| for sim_order in &orders { | ||
| order_id_to_order.insert(sim_order.id(), sim_order.clone()); | ||
| mempool_txs_detector.add_tx(&sim_order.order); | ||
| if let Order::Tx(mempool_tx) = sim_order.order.as_ref() { |
There was a problem hiding this comment.
This creates a fresh MempoolTxsDetector and feeds it all Order::Tx orders — including private txs from eth_sendRawTransaction. This contradicts the PR's goal of distinguishing mempool txs from private txs.
Should this use the shared MempoolTxsDetector from BlockBuildingContext (i.e. block_ctx.mempool_tx_detector) instead of constructing a local one?
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
Claude finished @ZanCorDX's task in 1m 54s —— View job PR Review: MempoolTxsDetector refactor (re-review after sync)
SummaryThe second commit ( Issues
|
| let mempool_txs_detector = MempoolTxsDetector::new(); | ||
| for sim_order in &orders { | ||
| order_id_to_order.insert(sim_order.id(), sim_order.clone()); | ||
| mempool_txs_detector.add_tx(&sim_order.order); | ||
| if let Order::Tx(mempool_tx) = sim_order.order.as_ref() { | ||
| mempool_txs_detector.add_tx(mempool_tx.tx_with_blobs.hash()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Still creates a fresh local MempoolTxsDetector and adds all Order::Tx — including private txs from eth_sendRawTransaction. This means stats logging will misclassify private txs as mempool txs, defeating the purpose of this PR for the stats path.
Should use the shared detector from BlockBuildingContext (accessible via self.block_building_helper) instead of constructing a local one.
| mempool_detector.add_tx(tx.hash()); | ||
| let order = Order::Tx(MempoolTx::new(tx)); | ||
| let command = ReplaceableOrderPoolCommand::Order(Arc::new(order)); | ||
| if let Err(e) = orderpool_sender.send(command).await { | ||
| mempool_detector.remove_tx(tx.hash()); | ||
| error!("Error sending order to orderpool: {:#}", e); | ||
| } |
There was a problem hiding this comment.
Bug: The new code block (lines 555-561) was added but the old code block (lines 562-566) was not removed. This duplicates the logic and will fail to compile — tx is moved into MempoolTx::new(tx) on line 556, making lines 559 (tx.hash()) and 562 (MempoolTx::new(tx)) invalid.
Fix: remove lines 562-566 (the old code) and save the hash before moving tx:
let hash = tx.hash();
mempool_detector.add_tx(hash);
let order = Order::Tx(MempoolTx::new(tx));
let command = ReplaceableOrderPoolCommand::Order(Arc::new(order));
if let Err(e) = orderpool_sender.send(command).await {
mempool_detector.remove_tx(hash);
error!("Error sending order to orderpool: {:#}", e);
}|
Claude finished @ZanCorDX's task in 1m 20s —— View job PR Review: MempoolTxsDetector refactor (re-review after latest sync)
SummaryThe latest commit (
Remaining issueBacktest path still adds all Nit
Overall the core changes look correct. The refactoring direction is sound — the shared long-lived |
📝 Summary
MempoolTxsDetector used to consider as mempool any MempoolTx but those coming from eth_sendRawTransaction should not be considered as mempool.
MempoolTxsDetector was changed, now it's a long lived object.
We insert txs into MempoolTxsDetector on the read mempool tasks and clean it on the OrderPool to avoid leaks.
✅ I have completed the following steps:
make lintmake test