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
2 changes: 1 addition & 1 deletion crates/optimism/trie/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub trait OpProofsStore: Send + Sync + Debug {
block_number: u64,
) -> impl Future<Output = OpProofsStorageResult<BlockStateDiff>> + Send;

/// Applies `BlockStateDiff` to the earliest state (updating/deleting nodes) and updates the
/// Applies [`BlockStateDiff`] to the earliest state (updating/deleting nodes) and updates the
/// earliest block number.
fn prune_earliest_state(
&self,
Expand Down
10 changes: 5 additions & 5 deletions crates/optimism/trie/src/db/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
T: Table<Value = VersionedValue<V>> + DupSort<SubKey = u64>,
Cursor: DbCursorRO<T> + DbDupCursorRO<T>,
{
/// Initializes new `BlockNumberVersionedCursor`
/// Initializes new [`BlockNumberVersionedCursor`].
pub const fn new(cursor: Cursor, max_block_number: u64) -> Self {
Self { _table: PhantomData, cursor, max_block_number }
}
Expand Down Expand Up @@ -161,7 +161,7 @@ where
}
}

/// MDBX implementation of `OpProofsTrieCursor`.
/// MDBX implementation of [`OpProofsTrieCursor`].
#[derive(Debug)]
pub struct MdbxTrieCursor<T: Table + DupSort, Cursor> {
inner: BlockNumberVersionedCursor<T, Cursor>,
Expand All @@ -174,7 +174,7 @@ impl<
Cursor: DbCursorRO<T> + DbDupCursorRO<T>,
> MdbxTrieCursor<T, Cursor>
{
/// Initializes new `MdbxTrieCursor`
/// Initializes new [`MdbxTrieCursor`].
pub const fn new(cursor: Cursor, max_block_number: u64, hashed_address: Option<B256>) -> Self {
Self { inner: BlockNumberVersionedCursor::new(cursor, max_block_number), hashed_address }
}
Expand Down Expand Up @@ -261,7 +261,7 @@ where
}
}

/// MDBX implementation of `OpProofsHashedCursor` for storage state.
/// MDBX implementation of [`OpProofsHashedCursor`] for storage state.
#[derive(Debug)]
pub struct MdbxStorageCursor<Cursor> {
inner: BlockNumberVersionedCursor<HashedStorageHistory, Cursor>,
Expand Down Expand Up @@ -294,7 +294,7 @@ where
}
}

/// MDBX implementation of `OpProofsHashedCursor` for account state.
/// MDBX implementation of [`OpProofsHashedCursor`] for account state.
#[derive(Debug)]
pub struct MdbxAccountCursor<Cursor> {
inner: BlockNumberVersionedCursor<HashedAccountHistory, Cursor>,
Expand Down
18 changes: 13 additions & 5 deletions crates/optimism/trie/src/db/models/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use reth_db::{
};
use serde::{Deserialize, Serialize};

/// Wrapper type for `Option<T>` that implements `Compress` and `Decompress`
/// Wrapper type for `Option<T>` that implements [`Compress`] and [`Decompress`]
///
/// Encoding:
/// - `None` => empty byte array (length 0)
Expand Down Expand Up @@ -56,13 +56,21 @@ impl<T: Decompress> Decompress for MaybeDeleted<T> {
}
}

/// Versioned value wrapper for `DupSort` tables
/// Versioned value wrapper for [`DupSort`] tables
///
/// For `DupSort` tables in MDBX, the Value type must contain the `SubKey` as a field.
/// This wrapper combines a `block_number` (the `SubKey`) with the actual value.
/// For [`DupSort`] tables in MDBX, the Value type must contain the [`DupSort::SubKey`] as a field.
/// This wrapper combines a [`block_number`] (the [`DupSort::SubKey`]) with
/// the actual value.
///
/// [`DupSort`]: reth_db::table::DupSort
/// [`DupSort::SubKey`]: reth_db::table::DupSort::SubKey
/// [`block_number`]: Self::block_number
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct VersionedValue<T> {
/// Block number (`SubKey` for `DupSort`)
/// Block number ([`DupSort::SubKey`] for [`DupSort`])
///
/// [`DupSort`]: reth_db::table::DupSort
/// [`DupSort::SubKey`]: reth_db::table::DupSort::SubKey
pub block_number: u64,
/// The actual value (may be deleted)
pub value: MaybeDeleted<T>,
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/trie/src/db/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use reth_primitives_traits::Account;
use reth_trie::{BranchNodeCompact, Nibbles, StoredNibbles};
use std::path::Path;

/// MDBX implementation of `OpProofsStorage`.
/// MDBX implementation of [`OpProofsStorage`].
#[derive(Debug)]
pub struct MdbxProofsStorage {
env: DatabaseEnv,
}

impl MdbxProofsStorage {
/// Creates a new `MdbxProofsStorage` instance with the given path.
/// Creates a new [`MdbxProofsStorage`] instance with the given path.
pub fn new(path: &Path) -> Result<Self, OpProofsStorageError> {
let env = init_db_for::<_, super::models::Tables>(path, DatabaseArguments::default())
.map_err(OpProofsStorageError::Other)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/trie/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl InMemoryProofsStorage {
}
}

/// In-memory implementation of `OpProofsTrieCursor`
/// In-memory implementation of [`OpProofsTrieCursor`].
#[derive(Debug)]
pub struct InMemoryTrieCursor {
/// Current position in the iteration (-1 means not positioned yet)
Expand Down Expand Up @@ -250,7 +250,7 @@ impl OpProofsTrieCursorRO for InMemoryTrieCursor {
}
}

/// In-memory implementation of `OpProofsHashedCursor` for storage slots
/// In-memory implementation of [`OpProofsHashedCursor`] for storage slots
#[derive(Debug)]
pub struct InMemoryStorageCursor {
/// Current position in the iteration (-1 means not positioned yet)
Expand Down
6 changes: 3 additions & 3 deletions crates/optimism/trie/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Common test suite for `OpProofsStorage` implementations.
//! Common test suite for [`OpProofsStorage`] implementations.

use alloy_primitives::{map::HashMap, B256, U256};
use reth_optimism_trie::{
Expand Down Expand Up @@ -1103,9 +1103,9 @@ async fn test_large_batch_operations<S: OpProofsStore>(
Ok(())
}

/// Test wiped storage in `HashedPostState`
/// Test wiped storage in [`HashedPostState`]
///
/// When `store_trie_updates` receives a `HashedPostState` with wiped=true for a storage entry,
/// When `store_trie_updates` receives a [`HashedPostState`] with wiped=true for a storage entry,
/// it should iterate all existing values for that address and create deletion entries for them.
#[test_case(InMemoryProofsStorage::new(); "InMemory")]
#[tokio::test]
Expand Down
Loading