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
47 changes: 46 additions & 1 deletion .github/workflows/sanity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ jobs:
- name: Run Clippy with stable
run: cargo clippy --all-targets --all-features -- -D warnings

clippy-no-default:
name: Clippy (no default features)
runs-on: warp-ubuntu-latest-x64-32x
steps:
- uses: actions/checkout@v5
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-stable-${{ hashFiles('**/Cargo.lock') }}
- name: Set up Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- name: Run Clippy with stable
run: cargo clippy --all-targets --no-default-features -- -D warnings

typos:
name: Typos
runs-on: warp-ubuntu-latest-x64-32x
Expand Down Expand Up @@ -81,4 +103,27 @@ jobs:
toolchain: stable
override: true
- name: Run tests with stable
run: cargo test --all-targets --all-features
run: cargo test --all-targets --all-features

doc:
name: Docs
runs-on: warp-ubuntu-latest-x64-32x
steps:
- uses: actions/checkout@v5
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-stable-${{ hashFiles('**/Cargo.lock') }}
- name: Set up Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --document-private-items --all-features --examples
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod steps;
/// Orderpool utils
pub mod orderpool2;

/// Externally available test utilities
// Externally available test utilities
#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils;

Expand Down
20 changes: 9 additions & 11 deletions src/orderpool2/prioritized_pool/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@ use {
crate::{
alloy::{
consensus::Transaction,
consensus::transaction::Recovered,
primitives::{Address, B256},
},
orderpool2::{AccountNonce, BundleNonce},
payload::CheckpointExt,
platform::types::Transaction as PlatformTransaction,
prelude::{
Bundle,
Checkpoint,
ControlFlow,
Optimism,
Platform,
Step,
StepContext,
},
prelude::{Bundle, Checkpoint, ControlFlow, Platform, Step, StepContext},
reth,
},
parking_lot::Mutex,
Expand All @@ -34,6 +24,13 @@ use {
},
};

#[cfg(feature = "optimism")]
use crate::{
alloy::consensus::transaction::Recovered,
platform::types::Transaction as PlatformTransaction,
prelude::Optimism,
};

#[derive(Clone)]
pub struct BundleWithNonces<B, P> {
bundle: B,
Expand Down Expand Up @@ -84,6 +81,7 @@ where
}
}

#[cfg(feature = "optimism")]
impl OrderpoolOrder for Recovered<PlatformTransaction<Optimism>> {
type ID = B256;

Expand Down
3 changes: 1 addition & 2 deletions src/payload/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ impl<P: Platform> BlockContext<P> {
/// [`StateProviderFactory::state_by_block_hash`]
/// - The chainspec of the chain we're building for.
///
/// [`PayloadJobGenerator::new_payload_job`]: reth_payload_builder::PayloadJobGenerator::new_payload_job
/// [`StateProviderFactory::state_by_block_hash`]: reth::providers::StateProviderFactory::state_by_block_hash
/// [`PayloadJobGenerator::new_payload_job`]: crate::reth::payload::builder::PayloadJobGenerator::new_payload_job
pub fn new(
parent: SealedHeader<types::Header<P>>,
attribs: types::PayloadBuilderAttributes<P>,
Expand Down
16 changes: 11 additions & 5 deletions src/payload/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<P: Platform> Executable<P> {
/// executable is invalid, no execution result will be produced.
///
/// For details on what makes an executable invalid see the
/// [`execute_transaction`] and [`execute_bundle`] methods.
/// [`Self::execute_transaction`] and [`Self::execute_bundle`] methods.
pub fn execute<DB>(
self,
block: &BlockContext<P>,
Expand Down Expand Up @@ -97,8 +97,11 @@ impl<P: Platform> Executable<P> {
/// - Transactions that fail gracefully (revert or halt) will produce an
/// execution result and state changes. It is up to higher levels of the
/// system to decide what to do with such transactions, e.g., whether to
/// remove them from the payload or not (see [`RevertProtection`]).
fn execute_transaction<DB>(
/// remove them from the payload or not (see
/// [`RemoveRevertedTransactions`]).
///
/// [`RemoveRevertedTransactions`]: crate::steps::RemoveRevertedTransactions
pub fn execute_transaction<DB>(
tx: Recovered<types::Transaction<P>>,
block: &BlockContext<P>,
db: &DB,
Expand Down Expand Up @@ -165,7 +168,8 @@ impl<P: Platform> Executable<P> {
/// gas used, nonces incremented, etc. Cleaning up transactions that are
/// allowed to fail and are optional from a bundle is beyond the scope
/// of this method. This is implemented by higher levels of the system,
/// such as the [`RevertProtection`] step in the pipelines API.
/// such as the [`RemoveRevertedTransactions`] step in the pipelines
/// API.
/// - If the bundle does not allow this failed transaction to fail, but
/// the transaction is optional, then it will be removed from the
/// bundle. The bundle stays valid.
Expand All @@ -184,7 +188,9 @@ impl<P: Platform> Executable<P> {
/// the execution has a certain balance in some account, etc. If this check
/// fails, the bundle will be considered invalid, and no execution result
/// will be produced.
fn execute_bundle<DB>(
///
/// [`RemoveRevertedTransactions`]: crate::steps::RemoveRevertedTransactions
pub fn execute_bundle<DB>(
bundle: types::Bundle<P>,
block: &BlockContext<P>,
db: &DB,
Expand Down
4 changes: 2 additions & 2 deletions src/payload/ext/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl<S> CachedStateProvider<S>
where
S: StateProvider,
{
/// Creates a new [`CachedStateProvider`] from an [`ExecutionCache`], state
/// provider, and [`CachedStateMetrics`].
/// Creates a new [`CachedStateProvider`] from an [`ExecutionCache`],
/// and [`StateProvider`].
pub const fn new_with_caches(
state_provider: S,
caches: ExecutionCache,
Expand Down
2 changes: 2 additions & 0 deletions src/pipelines/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//!
//! Before running the pipeline, the payload will have the platform-specific
//! [`BlockBuilder::apply_pre_execution_changes`] applied to its state.
//!
//! [`BlockBuilder::apply_pre_execution_changes`]: crate::reth::evm::execute::BlockBuilder::apply_pre_execution_changes

use {
super::{StepInstance, service::ServiceContext},
Expand Down
2 changes: 1 addition & 1 deletion src/pipelines/exec/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! Take this pipeline as an example:
//!
//! ```
//! ```text
//! Pipeline::default()────────────────────────┐
//! .with_prologue(PrologueStep) │
//! .with_step(Step1_1) │
Expand Down
5 changes: 4 additions & 1 deletion src/pipelines/step/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ impl<P: Platform> StepContext<P> {
/// Access to the state of the chain at the beginning of block that we are
/// building. This state does not include any changes made by the pipeline
/// during the payload building process. It does however include changes
/// applied by platform-specific [`BlockBuilder::apply_pre_execution_changes`]
/// applied by platform-specific
/// [`BlockBuilder::apply_pre_execution_changes`]
/// for this block.
///
/// [`BlockBuilder::apply_pre_execution_changes`]: crate::reth::evm::execute::BlockBuilder::apply_pre_execution_changes
pub fn provider(&self) -> &dyn StateProvider {
self.block.base_state()
}
Expand Down
7 changes: 5 additions & 2 deletions src/pipelines/step/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ impl<P: Platform> StepInstance<P> {
/// Initializes metrics recording for this step.
///
/// The input string is the metric name assigned to this step. This name is
/// not known before the pipeline instance is fully built and converted into a
/// service using [`PipelineServiceBuilder`]. It should be called only once.
/// not known before the pipeline instance is fully built and converted
/// into a service using [`PipelineServiceBuilder`]. It should be called
/// only once.
///
/// [`PipelineServiceBuilder`]: crate::pipelines::service::PipelineServiceBuilder
pub(crate) fn init_metrics(&self, name: &str) {
// Initialize the metrics name for this step.
self.name.init_metrics(name);
Expand Down
2 changes: 2 additions & 0 deletions src/pipelines/step/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ pub struct InitContext<P: Platform> {

impl<P: Platform> InitContext<P> {
/// Private API, called from [`PipelineServiceBuilder`].
///
/// [`PipelineServiceBuilder`]: crate::pipelines::service::PipelineServiceBuilder
pub(crate) fn new(
provider: Arc<dyn StateProviderFactory>,
metrics_scope: String,
Expand Down
8 changes: 6 additions & 2 deletions src/pipelines/step/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ impl Name {
/// Initializes the metric name for this step.
///
/// Metric names are initialized by
/// [`service::PipelineServiceBuilder`] through a call to `.into_service()`
/// [`PipelineServiceBuilder`] through a call to `.into_service()`
/// during reth node setup.
///
/// # Panics
/// This function will panic if the metric name has already been initialized.
///
/// This function will panic if the metric name has already been
/// initialized.
///
/// [`PipelineServiceBuilder`]: crate::pipelines::service::PipelineServiceBuilder
pub(super) fn init_metrics(&self, name: impl Into<String>) {
self
.metrics
Expand Down
11 changes: 9 additions & 2 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ pub trait Platform:
/// consensus engine such as transactions, blocks, headers, etc.
///
/// Two well known implementations of this trait are:
/// - [`EthereumNode`] for Ethereum L1 mainnet,
/// - [`OpNode`] for Optimism chains.
/// - [`EthereumNode`](crate::reth::ethereum::node::EthereumNode) for Ethereum
/// L1 mainnet,
#[cfg_attr(
feature = "optimism",
doc = " - [`OpNode`](crate::reth::optimism::node::OpNode) for Optimism \
chains."
)]
type NodeTypes: reth::api::NodeTypes;

/// A type that provides a complete EVM configuration ready to be used
Expand Down Expand Up @@ -133,6 +138,8 @@ pub trait Platform:
/// In Pipelines some steps require platforms to implement this trait if they
/// produce new transactions as part of their logic and want to remain
/// platform-agnostic, such as [`BuilderEpilogue`].
///
/// [`BuilderEpilogue`]: crate::steps::BuilderEpilogue
pub trait PlatformWithRpcTypes: Platform {
type RpcTypes: AlloyNetwork<
Header = types::Header<Self>,
Expand Down
6 changes: 6 additions & 0 deletions src/platform/optimism/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ use {
pub trait BlockOpExt<P: Platform> {
/// Returns `true` if [`Ecotone`] hard fork is active at the given block
/// timestamp.
///
/// [`Ecotone`]: crate::reth::optimism::forks::OpHardfork::Ecotone
fn is_ecotone_active(&self) -> bool;

/// Returns `true` if [`Holocene`] hard fork is active at the given block
/// timestamp.
///
/// [`Holocene`]: crate::reth::optimism::forks::OpHardfork::Holocene
fn is_holocene_active(&self) -> bool;

/// Returns `true` if [`Jovian`] hard fork is active at the given block
/// timestamp.
///
/// [`Jovian`]: crate::reth::optimism::forks::OpHardfork::Jovian
fn is_jovian_active(&self) -> bool;
}

Expand Down
5 changes: 4 additions & 1 deletion src/pool/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl<P: Platform> RethTransactionPoolTrait for NativeTransactionPool<P> {
/// hashes.
///
/// This adheres to the expected behavior of
/// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09):
/// [`GetPooledTransactions`]
///
/// The transactions must be in same order as in the request, but it is OK to
/// skip transactions
Expand All @@ -648,6 +648,9 @@ impl<P: Platform> RethTransactionPoolTrait for NativeTransactionPool<P> {
/// If the transaction is a blob transaction, the sidecar will be included.
///
/// Consumer: P2P
///
/// [`PooledTransactionVariant`]: crate::reth::ethereum::PooledTransactionVariant
/// [`GetPooledTransactions`]: https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09
fn get_pooled_transaction_elements(
&self,
tx_hashes: Vec<TxHash>,
Expand Down
8 changes: 6 additions & 2 deletions src/pool/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ impl<P: Platform> OrderPool<P> {
/// functionalities.
///
/// Attaching the order pool to the host node is optional, but greatly enhances
/// the functionality of the order pool. See more in the [`HostNode`]
/// documentation.
/// the functionality of the order pool. Specifically it allows:
/// - checking for permanent ineligibility of bundles at the RPC level and
/// rejecting them before they are sent to the order pool.
/// - simulation of bundles against the state of the chain at the RPC level.
/// - garbage collection of orders that have transactions that were included in
/// a committed block.
///
/// In future iterations, we're expecting to have our own implementation of the
/// system transaction pool.
Expand Down
8 changes: 5 additions & 3 deletions src/test_utils/exts/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ impl PlatformWithTestnet for Optimism {
/// that implement [`PayloadJobGenerator`] and are configured as payload
/// builders.
///
/// See [`crate::pipelines::service::PipelineServiceBuilder`] for an example of
/// a workflow that creates a payload builder attributes instance in real world
/// settings.
/// See the `PipelineServiceBuilder` in `crate::pipelines::service` for an
/// example of a workflow that creates a payload builder attributes instance in
/// real world settings.
///
/// [`PayloadJobGenerator`]: crate::reth::payload::builder::PayloadJobGenerator
pub trait PayloadBuilderAttributesMocked<P: Platform> {
fn mocked(parent: &SealedHeader<types::Header<P>>) -> Self;
}
Expand Down
6 changes: 5 additions & 1 deletion src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
//! - [`Ethereum`]
//! - [`Optimism`]
//!
//! If you want to make your own [`crate::Platform`] type implementation
//! If you want to make your own [`Platform`] type implementation
//! available for testing with those utils you need to implement the
//! [`TestablePlatform`] trait for it.
//!
//! [`Platform`]: crate::prelude::Platform
//! [`Ethereum`]: crate::prelude::Ethereum
//! [`Optimism`]: crate::prelude::Optimism

mod accounts;
mod ethereum;
Expand Down
2 changes: 2 additions & 0 deletions src/test_utils/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use {
/// variants of all internal unit tests for all platforms. You can use
/// [`rblib_test`] with externally defined platforms as long as they implement
/// this trait.
///
/// [`rblib_test`]: rblib_tests_macros::rblib_test
pub trait TestNodeFactory<P: PlatformWithRpcTypes> {
type ConsensusDriver: ConsensusDriver<P>;
type CliExtArgs: Default + Send + Sync;
Expand Down
Loading