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

refactor: move ethereum and op builder into separate crates #5876

Merged
merged 6 commits into from
Dec 28, 2023
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
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ members = [
"crates/net/network-api/",
"crates/payload/basic/",
"crates/payload/builder/",
"crates/payload/ethereum/",
"crates/payload/optimism/",
"crates/payload/validator/",
"crates/primitives/",
"crates/prune/",
Expand Down Expand Up @@ -105,6 +107,7 @@ reth-downloaders = { path = "crates/net/downloaders" }
reth-ecies = { path = "crates/net/ecies" }
reth-eth-wire = { path = "crates/net/eth-wire" }
reth-ethereum-forks = { path = "crates/ethereum-forks" }
reth-ethereum-payload-builder = { path = "crates/payload/ethereum" }
reth-interfaces = { path = "crates/interfaces" }
reth-ipc = { path = "crates/rpc/ipc" }
reth-libmdbx = { path = "crates/storage/libmdbx-rs" }
Expand Down
6 changes: 5 additions & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ reth-downloaders = { workspace = true, features = ["test-utils"] }
reth-tracing.workspace = true
reth-tasks.workspace = true
reth-net-nat.workspace = true
reth-optimism-payload-builder = { path = "../../crates/payload/optimism", optional = true }
reth-ethereum-payload-builder.workspace = true
reth-payload-builder.workspace = true
reth-payload-validator.workspace = true
reth-basic-payload-builder.workspace = true
Expand Down Expand Up @@ -134,10 +136,12 @@ optimism = [
"reth-provider/optimism",
"reth-beacon-consensus/optimism",
"reth-auto-seal-consensus/optimism",
"reth-basic-payload-builder/optimism",
"reth-network/optimism",
"reth-network-api/optimism",
"reth-blockchain-tree/optimism",
"reth-payload-builder/optimism",
"reth-optimism-payload-builder/optimism",
"reth-ethereum-payload-builder/optimism",
]
# no-op feature flag for switching between the `optimism` and default functionality in CI matrices
ethereum = []
Expand Down
9 changes: 5 additions & 4 deletions bin/reth/src/cli/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,18 @@ pub trait RethNodeCommandConfig: fmt::Debug {
.extradata(conf.extradata_rlp_bytes())
.max_gas_limit(conf.max_gas_limit());

// no extradata for optimism
#[cfg(feature = "optimism")]
let payload_job_config =
payload_job_config.compute_pending_block(conf.compute_pending_block());
let payload_job_config = payload_job_config.extradata(Default::default());

// The default payload builder is implemented on the unit type.
#[cfg(not(feature = "optimism"))]
let payload_builder = reth_basic_payload_builder::EthereumPayloadBuilder::default();
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::default();

// Optimism's payload builder is implemented on the OptimismPayloadBuilder type.
#[cfg(feature = "optimism")]
let payload_builder = reth_basic_payload_builder::OptimismPayloadBuilder::default();
let payload_builder = reth_optimism_payload_builder::OptimismPayloadBuilder::default()
.set_compute_pending_block(conf.compute_pending_block());

let payload_generator = BasicPayloadJobGenerator::with_builder(
components.provider(),
Expand Down
14 changes: 10 additions & 4 deletions bin/reth/src/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use alloy_rlp::Decodable;
use clap::Parser;
use eyre::Context;
use reth_basic_payload_builder::{
default_payload_builder, BuildArguments, BuildOutcome, Cancelled, PayloadConfig,
BuildArguments, BuildOutcome, Cancelled, PayloadBuilder, PayloadConfig,
};
use reth_beacon_consensus::BeaconConsensus;
use reth_blockchain_tree::{
Expand Down Expand Up @@ -244,8 +244,6 @@ impl Command {
Bytes::default(),
PayloadBuilderAttributes::try_new(best_block.hash, payload_attrs)?,
self.chain.clone(),
#[cfg(feature = "optimism")]
true,
);
let args = BuildArguments::new(
blockchain_db.clone(),
Expand All @@ -255,7 +253,15 @@ impl Command {
Cancelled::default(),
None,
);
match default_payload_builder(args)? {

#[cfg(feature = "optimism")]
let payload_builder = reth_optimism_payload_builder::OptimismPayloadBuilder::default()
.compute_pending_block();

#[cfg(not(feature = "optimism"))]
let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::default();

match payload_builder.try_build(args)? {
BuildOutcome::Better { payload, .. } => {
let block = payload.block();
debug!(target: "reth::cli", ?block, "Built new payload");
Expand Down
11 changes: 1 addition & 10 deletions crates/payload/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,4 @@ reth-metrics.workspace = true
metrics.workspace = true

# misc
tracing.workspace = true

[features]
optimism = [
"reth-primitives/optimism",
"reth-revm/optimism",
"reth-transaction-pool/optimism",
"reth-provider/optimism",
"reth-payload-builder/optimism"
]
tracing.workspace = true
Loading
Loading