Open rkrasiuk opened 3 months ago
Tree State is behind the rw lock https://github.com/paradigmxyz/reth/blob/9312424db05b066cee6fae40471dc679ed35cef8/crates/blockchain-tree/src/shareable.rs#L29-L32
Connecting buffered blocks is a recursive operation in a non-obvious case https://github.com/paradigmxyz/reth/blob/9312424db05b066cee6fae40471dc679ed35cef8/crates/blockchain-tree/src/blockchain_tree.rs#L828
In the worst case, this would connect up to 3 epochs worth of blocks. This might be the root cause of https://github.com/paradigmxyz/reth/issues/6905
Blockchain Tree should be rewritten into a message-passing service. The engine should send control commands to the tree service. The tree service should orchestrate how to prioritize the received actions.
The tree service interface should be async.
struct BlockchainTreeHandle { to_tree: UnboundedSender<TreeMessage>, } struct BlockchainTreeService { messages_rx: UnboundedReceiverStream<TreeMessage>, task_spawner: Arc<dyn TaskSpawner>, // for concurrent payload processing } // impl Future for BlockchainTreeService { ... }
Downgrade the lock to wrap only the actual tree state. Double-check if the lock is necessary at all.
Tree Action Prioritization:
We might need to move the ancestor check to the tree. This information should be included in the response that the tree sends back to the engine.
All existing tests should be ported over to the new service.
We should have chain generation test utils for easier testing of the tree .
This issue is stale because it has been open for 21 days with no activity.
Issues
Tree State is behind the rw lock https://github.com/paradigmxyz/reth/blob/9312424db05b066cee6fae40471dc679ed35cef8/crates/blockchain-tree/src/shareable.rs#L29-L32
Connecting buffered blocks is a recursive operation in a non-obvious case https://github.com/paradigmxyz/reth/blob/9312424db05b066cee6fae40471dc679ed35cef8/crates/blockchain-tree/src/blockchain_tree.rs#L828
In the worst case, this would connect up to 3 epochs worth of blocks. This might be the root cause of https://github.com/paradigmxyz/reth/issues/6905
Solution
Blockchain Tree should be rewritten into a message-passing service. The engine should send control commands to the tree service. The tree service should orchestrate how to prioritize the received actions.
The tree service interface should be async.
Downgrade the lock to wrap only the actual tree state. Double-check if the lock is necessary at all.
Tree Action Prioritization:
We might need to move the ancestor check to the tree. This information should be included in the response that the tree sends back to the engine.
Testing
All existing tests should be ported over to the new service.
We should have chain generation test utils for easier testing of the tree .