mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: refactor and integrate local engine into EngineNodeLauncher (#11703)
This commit is contained in:
@ -3,29 +3,64 @@ use std::sync::Arc;
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::{b256, hex};
|
||||
use futures::StreamExt;
|
||||
use reth::core::rpc::eth::helpers::EthTransactions;
|
||||
use reth::{args::DevArgs, core::rpc::eth::helpers::EthTransactions};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_e2e_test_utils::setup;
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
|
||||
use crate::utils::EthNode;
|
||||
use reth_node_api::{FullNodeComponents, NodeAddOns};
|
||||
use reth_node_builder::{EngineNodeLauncher, FullNode, NodeBuilder, NodeConfig, NodeHandle};
|
||||
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
|
||||
use reth_provider::{providers::BlockchainProvider2, CanonStateSubscriptions};
|
||||
use reth_tasks::TaskManager;
|
||||
|
||||
#[tokio::test]
|
||||
async fn can_run_dev_node() -> eyre::Result<()> {
|
||||
reth_tracing::init_test_tracing();
|
||||
let (mut nodes, _tasks, _) = setup(1, custom_chain(), true).await?;
|
||||
let (mut nodes, _tasks, _) = setup::<EthereumNode>(1, custom_chain(), true).await?;
|
||||
|
||||
assert_chain_advances(nodes.pop().unwrap()).await;
|
||||
assert_chain_advances(nodes.pop().unwrap().inner).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn assert_chain_advances(node: EthNode) {
|
||||
let mut notifications = node.inner.provider.canonical_state_stream();
|
||||
#[tokio::test]
|
||||
async fn can_run_dev_node_new_engine() -> eyre::Result<()> {
|
||||
reth_tracing::init_test_tracing();
|
||||
let tasks = TaskManager::current();
|
||||
let exec = tasks.executor();
|
||||
|
||||
let node_config = NodeConfig::test()
|
||||
.with_chain(custom_chain())
|
||||
.with_dev(DevArgs { dev: true, ..Default::default() });
|
||||
let NodeHandle { node, .. } = NodeBuilder::new(node_config.clone())
|
||||
.testing_node(exec.clone())
|
||||
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>()
|
||||
.with_components(EthereumNode::components())
|
||||
.with_add_ons(EthereumAddOns::default())
|
||||
.launch_with_fn(|builder| {
|
||||
let launcher = EngineNodeLauncher::new(
|
||||
builder.task_executor().clone(),
|
||||
builder.config().datadir(),
|
||||
Default::default(),
|
||||
);
|
||||
builder.launch_with(launcher)
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_chain_advances(node).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn assert_chain_advances<N, AddOns>(node: FullNode<N, AddOns>)
|
||||
where
|
||||
N: FullNodeComponents<Provider: CanonStateSubscriptions>,
|
||||
AddOns: NodeAddOns<N, EthApi: EthTransactions>,
|
||||
{
|
||||
let mut notifications = node.provider.canonical_state_stream();
|
||||
|
||||
// submit tx through rpc
|
||||
let raw_tx = hex!("02f876820a28808477359400847735940082520894ab0840c0e43688012c1adb0f5e3fc665188f83d28a029d394a5d630544000080c080a0a044076b7e67b5deecc63f61a8d7913fab86ca365b344b5759d1fe3563b4c39ea019eab979dd000da04dfc72bb0377c092d30fd9e1cab5ae487de49586cc8b0090");
|
||||
|
||||
let eth_api = node.inner.rpc_registry.eth_api();
|
||||
let eth_api = node.rpc_registry.eth_api();
|
||||
|
||||
let hash = eth_api.send_raw_transaction(raw_tx.into()).await.unwrap();
|
||||
|
||||
|
||||
@ -1,12 +1,7 @@
|
||||
use alloy_primitives::{Address, B256};
|
||||
use reth::rpc::types::engine::PayloadAttributes;
|
||||
use reth_e2e_test_utils::NodeHelperType;
|
||||
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
|
||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
||||
|
||||
/// Ethereum Node Helper type
|
||||
pub(crate) type EthNode = NodeHelperType<EthereumNode, EthereumAddOns>;
|
||||
|
||||
/// Helper function to create a new eth payload attributes
|
||||
pub(crate) fn eth_payload_attributes(timestamp: u64) -> EthPayloadBuilderAttributes {
|
||||
let attributes = PayloadAttributes {
|
||||
|
||||
Reference in New Issue
Block a user