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
25 changes: 25 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion crates/builder/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ workspace = true

[dependencies]
base-bundles.workspace = true
base-primitives = { workspace = true, features = ["op-rbuilder"] }
base-flashtypes.workspace = true

reth-optimism-node.workspace = true
Expand Down Expand Up @@ -59,6 +60,7 @@ reth-optimism-rpc.workspace = true
reth-tasks.workspace = true
reth-tracing-otlp = { workspace = true, optional = true }


alloy-primitives.workspace = true
alloy-consensus.workspace = true
alloy-contract.workspace = true
Expand Down Expand Up @@ -199,7 +201,7 @@ testing = [

interop = []

telemetry = [ "opentelemetry", "reth-tracing-otlp" ]
telemetry = [ "opentelemetry", "dep:reth-tracing-otlp" ]

custom-engine-api = []

Expand Down
5 changes: 2 additions & 3 deletions crates/builder/op-rbuilder/src/builders/builder_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ use revm::{
};
use tracing::{trace, warn};

use crate::{
builders::context::OpPayloadBuilderCtx, primitives::reth::ExecutionInfo, tx_signer::Signer,
};
use crate::{builders::context::OpPayloadBuilderCtx, tx_signer::Signer};
use base_primitives::op_rbuilder::reth::ExecutionInfo;

#[derive(Debug, Default)]
pub struct SimulationSuccessResult<T: SolCall> {
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ use tracing::{debug, info, trace};
use crate::{
gas_limiter::AddressGasLimiter,
metrics::OpRBuilderMetrics,
primitives::reth::{ExecutionInfo, TxnExecutionResult},
traits::PayloadTxsBounds,
tx::MaybeRevertingTransaction,
tx_data_store::{TxData, TxDataStore},
tx_signer::Signer,
};
use base_primitives::op_rbuilder::reth::{ExecutionInfo, TxnExecutionResult};

/// Container type that holds all necessities to build a new payload.
#[derive(Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use crate::{
get_nonce,
},
flashtestations::builder_tx::FlashtestationsBuilderTx,
primitives::reth::ExecutionInfo,
tx_signer::Signer,
};
use base_primitives::op_rbuilder::reth::ExecutionInfo;

sol!(
// From https://github.com/Uniswap/flashblocks_number_contract/blob/main/src/FlashblockNumber.sol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
sync::Arc,
time::Instant,
};

use alloy_consensus::{
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, constants::EMPTY_WITHDRAWALS, proofs,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::{
builder_tx::BuilderTxBase, context::OpPayloadBuilderCtx,
},
flashtestations::builder_tx::FlashtestationsBuilderTx,
primitives::reth::ExecutionInfo,
tx_signer::Signer,
};
use base_primitives::op_rbuilder::reth::ExecutionInfo;

// This will be the end of block transaction of a regular block
#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{sync::Arc, time::Instant};

use alloy_consensus::{
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, constants::EMPTY_WITHDRAWALS, proofs,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use crate::{
IERC20Permit,
IFlashtestationRegistry::{self, TEEServiceRegistered},
},
primitives::reth::ExecutionInfo,
tx_signer::Signer,
};
use base_primitives::op_rbuilder::reth::ExecutionInfo;

#[derive(Debug)]
pub struct FlashtestationsBuilderTxArgs {
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use crate::{
builders::{BuilderConfig, PayloadBuilder},
metrics::{VERSION, record_flag_gauge_metrics},
monitor_tx_pool::monitor_tx_pool,
primitives::reth::engine_api_builder::OpEngineApiBuilder,
revert_protection::{EthApiExtServer, RevertProtectionExt},
tx::FBPooledTransaction,
tx_data_store::{BaseApiExtServer, TxDataStoreExt},
};
use base_primitives::op_rbuilder::reth::engine_api_builder::OpEngineApiBuilder;

/// Launcher for the OP builder node.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod gas_limiter;
pub mod launcher;
pub mod metrics;
mod monitor_tx_pool;
pub mod primitives;
pub mod revert_protection;
pub mod telemetry;
pub mod traits;
pub mod tx;
pub mod tx_data_store;
Expand Down
4 changes: 0 additions & 4 deletions crates/builder/op-rbuilder/src/primitives/mod.rs

This file was deleted.

9 changes: 4 additions & 5 deletions crates/builder/op-rbuilder/src/revert_protection.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{sync::Arc, time::Instant};

use alloy_json_rpc::RpcObject;
use alloy_primitives::B256;
use base_primitives::op_rbuilder::bundle::{Bundle, BundleConditionalExt, BundleResult};
use jsonrpsee::{
core::{RpcResult, async_trait},
proc_macros::rpc,
Expand All @@ -16,7 +16,6 @@ use tracing::error;

use crate::{
metrics::OpRBuilderMetrics,
primitives::bundle::{Bundle, BundleResult},
tx::{FBPooledTransaction, MaybeFlashblockFilter, MaybeRevertingTransaction},
};

Expand Down Expand Up @@ -117,14 +116,14 @@ where
self.provider.best_block_number().map_err(|_e| EthApiError::InternalEthError)?;

// Only one transaction in the bundle is expected
let bundle_transaction = match bundle.transactions.len() {
let bundle_transaction = match bundle.txs.len() {
0 => {
return Err(EthApiError::InvalidParams(
"bundle must contain at least one transaction".into(),
)
.into());
}
1 => bundle.transactions[0].clone(),
1 => bundle.txs[0].clone(),
_ => {
return Err(EthApiError::InvalidParams(
"bundle must contain exactly one transaction".into(),
Expand All @@ -138,7 +137,7 @@ where
let recovered = recover_raw_transaction(&bundle_transaction)?;
let pool_transaction =
FBPooledTransaction::from(OpPooledTransaction::from_pooled(recovered))
.with_reverted_hashes(bundle.reverting_hashes.clone().unwrap_or_default())
.with_reverted_hashes(bundle.reverting_tx_hashes.clone())
.with_flashblock_number_min(conditional.flashblock_number_min)
.with_flashblock_number_max(conditional.flashblock_number_max)
.with_conditional(conditional.transaction_conditional);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use tracing_subscriber::{Layer, filter::Targets};
use url::Url;

#[cfg(feature = "telemetry")]
use crate::args::TelemetryArgs;
#[cfg(feature = "telemetry")]
use tracing_subscriber::{filter::Targets, Layer};
#[cfg(feature = "telemetry")]
use url::Url;

/// Setup telemetry layer with sampling and custom endpoint configuration
#[cfg(feature = "telemetry")]
pub fn setup_telemetry_layer(
args: &TelemetryArgs,
) -> eyre::Result<impl Layer<tracing_subscriber::Registry>> {
Expand All @@ -13,26 +16,20 @@ pub fn setup_telemetry_layer(
return Err(eyre::eyre!("OTLP endpoint is not set"));
}

// Otlp uses evn vars inside

if let Some(headers) = &args.otlp_headers {
unsafe { std::env::set_var("OTEL_EXPORTER_OTLP_HEADERS", headers) };
}

// Create OTLP layer with custom configuration
let otlp_layer = reth_tracing_otlp::span_layer(
"op-rbuilder",
&Url::parse(args.otlp_endpoint.as_ref().unwrap()).expect("Invalid OTLP endpoint"),
reth_tracing_otlp::OtlpProtocol::Http,
)?;

// Create a trace filter that sends more data to OTLP but less to stdout
let trace_filter = Targets::new()
.with_default(LevelFilter::WARN)
.with_target("op_rbuilder", LevelFilter::INFO)
.with_target("payload_builder", LevelFilter::DEBUG);

let filtered_layer = otlp_layer.with_filter(trace_filter);

Ok(filtered_layer)
}
Ok(otlp_layer.with_filter(trace_filter))
}
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/tests/framework/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ use tokio_util::sync::CancellationToken;
use crate::{
args::OpRbuilderArgs,
builders::{BuilderConfig, FlashblocksBuilder, PayloadBuilder, StandardBuilder},
primitives::reth::engine_api_builder::OpEngineApiBuilder,
revert_protection::{EthApiExtServer, RevertProtectionExt},
tests::{
EngineApi, Ipc, TEE_DEBUG_ADDRESS, TransactionPoolObserver, builder_signer, create_test_db,
Expand All @@ -55,6 +54,7 @@ use crate::{
tx_data_store::TxDataStore,
tx_signer::Signer,
};
use base_primitives::op_rbuilder::reth::engine_api_builder::OpEngineApiBuilder;

/// Clears OTEL-related environment variables that can interfere with CLI argument parsing.
/// This is necessary because clap reads env vars for args with `env = "..."` attributes,
Expand Down
29 changes: 18 additions & 11 deletions crates/builder/op-rbuilder/src/tests/framework/txs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use core::cmp::max;
use std::{collections::VecDeque, sync::Arc};

use crate::{tests::funded_signer, tx::FBPooledTransaction, tx_signer::Signer};
use alloy_consensus::TxEip1559;
use alloy_eips::{BlockNumberOrTag, eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718};
use alloy_primitives::{Address, B256, Bytes, TxHash, TxKind, U256, hex};
use alloy_provider::{PendingTransactionBuilder, Provider, RootProvider};
use base_primitives::op_rbuilder::bundle::{Bundle, BundleResult};
use dashmap::DashMap;
use futures::StreamExt;
use moka::future::Cache;
Expand All @@ -15,12 +16,7 @@ use reth_transaction_pool::{AllTransactionsEvents, FullTransactionEvent, Transac
use tokio::sync::watch;
use tracing::debug;

use crate::{
primitives::bundle::{Bundle, BundleResult},
tests::funded_signer,
tx::FBPooledTransaction,
tx_signer::Signer,
};
// local test helpers

#[derive(Clone, Copy, Default, Debug)]
pub struct BundleOpts {
Expand Down Expand Up @@ -202,15 +198,26 @@ impl TransactionBuilder {

if let Some(bundle_opts) = bundle_opts {
// Send the transaction as a bundle with the bundle options
// Map the test `BundleOpts` into the API `Bundle` shape.
let block_number = if let Some(max) = bundle_opts.block_number_max {
// prefer explicit max (target) when provided
max
} else if let Some(min) = bundle_opts.block_number_min {
// otherwise use min as the target
min
} else {
0u64
};

let bundle = Bundle {
transactions: vec![transaction_encoded.into()],
reverting_hashes: if with_reverted_hash { Some(vec![txn_hash]) } else { None },
block_number_min: bundle_opts.block_number_min,
block_number_max: bundle_opts.block_number_max,
txs: vec![transaction_encoded.into()],
block_number,
flashblock_number_min: bundle_opts.flashblock_number_min,
flashblock_number_max: bundle_opts.flashblock_number_max,
min_timestamp: bundle_opts.min_timestamp,
max_timestamp: bundle_opts.max_timestamp,
reverting_tx_hashes: if with_reverted_hash { vec![txn_hash] } else { vec![] },
..Default::default()
};

let result: BundleResult =
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/tests/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use op_alloy_network::Optimism;

use crate::{
args::OpRbuilderArgs,
primitives::bundle::MAX_BLOCK_RANGE_BLOCKS,
tests::{
BlockTransactionsExt, BundleOpts, ChainDriver, ChainDriverExt, LocalInstance, ONE_ETH,
OpRbuilderArgsTestExt, TransactionBuilderExt,
},
};
use base_primitives::op_rbuilder::bundle::MAX_BLOCK_RANGE_BLOCKS;

/// This test ensures that the transactions that get reverted and not included in the block,
/// are eventually dropped from the pool once their block range is reached.
Expand Down
Loading