-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
152 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! This module contains the implementation of the [crate::TraceProvider] trait for composing two trace providers together | ||
//! based off of the input depth. This implementation can be used to compose several layers of bisection. | ||
use crate::{Gindex, Position, TraceProvider}; | ||
use alloy_primitives::keccak256; | ||
use anyhow::Result; | ||
use durin_primitives::Claim; | ||
use std::{marker::PhantomData, sync::Arc}; | ||
|
||
/// The [SplitTraceProvider] is a [TraceProvider] that composes two trace providers together based off of the input depth. | ||
pub struct SplitTraceProvider<T, TOP, BOTTOM> | ||
where | ||
T: AsRef<[u8]> + Send + Sync, | ||
TOP: TraceProvider<T>, | ||
BOTTOM: TraceProvider<T>, | ||
{ | ||
pub top: TOP, | ||
pub bottom: BOTTOM, | ||
pub split_depth: u8, | ||
pub _phantom: PhantomData<T>, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl<T, TOP, BOTTOM> TraceProvider<T> for SplitTraceProvider<T, TOP, BOTTOM> | ||
where | ||
T: AsRef<[u8]> + Send + Sync, | ||
TOP: TraceProvider<T> + Sync, | ||
BOTTOM: TraceProvider<T> + Sync, | ||
{ | ||
async fn absolute_prestate(&self) -> Result<Arc<T>> { | ||
todo!() | ||
} | ||
|
||
async fn absolute_prestate_hash(&self) -> Result<Claim> { | ||
todo!() | ||
} | ||
|
||
async fn state_at(&self, position: Position) -> Result<Arc<T>> { | ||
if position.depth() <= self.split_depth { | ||
self.top.state_at(position).await | ||
} else { | ||
// TODO: Pass relative position based on split depth? | ||
self.bottom.state_at(position).await | ||
} | ||
} | ||
|
||
async fn state_hash(&self, position: Position) -> Result<Claim> { | ||
Ok(keccak256(self.state_at(position).await?.as_ref())) | ||
} | ||
|
||
async fn proof_at(&self, _: Position) -> Result<Arc<[u8]>> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.