Skip to content

Commit

Permalink
logs
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Jan 19, 2025
1 parent 55338f7 commit 9d5594e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions bin/client/src/interop/consolidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use core::fmt::Debug;
use kona_interop::MessageGraph;
use kona_preimage::{HintWriterClient, PreimageOracleClient};
use kona_proof::CachingOracle;
use kona_proof_interop::{OracleInteropProvider, PreState};
use kona_proof_interop::{BootInfo, OracleInteropProvider, PreState};
use revm::primitives::HashMap;
use tracing::info;

/// Executes the consolidation phase of the interop proof with the given [PreimageOracleClient] and
/// [HintWriterClient].
Expand All @@ -18,6 +19,7 @@ use revm::primitives::HashMap;
/// [OptimisticBlock]: kona_proof_interop::OptimisticBlock
pub(crate) async fn consolidate_dependencies<P, H>(
oracle: Arc<CachingOracle<P, H>>,
boot: BootInfo,
pre: PreState,
) -> Result<(), FaultProofProgramError>
where
Expand All @@ -26,15 +28,17 @@ where
{
let provider = OracleInteropProvider::new(oracle, pre.clone());

info!(target: "client_interop", "Deriving local-safe headers from prestate");

// Ensure that the pre-state is a transition state.
let PreState::TransitionState(transition_state) = pre else {
let PreState::TransitionState(ref transition_state) = pre else {
return Err(FaultProofProgramError::StateTransitionFailed);
};

let block_hashes = transition_state
.pending_progress
.iter()
.zip(transition_state.pre_state.output_roots)
.zip(transition_state.pre_state.output_roots.iter())
.map(|(optimistic_block, pre_state)| (pre_state.chain_id, optimistic_block.block_hash))
.collect::<HashMap<_, _>>();

Expand All @@ -44,8 +48,23 @@ where
headers.push((chain_id, header.seal(block_hash)));
}

info!(target: "client_interop", "Loaded {} local-safe headers", headers.len());

// TODO: Re-execution w/ bad blocks. Not complete, we just panic if any deps are invalid atm.
let graph = MessageGraph::derive(headers.as_slice(), provider).await.unwrap();
graph.resolve().await.unwrap();

// Transition to the Super Root at the next timestamp.
//
// TODO: This won't work if we replace blocks, `transition` doesn't allow replacement of pending progress
// just yet.
let post = pre.transition(None).ok_or(FaultProofProgramError::StateTransitionFailed)?;
let post_commitment = post.hash();

// Ensure that the post-state matches the claimed post-state.
if post_commitment != boot.claimed_post_state {
return Err(FaultProofProgramError::InvalidClaim(boot.claimed_post_state, post_commitment));
}

Ok(())
}
2 changes: 1 addition & 1 deletion bin/client/src/interop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where
if transition_state.step < TRANSITION_STATE_MAX_STEPS {
sub_transition(oracle, handle_register, boot, pre).await
} else {
consolidate_dependencies(oracle, pre).await
consolidate_dependencies(oracle, boot, pre).await
}
}
}
Expand Down

0 comments on commit 9d5594e

Please sign in to comment.