Skip to content
Open
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
189 changes: 138 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/flashbots/op-rbuilder"
exclude = [".github/"]

[workspace]
members = [ "crates/op-rbuilder", "crates/tdx-quote-provider"]
members = ["crates/op-rbuilder", "crates/tdx-quote-provider"]
default-members = ["crates/op-rbuilder"]
resolver = "2"

Expand Down Expand Up @@ -140,6 +140,7 @@ alloy-rpc-types-eth = { version = "1.0.23" }
alloy-signer-local = { version = "1.0.23" }
alloy-rpc-client = { version = "1.0.23" }
alloy-genesis = { version = "1.0.23" }
alloy-rlp = { version = "0.3.12" }
alloy-trie = { version = "0.9.0" }

# optimism
Expand Down
3 changes: 3 additions & 0 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ alloy-serde.workspace = true
alloy-json-rpc.workspace = true
alloy-signer-local.workspace = true
alloy-sol-types.workspace = true
alloy-rlp.workspace = true

# op
alloy-op-evm.workspace = true
Expand Down Expand Up @@ -132,6 +133,8 @@ ctor = { version = "0.4.2", optional = true }
rlimit = { version = "0.10", optional = true }
macros = { path = "src/tests/framework/macros", optional = true }
testcontainers = "0.24.0"
pod-sdk = { git = "https://github.com/podnetwork/pod-sdk", rev = "1c665bb9926960c83f3253ced3f3af2b972f7657" }
itertools = "0.14.0"

[target.'cfg(unix)'.dependencies]
tikv-jemallocator = { version = "0.6", optional = true }
Expand Down
3 changes: 3 additions & 0 deletions crates/op-rbuilder/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ impl CliExt for Cli {
if node_command.ext.flashblocks.enabled {
return BuilderMode::Flashblocks;
}
if node_command.ext.pod.is_enabled {
return BuilderMode::Pod;
}
}
BuilderMode::Standard
}
Expand Down
23 changes: 23 additions & 0 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! clap [Args](clap::Args) for optimism rollup configuration

use crate::{flashtestations::args::FlashtestationsArgs, tx_signer::Signer};
use alloy_primitives::Address;
use anyhow::{anyhow, Result};
use clap::Parser;
use reth_optimism_cli::commands::Commands;
Expand Down Expand Up @@ -51,6 +52,8 @@ pub struct OpRbuilderArgs {
)]
pub playground: Option<PathBuf>,
#[command(flatten)]
pub pod: PodArgs,
#[command(flatten)]
pub flashblocks: FlashblocksArgs,
#[command(flatten)]
pub telemetry: TelemetryArgs,
Expand Down Expand Up @@ -150,6 +153,26 @@ impl Default for FlashblocksArgs {
}
}

#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
pub struct PodArgs {
#[arg(long = "pod.enabled", default_value = "false", env = "ENABLE_POD")]
pub is_enabled: bool,

#[arg(
long = "pod.rpc-url",
env = "POD_RPC_URL",
default_value = "wss://rpc.v2.pod.network"
)]
pub pod_rpc_url: String,

#[arg(
long = "pod.contract-address",
env = "POD_CONTRACT_ADDRESS",
default_value = "0xedd0670497e00ded712a398563ea938a29dd28c7"
)]
pub pod_contract_address: Address,
}

/// Parameters for telemetry configuration
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
pub struct TelemetryArgs {
Expand Down
6 changes: 6 additions & 0 deletions crates/op-rbuilder/src/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ mod builder_tx;
mod context;
mod flashblocks;
mod generator;
mod pod;
mod standard;

pub use builder_tx::BuilderTx;
pub use flashblocks::FlashblocksBuilder;
pub use pod::PodBuilder;
pub use standard::StandardBuilder;

/// Defines the payload building mode for the OP builder.
Expand All @@ -34,6 +36,10 @@ pub enum BuilderMode {
/// block every short interval and makes it available through a websocket update
/// then merges them into a full block every chain block time.
Flashblocks,
/// Uses the pod payload builder that builds blocks every chain block time
/// but picks transactions from an auction running on pod, selecting the highest
/// bidding transactions.
Pod,
}

/// Defines the interface for any block builder implementation API entry point.
Expand Down
20 changes: 20 additions & 0 deletions crates/op-rbuilder/src/builders/pod/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::args::OpRbuilderArgs;
use alloy_primitives::Address;

/// Configuration values that are specific to the flashblocks builder.
#[derive(Debug, Clone)]
pub struct Config {
pub rpc_url: String,
pub contract_address: Address,
}

impl TryFrom<OpRbuilderArgs> for Config {
type Error = eyre::Report;

fn try_from(args: OpRbuilderArgs) -> Result<Self, Self::Error> {
Ok(Self {
rpc_url: args.pod.pod_rpc_url,
contract_address: args.pod.pod_contract_address,
})
}
}
37 changes: 37 additions & 0 deletions crates/op-rbuilder/src/builders/pod/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use config::Config;
use payload::PodPayloadBuilderBuilder;
use reth_node_builder::components::BasicPayloadServiceBuilder;

use crate::traits::{NodeBounds, PoolBounds};

use super::BuilderConfig;

mod config;
mod payload;
mod pod_client;

/// Block building strategy that builds blocks using auction running on pod by
/// producing blocks every chain block time.
pub struct PodBuilder;

impl super::PayloadBuilder for PodBuilder {
type Config = Config;

type ServiceBuilder<Node, Pool>
= BasicPayloadServiceBuilder<PodPayloadBuilderBuilder>
where
Node: NodeBounds,
Pool: PoolBounds;

fn new_service<Node, Pool>(
config: BuilderConfig<Self::Config>,
) -> eyre::Result<Self::ServiceBuilder<Node, Pool>>
where
Node: NodeBounds,
Pool: PoolBounds,
{
Ok(BasicPayloadServiceBuilder::new(PodPayloadBuilderBuilder(
config,
)))
}
}
Loading
Loading