Skip to content

Commit

Permalink
modify tree task
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Oct 10, 2024
1 parent 6bf31d0 commit ae359c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 2 additions & 5 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ use reth_ethereum_forks::{
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Head, DEV_HARDFORKS,
};
use reth_network_peers::{
base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes,
base_nodes, base_testnet_nodes, bsc_mainnet_nodes, bsc_testnet_nodes, holesky_nodes,
mainnet_nodes, op_nodes, op_testnet_nodes, opbnb_mainnet_nodes, opbnb_testnet_nodes,
sepolia_nodes, NodeRecord,
};
#[cfg(feature = "bsc")]
use reth_network_peers::{bsc_mainnet_nodes, bsc_testnet_nodes};
#[cfg(feature = "opbnb")]
use reth_network_peers::{opbnb_mainnet_nodes, opbnb_testnet_nodes};
use reth_primitives_traits::{
constants::{
DEV_GENESIS_HASH, EIP1559_INITIAL_BASE_FEE, EMPTY_WITHDRAWALS, ETHEREUM_BLOCK_GAS_LIMIT,
Expand Down
17 changes: 16 additions & 1 deletion crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,16 @@ where
);
task.set_invalid_block_hook(invalid_block_hook);
let incoming = task.incoming_tx.clone();
std::thread::Builder::new().name("Tree Task".to_string()).spawn(|| task.run()).unwrap();
std::thread::Builder::new()
.name("Tree Task".to_string())
.spawn(move || {
let runtime =
tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
runtime.block_on(async {
task.run();
});
})
.unwrap();
(incoming, outgoing)
}

Expand Down Expand Up @@ -1203,8 +1212,11 @@ where
EngineApiRequest::Beacon(request) => {
match request {
BeaconEngineMessage::ForkchoiceUpdated { state, payload_attrs, tx } => {
let start = Instant::now();
let mut output = self.on_forkchoice_updated(state, payload_attrs);
debug!("Forkchoice updated took {:?}", start.elapsed());

let start = Instant::now();
if let Ok(res) = &mut output {
// track last received forkchoice state
self.state
Expand All @@ -1220,12 +1232,15 @@ where
// handle the event if any
self.on_maybe_tree_event(res.event.take())?;
}
debug!("Sending response to beacon1 took {:?}", start.elapsed());

let start = Instant::now();
if let Err(err) =
tx.send(output.map(|o| o.outcome).map_err(Into::into))
{
error!("Failed to send event: {err:?}");
}
debug!("Sent response to beacon2 took {:?}", start.elapsed());
}
BeaconEngineMessage::NewPayload { payload, cancun_fields, tx } => {
let output = self.on_new_payload(payload, cancun_fields);
Expand Down

0 comments on commit ae359c3

Please sign in to comment.