add doc_markdown clippy lint (#8552)

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Thomas Coratger
2024-06-03 15:21:45 +02:00
committed by GitHub
parent 34af610b8e
commit 7c17c6e469
440 changed files with 2166 additions and 2145 deletions

View File

@ -1,7 +1,7 @@
//! A [Consensus] implementation for local testing purposes
//! that automatically seals blocks.
//!
//! The Mining task polls a [MiningMode], and will return a list of transactions that are ready to
//! The Mining task polls a [`MiningMode`], and will return a list of transactions that are ready to
//! be mined.
//!
//! These downloaders poll the miner, assemble the block, and return transactions that are ready to
@ -57,7 +57,7 @@ pub struct AutoSealConsensus {
}
impl AutoSealConsensus {
/// Create a new instance of [AutoSealConsensus]
/// Create a new instance of [`AutoSealConsensus`]
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
Self { chain_spec }
}
@ -143,7 +143,7 @@ where
}
}
/// Sets the [MiningMode] it operates in, default is [MiningMode::Auto]
/// Sets the [`MiningMode`] it operates in, default is [`MiningMode::Auto`]
pub fn mode(mut self, mode: MiningMode) -> Self {
self.mode = mode;
self

View File

@ -7,7 +7,7 @@ use reth_stages_api::PipelineError;
pub type BeaconEngineResult<Ok> = Result<Ok, BeaconConsensusEngineError>;
/// The error type for the beacon consensus engine service
/// [BeaconConsensusEngine](crate::BeaconConsensusEngine)
/// [`BeaconConsensusEngine`](crate::BeaconConsensusEngine)
///
/// Represents all possible error cases for the beacon consensus engine.
#[derive(Debug, thiserror::Error)]
@ -24,7 +24,7 @@ pub enum BeaconConsensusEngineError {
/// Hook error.
#[error(transparent)]
Hook(#[from] EngineHookError),
/// Common error. Wrapper around [RethError].
/// Common error. Wrapper around [`RethError`].
#[error(transparent)]
Common(#[from] RethError),
}

View File

@ -3,7 +3,7 @@ use reth_primitives::{SealedBlock, SealedHeader, B256};
use reth_rpc_types::engine::ForkchoiceState;
use std::{sync::Arc, time::Duration};
/// Events emitted by [crate::BeaconConsensusEngine].
/// Events emitted by [`crate::BeaconConsensusEngine`].
#[derive(Clone, Debug)]
pub enum BeaconConsensusEngineEvent {
/// The fork choice state was updated, and the current fork choice status

View File

@ -38,26 +38,26 @@ impl ForkchoiceStateTracker {
self.last_valid = Some(state);
}
/// Returns the [ForkchoiceStatus] of the latest received FCU.
/// Returns the [`ForkchoiceStatus`] of the latest received FCU.
///
/// Caution: this can be invalid.
pub(crate) fn latest_status(&self) -> Option<ForkchoiceStatus> {
self.latest.as_ref().map(|s| s.status)
}
/// Returns whether the latest received FCU is valid: [ForkchoiceStatus::Valid]
/// Returns whether the latest received FCU is valid: [`ForkchoiceStatus::Valid`]
#[allow(dead_code)]
pub(crate) fn is_latest_valid(&self) -> bool {
self.latest_status().map(|s| s.is_valid()).unwrap_or(false)
}
/// Returns whether the latest received FCU is syncing: [ForkchoiceStatus::Syncing]
/// Returns whether the latest received FCU is syncing: [`ForkchoiceStatus::Syncing`]
#[allow(dead_code)]
pub(crate) fn is_latest_syncing(&self) -> bool {
self.latest_status().map(|s| s.is_syncing()).unwrap_or(false)
}
/// Returns whether the latest received FCU is syncing: [ForkchoiceStatus::Invalid]
/// Returns whether the latest received FCU is syncing: [`ForkchoiceStatus::Invalid`]
#[allow(dead_code)]
pub(crate) fn is_latest_invalid(&self) -> bool {
self.latest_status().map(|s| s.is_invalid()).unwrap_or(false)
@ -75,7 +75,7 @@ impl ForkchoiceStateTracker {
self.last_syncing.as_ref().map(|s| s.head_block_hash)
}
/// Returns the last received ForkchoiceState to which we need to sync.
/// Returns the last received `ForkchoiceState` to which we need to sync.
pub(crate) const fn sync_target_state(&self) -> Option<ForkchoiceState> {
self.last_syncing
}
@ -94,7 +94,7 @@ pub(crate) struct ReceivedForkchoiceState {
status: ForkchoiceStatus,
}
/// A simplified representation of [PayloadStatusEnum] specifically for FCU.
/// A simplified representation of [`PayloadStatusEnum`] specifically for FCU.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ForkchoiceStatus {
/// The forkchoice state is valid.
@ -118,7 +118,7 @@ impl ForkchoiceStatus {
matches!(self, Self::Syncing)
}
/// Converts the general purpose [PayloadStatusEnum] into a [ForkchoiceStatus].
/// Converts the general purpose [`PayloadStatusEnum`] into a [`ForkchoiceStatus`].
pub(crate) const fn from_payload_status(status: &PayloadStatusEnum) -> Self {
match status {
PayloadStatusEnum::Valid | PayloadStatusEnum::Accepted => {
@ -137,7 +137,7 @@ impl From<PayloadStatusEnum> for ForkchoiceStatus {
}
}
/// A helper type to check represent hashes of a [ForkchoiceState]
/// A helper type to check represent hashes of a [`ForkchoiceState`]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum ForkchoiceStateHash {
Head(B256),
@ -146,7 +146,7 @@ pub(crate) enum ForkchoiceStateHash {
}
impl ForkchoiceStateHash {
/// Tries to find a matching hash in the given [ForkchoiceState].
/// Tries to find a matching hash in the given [`ForkchoiceState`].
pub(crate) fn find(state: &ForkchoiceState, hash: B256) -> Option<Self> {
if state.head_block_hash == hash {
Some(Self::Head(hash))
@ -159,7 +159,7 @@ impl ForkchoiceStateHash {
}
}
/// Returns true if this is the head hash of the [ForkchoiceState]
/// Returns true if this is the head hash of the [`ForkchoiceState`]
pub(crate) const fn is_head(&self) -> bool {
matches!(self, Self::Head(_))
}

View File

@ -18,8 +18,8 @@ pub(crate) struct PolledHook {
/// Manages hooks under the control of the engine.
///
/// This type polls the initialized hooks one by one, respecting the DB access level
/// (i.e. [crate::hooks::EngineHookDBAccessLevel::ReadWrite] that enforces running at most one such
/// hook).
/// (i.e. [`crate::hooks::EngineHookDBAccessLevel::ReadWrite`] that enforces running at most one
/// such hook).
pub(crate) struct EngineHooksController {
/// Collection of hooks.
///

View File

@ -99,7 +99,7 @@ pub enum EngineHookError {
/// Hook channel closed.
#[error("hook channel closed")]
ChannelClosed,
/// Common error. Wrapper around [RethError].
/// Common error. Wrapper around [`RethError`].
#[error(transparent)]
Common(#[from] RethError),
/// An internal error occurred.

View File

@ -77,11 +77,11 @@ impl<DB: Database + 'static> PruneHook<DB> {
}
/// This will try to spawn the pruner if it is idle:
/// 1. Check if pruning is needed through [Pruner::is_pruning_needed].
/// 1. Check if pruning is needed through [`Pruner::is_pruning_needed`].
///
/// 2.1. If pruning is needed, pass tip block number to the [Pruner::run] and spawn it in a
/// separate task. Set pruner state to [PrunerState::Running].
/// 2.2. If pruning is not needed, set pruner state back to [PrunerState::Idle].
/// 2.1. If pruning is needed, pass tip block number to the [`Pruner::run`] and spawn it in a
/// separate task. Set pruner state to [`PrunerState::Running`].
/// 2.2. If pruning is not needed, set pruner state back to [`PrunerState::Idle`].
///
/// If pruner is already running, do nothing.
fn try_spawn_pruner(&mut self, tip_block_number: BlockNumber) -> Option<EngineHookEvent> {
@ -141,8 +141,8 @@ impl<DB: Database + 'static> EngineHook for PruneHook<DB> {
/// The possible pruner states within the sync controller.
///
/// [PrunerState::Idle] means that the pruner is currently idle.
/// [PrunerState::Running] means that the pruner is currently running.
/// [`PrunerState::Idle`] means that the pruner is currently idle.
/// [`PrunerState::Running`] means that the pruner is currently running.
///
/// NOTE: The differentiation between these two states is important, because when the pruner is
/// running, it acquires the write lock over the database. This means that we cannot forward to the

View File

@ -1,4 +1,4 @@
//! StaticFile hook for the engine implementation.
//! `StaticFile` hook for the engine implementation.
use crate::{
engine::hooks::{EngineHook, EngineHookContext, EngineHookError, EngineHookEvent},
@ -16,12 +16,12 @@ use tracing::trace;
/// Manages producing static files under the control of the engine.
///
/// This type controls the [StaticFileProducer].
/// This type controls the [`StaticFileProducer`].
#[derive(Debug)]
pub struct StaticFileHook<DB> {
/// The current state of the static_file_producer.
/// The current state of the `static_file_producer`.
state: StaticFileProducerState<DB>,
/// The type that can spawn the static_file_producer task.
/// The type that can spawn the `static_file_producer` task.
task_spawner: Box<dyn TaskSpawner>,
}
@ -34,10 +34,10 @@ impl<DB: Database + 'static> StaticFileHook<DB> {
Self { state: StaticFileProducerState::Idle(Some(static_file_producer)), task_spawner }
}
/// Advances the static_file_producer state.
/// Advances the `static_file_producer` state.
///
/// This checks for the result in the channel, or returns pending if the static_file_producer is
/// idle.
/// This checks for the result in the channel, or returns pending if the `static_file_producer`
/// is idle.
fn poll_static_file_producer(
&mut self,
cx: &mut Context<'_>,
@ -67,19 +67,19 @@ impl<DB: Database + 'static> StaticFileHook<DB> {
Poll::Ready(Ok(event))
}
/// This will try to spawn the static_file_producer if it is idle:
/// This will try to spawn the `static_file_producer` if it is idle:
/// 1. Check if producing static files is needed through
/// [StaticFileProducer::get_static_file_targets](reth_static_file::StaticFileProducerInner::get_static_file_targets)
/// and then [StaticFileTargets::any](reth_static_file::StaticFileTargets::any).
/// [`StaticFileProducer::get_static_file_targets`](reth_static_file::StaticFileProducerInner::get_static_file_targets)
/// and then [`StaticFileTargets::any`](reth_static_file::StaticFileTargets::any).
///
/// 2.1. If producing static files is needed, pass static file request to the
/// [StaticFileProducer::run](reth_static_file::StaticFileProducerInner::run) and
/// [`StaticFileProducer::run`](reth_static_file::StaticFileProducerInner::run) and
/// spawn it in a separate task. Set static file producer state to
/// [StaticFileProducerState::Running].
/// [`StaticFileProducerState::Running`].
/// 2.2. If producing static files is not needed, set static file producer state back to
/// [StaticFileProducerState::Idle].
/// [`StaticFileProducerState::Idle`].
///
/// If static_file_producer is already running, do nothing.
/// If `static_file_producer` is already running, do nothing.
fn try_spawn_static_file_producer(
&mut self,
finalized_block_number: BlockNumber,
@ -157,14 +157,14 @@ impl<DB: Database + 'static> EngineHook for StaticFileHook<DB> {
}
}
/// The possible static_file_producer states within the sync controller.
/// The possible `static_file_producer` states within the sync controller.
///
/// [StaticFileProducerState::Idle] means that the static file producer is currently idle.
/// [StaticFileProducerState::Running] means that the static file producer is currently running.
/// [`StaticFileProducerState::Idle`] means that the static file producer is currently idle.
/// [`StaticFileProducerState::Running`] means that the static file producer is currently running.
#[derive(Debug)]
enum StaticFileProducerState<DB> {
/// [StaticFileProducer] is idle.
/// [`StaticFileProducer`] is idle.
Idle(Option<StaticFileProducer<DB>>),
/// [StaticFileProducer] is running and waiting for a response
/// [`StaticFileProducer`] is running and waiting for a response
Running(oneshot::Receiver<StaticFileProducerWithResult<DB>>),
}

View File

@ -16,7 +16,7 @@ use tokio::sync::oneshot;
/// Represents the outcome of forkchoice update.
///
/// This is a future that resolves to [ForkChoiceUpdateResult]
/// This is a future that resolves to [`ForkChoiceUpdateResult`]
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[derive(Debug)]
pub struct OnForkChoiceUpdated {
@ -32,7 +32,7 @@ pub struct OnForkChoiceUpdated {
// === impl OnForkChoiceUpdated ===
impl OnForkChoiceUpdated {
/// Returns the determined status of the received ForkchoiceState.
/// Returns the determined status of the received `ForkchoiceState`.
pub const fn forkchoice_status(&self) -> ForkchoiceStatus {
self.forkchoice_status
}

View File

@ -95,7 +95,7 @@ pub const MIN_BLOCKS_FOR_PIPELINE_RUN: u64 = EPOCH_SLOTS;
/// received by Engine API (JSON-RPC).
///
/// The consensus engine is idle until it receives the first
/// [BeaconEngineMessage::ForkchoiceUpdated] message from the CL which would initiate the sync. At
/// [`BeaconEngineMessage::ForkchoiceUpdated`] message from the CL which would initiate the sync. At
/// first, the consensus engine would run the [Pipeline] until the latest known block hash.
/// Afterward, it would attempt to create/restore the [`BlockchainTreeEngine`] from the blocks
/// that are currently available. In case the restoration is successful, the consensus engine would
@ -107,10 +107,10 @@ pub const MIN_BLOCKS_FOR_PIPELINE_RUN: u64 = EPOCH_SLOTS;
/// ## New Payload (`engine_newPayloadV{}`)
///
/// The engine receives new payloads from the CL. If the payload is connected to the canonical
/// chain, it will be fully validated added to a chain in the [BlockchainTreeEngine]: `VALID`
/// chain, it will be fully validated added to a chain in the [`BlockchainTreeEngine`]: `VALID`
///
/// If the payload's chain is disconnected (at least 1 block is missing) then it will be buffered:
/// `SYNCING` ([BlockStatus::Disconnected]).
/// `SYNCING` ([`BlockStatus::Disconnected`]).
///
/// ## Forkchoice Update (FCU) (`engine_forkchoiceUpdatedV{}`)
///
@ -125,14 +125,14 @@ pub const MIN_BLOCKS_FOR_PIPELINE_RUN: u64 = EPOCH_SLOTS;
///
/// ### The chain is connected
///
/// All blocks of the `head_hash`'s chain are present in the [BlockchainTreeEngine] and are
/// All blocks of the `head_hash`'s chain are present in the [`BlockchainTreeEngine`] and are
/// committed to the canonical chain. This also includes reorgs.
///
/// ### The chain is disconnected
///
/// In this case the [BlockchainTreeEngine] doesn't know how the new chain connects to the existing
/// canonical chain. It could be a simple commit (new blocks extend the current head) or a re-org
/// that requires unwinding the canonical chain.
/// In this case the [`BlockchainTreeEngine`] doesn't know how the new chain connects to the
/// existing canonical chain. It could be a simple commit (new blocks extend the current head) or a
/// re-org that requires unwinding the canonical chain.
///
/// This further distinguishes between two variants:
///
@ -231,7 +231,7 @@ where
Client: HeadersClient + BodiesClient + Clone + Unpin + 'static,
EngineT: EngineTypes + Unpin + 'static,
{
/// Create a new instance of the [BeaconConsensusEngine].
/// Create a new instance of the [`BeaconConsensusEngine`].
#[allow(clippy::too_many_arguments)]
pub fn new(
client: Client,
@ -264,16 +264,17 @@ where
)
}
/// Create a new instance of the [BeaconConsensusEngine] using the given channel to configure
/// the [BeaconEngineMessage] communication channel.
/// Create a new instance of the [`BeaconConsensusEngine`] using the given channel to configure
/// the [`BeaconEngineMessage`] communication channel.
///
/// By default the engine is started with idle pipeline.
/// The pipeline can be launched immediately in one of the following ways descending in
/// priority:
/// - Explicit [Option::Some] target block hash provided via a constructor argument.
/// - Explicit [`Option::Some`] target block hash provided via a constructor argument.
/// - The process was previously interrupted amidst the pipeline run. This is checked by
/// comparing the checkpoints of the first ([StageId::Headers]) and last ([StageId::Finish])
/// stages. In this case, the latest available header in the database is used as the target.
/// comparing the checkpoints of the first ([`StageId::Headers`]) and last
/// ([`StageId::Finish`]) stages. In this case, the latest available header in the database is
/// used as the target.
///
/// Propagates any database related error.
#[allow(clippy::too_many_arguments)]
@ -334,7 +335,7 @@ where
Ok((this, handle))
}
/// Returns current [EngineHookContext] that's used for polling engine hooks.
/// Returns current [`EngineHookContext`] that's used for polling engine hooks.
fn current_engine_hook_context(&self) -> RethResult<EngineHookContext> {
Ok(EngineHookContext {
tip_block_number: self.blockchain.canonical_tip().number,
@ -732,7 +733,7 @@ where
/// - It is fully validated and deemed VALID
/// - Any other ancestor of the invalid payload with a higher blockNumber is INVALID
/// - 0x0000000000000000000000000000000000000000000000000000000000000000 if the above
/// conditions are satisfied by a PoW block.
/// conditions are satisfied by a `PoW` block.
/// - null if client software cannot determine the ancestor of the invalid payload satisfying
/// the above conditions.
fn latest_valid_hash_for_invalid_payload(
@ -841,9 +842,9 @@ where
/// made canonical.
///
/// If the forkchoice state is consistent, this will return Ok(None). Otherwise, this will
/// return an instance of [OnForkChoiceUpdated] that is INVALID.
/// return an instance of [`OnForkChoiceUpdated`] that is INVALID.
///
/// This also updates the safe and finalized blocks in the [CanonChainTracker], if they are
/// This also updates the safe and finalized blocks in the [`CanonChainTracker`], if they are
/// consistent with the head block.
fn ensure_consistent_forkchoice_state(
&self,
@ -971,7 +972,7 @@ where
///
/// If the newest head is not invalid, then this will trigger a new pipeline run to sync the gap
///
/// See [Self::on_forkchoice_updated] and [BlockchainTreeEngine::make_canonical].
/// See [`Self::on_forkchoice_updated`] and [`BlockchainTreeEngine::make_canonical`].
fn on_failed_canonical_forkchoice_update(
&mut self,
state: &ForkchoiceState,
@ -1320,7 +1321,7 @@ where
/// Attempt to form a new canonical chain based on the current sync target.
///
/// This is invoked when we successfully __downloaded__ a new block from the network which
/// resulted in [BlockStatus::Valid].
/// resulted in [`BlockStatus::Valid`].
///
/// Note: This will not succeed if the sync target has changed since the block download request
/// was issued and the new target is still disconnected and additional missing blocks are
@ -1385,7 +1386,7 @@ where
}
}
/// Event handler for events emitted by the [EngineSyncController].
/// Event handler for events emitted by the [`EngineSyncController`].
///
/// This returns a result to indicate whether the engine future should resolve (fatal error).
fn on_sync_event(
@ -1785,7 +1786,7 @@ where
}
/// On initialization, the consensus engine will poll the message receiver and return
/// [Poll::Pending] until the first forkchoice update message is received.
/// [`Poll::Pending`] until the first forkchoice update message is received.
///
/// As soon as the consensus engine receives the first forkchoice updated message and updates the
/// local forkchoice state, it will launch the pipeline to sync to the head hash.
@ -1946,13 +1947,13 @@ enum BlockchainTreeAction<EngineT: EngineTypes> {
/// Action to insert a new block that we successfully downloaded from the network.
/// There are several outcomes for inserting a downloaded block into the tree:
///
/// ## [BlockStatus::Valid]
/// ## [`BlockStatus::Valid`]
///
/// The block is connected to the current canonical chain and is valid.
/// If the block is an ancestor of the current forkchoice head, then we can try again to
/// make the chain canonical.
///
/// ## [BlockStatus::Disconnected]
/// ## [`BlockStatus::Disconnected`]
///
/// The block is not connected to the canonical chain, and we need to download the
/// missing parent first.

View File

@ -29,7 +29,7 @@ use tracing::trace;
/// This type controls the [Pipeline] and supports (single) full block downloads.
///
/// Caution: If the pipeline is running, this type will not emit blocks downloaded from the network
/// [EngineSyncEvent::FetchedFullBlock] until the pipeline is idle to prevent commits to the
/// [`EngineSyncEvent::FetchedFullBlock`] until the pipeline is idle to prevent commits to the
/// database while the pipeline is still active.
pub(crate) struct EngineSyncController<DB, Client>
where
@ -359,7 +359,7 @@ where
}
}
/// A wrapper type around [SealedBlock] that implements the [Ord] trait by block number.
/// A wrapper type around [`SealedBlock`] that implements the [Ord] trait by block number.
#[derive(Debug, Clone, PartialEq, Eq)]
struct OrderedSealedBlock(SealedBlock);
@ -375,7 +375,7 @@ impl Ord for OrderedSealedBlock {
}
}
/// The event type emitted by the [EngineSyncController].
/// The event type emitted by the [`EngineSyncController`].
#[derive(Debug)]
pub(crate) enum EngineSyncEvent {
/// A full block has been downloaded from the network.
@ -402,8 +402,8 @@ pub(crate) enum EngineSyncEvent {
/// The possible pipeline states within the sync controller.
///
/// [PipelineState::Idle] means that the pipeline is currently idle.
/// [PipelineState::Running] means that the pipeline is currently running.
/// [`PipelineState::Idle`] means that the pipeline is currently idle.
/// [`PipelineState::Running`] means that the pipeline is currently running.
///
/// NOTE: The differentiation between these two states is important, because when the pipeline is
/// running, it acquires the write lock over the database. This means that we cannot forward to the
@ -451,7 +451,7 @@ mod tests {
}
impl TestPipelineBuilder {
/// Create a new [TestPipelineBuilder].
/// Create a new [`TestPipelineBuilder`].
fn new() -> Self {
Self {
pipeline_exec_outputs: VecDeque::new(),
@ -515,7 +515,7 @@ mod tests {
}
impl<Client> TestSyncControllerBuilder<Client> {
/// Create a new [TestSyncControllerBuilder].
/// Create a new [`TestSyncControllerBuilder`].
const fn new() -> Self {
Self { max_block: None, client: None }
}

View File

@ -22,7 +22,7 @@ pub mod noop;
/// test helpers for mocking consensus
pub mod test_utils;
/// Post execution input passed to [Consensus::validate_block_post_execution].
/// Post execution input passed to [`Consensus::validate_block_post_execution`].
#[derive(Debug)]
pub struct PostExecutionInput<'a> {
/// Receipts of the block.
@ -320,7 +320,7 @@ pub enum ConsensusError {
#[error(transparent)]
InvalidTransaction(#[from] InvalidTransactionError),
/// Error type transparently wrapping HeaderValidationError.
/// Error type transparently wrapping `HeaderValidationError`.
#[error(transparent)]
HeaderValidationError(#[from] HeaderValidationError),
}