Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-testing-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }

# reth optimism
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
Expand Down
2 changes: 2 additions & 0 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ reth-network-peers.workspace = true
reth-testing-utils.workspace = true
reth-optimism-forks.workspace = true
reth-node-builder.workspace = true
reth-rpc-eth-types.workspace = true

alloy-primitives.workspace = true
alloy-consensus.workspace = true
Expand All @@ -61,6 +62,7 @@ alloy-serde.workspace = true
alloy-op-evm.workspace = true
op-alloy-consensus.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-rpc-types.workspace = true
op-alloy-network.workspace = true

revm.workspace = true
Expand Down
12 changes: 0 additions & 12 deletions crates/op-rbuilder/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ pub struct BlockPayloadJobGenerator<Client, Tasks, Builder> {
last_payload: Arc<Mutex<CancellationToken>>,
/// The extra block deadline in seconds
extra_block_deadline: std::time::Duration,
/// Whether to enable revert protection
enable_revert_protection: bool,
}

// === impl EmptyBlockPayloadJobGenerator ===
Expand All @@ -90,7 +88,6 @@ impl<Client, Tasks, Builder> BlockPayloadJobGenerator<Client, Tasks, Builder> {
builder: Builder,
ensure_only_one_payload: bool,
extra_block_deadline: std::time::Duration,
enable_revert_protection: bool,
) -> Self {
Self {
client,
Expand All @@ -100,7 +97,6 @@ impl<Client, Tasks, Builder> BlockPayloadJobGenerator<Client, Tasks, Builder> {
ensure_only_one_payload,
last_payload: Arc::new(Mutex::new(CancellationToken::new())),
extra_block_deadline,
enable_revert_protection,
}
}
}
Expand Down Expand Up @@ -186,7 +182,6 @@ where
cancel: cancel_token,
deadline,
build_complete: None,
enable_revert_protection: self.enable_revert_protection,
};

job.spawn_build_job();
Expand Down Expand Up @@ -219,8 +214,6 @@ where
pub(crate) cancel: CancellationToken,
pub(crate) deadline: Pin<Box<Sleep>>, // Add deadline
pub(crate) build_complete: Option<oneshot::Receiver<Result<(), PayloadBuilderError>>>,
/// Block building options
pub(crate) enable_revert_protection: bool,
}

impl<Tasks, Builder> PayloadJob for BlockPayloadJob<Tasks, Builder>
Expand Down Expand Up @@ -263,8 +256,6 @@ pub struct BuildArguments<Attributes, Payload: BuiltPayload> {
pub config: PayloadConfig<Attributes, HeaderTy<Payload::Primitives>>,
/// A marker that can be used to cancel the job.
pub cancel: CancellationToken,
/// Whether to enable revert protection
pub enable_revert_protection: bool,
}

/// A [PayloadJob] is a future that's being polled by the `PayloadBuilderService`
Expand All @@ -280,7 +271,6 @@ where
let payload_config = self.config.clone();
let cell = self.cell.clone();
let cancel = self.cancel.clone();
let enable_revert_protection = self.enable_revert_protection;

let (tx, rx) = oneshot::channel();
self.build_complete = Some(rx);
Expand All @@ -290,7 +280,6 @@ where
cached_reads: Default::default(),
config: payload_config,
cancel,
enable_revert_protection,
};

let result = builder.try_build(args, cell);
Expand Down Expand Up @@ -650,7 +639,6 @@ mod tests {
builder.clone(),
false,
std::time::Duration::from_secs(1),
false,
);

// this is not nice but necessary
Expand Down
54 changes: 42 additions & 12 deletions crates/op-rbuilder/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
use args::CliExt;
use clap::Parser;
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
use reth_optimism_node::{node::OpAddOnsBuilder, OpNode};
use reth_optimism_node::{
node::{OpAddOnsBuilder, OpPoolBuilder},
OpNode,
};
use reth_transaction_pool::TransactionPool;

/// CLI argument parsing.
pub mod args;
pub mod generator;
mod metrics;
mod monitor_tx_pool;
mod primitives;
mod tx_signer;

#[cfg(feature = "flashblocks")]
pub mod payload_builder;
mod primitives;
mod revert_protection;
mod tx;
mod tx_signer;

#[cfg(not(feature = "flashblocks"))]
mod payload_builder_vanilla;
Expand All @@ -29,6 +33,8 @@ use metrics::{
VERGEN_CARGO_FEATURES, VERGEN_CARGO_TARGET_TRIPLE, VERGEN_GIT_SHA,
};
use monitor_tx_pool::monitor_tx_pool;
use revert_protection::{EthApiOverrideServer, RevertProtectionExt};
use tx::FBPooledTransaction;

// Prefer jemalloc for performance reasons.
#[cfg(all(feature = "jemalloc", unix))]
Expand All @@ -53,20 +59,44 @@ fn main() {
let op_node = OpNode::new(rollup_args.clone());
let handle = builder
.with_types::<OpNode>()
.with_components(op_node.components().payload(CustomOpPayloadBuilder::new(
builder_args.builder_signer,
std::time::Duration::from_secs(builder_args.extra_block_deadline_secs),
builder_args.enable_revert_protection,
builder_args.flashblocks_ws_url,
builder_args.chain_block_time,
builder_args.flashblock_block_time,
)))
.with_components(
op_node
.components()
.pool(
OpPoolBuilder::<FBPooledTransaction>::default()
.with_enable_tx_conditional(true)
.with_supervisor(
rollup_args.supervisor_http.clone(),
rollup_args.supervisor_safety_level,
),
)
.payload(CustomOpPayloadBuilder::new(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we can make CustomOpPayloadBuilder accept BuilderArgs as a constructor parameter to avoid passing too many individual arguments and changing this code as the list of arguments grows over time.

builder_args.builder_signer,
std::time::Duration::from_secs(builder_args.extra_block_deadline_secs),
builder_args.flashblocks_ws_url,
builder_args.chain_block_time,
builder_args.flashblock_block_time,
)),
)
.with_add_ons(
OpAddOnsBuilder::default()
.with_sequencer(rollup_args.sequencer.clone())
.with_enable_tx_conditional(rollup_args.enable_tx_conditional)
.build(),
)
.extend_rpc_modules(move |ctx| {
if builder_args.enable_revert_protection {
tracing::info!("Revert protection enabled");

let pool = ctx.pool().clone();
let revert_protection_ext = RevertProtectionExt::new(pool);

ctx.modules
.merge_configured(revert_protection_ext.into_rpc())?;
}

Ok(())
})
.on_node_started(move |ctx| {
version.register_version_metrics();
if builder_args.log_pool_transactions {
Expand Down
6 changes: 3 additions & 3 deletions crates/op-rbuilder/src/monitor_tx_pool.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::tx::FBPooledTransaction;
use futures_util::StreamExt;
use reth_optimism_node::txpool::OpPooledTransaction;
use reth_transaction_pool::{AllTransactionsEvents, FullTransactionEvent};
use tracing::info;

pub async fn monitor_tx_pool(mut new_transactions: AllTransactionsEvents<OpPooledTransaction>) {
pub async fn monitor_tx_pool(mut new_transactions: AllTransactionsEvents<FBPooledTransaction>) {
while let Some(event) = new_transactions.next().await {
transaction_event_log(event);
}
}

fn transaction_event_log(event: FullTransactionEvent<OpPooledTransaction>) {
fn transaction_event_log(event: FullTransactionEvent<FBPooledTransaction>) {
match event {
FullTransactionEvent::Pending(hash) => {
info!(
Expand Down
Loading
Loading