This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed14753
commit f422a6d
Showing
18 changed files
with
719 additions
and
813 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use crate::{ | ||
bsc::processor::BscEVMProcessor, | ||
database::StateProviderDatabase, | ||
stack::{InspectorStack, InspectorStackConfig}, | ||
}; | ||
use reth_evm::ConfigureEvm; | ||
use reth_interfaces::executor::BlockExecutionError; | ||
use reth_parlia_consensus::{Parlia, ParliaConfig}; | ||
use reth_primitives::ChainSpec; | ||
use reth_provider::{ | ||
ExecutorFactory, HeaderProvider, ParliaSnapshotReader, ParliaSnapshotWriter, | ||
PrunableBlockExecutor, StateProvider, | ||
}; | ||
use std::{fmt::Debug, sync::Arc}; | ||
|
||
/// Factory for creating [BscEVMProcessor]. | ||
#[derive(Clone, Debug)] | ||
pub struct BscEvmProcessorFactory<EvmConfig> { | ||
chain_spec: Arc<ChainSpec>, | ||
stack: Option<InspectorStack>, | ||
/// Type that defines how the produced EVM should be configured. | ||
evm_config: EvmConfig, | ||
/// Parlia consensus config | ||
parlia_config: ParliaConfig, | ||
} | ||
|
||
impl<EvmConfig> BscEvmProcessorFactory<EvmConfig> { | ||
/// Create new factory | ||
pub fn new( | ||
chain_spec: Arc<ChainSpec>, | ||
evm_config: EvmConfig, | ||
parlia_config: ParliaConfig, | ||
) -> Self { | ||
Self { chain_spec, stack: None, evm_config, parlia_config } | ||
} | ||
|
||
/// Sets the inspector stack for all generated executors. | ||
pub fn with_stack(mut self, stack: InspectorStack) -> Self { | ||
self.stack = Some(stack); | ||
self | ||
} | ||
|
||
/// Sets the inspector stack for all generated executors using the provided config. | ||
pub fn with_stack_config(mut self, config: InspectorStackConfig) -> Self { | ||
self.stack = Some(InspectorStack::new(config)); | ||
self | ||
} | ||
} | ||
|
||
impl<EvmConfig> ExecutorFactory for BscEvmProcessorFactory<EvmConfig> | ||
where | ||
EvmConfig: ConfigureEvm + Send + Sync + Clone + 'static, | ||
{ | ||
fn with_state<'a, SP: StateProvider + 'a>( | ||
&'a self, | ||
_sp: SP, | ||
) -> Box<dyn PrunableBlockExecutor<Error = BlockExecutionError> + 'a> { | ||
panic!("Please use with_state_and_provider instead") | ||
} | ||
|
||
fn with_state_and_provider< | ||
'a, | ||
SP: StateProvider + 'a, | ||
P: HeaderProvider + ParliaSnapshotReader + ParliaSnapshotWriter + 'a, | ||
>( | ||
&'a self, | ||
sp: SP, | ||
p: P, | ||
) -> Box<dyn PrunableBlockExecutor<Error = BlockExecutionError> + 'a> { | ||
let database_state = StateProviderDatabase::new(sp); | ||
let mut evm = BscEVMProcessor::new_with_db( | ||
self.chain_spec.clone(), | ||
database_state, | ||
self.evm_config.clone(), | ||
); | ||
if let Some(stack) = &self.stack { | ||
evm.set_stack(stack.clone()); | ||
} | ||
evm.set_parlia(Arc::new(Parlia::new(self.chain_spec.clone(), self.parlia_config.clone()))); | ||
evm.parlia_consensus.set_provider(p); | ||
Box::new(evm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/// Bsc-specific processor implementation for the `EVMProcessor` | ||
pub mod processor; | ||
pub mod factory; |
Oops, something went wrong.