From db1e6cbeea9539ed4ea557ebccaf1cbccaa7adfc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 17 Apr 2023 16:32:18 +0200 Subject: [PATCH] chore: rename executor -> blockchain-tree (#2285) --- Cargo.lock | 56 ++++++++----------- Cargo.toml | 2 +- bin/reth/Cargo.toml | 2 +- bin/reth/src/node/mod.rs | 6 +- .../{executor => blockchain-tree}/Cargo.toml | 17 +----- .../src/blockchain_tree/block_indices.rs | 0 .../src/blockchain_tree/chain.rs | 0 .../src/blockchain_tree/config.rs | 0 .../src/blockchain_tree/externals.rs | 0 .../src/blockchain_tree/mod.rs | 0 .../src/blockchain_tree/post_state_data.rs | 0 .../src/blockchain_tree/shareable.rs | 0 .../src/eth_dao_fork.rs | 0 .../{executor => blockchain-tree}/src/lib.rs | 1 + .../src/test_utils/executor.rs | 0 .../src/test_utils/factory.rs | 0 .../src/test_utils/mod.rs | 0 crates/consensus/beacon/Cargo.toml | 2 +- crates/consensus/beacon/src/engine/mod.rs | 4 +- crates/revm/Cargo.toml | 2 +- crates/revm/src/executor.rs | 16 +++--- crates/stages/Cargo.toml | 2 +- docs/crates/stages.md | 2 +- docs/repo/layout.md | 2 +- 24 files changed, 46 insertions(+), 68 deletions(-) rename crates/{executor => blockchain-tree}/Cargo.toml (66%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/block_indices.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/chain.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/config.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/externals.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/mod.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/post_state_data.rs (100%) rename crates/{executor => blockchain-tree}/src/blockchain_tree/shareable.rs (100%) rename crates/{executor => blockchain-tree}/src/eth_dao_fork.rs (100%) rename crates/{executor => blockchain-tree}/src/lib.rs (94%) rename crates/{executor => blockchain-tree}/src/test_utils/executor.rs (100%) rename crates/{executor => blockchain-tree}/src/test_utils/factory.rs (100%) rename crates/{executor => blockchain-tree}/src/test_utils/mod.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8591457c0..66852cae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4468,10 +4468,10 @@ dependencies = [ "reth-auto-seal-consensus", "reth-basic-payload-builder", "reth-beacon-consensus", + "reth-blockchain-tree", "reth-db", "reth-discv4", "reth-downloaders", - "reth-executor", "reth-interfaces", "reth-net-nat", "reth-network", @@ -4544,9 +4544,9 @@ dependencies = [ "assert_matches", "futures", "metrics", + "reth-blockchain-tree", "reth-consensus-common", "reth-db", - "reth-executor", "reth-interfaces", "reth-metrics-derive", "reth-payload-builder", @@ -4562,6 +4562,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "reth-blockchain-tree" +version = "0.1.0" +dependencies = [ + "aquamarine", + "assert_matches", + "parking_lot 0.12.1", + "reth-db", + "reth-interfaces", + "reth-primitives", + "reth-provider", + "tokio", +] + [[package]] name = "reth-codecs" version = "0.1.0" @@ -4762,29 +4776,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "reth-executor" -version = "0.1.0" -dependencies = [ - "aquamarine", - "assert_matches", - "auto_impl", - "hash-db", - "parking_lot 0.12.1", - "plain_hasher", - "reth-db", - "reth-interfaces", - "reth-primitives", - "reth-provider", - "reth-rlp", - "rlp", - "sha3", - "thiserror", - "tokio", - "tracing", - "triehash", -] - [[package]] name = "reth-interfaces" version = "0.1.0" @@ -5053,8 +5044,8 @@ dependencies = [ name = "reth-revm" version = "0.1.0" dependencies = [ + "reth-blockchain-tree", "reth-consensus-common", - "reth-executor", "reth-interfaces", "reth-primitives", "reth-provider", @@ -5282,11 +5273,11 @@ dependencies = [ "pprof", "rand 0.8.5", "rayon", + "reth-blockchain-tree", "reth-codecs", "reth-db", "reth-downloaders", "reth-eth-wire", - "reth-executor", "reth-interfaces", "reth-metrics-derive", "reth-primitives", @@ -6548,14 +6539,13 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot 0.12.1", @@ -6568,13 +6558,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 53d83439b..54aca15ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "crates/consensus/auto-seal", "crates/consensus/beacon", "crates/consensus/common", - "crates/executor", + "crates/blockchain-tree", "crates/interfaces", "crates/payload/builder", "crates/metrics/metrics-derive", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 9e6ff2977..3dd31b5cd 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -20,7 +20,7 @@ reth-interfaces = { path = "../../crates/interfaces", features = ["test-utils"] reth-transaction-pool = { path = "../../crates/transaction-pool" } reth-beacon-consensus = { path = "../../crates/consensus/beacon" } reth-auto-seal-consensus = { path = "../../crates/consensus/auto-seal" } -reth-executor = { path = "../../crates/executor" } +reth-blockchain-tree = { path = "../../crates/blockchain-tree" } reth-rpc-engine-api = { path = "../../crates/rpc/rpc-engine-api" } reth-rpc-builder = { path = "../../crates/rpc/rpc-builder" } reth-rpc = { path = "../../crates/rpc/rpc" } diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index 57e43d5de..c12dd8ea5 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -15,6 +15,9 @@ use futures::{pin_mut, stream::select as stream_select, StreamExt}; use reth_auto_seal_consensus::{AutoSealBuilder, AutoSealConsensus}; use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; use reth_beacon_consensus::{BeaconConsensus, BeaconConsensusEngine, BeaconEngineMessage}; +use reth_blockchain_tree::{ + config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree, +}; use reth_db::{ database::Database, mdbx::{Env, WriteMap}, @@ -26,9 +29,6 @@ use reth_downloaders::{ bodies::bodies::BodiesDownloaderBuilder, headers::reverse_headers::ReverseHeadersDownloaderBuilder, }; -use reth_executor::blockchain_tree::{ - config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree, -}; use reth_interfaces::{ consensus::{Consensus, ForkchoiceState}, p2p::{ diff --git a/crates/executor/Cargo.toml b/crates/blockchain-tree/Cargo.toml similarity index 66% rename from crates/executor/Cargo.toml rename to crates/blockchain-tree/Cargo.toml index 8a15ccd99..dd6790dd5 100644 --- a/crates/executor/Cargo.toml +++ b/crates/blockchain-tree/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "reth-executor" +name = "reth-blockchain-tree" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0" @@ -16,29 +16,15 @@ normal = [ # reth reth-primitives = { path = "../primitives" } reth-interfaces = { path = "../interfaces" } -reth-rlp = { path = "../rlp" } reth-db = { path = "../storage/db" } reth-provider = { path = "../storage/provider" } # common -thiserror = "1.0.37" -auto_impl = "1.0" -tracing = "0.1.37" -tokio = { version = "1.21.2", features = ["sync"] } parking_lot = { version = "0.12"} # mics aquamarine = "0.3.0" -triehash = "0.8" -# See to replace hashers to simplify libraries -plain_hasher = "0.2" -hash-db = "0.15" -# todo replace with faster rlp impl -rlp = { version = "0.5", default-features = false } -# replace with tiny-keccak (it is faster hasher) -sha3 = { version = "0.10", default-features = false } - [dev-dependencies] reth-db = { path = "../storage/db", features = ["test-utils"] } @@ -47,6 +33,7 @@ reth-primitives = { path = "../primitives", features = ["test-utils"] } reth-provider = { path = "../storage/provider", features = ["test-utils"] } parking_lot = "0.12" assert_matches = "1.5" +tokio = { version = "1", features = ["macros", "sync"] } [features] test-utils = [] diff --git a/crates/executor/src/blockchain_tree/block_indices.rs b/crates/blockchain-tree/src/blockchain_tree/block_indices.rs similarity index 100% rename from crates/executor/src/blockchain_tree/block_indices.rs rename to crates/blockchain-tree/src/blockchain_tree/block_indices.rs diff --git a/crates/executor/src/blockchain_tree/chain.rs b/crates/blockchain-tree/src/blockchain_tree/chain.rs similarity index 100% rename from crates/executor/src/blockchain_tree/chain.rs rename to crates/blockchain-tree/src/blockchain_tree/chain.rs diff --git a/crates/executor/src/blockchain_tree/config.rs b/crates/blockchain-tree/src/blockchain_tree/config.rs similarity index 100% rename from crates/executor/src/blockchain_tree/config.rs rename to crates/blockchain-tree/src/blockchain_tree/config.rs diff --git a/crates/executor/src/blockchain_tree/externals.rs b/crates/blockchain-tree/src/blockchain_tree/externals.rs similarity index 100% rename from crates/executor/src/blockchain_tree/externals.rs rename to crates/blockchain-tree/src/blockchain_tree/externals.rs diff --git a/crates/executor/src/blockchain_tree/mod.rs b/crates/blockchain-tree/src/blockchain_tree/mod.rs similarity index 100% rename from crates/executor/src/blockchain_tree/mod.rs rename to crates/blockchain-tree/src/blockchain_tree/mod.rs diff --git a/crates/executor/src/blockchain_tree/post_state_data.rs b/crates/blockchain-tree/src/blockchain_tree/post_state_data.rs similarity index 100% rename from crates/executor/src/blockchain_tree/post_state_data.rs rename to crates/blockchain-tree/src/blockchain_tree/post_state_data.rs diff --git a/crates/executor/src/blockchain_tree/shareable.rs b/crates/blockchain-tree/src/blockchain_tree/shareable.rs similarity index 100% rename from crates/executor/src/blockchain_tree/shareable.rs rename to crates/blockchain-tree/src/blockchain_tree/shareable.rs diff --git a/crates/executor/src/eth_dao_fork.rs b/crates/blockchain-tree/src/eth_dao_fork.rs similarity index 100% rename from crates/executor/src/eth_dao_fork.rs rename to crates/blockchain-tree/src/eth_dao_fork.rs diff --git a/crates/executor/src/lib.rs b/crates/blockchain-tree/src/lib.rs similarity index 94% rename from crates/executor/src/lib.rs rename to crates/blockchain-tree/src/lib.rs index 40ba2d8fd..5ba25b8e9 100644 --- a/crates/executor/src/lib.rs +++ b/crates/blockchain-tree/src/lib.rs @@ -13,6 +13,7 @@ pub mod eth_dao_fork; pub use reth_provider::post_state; pub mod blockchain_tree; +pub use blockchain_tree::*; #[cfg(any(test, feature = "test-utils"))] /// Common test helpers for mocking out executor and executor factory diff --git a/crates/executor/src/test_utils/executor.rs b/crates/blockchain-tree/src/test_utils/executor.rs similarity index 100% rename from crates/executor/src/test_utils/executor.rs rename to crates/blockchain-tree/src/test_utils/executor.rs diff --git a/crates/executor/src/test_utils/factory.rs b/crates/blockchain-tree/src/test_utils/factory.rs similarity index 100% rename from crates/executor/src/test_utils/factory.rs rename to crates/blockchain-tree/src/test_utils/factory.rs diff --git a/crates/executor/src/test_utils/mod.rs b/crates/blockchain-tree/src/test_utils/mod.rs similarity index 100% rename from crates/executor/src/test_utils/mod.rs rename to crates/blockchain-tree/src/test_utils/mod.rs diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index be60e932e..2a1fbe42c 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -33,7 +33,7 @@ metrics = "0.20.1" reth-payload-builder = { path = "../../payload/builder", features = ["test-utils"] } reth-interfaces = { path = "../../interfaces", features = ["test-utils"] } reth-stages = { path = "../../stages", features = ["test-utils"] } -reth-executor = { path = "../../executor", features = ["test-utils"] } +reth-blockchain-tree = { path = "../../blockchain-tree", features = ["test-utils"] } reth-db = { path = "../../storage/db", features = ["test-utils"] } reth-provider = { path = "../../storage/provider", features = ["test-utils"] } reth-tracing = { path = "../../tracing" } diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index 92f4ccb92..bba401f8a 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -641,8 +641,7 @@ enum PipelineTarget { mod tests { use super::*; use assert_matches::assert_matches; - use reth_db::mdbx::{test_utils::create_test_rw_db, Env, WriteMap}; - use reth_executor::{ + use reth_blockchain_tree::{ blockchain_tree::{ config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree, @@ -650,6 +649,7 @@ mod tests { post_state::PostState, test_utils::TestExecutorFactory, }; + use reth_db::mdbx::{test_utils::create_test_rw_db, Env, WriteMap}; use reth_interfaces::{sync::NoopSyncStateUpdate, test_utils::TestConsensus}; use reth_payload_builder::test_utils::spawn_test_payload_service; use reth_primitives::{ChainSpec, ChainSpecBuilder, SealedBlockWithSenders, H256, MAINNET}; diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index f34a2ebc8..7c5fb9afe 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -13,7 +13,7 @@ reth-interfaces = { path = "../interfaces" } reth-provider = { path = "../storage/provider" } reth-revm-primitives = { path = "./revm-primitives" } reth-revm-inspectors = { path = "./revm-inspectors" } -reth-executor = { path = "../executor" } +reth-blockchain-tree = { path = "../blockchain-tree" } reth-consensus-common = { path = "../consensus/common" } # revm diff --git a/crates/revm/src/executor.rs b/crates/revm/src/executor.rs index f4ed23b1a..e53986139 100644 --- a/crates/revm/src/executor.rs +++ b/crates/revm/src/executor.rs @@ -5,8 +5,8 @@ use crate::{ stack::{InspectorStack, InspectorStackConfig}, to_reth_acc, }; +use reth_blockchain_tree::post_state::PostState; use reth_consensus_common::calc; -use reth_executor::post_state::PostState; use reth_interfaces::executor::Error; use reth_primitives::{ Account, Address, Block, Bloom, Bytecode, ChainSpec, Hardfork, Header, Receipt, @@ -135,7 +135,7 @@ where let mut drained_balance = U256::ZERO; // drain all accounts ether - for address in reth_executor::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS { + for address in reth_blockchain_tree::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS { let db_account = db.load_account(address).map_err(|_| Error::ProviderError)?; let old = to_reth_acc(&db_account.info); // drain balance @@ -146,7 +146,7 @@ where } // add drained ether to beneficiary. - let beneficiary = reth_executor::eth_dao_fork::DAO_HARDFORK_BENEFICIARY; + let beneficiary = reth_blockchain_tree::eth_dao_fork::DAO_HARDFORK_BENEFICIARY; self.increment_account_balance(beneficiary, drained_balance, post_state)?; Ok(()) @@ -875,7 +875,7 @@ mod tests { let mut beneficiary_balance = 0; for (i, dao_address) in - reth_executor::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter().enumerate() + reth_blockchain_tree::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter().enumerate() { db.insert_account( *dao_address, @@ -913,10 +913,10 @@ mod tests { // beneficiary let db = executor.db(); let dao_beneficiary = - db.accounts.get(&reth_executor::eth_dao_fork::DAO_HARDFORK_BENEFICIARY).unwrap(); + db.accounts.get(&reth_blockchain_tree::eth_dao_fork::DAO_HARDFORK_BENEFICIARY).unwrap(); assert_eq!(dao_beneficiary.info.balance, U256::from(beneficiary_balance)); - for address in reth_executor::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter() { + for address in reth_blockchain_tree::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter() { let account = db.accounts.get(address).unwrap(); assert_eq!(account.info.balance, U256::ZERO); } @@ -924,14 +924,14 @@ mod tests { // check changesets let beneficiary_state = out .accounts() - .get(&reth_executor::eth_dao_fork::DAO_HARDFORK_BENEFICIARY) + .get(&reth_blockchain_tree::eth_dao_fork::DAO_HARDFORK_BENEFICIARY) .unwrap() .unwrap(); assert_eq!( beneficiary_state, Account { balance: U256::from(beneficiary_balance), ..Default::default() }, ); - for address in reth_executor::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter() { + for address in reth_blockchain_tree::eth_dao_fork::DAO_HARDKFORK_ACCOUNTS.iter() { let updated_account = out.accounts().get(address).unwrap().unwrap(); assert_eq!(updated_account, Account { balance: U256::ZERO, ..Default::default() }); } diff --git a/crates/stages/Cargo.toml b/crates/stages/Cargo.toml index 1bbb19ec8..f2337a52b 100644 --- a/crates/stages/Cargo.toml +++ b/crates/stages/Cargo.toml @@ -48,7 +48,7 @@ reth-db = { path = "../storage/db", features = ["test-utils", "mdbx"] } reth-interfaces = { path = "../interfaces", features = ["test-utils"] } reth-downloaders = { path = "../net/downloaders" } reth-eth-wire = { path = "../net/eth-wire" } # TODO(onbjerg): We only need this for [BlockBody] -reth-executor = { path = "../executor" } +reth-blockchain-tree = { path = "../blockchain-tree" } reth-rlp = { path = "../rlp" } reth-revm = { path = "../revm" } reth-trie = { path = "../trie", features = ["test-utils"] } diff --git a/docs/crates/stages.md b/docs/crates/stages.md index 7c4d5ce5e..430579d19 100644 --- a/docs/crates/stages.md +++ b/docs/crates/stages.md @@ -155,7 +155,7 @@ Once the transaction signer has been recovered, the signer is then added to the ## ExecutionStage -Finally, after all headers, bodies and senders are added to the database, the `ExecutionStage` starts to execute. This stage is responsible for executing all of the transactions and updating the state stored in the database. For every new block header added to the database, the corresponding transactions have their signers attached to them and `reth_executor::executor::execute_and_verify_receipt()` is called, pushing the state changes resulting from the execution to a `Vec`. +Finally, after all headers, bodies and senders are added to the database, the `ExecutionStage` starts to execute. This stage is responsible for executing all of the transactions and updating the state stored in the database. For every new block header added to the database, the corresponding transactions have their signers attached to them and `reth_blockchain_tree::executor::execute_and_verify_receipt()` is called, pushing the state changes resulting from the execution to a `Vec`. [File: crates/stages/src/stages/execution.rs](https://github.com/paradigmxyz/reth/blob/main/crates/stages/src/stages/execution.rs) ```rust,ignore diff --git a/docs/repo/layout.md b/docs/repo/layout.md index 6d4f4dd7a..11f8f2435 100644 --- a/docs/repo/layout.md +++ b/docs/repo/layout.md @@ -60,7 +60,7 @@ These crates are related to networking (p2p and RPC), as well as networking prot These crates are Ethereum-specific (e.g. EVM, consensus, transaction pools). -- [`executor`](../../crates/executor): Blazing-fast instrumented EVM using [`revm`](https://github.com/bluealloy/revm/). Used during consensus, syncing & during transaction simulation / gas estimation. +- [`executor`](../../crates/blockchain-tree): Blazing-fast instrumented EVM using [`revm`](https://github.com/bluealloy/revm/). Used during consensus, syncing & during transaction simulation / gas estimation. - [`consensus`](../../crates/consensus): Implementations of consensus protocols. - [`transaction-pool`](../../crates/transaction-pool): An in-memory pending transactions pool.