Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace.package]
version = "0.1.0"
edition = "2021"
edition = "2024"
rust-version = "1.86"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/flashbots/op-rbuilder"
Expand Down
5 changes: 1 addition & 4 deletions crates/op-rbuilder/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ impl CliExt for Cli {
return self;
};

let options = match PlaygroundOptions::new(playground_dir) {
Ok(options) => options,
Err(e) => exit(e),
};
let options = PlaygroundOptions::new(playground_dir).unwrap_or_else(|e| exit(e));

options.apply(self)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! clap [Args](clap::Args) for optimism rollup configuration

use crate::{flashtestations::args::FlashtestationsArgs, tx_signer::Signer};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use clap::Parser;
use reth_optimism_cli::commands::Commands;
use reth_optimism_node::args::RollupArgs;
Expand Down
4 changes: 2 additions & 2 deletions crates/op-rbuilder/src/args/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
//! configurations.

use alloy_primitives::hex;
use clap::{parser::ValueSource, CommandFactory};
use clap::{CommandFactory, parser::ValueSource};
use core::{
net::{IpAddr, Ipv4Addr, SocketAddr},
ops::Range,
time::Duration,
};
use eyre::{eyre, Result};
use eyre::{Result, eyre};
use reth_cli::chainspec::ChainSpecParser;
use reth_network_peers::TrustedPeer;
use reth_optimism_chainspec::OpChainSpec;
Expand Down
36 changes: 18 additions & 18 deletions crates/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_consensus::{
conditional::BlockConditionalAttributes, Eip658Value, Transaction, TxEip1559,
Eip658Value, Transaction, TxEip1559, conditional::BlockConditionalAttributes,
};
use alloy_eips::{eip7623::TOTAL_COST_FLOOR_PER_TOKEN, Encodable2718, Typed2718};
use alloy_eips::{Encodable2718, Typed2718, eip7623::TOTAL_COST_FLOOR_PER_TOKEN};
use alloy_op_evm::block::receipt_builder::OpReceiptBuilder;
use alloy_primitives::{Address, Bytes, TxKind, U256};
use alloy_rpc_types_eth::Withdrawals;
Expand All @@ -12,7 +12,7 @@ use reth::payload::PayloadBuilderAttributes;
use reth_basic_payload_builder::PayloadConfig;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_evm::{
eth::receipt_builder::ReceiptBuilderCtx, ConfigureEvm, Evm, EvmEnv, EvmError, InvalidTxError,
ConfigureEvm, Evm, EvmEnv, EvmError, InvalidTxError, eth::receipt_builder::ReceiptBuilderCtx,
};
use reth_node_api::PayloadBuilderError;
use reth_optimism_chainspec::OpChainSpec;
Expand All @@ -24,16 +24,16 @@ use reth_optimism_primitives::{OpReceipt, OpTransactionSigned};
use reth_optimism_txpool::{
conditional::MaybeConditionalTransaction,
estimated_da_size::DataAvailabilitySized,
interop::{is_valid_interop, MaybeInteropTransaction},
interop::{MaybeInteropTransaction, is_valid_interop},
};
use reth_payload_builder::PayloadId;
use reth_primitives::{Recovered, SealedHeader};
use reth_primitives_traits::{InMemorySize, SignedTransaction};
use reth_provider::ProviderError;
use reth_revm::{context::Block, State};
use reth_revm::{State, context::Block};
use reth_transaction_pool::{BestTransactionsAttributes, PoolTransaction};
use revm::{
context::result::ResultAndState, interpreter::as_u64_saturated, Database, DatabaseCommit,
Database, DatabaseCommit, context::result::ResultAndState, interpreter::as_u64_saturated,
};
use std::{sync::Arc, time::Instant};
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -397,24 +397,24 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {

num_txs_considered += 1;

if let Some(conditional) = conditional {
// TODO: ideally we should get this from the txpool stream
if !conditional.matches_block_attributes(&block_attr) {
best_txs.mark_invalid(tx.signer(), tx.nonce());
continue;
}
// TODO: ideally we should get this from the txpool stream
if let Some(conditional) = conditional
&& !conditional.matches_block_attributes(&block_attr)
{
best_txs.mark_invalid(tx.signer(), tx.nonce());
continue;
}

// TODO: remove this condition and feature once we are comfortable enabling interop for everything
if cfg!(feature = "interop") {
// We skip invalid cross chain txs, they would be removed on the next block update in
// the maintenance job
if let Some(interop) = interop {
if !is_valid_interop(interop, self.config.attributes.timestamp()) {
log_txn(TxnExecutionResult::InteropFailed);
best_txs.mark_invalid(tx.signer(), tx.nonce());
continue;
}
if let Some(interop) = interop
&& !is_valid_interop(interop, self.config.attributes.timestamp())
{
log_txn(TxnExecutionResult::InteropFailed);
best_txs.mark_invalid(tx.signer(), tx.nonce());
continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builders/flashblocks/best_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod tests {
};
use alloy_consensus::Transaction;
use reth_payload_util::{BestPayloadTransactions, PayloadTransactions};
use reth_transaction_pool::{pool::PendingPool, CoinbaseTipOrdering, PoolTransaction};
use reth_transaction_pool::{CoinbaseTipOrdering, PoolTransaction, pool::PendingPool};
use std::sync::Arc;

#[test]
Expand Down
24 changes: 14 additions & 10 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
use super::{config::FlashblocksConfig, wspub::WebSocketPublisher};
use crate::{
builders::{
context::{estimate_gas_for_builder_tx, OpPayloadBuilderCtx},
BuilderConfig, BuilderTx,
context::{OpPayloadBuilderCtx, estimate_gas_for_builder_tx},
flashblocks::{best_txs::BestFlashblocksTxs, config::FlashBlocksConfigExt},
generator::{BlockCell, BuildArguments},
BuilderConfig, BuilderTx,
},
metrics::OpRBuilderMetrics,
primitives::reth::ExecutionInfo,
traits::{ClientBounds, PoolBounds},
};
use alloy_consensus::{
constants::EMPTY_WITHDRAWALS, proofs, BlockBody, Header, EMPTY_OMMER_ROOT_HASH,
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, constants::EMPTY_WITHDRAWALS, proofs,
};
use alloy_eips::{eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE, Encodable2718};
use alloy_primitives::{map::foldhash::HashMap, Address, B256, U256};
use alloy_eips::{Encodable2718, eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
use alloy_primitives::{Address, B256, U256, map::foldhash::HashMap};
use core::time::Duration;
use reth::payload::PayloadBuilderAttributes;
use reth_basic_payload_builder::BuildOutcome;
use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates, ExecutedTrieUpdates};
use reth_evm::{execute::BlockBuilder, ConfigureEvm};
use reth_evm::{ConfigureEvm, execute::BlockBuilder};
use reth_node_api::{Block, NodePrimitives, PayloadBuilderError};
use reth_optimism_consensus::{calculate_receipt_root_no_memo_optimism, isthmus};
use reth_optimism_evm::{OpEvmConfig, OpNextBlockEnvAttributes};
Expand All @@ -34,7 +34,7 @@ use reth_provider::{
StorageRootProvider,
};
use reth_revm::{
database::StateProviderDatabase, db::states::bundle_state::BundleRetention, State,
State, database::StateProviderDatabase, db::states::bundle_state::BundleRetention,
};
use revm::Database;
use rollup_boost::{
Expand All @@ -48,7 +48,7 @@ use std::{
};
use tokio::sync::{
mpsc,
mpsc::{error::SendError, Sender},
mpsc::{Sender, error::SendError},
};
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, metadata::Level, span, warn};
Expand Down Expand Up @@ -362,7 +362,9 @@ where
if let Some(da_limit) = da_per_batch {
// We error if we can't insert any tx aside from builder tx in flashblock
if da_limit / 2 < builder_tx_da_size {
error!("Builder tx da size subtraction caused max_da_block_size to be 0. No transaction would be included.");
error!(
"Builder tx da size subtraction caused max_da_block_size to be 0. No transaction would be included."
);
}
}
let mut total_da_per_batch = da_per_batch;
Expand Down Expand Up @@ -568,7 +570,9 @@ where
if let Some(da) = total_da_per_batch.as_mut() {
*da += da_limit;
} else {
error!("Builder end up in faulty invariant, if da_per_batch is set then total_da_per_batch must be set");
error!(
"Builder end up in faulty invariant, if da_per_batch is set then total_da_per_batch must be set"
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/op-rbuilder/src/builders/flashblocks/service.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use super::{payload::OpPayloadBuilder, FlashblocksConfig};
use super::{FlashblocksConfig, payload::OpPayloadBuilder};
use crate::{
builders::{
builder_tx::StandardBuilderTx, generator::BlockPayloadJobGenerator, BuilderConfig,
BuilderTx,
BuilderConfig, BuilderTx, builder_tx::StandardBuilderTx,
generator::BlockPayloadJobGenerator,
},
flashtestations::service::spawn_flashtestations_service,
traits::{NodeBounds, PoolBounds},
};
use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig;
use reth_node_api::NodeTypes;
use reth_node_builder::{components::PayloadServiceBuilder, BuilderContext};
use reth_node_builder::{BuilderContext, components::PayloadServiceBuilder};
use reth_optimism_evm::OpEvmConfig;
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_provider::CanonStateSubscriptions;
Expand Down
5 changes: 2 additions & 3 deletions crates/op-rbuilder/src/builders/flashblocks/wspub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ use std::{io, net::TcpListener, sync::Arc};
use tokio::{
net::TcpStream,
sync::{
broadcast::{self, error::RecvError, Receiver},
broadcast::{self, Receiver, error::RecvError},
watch,
},
};
use tokio_tungstenite::{
accept_async,
WebSocketStream, accept_async,
tungstenite::{Message, Utf8Bytes},
WebSocketStream,
};
use tracing::{debug, warn};

Expand Down
8 changes: 4 additions & 4 deletions crates/op-rbuilder/src/builders/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
use tokio::{
sync::{oneshot, Notify},
sync::{Notify, oneshot},
time::{Duration, Sleep},
};
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -471,14 +471,14 @@ mod tests {
use reth::tasks::TokioTaskExecutor;
use reth_chain_state::ExecutedBlockWithTrieUpdates;
use reth_node_api::NodePrimitives;
use reth_optimism_payload_builder::{payload::OpPayloadBuilderAttributes, OpPayloadPrimitives};
use reth_optimism_payload_builder::{OpPayloadPrimitives, payload::OpPayloadBuilderAttributes};
use reth_optimism_primitives::OpPrimitives;
use reth_primitives::SealedBlock;
use reth_provider::test_utils::MockEthProvider;
use reth_testing_utils::generators::{random_block_range, BlockRangeParams};
use reth_testing_utils::generators::{BlockRangeParams, random_block_range};
use tokio::{
task,
time::{sleep, Duration},
time::{Duration, sleep},
};

#[tokio::test]
Expand Down
12 changes: 6 additions & 6 deletions crates/op-rbuilder/src/builders/standard/payload.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use crate::{
builders::{generator::BuildArguments, BuilderConfig},
builders::{BuilderConfig, generator::BuildArguments},
flashtestations::service::spawn_flashtestations_service,
metrics::OpRBuilderMetrics,
primitives::reth::ExecutionInfo,
traits::{ClientBounds, NodeBounds, PayloadTxsBounds, PoolBounds},
};
use alloy_consensus::{
constants::EMPTY_WITHDRAWALS, proofs, BlockBody, Header, EMPTY_OMMER_ROOT_HASH,
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, constants::EMPTY_WITHDRAWALS, proofs,
};
use alloy_eips::{eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
use alloy_primitives::U256;
use reth::payload::PayloadBuilderAttributes;
use reth_basic_payload_builder::{BuildOutcome, BuildOutcomeKind, MissingPayloadBehaviour};
use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates, ExecutedTrieUpdates};
use reth_evm::{execute::BlockBuilder, ConfigureEvm};
use reth_evm::{ConfigureEvm, execute::BlockBuilder};
use reth_node_api::{Block, PayloadBuilderError};
use reth_node_builder::{components::PayloadBuilderBuilder, BuilderContext};
use reth_node_builder::{BuilderContext, components::PayloadBuilderBuilder};
use reth_optimism_consensus::{calculate_receipt_root_no_memo_optimism, isthmus};
use reth_optimism_evm::{OpEvmConfig, OpNextBlockEnvAttributes};
use reth_optimism_forks::OpHardforks;
Expand All @@ -28,7 +28,7 @@ use reth_provider::{
StorageRootProvider,
};
use reth_revm::{
database::StateProviderDatabase, db::states::bundle_state::BundleRetention, State,
State, database::StateProviderDatabase, db::states::bundle_state::BundleRetention,
};
use reth_transaction_pool::{
BestTransactions, BestTransactionsAttributes, PoolTransaction, TransactionPool,
Expand All @@ -38,7 +38,7 @@ use std::{sync::Arc, time::Instant};
use tokio_util::sync::CancellationToken;
use tracing::{error, info, warn};

use super::super::context::{estimate_gas_for_builder_tx, OpPayloadBuilderCtx};
use super::super::context::{OpPayloadBuilderCtx, estimate_gas_for_builder_tx};

pub struct StandardPayloadBuilderBuilder(pub BuilderConfig<()>);

Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/flashtestations/args.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{utils::parse_ether, Address, U256};
use alloy_primitives::{Address, U256, utils::parse_ether};

use crate::tx_signer::Signer;

Expand Down
4 changes: 2 additions & 2 deletions crates/op-rbuilder/src/flashtestations/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use tracing::{info, warn};
use crate::{
builders::BuilderTx,
traits::NodeBounds,
tx_signer::{generate_ethereum_keypair, Signer},
tx_signer::{Signer, generate_ethereum_keypair},
};

use super::{
args::FlashtestationsArgs,
attestation::{get_attestation_provider, AttestationConfig, AttestationProvider},
attestation::{AttestationConfig, AttestationProvider, get_attestation_provider},
tx_manager::TxManager,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/op-rbuilder/src/flashtestations/tx_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_consensus::TxEip1559;
use alloy_eips::Encodable2718;
use alloy_network::ReceiptResponse;
use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256};
use alloy_primitives::{Address, B256, Bytes, TxHash, TxKind, U256, keccak256};
use alloy_rpc_types_eth::TransactionRequest;
use alloy_transport::TransportResult;
use op_alloy_consensus::OpTypedTransaction;
Expand All @@ -12,7 +12,7 @@ use std::time::Duration;

use alloy_provider::{PendingTransactionBuilder, Provider, ProviderBuilder};
use alloy_signer_local::PrivateKeySigner;
use alloy_sol_types::{sol, SolCall, SolValue};
use alloy_sol_types::{SolCall, SolValue, sol};
use op_alloy_network::Optimism;
use tracing::{debug, error, info};

Expand Down
4 changes: 2 additions & 2 deletions crates/op-rbuilder/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use reth_optimism_rpc::OpEthApiBuilder;
use crate::{
args::*,
builders::{BuilderConfig, BuilderMode, FlashblocksBuilder, PayloadBuilder, StandardBuilder},
metrics::{record_flag_gauge_metrics, VERSION},
metrics::{VERSION, record_flag_gauge_metrics},
monitor_tx_pool::monitor_tx_pool,
primitives::reth::engine_api_builder::OpEngineApiBuilder,
revert_protection::{EthApiExtServer, RevertProtectionExt},
Expand All @@ -18,8 +18,8 @@ use reth_db::mdbx::DatabaseEnv;
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_cli::chainspec::OpChainSpecParser;
use reth_optimism_node::{
node::{OpAddOns, OpAddOnsBuilder, OpEngineValidatorBuilder, OpPoolBuilder},
OpNode,
node::{OpAddOns, OpAddOnsBuilder, OpEngineValidatorBuilder, OpPoolBuilder},
};
use reth_transaction_pool::TransactionPool;
use std::{marker::PhantomData, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use metrics::IntoF64;
use reth_metrics::{
metrics::{gauge, Counter, Gauge, Histogram},
Metrics,
metrics::{Counter, Gauge, Histogram, gauge},
};

use crate::args::OpRbuilderArgs;
Expand Down
Loading
Loading