Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into alexey/exex-wal-canon…
Browse files Browse the repository at this point in the history
…icalize
  • Loading branch information
shekhirin committed Sep 26, 2024
2 parents f108940 + 65f2664 commit 2ad2405
Show file tree
Hide file tree
Showing 141 changed files with 675 additions and 870 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2024-09-25
components: clippy
- uses: Swatinem/rust-cache@v2
with:
Expand Down
17 changes: 14 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ reth-prune.workspace = true
alloy-rlp.workspace = true
alloy-rpc-types = { workspace = true, features = ["engine"] }
alloy-consensus.workspace = true
alloy-primitives.workspace = true

# tracing
tracing.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Command for debugging block building.
use alloy_consensus::TxEip4844;
use alloy_primitives::Address;
use alloy_rlp::Decodable;
use alloy_rpc_types::engine::{BlobsBundleV1, PayloadAttributes};
use clap::Parser;
Expand All @@ -24,7 +25,7 @@ use reth_node_api::{NodeTypesWithDB, NodeTypesWithEngine, PayloadBuilderAttribut
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider};
use reth_payload_builder::database::CachedReads;
use reth_primitives::{
revm_primitives::KzgSettings, Address, BlobTransaction, BlobTransactionSidecar, Bytes,
revm_primitives::KzgSettings, BlobTransaction, BlobTransactionSidecar, Bytes,
PooledTransactionsElement, SealedBlock, SealedBlockWithSenders, Transaction, TransactionSigned,
B256, U256,
};
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Command for debugging execution.

use crate::{args::NetworkArgs, utils::get_single_header};
use alloy_primitives::BlockNumber;
use clap::Parser;
use futures::{stream::select as stream_select, StreamExt};
use reth_beacon_consensus::EthBeaconConsensus;
Expand All @@ -22,7 +23,7 @@ use reth_network_api::NetworkInfo;
use reth_network_p2p::{headers::client::HeadersClient, BlockClient};
use reth_node_api::{NodeTypesWithDB, NodeTypesWithDBAdapter, NodeTypesWithEngine};
use reth_node_ethereum::EthExecutorProvider;
use reth_primitives::{BlockHashOrNumber, BlockNumber, B256};
use reth_primitives::{BlockHashOrNumber, B256};
use reth_provider::{
BlockExecutionWriter, ChainSpecProvider, ProviderFactory, StageCheckpointReader,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/blockchain-tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ reth-execution-types.workspace = true
reth-stages-api.workspace = true
reth-trie = { workspace = true, features = ["metrics"] }
reth-trie-db = { workspace = true, features = ["metrics"] }
reth-trie-parallel = { workspace = true, features = ["parallel"] }
reth-trie-parallel.workspace = true
reth-network.workspace = true
reth-consensus.workspace = true
reth-node-types.workspace = true
Expand Down
40 changes: 20 additions & 20 deletions crates/blockchain-tree/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@ use reth_metrics::{
};
use std::time::{Duration, Instant};

/// Metrics for the entire blockchain tree
#[derive(Metrics)]
#[metrics(scope = "blockchain_tree")]
pub struct TreeMetrics {
/// Total number of sidechains (not including the canonical chain)
pub sidechains: Gauge,
/// The highest block number in the canonical chain
pub canonical_chain_height: Gauge,
/// The number of reorgs
pub reorgs: Counter,
/// The latest reorg depth
pub latest_reorg_depth: Gauge,
/// Longest sidechain height
pub longest_sidechain_height: Gauge,
/// The number of times cached trie updates were used for insert.
pub trie_updates_insert_cached: Counter,
/// The number of times trie updates were recomputed for insert.
pub trie_updates_insert_recomputed: Counter,
}

/// Metrics for the blockchain tree block buffer
#[derive(Metrics)]
#[metrics(scope = "blockchain_tree.block_buffer")]
Expand Down Expand Up @@ -65,6 +45,26 @@ impl MakeCanonicalDurationsRecorder {
}
}

/// Metrics for the entire blockchain tree
#[derive(Metrics)]
#[metrics(scope = "blockchain_tree")]
pub struct TreeMetrics {
/// Total number of sidechains (not including the canonical chain)
pub sidechains: Gauge,
/// The highest block number in the canonical chain
pub canonical_chain_height: Gauge,
/// The number of reorgs
pub reorgs: Counter,
/// The latest reorg depth
pub latest_reorg_depth: Gauge,
/// Longest sidechain height
pub longest_sidechain_height: Gauge,
/// The number of times cached trie updates were used for insert.
pub trie_updates_insert_cached: Counter,
/// The number of times trie updates were recomputed for insert.
pub trie_updates_insert_recomputed: Counter,
}

/// Represents actions for making a canonical chain.
#[derive(Debug, Copy, Clone)]
pub(crate) enum MakeCanonicalAction {
Expand Down
2 changes: 1 addition & 1 deletion crates/chainspec/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use reth_primitives_traits::Header;

/// Trait representing type configuring a chain spec.
#[auto_impl::auto_impl(&, Arc)]
pub trait EthChainSpec: Send + Sync + Unpin + Debug + 'static {
pub trait EthChainSpec: Send + Sync + Unpin + Debug {
// todo: make chain spec type generic over hardfork
//type Hardfork: Clone + Copy + 'static;

Expand Down
19 changes: 14 additions & 5 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,7 @@ impl ChainSpec {

/// Returns the hardfork display helper.
pub fn display_hardforks(&self) -> DisplayHardforks {
DisplayHardforks::new(
&self.hardforks,
self.paris_block_and_final_difficulty.map(|(block, _)| block),
)
DisplayHardforks::new(&self, self.paris_block_and_final_difficulty.map(|(block, _)| block))
}

/// Get the fork id for the given hardfork.
Expand Down Expand Up @@ -613,6 +610,18 @@ impl Hardforks for ChainSpec {
fn forks_iter(&self) -> impl Iterator<Item = (&dyn Hardfork, ForkCondition)> {
self.hardforks.forks_iter()
}

fn fork_id(&self, head: &Head) -> ForkId {
self.fork_id(head)
}

fn latest_fork_id(&self) -> ForkId {
self.latest_fork_id()
}

fn fork_filter(&self, head: Head) -> ForkFilter {
self.fork_filter(head)
}
}

impl EthereumHardforks for ChainSpec {
Expand Down Expand Up @@ -820,7 +829,7 @@ fn into_optimism_chain_spec(genesis: Genesis) -> ChainSpec {
#[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync {
/// The chain spec type.
type ChainSpec: EthChainSpec;
type ChainSpec: EthChainSpec + 'static;

/// Get an [`Arc`] to the [`ChainSpec`].
fn chain_spec(&self) -> Arc<Self::ChainSpec>;
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/commands/src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
let net = NetworkConfigBuilder::new(p2p_secret_key)
.peer_config(config.peers_config_with_basic_nodes_from_file(None))
.external_ip_resolver(self.network.nat)
.chain_spec(self.chain.clone())
.disable_discv4_discovery_if(self.chain.chain.is_optimism())
.boot_nodes(boot_nodes.clone())
.apply(|builder| {
self.network.discovery.apply_to_builder(builder, rlpx_socket, boot_nodes)
})
.build_with_noop_provider()
.build_with_noop_provider(self.chain)
.manager()
.await?;
let network = net.handle().clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ eyre.workspace = true
[dev-dependencies]
tempfile.workspace = true
reth-network-peers.workspace = true
reth-primitives.workspace = true
alloy-primitives.workspace = true
2 changes: 1 addition & 1 deletion crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ where
mod tests {
use super::{Config, EXTENSION};
use crate::PruneConfig;
use alloy_primitives::Address;
use reth_network_peers::TrustedPeer;
use reth_primitives::Address;
use reth_prune_types::{PruneMode, PruneModes, ReceiptsLogPruneConfig};
use std::{collections::BTreeMap, path::Path, str::FromStr, time::Duration};

Expand Down
5 changes: 4 additions & 1 deletion crates/consensus/auto-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ alloy-primitives.workspace = true
revm-primitives.workspace = true
alloy-rpc-types-engine.workspace = true

# optimism
reth-optimism-consensus = { workspace = true, optional = true }

# async
futures-util.workspace = true
tokio = { workspace = true, features = ["sync", "time"] }
tokio-stream.workspace = true
tracing.workspace = true

[features]
optimism = ["reth-provider/optimism"]
optimism = ["reth-provider/optimism", "reth-optimism-consensus"]
8 changes: 7 additions & 1 deletion crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,13 @@ impl StorageInner {
header.receipts_root = {
#[cfg(feature = "optimism")]
let receipts_root = execution_outcome
.optimism_receipts_root_slow(header.number, &chain_spec, header.timestamp)
.generic_receipts_root_slow(header.number, |receipts| {
reth_optimism_consensus::calculate_receipt_root_no_memo_optimism(
receipts,
&chain_spec,
header.timestamp,
)
})
.expect("Receipts is present");

#[cfg(not(feature = "optimism"))]
Expand Down
3 changes: 1 addition & 2 deletions crates/consensus/auto-seal/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use reth_beacon_consensus::{BeaconEngineMessage, ForkchoiceStatus};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_engine_primitives::EngineTypes;
use reth_evm::execute::BlockExecutorProvider;
use reth_primitives::IntoRecoveredTransaction;
use reth_provider::{CanonChainTracker, StateProviderFactory};
use reth_stages_api::PipelineEvent;
use reth_tokio_util::EventStream;
Expand Down Expand Up @@ -87,7 +86,7 @@ where
Pool: TransactionPool + Unpin + 'static,
Engine: EngineTypes,
Executor: BlockExecutorProvider,
ChainSpec: EthChainSpec + EthereumHardforks,
ChainSpec: EthChainSpec + EthereumHardforks + 'static,
{
type Output = ();

Expand Down
3 changes: 3 additions & 0 deletions crates/engine/tree/src/tree/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use reth_blockchain_tree::metrics::TreeMetrics;
use reth_evm::metrics::ExecutorMetrics;
use reth_metrics::{
metrics::{Counter, Gauge, Histogram},
Expand All @@ -13,6 +14,8 @@ pub(crate) struct EngineApiMetrics {
pub(crate) executor: ExecutorMetrics,
/// Metrics for block validation
pub(crate) block_validation: BlockValidationMetrics,
/// A copy of legacy blockchain tree metrics, to be replaced when we replace the old tree
pub(crate) tree: TreeMetrics,
}

/// Metrics for the `EngineApi`.
Expand Down
Loading

0 comments on commit 2ad2405

Please sign in to comment.