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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ lto = "fat"
codegen-units = 1
incremental = false

[workspace.lints.rust]
unreachable_pub = "warn"

[workspace.dependencies]
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.7.0" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", tag = "v1.7.0" }
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 @@ -8,6 +8,9 @@ homepage.workspace = true
repository.workspace = true
default-run = "op-rbuilder"

[lints]
workspace = true

[dependencies]
reth.workspace = true
reth-optimism-node.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/op-rbuilder/src/args/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use url::{Host, Url};

use super::Cli;

pub struct PlaygroundOptions {
pub(super) struct PlaygroundOptions {
/// Sets node.chain in NodeCommand
pub chain: Arc<OpChainSpec>,

Expand Down Expand Up @@ -78,7 +78,7 @@ pub struct PlaygroundOptions {

impl PlaygroundOptions {
/// Creates a new `PlaygroundOptions` instance with the specified genesis path.
pub fn new(path: &Path) -> Result<Self> {
pub(super) fn new(path: &Path) -> Result<Self> {
if !path.exists() {
return Err(eyre!(
"Playground data directory {} does not exist",
Expand Down Expand Up @@ -112,7 +112,7 @@ impl PlaygroundOptions {
})
}

pub fn apply(self, cli: Cli) -> Cli {
pub(super) fn apply(self, cli: Cli) -> Cli {
let mut cli = cli;
let Commands::Node(ref mut node) = cli.command else {
// playground defaults are only relevant if running the node commands.
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builders/builder_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub trait BuilderTx {
// Scaffolding for how to construct the end of block builder transaction
// This will be the regular end of block transaction without the TEE key
#[derive(Clone)]
pub struct StandardBuilderTx {
pub(super) struct StandardBuilderTx {
#[allow(dead_code)]
pub signer: Option<Signer>,
}
Expand Down
50 changes: 25 additions & 25 deletions crates/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use crate::{

/// Container type that holds all necessities to build a new payload.
#[derive(Debug)]
pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
pub(super) struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
/// The type that knows how to perform system calls and configure the evm.
pub evm_config: OpEvmConfig,
/// The DA config for the payload builder
Expand Down Expand Up @@ -79,41 +79,41 @@ pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {

impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
/// Returns the parent block the payload will be build on.
pub fn parent(&self) -> &SealedHeader {
pub(super) fn parent(&self) -> &SealedHeader {
&self.config.parent_header
}

/// Returns the builder attributes.
pub const fn attributes(&self) -> &OpPayloadBuilderAttributes<OpTransactionSigned> {
pub(super) const fn attributes(&self) -> &OpPayloadBuilderAttributes<OpTransactionSigned> {
&self.config.attributes
}

/// Returns the withdrawals if shanghai is active.
pub fn withdrawals(&self) -> Option<&Withdrawals> {
pub(super) fn withdrawals(&self) -> Option<&Withdrawals> {
self.chain_spec
.is_shanghai_active_at_timestamp(self.attributes().timestamp())
.then(|| &self.attributes().payload_attributes.withdrawals)
}

/// Returns the block gas limit to target.
pub fn block_gas_limit(&self) -> u64 {
pub(super) fn block_gas_limit(&self) -> u64 {
self.attributes()
.gas_limit
.unwrap_or(self.evm_env.block_env.gas_limit)
}

/// Returns the block number for the block.
pub fn block_number(&self) -> u64 {
pub(super) fn block_number(&self) -> u64 {
as_u64_saturated!(self.evm_env.block_env.number)
}

/// Returns the current base fee
pub fn base_fee(&self) -> u64 {
pub(super) fn base_fee(&self) -> u64 {
self.evm_env.block_env.basefee
}

/// Returns the current blob gas price.
pub fn get_blob_gasprice(&self) -> Option<u64> {
pub(super) fn get_blob_gasprice(&self) -> Option<u64> {
self.evm_env
.block_env
.blob_gasprice()
Expand All @@ -123,7 +123,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
/// Returns the blob fields for the header.
///
/// This will always return `Some(0)` after ecotone.
pub fn blob_fields(&self) -> (Option<u64>, Option<u64>) {
pub(super) fn blob_fields(&self) -> (Option<u64>, Option<u64>) {
// OP doesn't support blobs/EIP-4844.
// https://specs.optimism.io/protocol/exec-engine.html#ecotone-disable-blob-transactions
// Need [Some] or [None] based on hardfork to match block hash.
Expand All @@ -137,7 +137,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
/// Returns the extra data for the block.
///
/// After holocene this extracts the extradata from the paylpad
pub fn extra_data(&self) -> Result<Bytes, PayloadBuilderError> {
pub(super) fn extra_data(&self) -> Result<Bytes, PayloadBuilderError> {
if self.is_holocene_active() {
self.attributes()
.get_holocene_extra_data(
Expand All @@ -152,52 +152,52 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
}

/// Returns the current fee settings for transactions from the mempool
pub fn best_transaction_attributes(&self) -> BestTransactionsAttributes {
pub(super) fn best_transaction_attributes(&self) -> BestTransactionsAttributes {
BestTransactionsAttributes::new(self.base_fee(), self.get_blob_gasprice())
}

/// Returns the unique id for this payload job.
pub fn payload_id(&self) -> PayloadId {
pub(super) fn payload_id(&self) -> PayloadId {
self.attributes().payload_id()
}

/// Returns true if regolith is active for the payload.
pub fn is_regolith_active(&self) -> bool {
pub(super) fn is_regolith_active(&self) -> bool {
self.chain_spec
.is_regolith_active_at_timestamp(self.attributes().timestamp())
}

/// Returns true if ecotone is active for the payload.
pub fn is_ecotone_active(&self) -> bool {
pub(super) fn is_ecotone_active(&self) -> bool {
self.chain_spec
.is_ecotone_active_at_timestamp(self.attributes().timestamp())
}

/// Returns true if canyon is active for the payload.
pub fn is_canyon_active(&self) -> bool {
pub(super) fn is_canyon_active(&self) -> bool {
self.chain_spec
.is_canyon_active_at_timestamp(self.attributes().timestamp())
}

/// Returns true if holocene is active for the payload.
pub fn is_holocene_active(&self) -> bool {
pub(super) fn is_holocene_active(&self) -> bool {
self.chain_spec
.is_holocene_active_at_timestamp(self.attributes().timestamp())
}

/// Returns true if isthmus is active for the payload.
pub fn is_isthmus_active(&self) -> bool {
pub(super) fn is_isthmus_active(&self) -> bool {
self.chain_spec
.is_isthmus_active_at_timestamp(self.attributes().timestamp())
}

/// Returns the chain id
pub fn chain_id(&self) -> u64 {
pub(super) fn chain_id(&self) -> u64 {
self.chain_spec.chain_id()
}

/// Returns the builder signer
pub fn builder_signer(&self) -> Option<Signer> {
pub(super) fn builder_signer(&self) -> Option<Signer> {
self.builder_signer
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
}

/// Executes all sequencer transactions that are included in the payload attributes.
pub fn execute_sequencer_transactions<DB, E: Debug + Default>(
pub(super) fn execute_sequencer_transactions<DB, E: Debug + Default>(
&self,
state: &mut State<DB>,
) -> Result<ExecutionInfo<E>, PayloadBuilderError>
Expand Down Expand Up @@ -325,7 +325,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
/// Executes the given best transactions and updates the execution info.
///
/// Returns `Ok(Some(())` if the job was cancelled.
pub fn execute_best_transactions<DB, E: Debug + Default>(
pub(super) fn execute_best_transactions<DB, E: Debug + Default>(
&self,
info: &mut ExecutionInfo<E>,
state: &mut State<DB>,
Expand Down Expand Up @@ -567,7 +567,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
Ok(None)
}

pub fn add_builder_tx<DB, Extra: Debug + Default>(
pub(super) fn add_builder_tx<DB, Extra: Debug + Default>(
&self,
info: &mut ExecutionInfo<Extra>,
state: &mut State<DB>,
Expand Down Expand Up @@ -628,7 +628,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
/// Calculates EIP 2718 builder transaction size
// TODO: this function could be improved, ideally we shouldn't take mut ref to db and maybe
// it's possible to do this without db at all
pub fn estimate_builder_tx_da_size<DB>(
pub(super) fn estimate_builder_tx_da_size<DB>(
&self,
state: &mut State<DB>,
builder_tx_gas: u64,
Expand Down Expand Up @@ -656,7 +656,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
}
}

pub fn estimate_gas_for_builder_tx(input: Vec<u8>) -> u64 {
pub(super) fn estimate_gas_for_builder_tx(input: Vec<u8>) -> u64 {
// Count zero and non-zero bytes
let (zero_bytes, nonzero_bytes) = input.iter().fold((0, 0), |(zeros, nonzeros), &byte| {
if byte == 0 {
Expand All @@ -678,7 +678,7 @@ pub fn estimate_gas_for_builder_tx(input: Vec<u8>) -> u64 {
}

/// Creates signed builder tx to Address::ZERO and specified message as input
pub fn signed_builder_tx<DB>(
pub(super) fn signed_builder_tx<DB>(
state: &mut State<DB>,
builder_tx_gas: u64,
message: Vec<u8>,
Expand Down
8 changes: 4 additions & 4 deletions crates/op-rbuilder/src/builders/flashblocks/best_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tracing::debug;

use crate::tx::MaybeFlashblockFilter;

pub struct BestFlashblocksTxs<T, I>
pub(super) struct BestFlashblocksTxs<T, I>
where
T: PoolTransaction,
I: PayloadTransactions<Transaction = T>,
Expand All @@ -23,7 +23,7 @@ where
T: PoolTransaction,
I: PayloadTransactions<Transaction = T>,
{
pub fn new(inner: I) -> Self {
pub(super) fn new(inner: I) -> Self {
Self {
inner,
current_flashblock_number: 0,
Expand All @@ -33,13 +33,13 @@ where

/// Replaces current iterator with new one. We use it on new flashblock building, to refresh
/// priority boundaries
pub fn refresh_iterator(&mut self, inner: I, current_flashblock_number: u64) {
pub(super) fn refresh_iterator(&mut self, inner: I, current_flashblock_number: u64) {
self.inner = inner;
self.current_flashblock_number = current_flashblock_number;
}

/// Remove transaction from next iteration and it already in the state
pub fn mark_commited(&mut self, txs: Vec<TxHash>) {
pub(super) fn mark_commited(&mut self, txs: Vec<TxHash>) {
self.commited_transactions.extend(txs);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builders/flashblocks/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
}
}

pub trait FlashBlocksConfigExt {
pub(super) trait FlashBlocksConfigExt {
fn flashblocks_per_block(&self) -> u64;
}

Expand Down
20 changes: 10 additions & 10 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,36 @@ struct FlashblocksExtraCtx {

impl OpPayloadBuilderCtx<FlashblocksExtraCtx> {
/// Returns the current flashblock index
pub fn flashblock_index(&self) -> u64 {
pub(crate) fn flashblock_index(&self) -> u64 {
self.extra_ctx.flashblock_index
}

/// Returns the target flashblock count
pub fn target_flashblock_count(&self) -> u64 {
pub(crate) fn target_flashblock_count(&self) -> u64 {
self.extra_ctx.target_flashblock_count
}

/// Increments the flashblock index
pub fn increment_flashblock_index(&mut self) -> u64 {
pub(crate) fn increment_flashblock_index(&mut self) -> u64 {
self.extra_ctx.flashblock_index += 1;
self.extra_ctx.flashblock_index
}

/// Sets the target flashblock count
pub fn set_target_flashblock_count(&mut self, target_flashblock_count: u64) -> u64 {
pub(crate) fn set_target_flashblock_count(&mut self, target_flashblock_count: u64) -> u64 {
self.extra_ctx.target_flashblock_count = target_flashblock_count;
self.extra_ctx.target_flashblock_count
}

/// Returns if the flashblock is the last one
pub fn is_last_flashblock(&self) -> bool {
pub(crate) fn is_last_flashblock(&self) -> bool {
self.flashblock_index() == self.target_flashblock_count() - 1
}
}

/// Optimism's payload builder
#[derive(Debug, Clone)]
pub struct OpPayloadBuilder<Pool, Client, BT> {
pub(super) struct OpPayloadBuilder<Pool, Client, BT> {
/// The type responsible for creating the evm.
pub evm_config: OpEvmConfig,
/// The transaction pool
Expand All @@ -125,7 +125,7 @@ pub struct OpPayloadBuilder<Pool, Client, BT> {

impl<Pool, Client, BT> OpPayloadBuilder<Pool, Client, BT> {
/// `OpPayloadBuilder` constructor.
pub fn new(
pub(super) fn new(
evm_config: OpEvmConfig,
pool: Pool,
client: Client,
Expand Down Expand Up @@ -646,7 +646,7 @@ where
}

/// Sends built payload via payload builder handle broadcast channel to the engine
pub fn send_payload_to_engine(&self, payload: OpBuiltPayload) {
pub(super) fn send_payload_to_engine(&self, payload: OpBuiltPayload) {
// Send built payload as created one
match self.payload_builder_handle.get() {
Some(handle) => {
Expand All @@ -666,7 +666,7 @@ where

/// Spawn task that will send new flashblock level cancel token in steady intervals (first interval
/// may vary if --flashblocks.dynamic enabled)
pub fn spawn_timer_task(
pub(super) fn spawn_timer_task(
&self,
block_cancel: CancellationToken,
fb_cancel_token_tx: Sender<Option<CancellationToken>>,
Expand Down Expand Up @@ -713,7 +713,7 @@ where

/// Calculate number of flashblocks.
/// If dynamic is enabled this function will take time drift into the account.
pub fn calculate_flashblocks(&self, timestamp: u64) -> (u64, Duration) {
pub(super) fn calculate_flashblocks(&self, timestamp: u64) -> (u64, Duration) {
if self.config.specific.fixed {
return (
self.config.flashblocks_per_block(),
Expand Down
6 changes: 3 additions & 3 deletions crates/op-rbuilder/src/builders/flashblocks/wspub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ use crate::metrics::OpRBuilderMetrics;
/// updates about new flashblocks. It maintains a count of sent messages and active subscriptions.
///
/// This is modelled as a `futures::Sink` that can be used to send `FlashblocksPayloadV1` messages.
pub struct WebSocketPublisher {
pub(super) struct WebSocketPublisher {
sent: Arc<AtomicUsize>,
subs: Arc<AtomicUsize>,
term: watch::Sender<bool>,
pipe: broadcast::Sender<Utf8Bytes>,
}

impl WebSocketPublisher {
pub fn new(addr: SocketAddr, metrics: Arc<OpRBuilderMetrics>) -> io::Result<Self> {
pub(super) fn new(addr: SocketAddr, metrics: Arc<OpRBuilderMetrics>) -> io::Result<Self> {
let (pipe, _) = broadcast::channel(100);
let (term, _) = watch::channel(false);

Expand All @@ -61,7 +61,7 @@ impl WebSocketPublisher {
})
}

pub fn publish(&self, payload: &FlashblocksPayloadV1) -> io::Result<usize> {
pub(super) fn publish(&self, payload: &FlashblocksPayloadV1) -> io::Result<usize> {
// Serialize the payload to a UTF-8 string
// serialize only once, then just copy around only a pointer
// to the serialized data for each subscription.
Expand Down
Loading
Loading