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

@ -31,10 +31,10 @@ use crate::metrics::ParallelStateRootMetrics;
/// nodes in the process. Upon encountering a leaf node, it will poll the storage root
/// task for the corresponding hashed address.
///
/// Internally, the calculator uses [ConsistentDbView] since
/// Internally, the calculator uses [`ConsistentDbView`] since
/// it needs to rely on database state saying the same until
/// the last transaction is open.
/// See docs of using [ConsistentDbView] for caveats.
/// See docs of using [`ConsistentDbView`] for caveats.
///
/// For sync usage, take a look at `ParallelStateRoot`.
#[derive(Debug)]

View File

@ -29,10 +29,10 @@ use crate::metrics::ParallelStateRootMetrics;
/// accounts in parallel. Once that's done, it proceeds to walking the state
/// trie retrieving the pre-computed storage roots when needed.
///
/// Internally, the calculator uses [ConsistentDbView] since
/// Internally, the calculator uses [`ConsistentDbView`] since
/// it needs to rely on database state saying the same until
/// the last transaction is open.
/// See docs of using [ConsistentDbView] for caveats.
/// See docs of using [`ConsistentDbView`] for caveats.
///
/// If possible, use more optimized `AsyncStateRoot` instead.
#[derive(Debug)]

View File

@ -42,7 +42,7 @@ where
}
/// The structure wrapping a database cursor for hashed storage and
/// a target hashed address. Implements [HashedCursor] and [HashedStorageCursor]
/// a target hashed address. Implements [`HashedCursor`] and [`HashedStorageCursor`]
/// for iterating over hashed storage.
#[derive(Debug)]
pub struct DatabaseHashedStorageCursor<C> {
@ -53,7 +53,7 @@ pub struct DatabaseHashedStorageCursor<C> {
}
impl<C> DatabaseHashedStorageCursor<C> {
/// Create new [DatabaseHashedStorageCursor].
/// Create new [`DatabaseHashedStorageCursor`].
pub const fn new(cursor: C, hashed_address: B256) -> Self {
Self { cursor, hashed_address }
}

View File

@ -40,7 +40,7 @@ impl<'a, CF: HashedCursorFactory> HashedCursorFactory for HashedPostStateCursorF
pub struct HashedPostStateAccountCursor<'b, C> {
/// The database cursor.
cursor: C,
/// The reference to the in-memory [HashedPostStateSorted].
/// The reference to the in-memory [`HashedPostStateSorted`].
post_state: &'b HashedPostStateSorted,
/// The post state account index where the cursor is currently at.
post_state_account_index: usize,
@ -50,7 +50,7 @@ pub struct HashedPostStateAccountCursor<'b, C> {
}
impl<'b, C> HashedPostStateAccountCursor<'b, C> {
/// Create new instance of [HashedPostStateAccountCursor].
/// Create new instance of [`HashedPostStateAccountCursor`].
pub const fn new(cursor: C, post_state: &'b HashedPostStateSorted) -> Self {
Self { cursor, post_state, last_account: None, post_state_account_index: 0 }
}
@ -101,7 +101,7 @@ where
/// database and the post state. The two entries are compared and the lowest is returned.
///
/// The returned account key is memoized and the cursor remains positioned at that key until
/// [HashedCursor::seek] or [HashedCursor::next] are called.
/// [`HashedCursor::seek`] or [`HashedCursor::next`] are called.
fn seek(&mut self, key: B256) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
self.last_account = None;
@ -144,7 +144,7 @@ where
/// If the cursor is positioned at the entry, return the entry with next greater key.
/// Returns [None] if the previous memoized or the next greater entries are missing.
///
/// NOTE: This function will not return any entry unless [HashedCursor::seek] has been
/// NOTE: This function will not return any entry unless [`HashedCursor::seek`] has been
/// called.
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
let last_account = match self.last_account.as_ref() {
@ -194,7 +194,7 @@ pub struct HashedPostStateStorageCursor<'b, C> {
}
impl<'b, C> HashedPostStateStorageCursor<'b, C> {
/// Create new instance of [HashedPostStateStorageCursor] for the given hashed address.
/// Create new instance of [`HashedPostStateStorageCursor`] for the given hashed address.
pub const fn new(
cursor: C,
post_state: &'b HashedPostStateSorted,
@ -304,7 +304,7 @@ where
///
/// # Panics
///
/// If the account key is not set. [HashedCursor::seek] must be called first in order to
/// If the account key is not set. [`HashedCursor::seek`] must be called first in order to
/// position the cursor.
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
let last_slot = match self.last_slot.as_ref() {
@ -353,8 +353,8 @@ where
{
/// Returns `true` if the account has no storage entries.
///
/// This function should be called before attempting to call [HashedCursor::seek] or
/// [HashedCursor::next].
/// This function should be called before attempting to call [`HashedCursor::seek`] or
/// [`HashedCursor::next`].
fn is_storage_empty(&mut self) -> Result<bool, reth_db::DatabaseError> {
let is_empty = match self.post_state.storages.get(&self.hashed_address) {
Some(storage) => {

View File

@ -47,7 +47,7 @@ pub struct TrieNodeIter<C, H: HashedCursor> {
}
impl<C, H: HashedCursor> TrieNodeIter<C, H> {
/// Creates a new [TrieNodeIter].
/// Creates a new [`TrieNodeIter`].
pub const fn new(walker: TrieWalker<C>, hashed_cursor: H) -> Self {
Self {
walker,
@ -58,7 +58,7 @@ impl<C, H: HashedCursor> TrieNodeIter<C, H> {
}
}
/// Sets the last iterated hashed key and returns the modified [TrieNodeIter].
/// Sets the last iterated hashed key and returns the modified [`TrieNodeIter`].
/// This is used to resume iteration from the last checkpoint.
pub const fn with_last_hashed_key(mut self, previous_hashed_key: B256) -> Self {
self.previous_hashed_key = Some(previous_hashed_key);

View File

@ -63,7 +63,7 @@ where
}
impl PrefixSetMut {
/// Create [PrefixSetMut] with pre-allocated capacity.
/// Create [`PrefixSetMut`] with pre-allocated capacity.
pub fn with_capacity(capacity: usize) -> Self {
Self { keys: Vec::with_capacity(capacity), ..Default::default() }
}
@ -130,7 +130,7 @@ impl PrefixSetMut {
/// A sorted prefix set that has an immutable _sorted_ list of unique keys.
///
/// See also [PrefixSetMut::freeze].
/// See also [`PrefixSetMut::freeze`].
#[derive(Debug, Default, Clone)]
pub struct PrefixSet {
keys: Arc<Vec<Nibbles>>,

View File

@ -32,7 +32,7 @@ pub struct HashedPostState {
}
impl HashedPostState {
/// Initialize [HashedPostState] from bundle state.
/// Initialize [`HashedPostState`] from bundle state.
/// Hashes all changed accounts and storage entries that are currently stored in the bundle
/// state.
pub fn from_bundle_state<'a>(
@ -54,11 +54,11 @@ impl HashedPostState {
this
}
/// Initialize [HashedPostState] from revert range.
/// Initialize [`HashedPostState`] from revert range.
/// Iterate over state reverts in the specified block range and
/// apply them to hashed state in reverse.
///
/// NOTE: In order to have the resulting [HashedPostState] be a correct
/// NOTE: In order to have the resulting [`HashedPostState`] be a correct
/// overlay of the plain state, the end of the range must be the current tip.
pub fn from_revert_range<TX: DbTx>(
tx: &TX,
@ -142,7 +142,7 @@ impl HashedPostState {
}
}
/// Converts hashed post state into [HashedPostStateSorted].
/// Converts hashed post state into [`HashedPostStateSorted`].
pub fn into_sorted(self) -> HashedPostStateSorted {
let mut accounts = Vec::new();
let mut destroyed_accounts = HashSet::default();
@ -164,7 +164,7 @@ impl HashedPostState {
HashedPostStateSorted { accounts, destroyed_accounts, storages }
}
/// Construct [TriePrefixSets] from hashed post state.
/// Construct [`TriePrefixSets`] from hashed post state.
/// The prefix sets contain the hashed account and storage keys that have been changed in the
/// post state.
pub fn construct_prefix_sets(&self) -> TriePrefixSets {
@ -198,7 +198,7 @@ impl HashedPostState {
}
}
/// Calculate the state root for this [HashedPostState].
/// Calculate the state root for this [`HashedPostState`].
/// Internally, this method retrieves prefixsets and uses them
/// to calculate incremental state root.
///
@ -226,7 +226,7 @@ impl HashedPostState {
///
/// # Returns
///
/// The state root for this [HashedPostState].
/// The state root for this [`HashedPostState`].
pub fn state_root<TX: DbTx>(&self, tx: &TX) -> Result<B256, StateRootError> {
let sorted = self.clone().into_sorted();
let prefix_sets = self.construct_prefix_sets();
@ -236,8 +236,8 @@ impl HashedPostState {
.root()
}
/// Calculates the state root for this [HashedPostState] and returns it alongside trie updates.
/// See [Self::state_root] for more info.
/// Calculates the state root for this [`HashedPostState`] and returns it alongside trie
/// updates. See [`Self::state_root`] for more info.
pub fn state_root_with_updates<TX: DbTx>(
&self,
tx: &TX,
@ -261,7 +261,7 @@ pub struct HashedStorage {
}
impl HashedStorage {
/// Create new instance of [HashedStorage].
/// Create new instance of [`HashedStorage`].
pub fn new(wiped: bool) -> Self {
Self { wiped, storage: HashMap::default() }
}
@ -283,7 +283,7 @@ impl HashedStorage {
}
}
/// Converts hashed storage into [HashedStorageSorted].
/// Converts hashed storage into [`HashedStorageSorted`].
pub fn into_sorted(self) -> HashedStorageSorted {
let mut non_zero_valued_slots = Vec::new();
let mut zero_valued_slots = HashSet::default();

View File

@ -6,7 +6,7 @@ use reth_primitives::{
/// Re-export of [triehash].
pub use triehash;
/// Compute the state root of a given set of accounts using [triehash::sec_trie_root].
/// Compute the state root of a given set of accounts using [`triehash::sec_trie_root`].
pub fn state_root<I, S>(accounts: I) -> B256
where
I: IntoIterator<Item = (Address, (Account, S))>,
@ -20,14 +20,14 @@ where
triehash::sec_trie_root::<KeccakHasher, _, _, _>(encoded_accounts)
}
/// Compute the storage root for a given account using [triehash::sec_trie_root].
/// Compute the storage root for a given account using [`triehash::sec_trie_root`].
pub fn storage_root<I: IntoIterator<Item = (B256, U256)>>(storage: I) -> B256 {
let encoded_storage = storage.into_iter().map(|(k, v)| (k, encode_fixed_size(&v)));
triehash::sec_trie_root::<KeccakHasher, _, _, _>(encoded_storage)
}
/// Compute the state root of a given set of accounts with prehashed keys using
/// [triehash::trie_root].
/// [`triehash::trie_root`].
pub fn state_root_prehashed<I, S>(accounts: I) -> B256
where
I: IntoIterator<Item = (B256, (Account, S))>,
@ -42,7 +42,7 @@ where
triehash::trie_root::<KeccakHasher, _, _, _>(encoded_accounts)
}
/// Compute the storage root for a given account with prehashed slots using [triehash::trie_root].
/// Compute the storage root for a given account with prehashed slots using [`triehash::trie_root`].
pub fn storage_root_prehashed<I: IntoIterator<Item = (B256, U256)>>(storage: I) -> B256 {
let encoded_storage = storage.into_iter().map(|(k, v)| (k, encode_fixed_size(&v)));
triehash::trie_root::<KeccakHasher, _, _, _>(encoded_storage)

View File

@ -23,7 +23,7 @@ use tracing::{debug, trace};
#[cfg(feature = "metrics")]
use crate::metrics::{StateRootMetrics, TrieRootMetrics, TrieType};
/// StateRoot is used to compute the root node of a state trie.
/// `StateRoot` is used to compute the root node of a state trie.
#[derive(Debug)]
pub struct StateRoot<T, H> {
/// The factory for trie cursors.
@ -94,7 +94,7 @@ impl<T, H> StateRoot<T, H> {
}
impl<'a, TX: DbTx> StateRoot<&'a TX, &'a TX> {
/// Create a new [StateRoot] instance.
/// Create a new [`StateRoot`] instance.
pub fn from_tx(tx: &'a TX) -> Self {
Self {
trie_cursor_factory: tx,
@ -341,7 +341,7 @@ where
}
}
/// StorageRoot is used to compute the root node of an account storage trie.
/// `StorageRoot` is used to compute the root node of an account storage trie.
#[derive(Debug)]
pub struct StorageRoot<T, H> {
/// A reference to the database transaction.

View File

@ -29,7 +29,7 @@ pub struct TrieWalker<C> {
}
impl<C> TrieWalker<C> {
/// Constructs a new TrieWalker from existing stack and a cursor.
/// Constructs a new `TrieWalker` from existing stack and a cursor.
pub fn from_stack(cursor: C, stack: Vec<CursorSubNode>, changes: PrefixSet) -> Self {
let mut this =
Self { cursor, changes, stack, can_skip_current_node: false, trie_updates: None };
@ -111,7 +111,7 @@ impl<C> TrieWalker<C> {
}
impl<C: TrieCursor> TrieWalker<C> {
/// Constructs a new TrieWalker, setting up the initial state of the stack and cursor.
/// Constructs a new `TrieWalker`, setting up the initial state of the stack and cursor.
pub fn new(cursor: C, changes: PrefixSet) -> Self {
// Initialize the walker with a single empty stack element.
let mut this = Self {