Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Nov 13, 2024
1 parent 5e0f541 commit 819e68f
Show file tree
Hide file tree
Showing 51 changed files with 378 additions and 259 deletions.
2 changes: 1 addition & 1 deletion crates/bsc/chainspec/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use alloc::sync::Arc;
use std::sync::Arc;

use alloy_chains::Chain;
use alloy_consensus::constants::DEV_GENESIS_HASH;
use alloy_primitives::U256;
use once_cell::sync::Lazy;
use reth_bsc_forks::DEV_HARDFORKS;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use alloy_consensus::constants::DEV_GENESIS_HASH;

use crate::BscChainSpec;

Expand Down
2 changes: 1 addition & 1 deletion crates/bsc/consensus/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::U256;
use alloy_consensus::constants::ETH_TO_WEI;
use alloy_primitives::U256;

/// Fixed number of extra-data prefix bytes reserved for signer vanity
pub const EXTRA_VANITY_LEN: usize = 32;
Expand Down
2 changes: 1 addition & 1 deletion crates/bsc/consensus/src/validation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK};
use alloy_primitives::{Bloom, B256};
use reth_chainspec::{EthChainSpec, EthereumHardfork, EthereumHardforks};
use reth_consensus::ConsensusError;
use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK};
use reth_primitives::{
gas_spent_by_transactions, BlockWithSenders, GotExpected, Header, Receipt, SealedHeader,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bsc/engine/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use alloy_rpc_types::{engine::ForkchoiceState, BlockId, RpcBlockHash};
use reth_beacon_consensus::{
BeaconEngineMessage, EngineNodeTypes, ForkchoiceStatus, MIN_BLOCKS_FOR_PIPELINE_RUN,
};
use reth_engine_primitives::EngineApiMessageVersion;
use reth_bsc_consensus::Parlia;
use reth_bsc_evm::SnapshotReader;
use reth_chainspec::EthChainSpec;
use reth_engine_primitives::EngineApiMessageVersion;
use reth_network_api::events::EngineMessage;
use reth_network_p2p::{
headers::client::{HeadersClient, HeadersDirection, HeadersRequest},
Expand Down
11 changes: 5 additions & 6 deletions crates/bsc/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ use reth_bsc_consensus::Parlia;
use reth_bsc_engine::{BscEngineTypes, BscEngineValidator};
use reth_bsc_evm::{BscEvmConfig, BscExecutorProvider};
use reth_bsc_payload_builder::{BscBuiltPayload, BscPayloadBuilderAttributes};
use reth_ethereum_engine_primitives::EthPayloadAttributes;
use reth_network::NetworkHandle;
use reth_primitives::{Block, Header};
use reth_node_api::{
AddOnsContext, ConfigureEvm, EngineValidator, FullNodeComponents, NodePrimitives,
NodeTypesWithDB,
};
use reth_node_builder::{
components::{
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
PayloadServiceBuilder, PoolBuilder, ParliaBuilder,
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, ParliaBuilder,
PayloadServiceBuilder, PoolBuilder,
},
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
rpc::{EngineValidatorBuilder, RpcAddOns},
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
};
use reth_ethereum_engine_primitives::EthPayloadAttributes;
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{Block, Header};
use reth_provider::CanonStateSubscriptions;
use reth_rpc::EthApi;
use reth_tracing::tracing::{debug, info};
Expand Down Expand Up @@ -99,7 +99,6 @@ pub type BscAddOns<N> = RpcAddOns<
BscEngineValidatorBuilder,
>;


impl<Types, N> Node<N> for BscNode
where
Types: NodeTypesWithDB + NodeTypesWithEngine<Engine = BscEngineTypes, ChainSpec = BscChainSpec>,
Expand Down
7 changes: 1 addition & 6 deletions crates/bsc/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,7 @@ where
// seal the block
let block = Block {
header,
body: BlockBody {
transactions: executed_txs,
ommers: vec![],
withdrawals,
sidecars: None,
},
body: BlockBody { transactions: executed_txs, ommers: vec![], withdrawals, sidecars: None },
};

let sealed_block = block.seal_slow();
Expand Down
2 changes: 0 additions & 2 deletions crates/bsc/payload/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,3 @@ impl From<BscBuiltPayload> for ExecutionPayloadEnvelopeV4 {
}
}
}


28 changes: 16 additions & 12 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ pub struct PruneConfig {

impl Default for PruneConfig {
fn default() -> Self {
Self { block_interval: DEFAULT_BLOCK_INTERVAL, recent_sidecars_kept_blocks: 0, segments: PruneModes::none() }
Self {
block_interval: DEFAULT_BLOCK_INTERVAL,
recent_sidecars_kept_blocks: 0,
segments: PruneModes::none(),
}
}
}

Expand All @@ -411,14 +415,14 @@ impl PruneConfig {
block_interval,
recent_sidecars_kept_blocks,
segments:
PruneModes {
sender_recovery,
transaction_lookup,
receipts,
account_history,
storage_history,
receipts_log_filter,
},
PruneModes {
sender_recovery,
transaction_lookup,
receipts,
account_history,
storage_history,
receipts_log_filter,
},
} = other;

// Merge block_interval, only update if it's the default interval
Expand Down Expand Up @@ -564,7 +568,7 @@ mod tests {
config_path,
toml::to_string(&config).expect("Failed to serialize config"),
)
.expect("Failed to write config file");
.expect("Failed to write config file");
})
}

Expand All @@ -586,7 +590,7 @@ mod tests {
config_path,
toml::to_string(&config).expect("Failed to serialize config"),
)
.expect("Failed to write config file");
.expect("Failed to write config file");

// Load the config from the file
let loaded_config = Config::from_path(config_path).unwrap();
Expand All @@ -607,7 +611,7 @@ mod tests {
config_path,
toml::to_string(&config).expect("Failed to serialize config"),
)
.expect("Failed to write config file");
.expect("Failed to write config file");

// Load the config from the file
let loaded_config = Config::from_path(config_path).unwrap();
Expand Down
8 changes: 2 additions & 6 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,8 @@ impl StorageInner {
// root here

let Block { mut header, body, .. } = block.block;
let body = BlockBody {
transactions: body.transactions,
ommers,
withdrawals,
sidecars: None,
};
let body =
BlockBody { transactions: body.transactions, ommers, withdrawals, sidecars: None };
trace!(target: "consensus::auto", ?execution_outcome, ?header, ?body, "executed block, calculating state root and completing header");

// now we need to update certain header fields with the results of the execution
Expand Down
7 changes: 1 addition & 6 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,7 @@ mod tests {
(
SealedBlock {
header: SealedHeader::new(header, seal),
body: BlockBody {
transactions,
ommers,
withdrawals: None,
sidecars: None,
},
body: BlockBody { transactions, ommers, withdrawals: None, sidecars: None },
},
parent,
)
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/local/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
if chain_spec.is_optimism() { EngineApiKind::OpStack } else { EngineApiKind::Ethereum };

let persistence_handle =
PersistenceHandle::spawn_service(provider, pruner, sync_metrics_tx, false);
PersistenceHandle::spawn_service(provider, pruner, sync_metrics_tx, false);
let payload_validator = ExecutionPayloadValidator::new(chain_spec);

let canonical_in_memory_state = blockchain_db.canonical_in_memory_state();
Expand Down
4 changes: 2 additions & 2 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ where
// TODO: add prefetch tx
// if let Some(tx) = tx.as_ref() {
// tx.send(state.clone()).unwrap_or_else(|err| {
// debug!(target: "evm_executor", ?err, "Failed to send post state to prefetch channel")
// });
// debug!(target: "evm_executor", ?err, "Failed to send post state to prefetch
// channel") });
// }

evm.db_mut().commit(state);
Expand Down
4 changes: 2 additions & 2 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use reth_node_api::{
};
use reth_node_builder::{
components::{
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
PayloadServiceBuilder, PoolBuilder, ParliaBuilder,
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, ParliaBuilder,
PayloadServiceBuilder, PoolBuilder,
},
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
rpc::{EngineValidatorBuilder, RpcAddOns},
Expand Down
7 changes: 1 addition & 6 deletions crates/ethereum/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,7 @@ where
// seal the block
let block = Block {
header,
body: BlockBody {
transactions: executed_txs,
ommers: vec![],
withdrawals,
sidecars: None,
},
body: BlockBody { transactions: executed_txs, ommers: vec![], withdrawals, sidecars: None },
};

let sealed_block = block.seal_slow();
Expand Down
4 changes: 3 additions & 1 deletion crates/evm/execution-types/src/execution_outcome.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::BlockExecutionOutput;
use alloy_eips::eip7685::Requests;
use alloy_primitives::{Address, BlockNumber, Bloom, Log, B256, U256};
use reth_primitives::{logs_bloom, parlia::Snapshot, Account, Bytecode, Receipt, Receipts, StorageEntry};
use reth_primitives::{
logs_bloom, parlia::Snapshot, Account, Bytecode, Receipt, Receipts, StorageEntry,
};
use reth_trie::HashedPostState;
use revm::{
db::{states::BundleState, BundleAccount},
Expand Down
27 changes: 17 additions & 10 deletions crates/evm/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
//! Traits for execution.
// Re-export execution types
pub use reth_execution_errors::{
BlockExecutionError, BlockValidationError, InternalBlockExecutionError,
};
pub use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
pub use reth_storage_errors::provider::ProviderError;
use revm::db::states::bundle_state::BundleRetention;
use crate::system_calls::OnStateHook;
use alloc::{boxed::Box, vec::Vec};
use alloy_eips::eip7685::Requests;
use alloy_primitives::BlockNumber;
use core::{fmt::Display, marker::PhantomData};
use reth_consensus::ConsensusError;
pub use reth_execution_errors::{
BlockExecutionError, BlockValidationError, InternalBlockExecutionError,
};
pub use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
use reth_primitives::{BlockWithSenders, Header, Receipt};
use reth_prune_types::PruneModes;
use reth_revm::batch::BlockBatchRecord;
use revm::{db::BundleState, State};
use revm_primitives::{db::Database, U256, EvmState};
pub use reth_storage_errors::provider::ProviderError;
use revm::{
db::{states::bundle_state::BundleRetention, BundleState},
State,
};
use revm_primitives::{db::Database, EvmState, U256};
use tokio::sync::mpsc::UnboundedSender;

/// A general purpose executor trait that executes an input (e.g. block) and produces an output
Expand Down Expand Up @@ -282,7 +284,11 @@ where
type BatchExecutor<DB: Database<Error: Into<ProviderError> + Display>> =
BasicBatchExecutor<F::Strategy<DB>, DB>;

fn executor<DB>(&self, db: DB, _prefetch_rx: Option<UnboundedSender<EvmState>>) -> Self::Executor<DB>
fn executor<DB>(
&self,
db: DB,
_prefetch_rx: Option<UnboundedSender<EvmState>>,
) -> Self::Executor<DB>
where
DB: Database<Error: Into<ProviderError> + Display>,
{
Expand Down Expand Up @@ -703,7 +709,8 @@ mod tests {
let provider = BasicBlockExecutorProvider::new(strategy_factory);
let db = CacheDB::<EmptyDBTyped<ProviderError>>::default();
let executor = provider.executor(db, None);
let result = executor.execute(BlockExecutionInput::new(&Default::default(), U256::ZERO, None));
let result =
executor.execute(BlockExecutionInput::new(&Default::default(), U256::ZERO, None));

assert!(result.is_ok());
let block_execution_output = result.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/exex/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use reth_node_builder::{
};
use reth_node_core::node_config::NodeConfig;
use reth_node_ethereum::{
node::{EthereumAddOns, EthereumNetworkBuilder, EthereumPayloadBuilder, EthereumParliaBuilder},
node::{EthereumAddOns, EthereumNetworkBuilder, EthereumParliaBuilder, EthereumPayloadBuilder},
EthEngineTypes, EthEvmConfig,
};
use reth_payload_builder::noop::NoopPayloadBuilderService;
Expand Down
2 changes: 1 addition & 1 deletion crates/node/api/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{future::Future, marker::PhantomData};

use alloy_rpc_types_engine::JwtSecret;
use reth_beacon_consensus::BeaconConsensusEngineHandle;
use reth_bsc_consensus::BscTraceHelper;
use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_network_api::FullNetwork;
Expand All @@ -14,7 +15,6 @@ use reth_primitives::Header;
use reth_provider::FullProvider;
use reth_tasks::TaskExecutor;
use reth_transaction_pool::TransactionPool;
use reth_bsc_consensus::BscTraceHelper;

use crate::ConfigureEvm;

Expand Down
7 changes: 4 additions & 3 deletions crates/node/builder/src/components/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use reth_transaction_pool::TransactionPool;
use crate::{
components::{
Components, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, NodeComponents,
PayloadServiceBuilder, PoolBuilder, ParliaBuilder,
ParliaBuilder, PayloadServiceBuilder, PoolBuilder,
},
BuilderContext, ConfigureEvm, FullNodeTypes,
};
Expand Down Expand Up @@ -322,8 +322,9 @@ where
}

/// Configures the parlia builder.
///
/// This accepts a [`ParliaBuilder`] instance that will be used to create the node's components for parlia.
///
/// This accepts a [`ParliaBuilder`] instance that will be used to create the node's components
/// for parlia.
pub fn parlia<PB>(
self,
parlia_builder: PB,
Expand Down
1 change: 0 additions & 1 deletion crates/node/builder/src/components/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ where
self(ctx)
}
}

4 changes: 2 additions & 2 deletions crates/node/builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ mod builder;
mod consensus;
mod execute;
mod network;
mod parlia;
mod payload;
mod pool;
mod parlia;

pub use builder::*;
pub use consensus::*;
pub use execute::*;
pub use network::*;
pub use parlia::*;
pub use payload::*;
pub use pool::*;
pub use parlia::*;
#[cfg(feature = "bsc")]
use reth_bsc_consensus::Parlia;
use reth_consensus::Consensus;
Expand Down
4 changes: 2 additions & 2 deletions crates/node/builder/src/components/parlia.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Parlia component for the node builder.
use crate::{BuilderContext, FullNodeTypes};
use std::future::Future;
use reth_bsc_consensus::Parlia;
use std::future::Future;

/// Needed for bsc parlia consensus.
pub trait ParliaBuilder<Node: FullNodeTypes>: Send {
Expand All @@ -24,4 +24,4 @@ where
) -> impl Future<Output = eyre::Result<Parlia>> {
self(ctx)
}
}
}
Loading

0 comments on commit 819e68f

Please sign in to comment.