Skip to content

Commit

Permalink
chore(client): Improve BootInfo field names
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Oct 9, 2024
1 parent 25af581 commit 62b5128
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
23 changes: 15 additions & 8 deletions bin/client/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ pub const L2_ROLLUP_CONFIG_KEY: U256 = U256::from_be_slice(&[6]);
/// **Verified inputs:**
/// - `l1_head`: The L1 head hash containing the safe L2 chain data that may reproduce the L2 head
/// hash.
/// - `l2_output_root`: The latest finalized L2 output root.
/// - `agreed_l2_output_root`:The agreed upon safe L2 output root.
/// - `chain_id`: The L2 chain ID.
///
/// **User submitted inputs:**
/// - `l2_claim`: The L2 output root claim.
/// - `l2_claim_block`: The L2 claim block number.
/// - `claimed_l2_output_root`: The L2 output root claim.
/// - `claimed_l2_block_number`: The L2 claim block number.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BootInfo {
/// The L1 head hash containing the safe L2 chain data that may reproduce the L2 head hash.
pub l1_head: B256,
/// The latest finalized L2 output root.
pub l2_output_root: B256,
/// The agreed upon safe L2 output root.
pub agreed_l2_output_root: B256,
/// The L2 output root claim.
pub l2_claim: B256,
pub claimed_l2_output_root: B256,
/// The L2 claim block number.
pub l2_claim_block: u64,
pub claimed_l2_block_number: u64,
/// The L2 chain ID.
pub chain_id: u64,
/// The rollup config for the L2 chain.
Expand Down Expand Up @@ -107,6 +107,13 @@ impl BootInfo {
.map_err(|e| anyhow!("Failed to deserialize rollup config: {}", e))?
};

Ok(Self { l1_head, l2_output_root, l2_claim, l2_claim_block, chain_id, rollup_config })
Ok(Self {
l1_head,
agreed_l2_output_root: l2_output_root,
claimed_l2_output_root: l2_claim,
claimed_l2_block_number: l2_claim_block,
chain_id,
rollup_config,
})
}
}
2 changes: 1 addition & 1 deletion bin/client/src/kona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn main() -> Result<()> {
// EPILOGUE //
////////////////////////////////////////////////////////////////

if number != boot.l2_claim_block || output_root != boot.l2_claim {
if number != boot.claimed_l2_block_number || output_root != boot.claimed_l2_output_root {
tracing::error!(
target: "client",
"Failed to validate L2 block #{number} with output root {output_root}",
Expand Down
7 changes: 5 additions & 2 deletions bin/client/src/l1/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,15 @@ where
) -> Result<(BlockInfo, L2BlockInfo, Sealed<Header>)> {
// Find the initial safe head, based off of the starting L2 block number in the boot info.
caching_oracle
.write(&HintType::StartingL2Output.encode_with(&[boot_info.l2_output_root.as_ref()]))
.write(
&HintType::StartingL2Output
.encode_with(&[boot_info.agreed_l2_output_root.as_ref()]),
)
.await?;
let mut output_preimage = [0u8; 128];
caching_oracle
.get_exact(
PreimageKey::new(*boot_info.l2_output_root, PreimageKeyType::Keccak256),
PreimageKey::new(*boot_info.agreed_l2_output_root, PreimageKeyType::Keccak256),
&mut output_preimage,
)
.await?;
Expand Down
8 changes: 6 additions & 2 deletions bin/client/src/l2/chain_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ impl<T: CommsClient> OracleL2ChainProvider<T> {
// Fetch the starting L2 output preimage.
self.oracle
.write(
&HintType::StartingL2Output.encode_with(&[self.boot_info.l2_output_root.as_ref()]),
&HintType::StartingL2Output
.encode_with(&[self.boot_info.agreed_l2_output_root.as_ref()]),
)
.await?;
let output_preimage = self
.oracle
.get(PreimageKey::new(*self.boot_info.l2_output_root, PreimageKeyType::Keccak256))
.get(PreimageKey::new(
*self.boot_info.agreed_l2_output_root,
PreimageKeyType::Keccak256,
))
.await?;

// Fetch the starting block header.
Expand Down

0 comments on commit 62b5128

Please sign in to comment.