-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): Interop consolidation sub-problem
- Loading branch information
Showing
16 changed files
with
336 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
//! Consolidation phase of the interop proof program. | ||
use super::FaultProofProgramError; | ||
use alloc::{sync::Arc, vec::Vec}; | ||
use core::fmt::Debug; | ||
use kona_interop::MessageGraph; | ||
use kona_preimage::{HintWriterClient, PreimageOracleClient}; | ||
use kona_proof::CachingOracle; | ||
use kona_proof_interop::{OracleInteropProvider, PreState}; | ||
use revm::primitives::HashMap; | ||
|
||
/// Executes the consolidation phase of the interop proof with the given [PreimageOracleClient] and | ||
/// [HintWriterClient]. | ||
/// | ||
/// This phase is responsible for checking the dependencies between [OptimisticBlock]s in the | ||
/// superchain and ensuring that all dependencies are satisfied. | ||
/// | ||
/// [OptimisticBlock]: kona_proof_interop::OptimisticBlock | ||
pub(crate) async fn consolidate_dependencies<P, H>( | ||
oracle: Arc<CachingOracle<P, H>>, | ||
pre: PreState, | ||
) -> Result<(), FaultProofProgramError> | ||
where | ||
P: PreimageOracleClient + Send + Sync + Debug + Clone, | ||
H: HintWriterClient + Send + Sync + Debug + Clone, | ||
{ | ||
let provider = OracleInteropProvider::new(oracle, pre.clone()); | ||
|
||
// Ensure that the pre-state is a transition state. | ||
let PreState::TransitionState(transition_state) = pre else { | ||
return Err(FaultProofProgramError::StateTransitionFailed); | ||
}; | ||
|
||
let block_hashes = transition_state | ||
.pending_progress | ||
.iter() | ||
.zip(transition_state.pre_state.output_roots) | ||
.map(|(optimistic_block, pre_state)| (pre_state.chain_id, optimistic_block.block_hash)) | ||
.collect::<HashMap<_, _>>(); | ||
|
||
let mut headers = Vec::with_capacity(block_hashes.len()); | ||
for (chain_id, block_hash) in block_hashes { | ||
let header = provider.header_by_hash(chain_id, block_hash).await?; | ||
headers.push((chain_id, header.seal(block_hash))); | ||
} | ||
|
||
let graph = MessageGraph::derive(headers.as_slice(), provider).await.unwrap(); | ||
graph.resolve().await.unwrap(); | ||
|
||
Ok(()) | ||
} |
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
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.