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

fix: update executor type in commands for bsc #34

Merged
merged 1 commit into from
Jun 25, 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
8 changes: 8 additions & 0 deletions bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ impl Command {
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(provider_factory.chain_spec()));

#[cfg(feature = "bsc")]
let executor = block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec());

// configure blockchain tree
Expand Down Expand Up @@ -268,6 +271,11 @@ impl Command {
SealedBlockWithSenders::new(block.clone(), senders).unwrap();

let db = StateProviderDatabase::new(blockchain_db.latest()?);
#[cfg(feature = "bsc")]
let executor =
block_executor!(provider_factory.chain_spec(), provider_factory.clone())
.executor(db);
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec()).executor(db);

let BlockExecutionOutput { state, receipts, requests, .. } =
Expand Down
3 changes: 3 additions & 0 deletions bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ impl Command {
let prune_modes = config.prune.clone().map(|prune| prune.segments).unwrap_or_default();

let (tip_tx, tip_rx) = watch::channel(B256::ZERO);
#[cfg(feature = "bsc")]
let executor = block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec());

let pipeline = Pipeline::builder()
Expand Down
4 changes: 4 additions & 0 deletions bin/reth/src/commands/debug_cmd/in_memory_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ impl Command {
provider_factory.static_file_provider(),
));

#[cfg(feature = "bsc")]
let executor =
block_executor!(provider_factory.chain_spec(), provider_factory.clone()).executor(db);
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec()).executor(db);

let merkle_block_td =
Expand Down
4 changes: 4 additions & 0 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl Command {
)
.await?;

#[cfg(feature = "bsc")]
let executor_provider =
block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor_provider = block_executor!(provider_factory.chain_spec());

// Initialize the fetch client
Expand Down
3 changes: 3 additions & 0 deletions bin/reth/src/commands/debug_cmd/replay_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ impl Command {
let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(provider_factory.chain_spec()));

#[cfg(feature = "bsc")]
let executor = block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec());

// Configure blockchain tree
Expand Down
3 changes: 3 additions & 0 deletions bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ where
.expect("failed to set download range");

let (tip_tx, tip_rx) = watch::channel(B256::ZERO);
#[cfg(feature = "bsc")]
let executor = block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec());

let max_block = file_client.max_block().unwrap_or(0);
Expand Down
6 changes: 5 additions & 1 deletion bin/reth/src/commands/stage/dump/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ async fn unwind_and_copy<DB: Database>(
}

/// Try to re-execute the stage without committing
async fn dry_run<DB: Database>(
async fn dry_run<DB: Database + 'static>(
output_provider_factory: ProviderFactory<DB>,
to: u64,
from: u64,
) -> eyre::Result<()> {
info!(target: "reth::cli", "Executing stage. [dry-run]");

#[cfg(feature = "bsc")]
let executor =
block_executor!(output_provider_factory.chain_spec(), output_provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(output_provider_factory.chain_spec());
let mut exec_stage = ExecutionStage::new_with_executor(executor);

Expand Down
4 changes: 4 additions & 0 deletions bin/reth/src/commands/stage/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl Command {
None,
),
StageEnum::Execution => {
#[cfg(feature = "bsc")]
let executor =
block_executor!(provider_factory.chain_spec(), provider_factory.clone());
#[cfg(not(feature = "bsc"))]
let executor = block_executor!(provider_factory.chain_spec());
(
Box::new(ExecutionStage::new(
Expand Down
14 changes: 13 additions & 1 deletion bin/reth/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// Creates the block executor type based on the configured feature.
///
/// Note(mattsse): This is incredibly horrible and will be replaced
#[cfg(not(feature = "optimism"))]
#[cfg(all(not(feature = "optimism"), not(feature = "bsc")))]
macro_rules! block_executor {
($chain_spec:expr) => {
reth_node_ethereum::EthExecutorProvider::ethereum($chain_spec)
Expand All @@ -17,4 +17,16 @@ macro_rules! block_executor {
};
}

#[cfg(feature = "bsc")]
macro_rules! block_executor {
($chain_spec:expr) => {
// In some cases provider is not available
// And we don't really need a bsc executor provider
reth_node_ethereum::EthExecutorProvider::ethereum($chain_spec)
};
($chain_spec:expr, $provider:expr) => {
reth_node_bsc::BscExecutorProvider::bsc($chain_spec, $provider)
};
}

pub(crate) use block_executor;
1 change: 0 additions & 1 deletion crates/bsc/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ mod tests {
assert_eq!(storage.headers.get(&block.number), Some(&block));
assert_eq!(storage.hash_to_number.get(&block.hash()), Some(&block.number));
assert_eq!(storage.bodies.get(&block.hash()), Some(&BlockBody::default()));
assert_eq!(storage.block_hash(block.number), Some(block.hash()));
assert_eq!(
storage.header_by_hash_or_number(BlockHashOrNumber::Hash(block.hash())),
Some(block.clone())
Expand Down
4 changes: 1 addition & 3 deletions crates/bsc/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use reth_node_builder::{
BuilderContext, Node, PayloadBuilderConfig,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::parlia::ParliaConfig;
use reth_provider::CanonStateSubscriptions;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::{
Expand Down Expand Up @@ -92,11 +91,10 @@ where
) -> eyre::Result<(Self::EVM, Self::Executor)> {
let chain_spec = ctx.chain_spec();
let evm_config = BscEvmConfig::default();
// TODO: parlia config
let executor = BscExecutorProvider::new(
chain_spec,
evm_config,
ParliaConfig::default(),
ctx.reth_config().parlia.clone(),
ctx.provider().clone(),
);

Expand Down
Loading