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
1 change: 1 addition & 0 deletions crates/exex/external-proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ alloy-primitives = { workspace = true }
# reth
reth-chainspec.workspace = true
reth-db-api.workspace = true
reth-db.workspace = true
reth-node-types.workspace = true
reth-node-api.workspace = true
reth-primitives-traits.workspace = true
Expand Down
64 changes: 64 additions & 0 deletions crates/exex/external-proofs/src/storage/mdbx/cursor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use crate::storage::{OpProofsHashedCursor, OpProofsStorageResult, OpProofsTrieCursor};
use alloy_primitives::{B256, U256};
use reth_primitives_traits::Account;
use reth_trie::{BranchNodeCompact, Nibbles};

/// MDBX implementation of `OpProofsTrieCursor`.
#[derive(Debug)]
pub struct MdbxTrieCursor {}

impl OpProofsTrieCursor for MdbxTrieCursor {
fn seek_exact(
&mut self,
_path: Nibbles,
) -> OpProofsStorageResult<Option<(Nibbles, BranchNodeCompact)>> {
unimplemented!()
}

fn seek(
&mut self,
_path: Nibbles,
) -> OpProofsStorageResult<Option<(Nibbles, BranchNodeCompact)>> {
unimplemented!()
}

fn next(&mut self) -> OpProofsStorageResult<Option<(Nibbles, BranchNodeCompact)>> {
unimplemented!()
}

fn current(&mut self) -> OpProofsStorageResult<Option<Nibbles>> {
unimplemented!()
}
}

/// MDBX implementation of `OpProofsHashedCursor` for storage state.
#[derive(Debug)]
pub struct MdbxStorageCursor {}

impl OpProofsHashedCursor for MdbxStorageCursor {
type Value = U256;

fn seek(&mut self, _key: B256) -> OpProofsStorageResult<Option<(B256, Self::Value)>> {
unimplemented!()
}

fn next(&mut self) -> OpProofsStorageResult<Option<(B256, Self::Value)>> {
unimplemented!()
}
}

/// MDBX implementation of `OpProofsHashedCursor` for account state.
#[derive(Debug)]
pub struct MdbxAccountCursor {}

impl OpProofsHashedCursor for MdbxAccountCursor {
type Value = Account;

fn seek(&mut self, _key: B256) -> OpProofsStorageResult<Option<(B256, Self::Value)>> {
unimplemented!()
}

fn next(&mut self) -> OpProofsStorageResult<Option<(B256, Self::Value)>> {
unimplemented!()
}
}
6 changes: 6 additions & 0 deletions crates/exex/external-proofs/src/storage/mdbx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@

mod models;
pub use models::*;

mod store;
pub use store::MdbxProofsStorage;

mod cursor;
pub use cursor::{MdbxAccountCursor, MdbxStorageCursor, MdbxTrieCursor};
139 changes: 139 additions & 0 deletions crates/exex/external-proofs/src/storage/mdbx/store.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
use crate::storage::{
mdbx::{MdbxAccountCursor, MdbxStorageCursor, MdbxTrieCursor},
BlockStateDiff, OpProofsStorage, OpProofsStorageError, OpProofsStorageResult,
};
use alloy_primitives::{map::HashMap, B256, U256};
use async_trait::async_trait;
use reth_db::{
mdbx::{init_db_for, DatabaseArguments},
DatabaseEnv,
};
use reth_primitives_traits::Account;
use reth_trie::{BranchNodeCompact, Nibbles};
use std::path::Path;

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

impl MdbxProofsStorage {
/// 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)?;
Ok(Self { _env: env })
}
}

#[async_trait]
impl OpProofsStorage for MdbxProofsStorage {
type TrieCursor = MdbxTrieCursor;
type StorageCursor = MdbxStorageCursor;
type AccountHashedCursor = MdbxAccountCursor;

async fn store_account_branches(
&self,
_block_number: u64,
_updates: Vec<(Nibbles, Option<BranchNodeCompact>)>,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn store_storage_branches(
&self,
_block_number: u64,
_hashed_address: B256,
_items: Vec<(Nibbles, Option<BranchNodeCompact>)>,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn store_hashed_accounts(
&self,
_accounts: Vec<(B256, Option<Account>)>,
_block_number: u64,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn store_hashed_storages(
&self,
_hashed_address: B256,
_storages: Vec<(B256, U256)>,
_block_number: u64,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn get_earliest_block_number(&self) -> OpProofsStorageResult<Option<(u64, B256)>> {
unimplemented!()
}

async fn get_latest_block_number(&self) -> OpProofsStorageResult<Option<(u64, B256)>> {
unimplemented!()
}

fn trie_cursor(
&self,
_hashed_address: Option<B256>,
_max_block_number: u64,
) -> OpProofsStorageResult<Self::TrieCursor> {
unimplemented!()
}

fn storage_hashed_cursor(
&self,
_hashed_address: B256,
_max_block_number: u64,
) -> OpProofsStorageResult<Self::StorageCursor> {
unimplemented!()
}

fn account_hashed_cursor(
&self,
_max_block_number: u64,
) -> OpProofsStorageResult<Self::AccountHashedCursor> {
unimplemented!()
}

async fn store_trie_updates(
&self,
_block_number: u64,
_block_state_diff: BlockStateDiff,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn fetch_trie_updates(
&self,
_block_number: u64,
) -> OpProofsStorageResult<BlockStateDiff> {
unimplemented!()
}

async fn prune_earliest_state(
&self,
_new_earliest_block_number: u64,
_diff: BlockStateDiff,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn replace_updates(
&self,
_latest_common_block_number: u64,
_blocks_to_add: HashMap<u64, BlockStateDiff>,
) -> OpProofsStorageResult<()> {
unimplemented!()
}

async fn set_earliest_block_number(
&self,
_block_number: u64,
_hash: B256,
) -> OpProofsStorageResult<()> {
unimplemented!()
}
}