Skip to content

Commit

Permalink
feat: introduce evm config trait (paradigmxyz#6461)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Cline <[email protected]>
Co-authored-by: Oliver Nordbjerg <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2024
1 parent 0ddb753 commit a7e183d
Show file tree
Hide file tree
Showing 24 changed files with 198 additions and 168 deletions.
99 changes: 51 additions & 48 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ use tracing::{debug, error, info, instrument, trace, warn};
/// * [BlockchainTree::make_canonical]: Check if we have the hash of a block that is the current
/// canonical head and commit it to db.
#[derive(Debug)]
pub struct BlockchainTree<DB: Database, EF: ExecutorFactory> {
pub struct BlockchainTree<DB: Database, EVM: ExecutorFactory> {
/// The state of the tree
///
/// Tracks all the chains, the block indices, and the block buffer.
state: TreeState,
/// External components (the database, consensus engine etc.)
externals: TreeExternals<DB, EF>,
externals: TreeExternals<DB, EVM>,
/// Tree configuration
config: BlockchainTreeConfig,
/// Broadcast channel for canon state changes notifications.
Expand All @@ -76,10 +76,10 @@ pub struct BlockchainTree<DB: Database, EF: ExecutorFactory> {
prune_modes: Option<PruneModes>,
}

impl<DB: Database, EF: ExecutorFactory> BlockchainTree<DB, EF> {
impl<DB: Database, EVM: ExecutorFactory> BlockchainTree<DB, EVM> {
/// Create a new blockchain tree.
pub fn new(
externals: TreeExternals<DB, EF>,
externals: TreeExternals<DB, EVM>,
config: BlockchainTreeConfig,
prune_modes: Option<PruneModes>,
) -> RethResult<Self> {
Expand Down
6 changes: 3 additions & 3 deletions crates/blockchain-tree/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ impl AppendableChain {
/// - [BlockAttachment] represents if the block extends the canonical chain, and thus we can
/// cache the trie state updates.
/// - [BlockValidationKind] determines if the state root __should__ be validated.
fn validate_and_execute<BSDP, DB, EF>(
fn validate_and_execute<BSDP, DB, EVM>(
block: SealedBlockWithSenders,
parent_block: &SealedHeader,
bundle_state_data_provider: BSDP,
externals: &TreeExternals<DB, EF>,
externals: &TreeExternals<DB, EVM>,
block_attachment: BlockAttachment,
block_validation_kind: BlockValidationKind,
) -> RethResult<(BundleStateWithReceipts, Option<TrieUpdates>)>
where
BSDP: BundleStateDataProvider,
DB: Database,
EF: ExecutorFactory,
EVM: ExecutorFactory,
{
// some checks are done before blocks comes here.
externals.consensus.validate_header_against_parent(&block, parent_block)?;
Expand Down
10 changes: 5 additions & 5 deletions crates/blockchain-tree/src/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ use std::{collections::BTreeMap, sync::Arc};
/// - The executor factory to execute blocks with
/// - The chain spec
#[derive(Debug)]
pub struct TreeExternals<DB, EF> {
pub struct TreeExternals<DB, EVM> {
/// The provider factory, used to commit the canonical chain, or unwind it.
pub(crate) provider_factory: ProviderFactory<DB>,
/// The consensus engine.
pub(crate) consensus: Arc<dyn Consensus>,
/// The executor factory to execute blocks with.
pub(crate) executor_factory: EF,
pub(crate) executor_factory: EVM,
}

impl<DB, EF> TreeExternals<DB, EF> {
impl<DB, EVM> TreeExternals<DB, EVM> {
/// Create new tree externals.
pub fn new(
provider_factory: ProviderFactory<DB>,
consensus: Arc<dyn Consensus>,
executor_factory: EF,
executor_factory: EVM,
) -> Self {
Self { provider_factory, consensus, executor_factory }
}
}

impl<DB: Database, EF> TreeExternals<DB, EF> {
impl<DB: Database, EVM> TreeExternals<DB, EVM> {
/// Fetches the latest canonical block hashes by walking backwards from the head.
///
/// Returns the hashes sorted by increasing block numbers
Expand Down
Loading

0 comments on commit a7e183d

Please sign in to comment.