diff --git a/.github/workflows/sanity.yaml b/.github/workflows/sanity.yaml index b94c915..cc1950b 100644 --- a/.github/workflows/sanity.yaml +++ b/.github/workflows/sanity.yaml @@ -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 @@ -81,4 +103,27 @@ jobs: toolchain: stable override: true - name: Run tests with stable - run: cargo test --all-targets --all-features \ No newline at end of file + 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 \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index c3e0a48..857aff4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/orderpool2/prioritized_pool/step.rs b/src/orderpool2/prioritized_pool/step.rs index 42abaa5..b78a9d8 100644 --- a/src/orderpool2/prioritized_pool/step.rs +++ b/src/orderpool2/prioritized_pool/step.rs @@ -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, @@ -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 { bundle: B, @@ -84,6 +81,7 @@ where } } +#[cfg(feature = "optimism")] impl OrderpoolOrder for Recovered> { type ID = B256; diff --git a/src/payload/block.rs b/src/payload/block.rs index 77873d4..90d7c75 100644 --- a/src/payload/block.rs +++ b/src/payload/block.rs @@ -66,8 +66,7 @@ impl BlockContext

{ /// [`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>, attribs: types::PayloadBuilderAttributes

, diff --git a/src/payload/exec.rs b/src/payload/exec.rs index 1ae4123..d914d9d 100644 --- a/src/payload/exec.rs +++ b/src/payload/exec.rs @@ -69,7 +69,7 @@ impl Executable

{ /// 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( self, block: &BlockContext

, @@ -97,8 +97,11 @@ impl Executable

{ /// - 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( + /// remove them from the payload or not (see + /// [`RemoveRevertedTransactions`]). + /// + /// [`RemoveRevertedTransactions`]: crate::steps::RemoveRevertedTransactions + pub fn execute_transaction( tx: Recovered>, block: &BlockContext

, db: &DB, @@ -165,7 +168,8 @@ impl Executable

{ /// 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. @@ -184,7 +188,9 @@ impl Executable

{ /// 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( + /// + /// [`RemoveRevertedTransactions`]: crate::steps::RemoveRevertedTransactions + pub fn execute_bundle( bundle: types::Bundle

, block: &BlockContext

, db: &DB, diff --git a/src/payload/ext/cached_state.rs b/src/payload/ext/cached_state.rs index 15c65a9..d957b26 100644 --- a/src/payload/ext/cached_state.rs +++ b/src/payload/ext/cached_state.rs @@ -50,8 +50,8 @@ impl CachedStateProvider 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, diff --git a/src/pipelines/exec/mod.rs b/src/pipelines/exec/mod.rs index 89b41cf..7f1f5d7 100644 --- a/src/pipelines/exec/mod.rs +++ b/src/pipelines/exec/mod.rs @@ -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}, diff --git a/src/pipelines/exec/scope.rs b/src/pipelines/exec/scope.rs index becf173..af8c0bb 100644 --- a/src/pipelines/exec/scope.rs +++ b/src/pipelines/exec/scope.rs @@ -4,7 +4,7 @@ //! //! Take this pipeline as an example: //! -//! ``` +//! ```text //! Pipeline::default()────────────────────────┐ //! .with_prologue(PrologueStep) │ //! .with_step(Step1_1) │ diff --git a/src/pipelines/step/context.rs b/src/pipelines/step/context.rs index a8d923a..03f468b 100644 --- a/src/pipelines/step/context.rs +++ b/src/pipelines/step/context.rs @@ -43,8 +43,11 @@ impl StepContext

{ /// 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() } diff --git a/src/pipelines/step/instance.rs b/src/pipelines/step/instance.rs index 3c27d43..3a4e28d 100644 --- a/src/pipelines/step/instance.rs +++ b/src/pipelines/step/instance.rs @@ -280,8 +280,11 @@ impl StepInstance

{ /// 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); diff --git a/src/pipelines/step/mod.rs b/src/pipelines/step/mod.rs index 1c732db..028501b 100644 --- a/src/pipelines/step/mod.rs +++ b/src/pipelines/step/mod.rs @@ -165,6 +165,8 @@ pub struct InitContext { impl InitContext

{ /// Private API, called from [`PipelineServiceBuilder`]. + /// + /// [`PipelineServiceBuilder`]: crate::pipelines::service::PipelineServiceBuilder pub(crate) fn new( provider: Arc, metrics_scope: String, diff --git a/src/pipelines/step/name.rs b/src/pipelines/step/name.rs index 6841926..2af1e32 100644 --- a/src/pipelines/step/name.rs +++ b/src/pipelines/step/name.rs @@ -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) { self .metrics diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 9a72c48..ed1b892 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -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 @@ -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, diff --git a/src/platform/optimism/ext.rs b/src/platform/optimism/ext.rs index 5f1d046..443278b 100644 --- a/src/platform/optimism/ext.rs +++ b/src/platform/optimism/ext.rs @@ -14,14 +14,20 @@ use { pub trait BlockOpExt { /// 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; } diff --git a/src/pool/native.rs b/src/pool/native.rs index 73eefb1..4c083e7 100644 --- a/src/pool/native.rs +++ b/src/pool/native.rs @@ -639,7 +639,7 @@ impl RethTransactionPoolTrait for NativeTransactionPool

{ /// 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 @@ -648,6 +648,9 @@ impl RethTransactionPoolTrait for NativeTransactionPool

{ /// 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, diff --git a/src/pool/setup.rs b/src/pool/setup.rs index c76f5a1..ff4baa9 100644 --- a/src/pool/setup.rs +++ b/src/pool/setup.rs @@ -57,8 +57,12 @@ impl OrderPool

{ /// 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. diff --git a/src/test_utils/exts/mock.rs b/src/test_utils/exts/mock.rs index 565b209..663b386 100644 --- a/src/test_utils/exts/mock.rs +++ b/src/test_utils/exts/mock.rs @@ -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 { fn mocked(parent: &SealedHeader>) -> Self; } diff --git a/src/test_utils/mod.rs b/src/test_utils/mod.rs index de17906..553e388 100644 --- a/src/test_utils/mod.rs +++ b/src/test_utils/mod.rs @@ -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; diff --git a/src/test_utils/platform.rs b/src/test_utils/platform.rs index 9066af7..5b5813b 100644 --- a/src/test_utils/platform.rs +++ b/src/test_utils/platform.rs @@ -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 { type ConsensusDriver: ConsensusDriver

; type CliExtArgs: Default + Send + Sync;