Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce evm config trait #6461

Merged
merged 21 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading