From c1f27bab846d7f1d74204b781b99e883b2bbd301 Mon Sep 17 00:00:00 2001 From: CeciliaZ030 Date: Tue, 13 Aug 2024 19:55:32 +0000 Subject: [PATCH] Revert "compile" This reverts commit 863740ba4eb353246d669c342b606aa844e72001. --- bin/reth/src/main.rs | 260 ++++++++++---------------- bin/reth/src/node.rs | 37 ++-- crates/payload/builder/src/service.rs | 2 - crates/primitives/src/block.rs | 2 - 4 files changed, 112 insertions(+), 189 deletions(-) diff --git a/bin/reth/src/main.rs b/bin/reth/src/main.rs index 137b8c5dea64..24133dc06bdf 100644 --- a/bin/reth/src/main.rs +++ b/bin/reth/src/main.rs @@ -29,7 +29,6 @@ fn main() { } }*/ -use alloy_signer::k256::elliptic_curve::rand_core::block; use alloy_sol_types::{sol, SolEventInterface, SolInterface}; use db::Database; use execution::execute_block; @@ -41,10 +40,10 @@ use payload::PayloadTestContext; use reth::args::{DiscoveryArgs, NetworkArgs, RpcServerArgs}; use reth_chainspec::{ChainSpec, ChainSpecBuilder, MAINNET}; use reth_consensus::Consensus; -use reth_db::{database_metrics::DatabaseMetrics, test_utils::TempDatabase, DatabaseEnv}; +use reth_db::{test_utils::TempDatabase, DatabaseEnv}; use reth_execution_types::Chain; use reth_exex::{ExExContext, ExExEvent}; -use reth_node_api::{FullNodeTypesAdapter, NodeAddOns, NodeTypes}; +use reth_node_api::{FullNodeTypesAdapter, NodeAddOns}; //use reth_node_api::{EngineTypes, FullNodeComponents, NodeAddOns}; use reth_node_builder::{components::Components, rpc::EthApiBuilderProvider, AddOns, FullNode, Node, NodeAdapter, NodeBuilder, NodeComponentsBuilder, NodeConfig, NodeHandle, RethFullAdapter}; use reth_node_ethereum::{node::EthereumAddOns, EthEvmConfig, EthExecutorProvider, EthereumNode}; @@ -113,23 +112,14 @@ static CHAIN_SPEC: Lazy> = Lazy::new(|| { struct Rollup { ctx: ExExContext, - // node: TestNodeContext, + node: TestNodeContext, } impl Rollup { - fn new(ctx: ExExContext/* , node: TestNodeContext */) -> eyre::Result { - Ok(Self { ctx/* , node */}) + fn new(ctx: ExExContext, node: TestNodeContext) -> eyre::Result { + Ok(Self { ctx, node }) } - async fn fuckoff(self) -> eyre::Result<()> { - self.fuckoff2().await - } - - async fn fuckoff2(self) -> eyre::Result<()> { - Ok(()) - } -// } - async fn start(mut self) -> eyre::Result<()> { // Process all new chain state notifications while let Some(notification) = self.ctx.notifications.recv().await { @@ -146,7 +136,6 @@ impl Rollup { Ok(()) } - /// Process a new chain commit. /// /// This function decodes all transactions to the rollup contract into events, executes the @@ -204,21 +193,11 @@ impl Rollup { let block_number = 10; // // assert the block has been committed to the blockchain - unsafe { - let mut node = MY_STATIC.get_mut().unwrap(); - tokio::task::block_in_place(|| { - tokio::runtime::Handle::current().block_on(async move { - // do something async - node.assert_new_block(tx_hash, block_hash, block_number).await.unwrap(); - }); - }); - // node.assert_new_block(tx_hash, block_hash, block_number).await?; - // println!("{:?}", node.inner.evm_config); - } - + self.node.assert_new_block(tx_hash, block_hash, block_number).await?; //let tx_hash = self.node.rpc.inject_tx(raw_tx).await?; + println!("{:?}", self.node.inner.evm_config); /*if let RollupContractCalls::submitBlock(RollupContract::submitBlockCall { header, @@ -407,25 +386,7 @@ type Adapter = NodeAdapter< >>::Components, >; -type TestNodeContext = NodeTestContext< - NodeAdapter< - FullNodeTypesAdapter>, BlockchainProvider>>>, - Components< - FullNodeTypesAdapter>, - BlockchainProvider>>>, - Pool< - TransactionValidationTaskExecutor>>, EthPooledTransaction>>, - CoinbaseTipOrdering, - DiskFileBlobStore - >, - EthEvmConfig, - EthExecutorProvider, - Arc> - >, - EthereumAddOns - >; - -unsafe impl Sync for TestNodeContext {} +type TestNodeContext = NodeTestContext>, BlockchainProvider>>>, Components>, BlockchainProvider>>>, Pool>>, EthPooledTransaction>>, CoinbaseTipOrdering, DiskFileBlobStore>, EthEvmConfig, EthExecutorProvider, Arc>>, EthereumAddOns>; /// Type alias for a type of NodeHelper pub type NodeHelperType = NodeTestContext, AO>; @@ -488,139 +449,106 @@ where Ok((nodes, tasks, Wallet::default().with_chain_id(chain_spec.chain().into()))) } -struct GGGG { - ctx: ExExContext, -} - -impl GGGG { - async fn new(ctx: ExExContext) -> eyre::Result { - Ok(Self { ctx }) - } - - async fn fuckoff(self) -> eyre::Result<()> { - Ok(()) - } -} - - -static mut MY_STATIC: Lazy> = Lazy::new(|| { - std::sync::Mutex::new(futures::executor::block_on(async_init())) -}); - -async fn async_init() -> TestNodeContext { - let (mut nodes, _tasks, _wallet) = setup::( - 1, - Arc::new( - ChainSpecBuilder::default() - .chain(MAINNET.chain) - .genesis(serde_json::from_str(include_str!("../../../crates/ethereum/node/tests/assets/genesis.json")).unwrap()) - .cancun_activated() - .build(), - ), - false, - ) - .await.unwrap(); - nodes.pop().unwrap() -} - -fn main() {} - -async fn mainn() -> eyre::Result<()> { +fn main() -> eyre::Result<()> { println!("Brecht"); - reth::cli::Cli::parse_args().run(|builder, _| async move { let handle = builder .node(EthereumNode::default()) - .install_exex("Rollup", move |ctx| async move { - // let inner_ex = |usize| async move { eyre::Result::Ok(()) }; - + .install_exex("Rollup", move |ctx| async { + //let connection = Connection::open(DATABASE_PATH)?; + + let network_config = NetworkArgs { + discovery: DiscoveryArgs { disable_discovery: true, ..DiscoveryArgs::default() }, + ..NetworkArgs::default() + }; + + let tasks = TaskManager::current(); + let exec = tasks.executor(); + + // let node_config = NodeConfig::test() + // .with_chain(CHAIN_SPEC.clone()) + // .with_network(network_config.clone()) + // .with_unused_ports() + // .with_rpc(RpcServerArgs::default().with_unused_ports().with_http()) + // .set_dev(true); + + // let node_handle: = NodeBuilder::new(node_config.clone()) + // .testing_node(exec.clone()) + // .node(Default::default()) + // .launch() + // .await?; + + // let mut node = NodeTestContext::new(node_handle.node).await?; + + let (mut nodes, _tasks, _wallet) = setup::( + 1, + Arc::new( + ChainSpecBuilder::default() + .chain(MAINNET.chain) + .genesis(serde_json::from_str(include_str!("../../../crates/ethereum/node/tests/assets/genesis.json")).unwrap()) + .cancun_activated() + .build(), + ), + false, + ) + .await?; + + let node = nodes.pop().unwrap(); - // let g = GGGG::new(ctx).await?; + //Ok((nodes, tasks, Wallet::default().with_chain_id(chain_spec.chain().into()))) + // let wallet = Wallet::default(); + // let raw_tx = TransactionTestContext::transfer_tx_bytes(1, wallet.inner).await; + + // // make the node advance + // let tx_hash = node.rpc.inject_tx(raw_tx).await?; + + // // make the node advance + // let (payload, _): (EthBuiltPayload, _) = node.advance_block(vec![], eth_payload_attributes).await?; + + // let block_hash = payload.block().hash(); + // let block_number = payload.block().number; + + // // assert the block has been committed to the blockchain + // node.assert_new_block(tx_hash, block_hash, block_number).await?; + - // let (mut nodes, _tasks, _wallet) = setup::( - // 1, - // Arc::new( - // ChainSpecBuilder::default() - // .chain(MAINNET.chain) - // .genesis(serde_json::from_str(include_str!("../../../crates/ethereum/node/tests/assets/genesis.json")).unwrap()) - // .cancun_activated() - // .build(), - // ), - // false, + // let wallet = Wallet::default(); + // let raw_tx = TransactionTestContext::transfer_tx_bytes(1, wallet.inner).await; + + // // make the node advance + // let tx_hash = node.rpc.inject_tx(raw_tx).await?; + + // // make the node advance + // let (payload, _) = node.advance_block(vec![], eth_payload_attributes).await?; + + // let block_hash = payload.block().hash(); + // let block_number = payload.block().number; + + // // assert the block has been committed to the blockchain + // node.assert_new_block(tx_hash, block_hash, block_number).await?; + + // // setup payload for submission + // let envelope_v3: ::ExecutionPayloadV3 = payload.into(); + + // // submit payload to engine api + // let submission = EngineApiClient::::new_payload_v3( + // &self.engine_api_client, + // envelope_v3.execution_payload(), + // versioned_hashes, + // payload_builder_attributes.parent_beacon_block_root().unwrap(), // ) - // .await.unwrap(); - // let node = nodes.pop().unwrap(); + // .await?; - // let g = GGGG::new(ctx).await?; - // g.fuckoff().await?; - - // Rollup::new(ctx/* , node */) - // .unwrap() - // .start().await; + //let f: Pin> + Send>> = + // Box::pin(Rollup::new(ctx, connection, node)?.start()); + //f - Ok(Rollup::new(ctx)?.start()) - // Ok(inner_ex(5)) + Ok(Rollup::new(ctx, node)?.start()) }) .launch() .await?; - handle.wait_for_node_exit().await }) } - -type CTXXX = ExExContext, BlockchainProvider>>, Components, BlockchainProvider>>, Pool>, EthPooledTransaction>>, CoinbaseTipOrdering, DiskFileBlobStore>, EthEvmConfig, EthExecutorProvider, Arc>>>; - -pub fn barrrrr( exex_id: impl Into, exex: F) -where - F: FnOnce(ExExContext, CB::Components>>) -> R - + Send - + 'static, - - DB: reth_db_api::Database + DatabaseMetrics + reth_db::database_metrics::DatabaseMetadata + Clone + Unpin + 'static, - T: NodeTypes, - CB: NodeComponentsBuilder>, - - R: Future> + Send, - E: Future> + Send, -{ -} - -pub fn barrrr( exex_id: impl Into, exex: F) -where - F: FnOnce(usize) -> R - + Send - + 'static, - R: Future> + Send, - E: Future> + Send, -{ -} - -fn test() { - // let inner = |usize| async move { eyre::Result::Ok(()) }; - - barrrr("test", |ctx| async move { - let inner_ex = |usize| async move { eyre::Result::Ok(()) }; - let (mut nodes, _tasks, _wallet) = setup::( - 1, - Arc::new( - ChainSpecBuilder::default() - .chain(MAINNET.chain) - .genesis(serde_json::from_str(include_str!("../../../crates/ethereum/node/tests/assets/genesis.json")).unwrap()) - .cancun_activated() - .build(), - ), - false, - ) - .await?; - - let node = nodes.pop().unwrap(); - // Rollup::new(ctx, node) - // .unwrap() - // .start() - // .await; - - // Ok(Rollup::new(ctx, node)?.start()) - Ok(inner_ex(5))}); -} \ No newline at end of file diff --git a/bin/reth/src/node.rs b/bin/reth/src/node.rs index 130573bf7895..1017c5ffb186 100644 --- a/bin/reth/src/node.rs +++ b/bin/reth/src/node.rs @@ -214,7 +214,6 @@ where Ok(()) } - /// Asserts that a new block has been added to the blockchain /// and the tx has been included in the block. /// @@ -227,24 +226,24 @@ where ) -> eyre::Result<()> { // get head block from notifications stream and verify the tx has been pushed to the // pool is actually present in the canonical block - // let head = self.engine_api.canonical_stream.next().await.unwrap(); - // let tx = head.tip().transactions().next(); - // assert_eq!(tx.unwrap().hash().as_slice(), tip_tx_hash.as_slice()); - - // loop { - // // wait for the block to commit - // tokio::time::sleep(std::time::Duration::from_millis(20)).await; - // if let Some(latest_block) = - // self.inner.provider.block_by_number_or_tag(BlockNumberOrTag::Latest)? - // { - // if latest_block.number == block_number { - // // make sure the block hash we submitted via FCU engine api is the new latest - // // block using an RPC call - // assert_eq!(latest_block.hash_slow(), block_hash); - // break - // } - // } - // } + let head = self.engine_api.canonical_stream.next().await.unwrap(); + let tx = head.tip().transactions().next(); + assert_eq!(tx.unwrap().hash().as_slice(), tip_tx_hash.as_slice()); + + loop { + // wait for the block to commit + tokio::time::sleep(std::time::Duration::from_millis(20)).await; + if let Some(latest_block) = + self.inner.provider.block_by_number_or_tag(BlockNumberOrTag::Latest)? + { + if latest_block.number == block_number { + // make sure the block hash we submitted via FCU engine api is the new latest + // block using an RPC call + assert_eq!(latest_block.hash_slow(), block_hash); + break + } + } + } Ok(()) } } diff --git a/crates/payload/builder/src/service.rs b/crates/payload/builder/src/service.rs index 02be97938905..8946cd587506 100644 --- a/crates/payload/builder/src/service.rs +++ b/crates/payload/builder/src/service.rs @@ -100,8 +100,6 @@ pub struct PayloadBuilderHandle { to_service: mpsc::UnboundedSender>, } -unsafe impl Sync for PayloadBuilderHandle where Engine: PayloadTypes {} - // === impl PayloadBuilderHandle === impl PayloadBuilderHandle diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 65e69d314ff6..f646449209c5 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -487,8 +487,6 @@ pub struct SealedBlockWithSenders { pub senders: Vec
, } -unsafe impl Sync for SealedBlockWithSenders {} - impl SealedBlockWithSenders { /// New sealed block with sender. Return none if len of tx and senders does not match pub fn new(block: SealedBlock, senders: Vec
) -> Option {