Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
65e56b4
feat: BlockchainTree, pending and sidechain blocks
rakita Mar 2, 2023
0c84127
Update pipeline sync status, upate plain state on revert, tie reorg fn
rakita Mar 2, 2023
e1ebfe3
Refactor History/Hashing unwind stages.
rakita Mar 2, 2023
9b1d6c1
Merge remote-tracking branch 'origin/main' into o/r/blockchain_tree
rakita Mar 2, 2023
601849d
tests and debug
rakita Mar 4, 2023
1f981c6
Merge remote-tracking branch 'origin/main' into o/r/blockchain_tree
rakita Mar 4, 2023
79c3e03
nits
rakita Mar 4, 2023
3e536bb
add tests for insert get_take fn
rakita Mar 6, 2023
33879bc
bug: Remove old account/storage root in merkle trie
rakita Mar 6, 2023
55d71ed
Merge remote-tracking branch 'origin/main' into o/r/blockchain_tree
rakita Mar 6, 2023
423e75f
Return new_root
rakita Mar 6, 2023
f09b652
Merge remote-tracking branch 'origin/rakita/remove_old_merkle_root' i…
rakita Mar 6, 2023
b67f625
Remove storage empty root from db
rakita Mar 6, 2023
473d970
Merge remote-tracking branch 'origin/rakita/remove_old_merkle_root' i…
rakita Mar 6, 2023
a80e173
pending merge
rakita Mar 6, 2023
c54aeab
Remove storage empty root from db
rakita Mar 6, 2023
d2e4b1d
Merge remote-tracking branch 'origin/rakita/remove_old_merkle_root' i…
rakita Mar 6, 2023
94934e6
missing letter
rakita Mar 6, 2023
fd1b2c8
Merge remote-tracking branch 'origin/rakita/remove_old_merkle_root' i…
rakita Mar 6, 2023
7f3ff45
Test for inserting and taking blocks
rakita Mar 7, 2023
034ee90
Merge remote-tracking branch 'origin/main' into o/r/blockchain_tree
rakita Mar 7, 2023
89f91b5
Merge remote-tracking branch 'origin/main' into o/r/blockchain_tree
rakita Mar 8, 2023
1e06366
refactor in executor factory
rakita Mar 8, 2023
04c8f71
Added tree tests
rakita Mar 9, 2023
0657528
clippy fmt
rakita Mar 9, 2023
e09e6cd
Added rest of tests
Mar 10, 2023
3eb05ff
update state root for tests
rakita Mar 10, 2023
a4a1077
Introudce Arc<ChainSpec>, rm pub from Tree internals
rakita Mar 10, 2023
062cbf8
nit and PR comments, first part
rakita Mar 10, 2023
06d6d5c
nits and bits, part2
rakita Mar 11, 2023
2db7a91
nits and bits p3
rakita Mar 13, 2023
33cad82
Merge remote-tracking branch 'origin/main' into r/blockchain_tree
rakita Mar 13, 2023
5d0b7d4
get take and test data refactor
rakita Mar 13, 2023
7d18b4a
Merge remote-tracking branch 'origin/main' into r/blockchain_tree
rakita Mar 14, 2023
f594321
fmt, nits.
rakita Mar 14, 2023
d23ee32
TreeTester and some cleanup
rakita Mar 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions bin/reth/src/args/network_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reth_net_nat::NatResolver;
use reth_network::NetworkConfigBuilder;
use reth_primitives::{ChainSpec, NodeRecord};
use reth_staged_sync::Config;
use std::path::PathBuf;
use std::{path::PathBuf, sync::Arc};

/// Parameters for configuring the network more granularity via CLI
#[derive(Debug, Args)]
Expand Down Expand Up @@ -50,7 +50,11 @@ pub struct NetworkArgs {
impl NetworkArgs {
/// Build a [`NetworkConfigBuilder`] from a [`Config`] and a [`ChainSpec`], in addition to the
/// values in this option struct.
pub fn network_config(&self, config: &Config, chain_spec: ChainSpec) -> NetworkConfigBuilder {
pub fn network_config(
&self,
config: &Config,
chain_spec: Arc<ChainSpec>,
) -> NetworkConfigBuilder {
let peers_file = (!self.no_persist_peers).then_some(&self.peers_file);
let network_config_builder = config
.network_config(self.nat, peers_file.map(|f| f.as_ref().to_path_buf()))
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/chain/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct ImportCommand {
default_value = "mainnet",
value_parser = genesis_value_parser
)]
chain: ChainSpec,
chain: Arc<ChainSpec>,

/// The path to a block file for import.
///
Expand Down Expand Up @@ -140,7 +140,7 @@ impl ImportCommand {
.build(file_client.clone(), consensus.clone(), db)
.into_task();

let factory = reth_executor::Factory::new(Arc::new(self.chain.clone()));
let factory = reth_executor::Factory::new(self.chain.clone());

let mut pipeline = Pipeline::builder()
.with_sync_state_updater(file_client)
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/chain/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct InitCommand {
default_value = "mainnet",
value_parser = genesis_value_parser
)]
chain: ChainSpec,
chain: Arc<ChainSpec>,
}

impl InitCommand {
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ impl<'a, DB: Database> DbTool<'a, DB> {
let chain = random_block_range(0..len, Default::default(), 0..64);

self.db.update(|tx| {
chain.iter().try_for_each(|block| {
insert_canonical_block(tx, block, true)?;
chain.into_iter().try_for_each(|block| {
insert_canonical_block(tx, block, None, true)?;
Ok::<_, eyre::Error>(())
})
})??;
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct Command {
default_value = "mainnet",
value_parser = genesis_value_parser
)]
chain: ChainSpec,
chain: Arc<ChainSpec>,

/// Enable Prometheus metrics.
///
Expand Down Expand Up @@ -443,7 +443,7 @@ impl Command {
builder = builder.with_max_block(max_block)
}

let factory = reth_executor::Factory::new(Arc::new(self.chain.clone()));
let factory = reth_executor::Factory::new(self.chain.clone());
let pipeline = builder
.with_sync_state_updater(updater.clone())
.add_stages(
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Command {
default_value = "mainnet",
value_parser = chain_spec_value_parser
)]
chain: ChainSpec,
chain: Arc<ChainSpec>,

/// Disable the discovery service.
#[command(flatten)]
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/stage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Command {
default_value = "mainnet",
value_parser = chain_spec_value_parser
)]
chain: ChainSpec,
chain: Arc<ChainSpec>,

/// Enable Prometheus metrics.
///
Expand Down Expand Up @@ -171,7 +171,7 @@ impl Command {
stage.execute(&mut tx, input).await?;
}
StageEnum::Execution => {
let factory = reth_executor::Factory::new(Arc::new(self.chain.clone()));
let factory = reth_executor::Factory::new(self.chain.clone());
let mut stage = ExecutionStage::new(factory, 10_000);
stage.commit_threshold = num_blocks;
if !self.skip_unwind {
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/test_eth_chain/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<TestOutcome> {
// insert genesis
let header: SealedHeader = suite.genesis_block_header.into();
let genesis_block = SealedBlock { header, body: vec![], ommers: vec![], withdrawals: None };
reth_provider::insert_canonical_block(&tx, &genesis_block, has_block_reward)?;
reth_provider::insert_canonical_block(&tx, genesis_block, None, has_block_reward)?;

let mut last_block = None;
suite.blocks.iter().try_for_each(|block| -> eyre::Result<()> {
let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?;
reth_provider::insert_canonical_block(&tx, &decoded, has_block_reward)?;
last_block = Some(decoded.number);
reth_provider::insert_canonical_block(&tx, decoded, None, has_block_reward)?;
Ok(())
})?;

Expand Down
12 changes: 7 additions & 5 deletions crates/consensus/src/beacon/beacon_consensus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Consensus for ethereum network
use std::sync::Arc;

use crate::validation;
use reth_interfaces::consensus::{Consensus, ConsensusError, ForkchoiceState};
use reth_primitives::{ChainSpec, Hardfork, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT, U256};
Expand All @@ -15,13 +17,13 @@ pub struct BeaconConsensus {
/// Watcher over the forkchoice state
forkchoice_state_rx: watch::Receiver<ForkchoiceState>,
/// Configuration
chain_spec: ChainSpec,
chain_spec: Arc<ChainSpec>,
}

impl BeaconConsensus {
/// Create a new instance of [BeaconConsensus]
pub fn new(
chain_spec: ChainSpec,
chain_spec: Arc<ChainSpec>,
forkchoice_state_rx: watch::Receiver<ForkchoiceState>,
) -> Self {
Self { chain_spec, forkchoice_state_rx }
Expand Down Expand Up @@ -92,14 +94,14 @@ impl Consensus for BeaconConsensus {

#[cfg(test)]
mod test {
use super::BeaconConsensus;
use reth_interfaces::consensus::Consensus;
use reth_primitives::{ChainSpecBuilder, U256};

use super::BeaconConsensus;
use std::sync::Arc;

#[test]
fn test_has_block_reward_before_paris() {
let chain_spec = ChainSpecBuilder::mainnet().build();
let chain_spec = Arc::new(ChainSpecBuilder::mainnet().build());
let (consensus, _) = BeaconConsensus::builder().build(chain_spec);
assert!(consensus.has_block_reward(U256::ZERO, U256::ZERO));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/beacon/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl BeaconConsensusBuilder {
/// [watch::channel] for updating the forkchoice state.
pub fn build(
self,
chain_spec: ChainSpec,
chain_spec: Arc<ChainSpec>,
) -> (Arc<BeaconConsensus>, watch::Sender<ForkchoiceState>) {
let (forkchoice_state_tx, forkchoice_state_rx) = watch::channel(ForkchoiceState::default());
let inner = Arc::new(BeaconConsensus::new(chain_spec, forkchoice_state_rx));
Expand Down
15 changes: 14 additions & 1 deletion crates/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/paradigmxyz/reth"
readme = "README.md"

[package.metadata.cargo-udeps.ignore]
normal = [
# Used for diagrams in docs
"aquamarine",
]

[dependencies]
# reth
reth-primitives = { path = "../primitives" }
Expand All @@ -17,7 +23,7 @@ reth-db = { path = "../storage/db" }
reth-provider = { path = "../storage/provider" }

# revm
revm = { version = "3.0.0"}
revm = { version = "3.0.0" }

# common
async-trait = "0.1.57"
Expand All @@ -26,6 +32,9 @@ auto_impl = "1.0"
tracing = "0.1.37"
tokio = { version = "1.21.2", features = ["sync"] }

# mics
aquamarine = "0.2.1" #docs

triehash = "0.8"
# See to replace hashers to simplify libraries
plain_hasher = "0.2"
Expand All @@ -38,3 +47,7 @@ sha3 = { version = "0.10", default-features = false }

[dev-dependencies]
reth-db = { path = "../storage/db", features = ["test-utils"] }
reth-interfaces = { path = "../interfaces", features = ["test-utils"] }
reth-primitives = { path = "../primitives", features = ["test-utils"] }
reth-provider = { path = "../storage/provider", features = ["test-utils"] }
parking_lot = "0.12"
Loading