Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Revert "chore: Smaller Nits" #146

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ min-debug-logs = ["tracing/release_max_level_debug"]
min-trace-logs = ["tracing/release_max_level_trace"]
optimism = [
"reth-primitives/optimism",
"reth-primitives/value-256",
"reth-revm/optimism",
"reth-interfaces/optimism",
"reth-rpc/optimism",
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/args/payload_builder_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl TypedValueParser for ExtradataValueParser {
format!(
"Payload builder extradata size exceeds {MAXIMUM_EXTRA_DATA_SIZE}bytes limit"
),
))
));
}
Ok(val.to_string())
}
Expand Down
7 changes: 5 additions & 2 deletions bin/reth/src/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,11 @@ impl Command {
// TODO: add support for withdrawals
withdrawals: None,
#[cfg(feature = "optimism")]
optimism_payload_attributes: reth_rpc_types::engine::OptimismPayloadAttributes::default(
),
optimism_payload_attributes: reth_rpc_types::engine::OptimismPayloadAttributes {
transactions: None,
no_tx_pool: None,
gas_limit: None,
},
};
let payload_config = PayloadConfig::new(
Arc::clone(&best_block),
Expand Down
1 change: 1 addition & 0 deletions bin/reth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub mod dirs;
pub mod init;
pub mod node;
pub mod p2p;
pub mod precaution;
pub mod prometheus_exporter;
pub mod recover;
pub mod runner;
Expand Down
4 changes: 4 additions & 0 deletions bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn main() {
// Ensure feature flags are set correctly for different chains
reth::precaution::ensure_ethereum!();
reth::precaution::ensure_optimism!();

if let Err(err) = reth::cli::run() {
eprintln!("Error: {err:?}");
std::process::exit(1);
Expand Down
13 changes: 9 additions & 4 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ use std::{
use tokio::sync::{mpsc::unbounded_channel, oneshot, watch};
use tracing::*;

#[cfg(feature = "optimism")]
use reth_rpc_api::EngineApiClient;
#[cfg(feature = "optimism")]
use reth_rpc_types::engine::ForkchoiceState;

pub mod cl_events;
pub mod events;

Expand Down Expand Up @@ -558,9 +563,9 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
#[cfg(feature = "optimism")]
if self.chain.optimism && !self.rollup.enable_genesis_walkback {
let client = _rpc_server_handles.auth.http_client();
reth_rpc_api::EngineApiClient::fork_choice_updated_v2(
EngineApiClient::fork_choice_updated_v2(
&client,
reth_rpc_types::engine::ForkchoiceState {
ForkchoiceState {
head_block_hash: head.hash,
safe_block_hash: head.hash,
finalized_block_hash: head.hash,
Expand Down Expand Up @@ -789,15 +794,15 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
// try to look up the header in the database
if let Some(header) = header {
info!(target: "reth::cli", ?tip, "Successfully looked up tip block in the database");
return Ok(header.seal_slow())
return Ok(header.seal_slow());
}

info!(target: "reth::cli", ?tip, "Fetching tip block from the network.");
loop {
match get_single_header(&client, tip).await {
Ok(tip_header) => {
info!(target: "reth::cli", ?tip, "Successfully fetched tip");
return Ok(tip_header)
return Ok(tip_header);
}
Err(error) => {
error!(target: "reth::cli", %error, "Failed to fetch the tip. Retrying...");
Expand Down
24 changes: 24 additions & 0 deletions bin/reth/src/precaution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//! Helpers to ensure certain features are enabled or disabled.
//!
//! The motivation for this is to prevent that a binary is accidentally built with a feature that is
//! not intended to be used.
//!
//! Currently conflicting features are: `value-u256` which is required by optimism.

/// A macro to ensure that the crate's features are compatible with ethereum
#[macro_export]
macro_rules! ensure_ethereum {
() => {
#[cfg(feature = "value-256")]
compile_error!("The `value-256` feature is enabled but for `ethereum` it must be disabled: https://github.com/paradigmxyz/reth/issues/4891");
};
}

/// A macro to ensure that the crate's features are compatible with optimism
#[macro_export]
macro_rules! ensure_optimism {
() => {
#[cfg(not(feature = "value-256"))]
compile_error!("The `value-256` feature is disabled but for `optimism` it must be enabled: https://github.com/paradigmxyz/reth/issues/4891");
};
}
Loading
Loading