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
716 changes: 471 additions & 245 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 22 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,34 @@ ethereum-consensus = { git = "https://github.com/datachainlab/ethereum-light-cli
ethereum-light-client-verifier = { git = "https://github.com/datachainlab/ethereum-light-client-rs", rev = "v0.2.0", default-features = false }

# Kona
kona-mpt = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-client = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-host = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-proof = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-preimage = {git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-executor = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-driver = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-providers-alloy= { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-genesis = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-protocol = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-derive = { git="https://github.com/anton-rs/kona", rev= "kona-client/v1.0.2", default-features = false }
kona-mpt = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-client = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-host = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-proof = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-preimage = {git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-executor = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-driver = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-providers-alloy= { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-genesis = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-protocol = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-derive = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }
kona-registry = { git="https://github.com/op-rs/kona", rev= "kona-node/v1.1.3", default-features = false }

# Alloy
alloy-consensus = { version = "1.0.9", default-features = false }
alloy-primitives = { version = "1.1.2", default-features = false }
alloy-eips = { version = "1.0.9", default-features = false }
alloy-trie = { version = "0.8.1", default-features = false }
alloy-consensus = { version = "1.0.38", default-features = false }
alloy-primitives = { version = "1.3.1", default-features = false }
alloy-eips = { version = "1.0.38", default-features = false }
alloy-trie = { version = "0.9.1", default-features = false }

# OP Alloy
op-alloy-rpc-types-engine = { version = "0.17.2", default-features = false }
op-alloy-consensus= { version = "0.17.2", default-features = false }
op-alloy-rpc-types-engine = { version = "0.20.0", default-features = false }
op-alloy-consensus= { version = "0.20.0", default-features = false }

# Ethereum
revm = { version = "24.0.1", default-features = false }
op-revm = { version = "5.0.1", default-features = false }
alloy-evm = { version = "0.10.0", default-features = false, features = ["op"] }
alloy-op-evm = { version = "0.10.0", default-features = false }
revm = { version = "29.0.1", default-features = false }
op-revm = { version = "10.1.0", default-features = false }
alloy-evm = { version = "0.21.0", default-features = false, features = ["op"] }
alloy-op-evm = { version = "0.21.0", default-features = false }

# Cryptography
sha2 = { version = "0.10.8", default-features = false }
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PHONY: sync-lock
sync-lock:
cargo update -p kona-client
cd tools/deps && python sync_lock.py
# Check build
cargo build
1 change: 1 addition & 0 deletions derivation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kona-derive = { workspace = true }
kona-proof = { workspace = true }
kona-genesis = { workspace = true, features = ["serde"] }
kona-client = { workspace = true }
kona-registry = { workspace = true }

# Alloy
alloy-primitives = { workspace = true }
Expand Down
33 changes: 29 additions & 4 deletions derivation/src/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ use core::clone::Clone;
use core::fmt::Debug;
use kona_client::fpvm_evm::FpvmOpEvmFactory;
use kona_client::single::fetch_safe_head_hash;
use kona_derive::sources::EthereumDataSource;
use kona_derive::EthereumDataSource;
use kona_driver::Driver;
use kona_executor::TrieDBProvider;
use kona_genesis::RollupConfig;
use kona_genesis::{L1ChainConfig, RollupConfig};
use kona_preimage::{PreimageKey, PreimageOracleClient};
use kona_proof::boot::L2_ROLLUP_CONFIG_KEY;
use kona_proof::boot::{L1_CONFIG_KEY, L2_ROLLUP_CONFIG_KEY};
use kona_proof::sync::new_oracle_pipeline_cursor;
use kona_proof::{
executor::KonaExecutor,
l1::{OracleBlobProvider, OracleL1ChainProvider, OraclePipeline},
l2::OracleL2ChainProvider,
BootInfo,
};
use kona_registry::L1_CONFIGS;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -64,13 +65,15 @@ impl Derivation {
oracle: MemoryOracleClient,
) -> Result<(Header, u64), Error> {
verify_config(rollup_config, &oracle).await?;
let l1_config = load_l1_config(rollup_config, &oracle).await?;
let boot = &BootInfo {
l1_head: self.l1_head_hash,
agreed_l2_output_root: self.agreed_l2_output_root,
claimed_l2_output_root: self.l2_output_root,
claimed_l2_block_number: self.l2_block_number,
chain_id,
rollup_config: rollup_config.clone(),
l1_config: l1_config.clone(),
};
let rollup_config = Arc::new(boot.rollup_config.clone());
let safe_head_hash = fetch_safe_head_hash(&oracle, boot.agreed_l2_output_root).await?;
Expand Down Expand Up @@ -98,6 +101,7 @@ impl Derivation {
EthereumDataSource::new_from_parts(l1_provider.clone(), beacon, &rollup_config);
let pipeline = OraclePipeline::new(
rollup_config.clone(),
l1_config.into(),
cursor.clone(),
oracle.clone(),
da_provider,
Expand Down Expand Up @@ -159,6 +163,27 @@ async fn verify_config(
Ok(())
}

async fn load_l1_config(
rollup_config: &RollupConfig,
oracle: &MemoryOracleClient,
) -> Result<L1ChainConfig, Error> {
let l1_config = if let Some(config) = L1_CONFIGS.get(&rollup_config.l1_chain_id) {
config.clone()
} else {
// for devnet only
let config_key = PreimageKey::new_local(L1_CONFIG_KEY.to());
let ser_cfg = oracle
.get(config_key)
.await
.map_err(|e| Error::UnexpectedPreimageKey {
source: e,
key: config_key.key_value().to_be_bytes(),
})?;
serde_json::from_slice(&ser_cfg).map_err(Error::SerdeError)?
};
Ok(l1_config)
}

#[cfg(test)]
mod test {
use crate::derivation::verify_config;
Expand All @@ -185,7 +210,7 @@ mod test {
fn test_verify_config_invalid_error() {
let rollup_config = RollupConfig::default();
let rollup_config2 = RollupConfig {
l2_chain_id: rollup_config.l2_chain_id + 1,
l2_chain_id: (rollup_config.l2_chain_id.id() + 1).into(),
..rollup_config.clone()
};

Expand Down
2 changes: 1 addition & 1 deletion derivation/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum Error {
#[error("DriverError: err={0:?}")]
DriverError(#[from] kona_driver::DriverError<kona_executor::ExecutorError>),
#[error("PipelineError: err={0:?}")]
PipelineError(#[from] kona_derive::errors::PipelineErrorKind),
PipelineError(#[from] kona_derive::PipelineErrorKind),
#[error("SerdeError: err={0:?}")]
SerdeError(#[from] serde_json::Error),
#[error("UnexpectedLocalPreimageKey: key={0:?}")]
Expand Down
1 change: 1 addition & 0 deletions derivation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![no_std]
#![allow(clippy::result_large_err)]
extern crate alloc;

pub mod derivation;
Expand Down
11 changes: 5 additions & 6 deletions derivation/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ark_ff::BigInteger;
use hashbrown::{HashMap, HashSet};
use kona_preimage::errors::{PreimageOracleError, PreimageOracleResult};
use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient};
use kona_proof::boot::L2_ROLLUP_CONFIG_KEY;
use kona_proof::boot::{L1_CONFIG_KEY, L2_ROLLUP_CONFIG_KEY};
use kona_proof::l1::ROOTS_OF_UNITY;
use kona_proof::FlushableCache;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -46,8 +46,7 @@ impl PreimageOracleClient for MemoryOracleClient {
Ok(value.clone())
} else {
Err(PreimageOracleError::Other(format!(
"key not found: {:?}",
key
"key not found: {key:?}"
)))
}
}
Expand All @@ -58,8 +57,7 @@ impl PreimageOracleClient for MemoryOracleClient {
Ok(())
} else {
Err(PreimageOracleError::Other(format!(
"key not found: {:?}",
key
"key not found: {key:?}"
)))
}
}
Expand Down Expand Up @@ -124,7 +122,8 @@ impl TryFrom<Vec<Preimage>> for MemoryOracleClient {
}
PreimageKeyType::Sha256 => verify_sha256_preimage(&preimage_key, &preimage.data)?,
PreimageKeyType::Local => {
if preimage_key.key_value() != L2_ROLLUP_CONFIG_KEY {
let key = preimage_key.key_value();
if key != L2_ROLLUP_CONFIG_KEY && key != L1_CONFIG_KEY {
return Err(Error::UnexpectedLocalPreimageKey(preimage_key));
}
}
Expand Down
4 changes: 2 additions & 2 deletions light-client/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ mod test {
"48b7747ba1094684d9197bbaa5dcb134587d23e493fb53a29e400c50e50f5147"
)),
);
assert!(res.is_ok(), "{:?}", res);
assert!(res.is_ok(), "{res:?}");
}

#[test]
Expand Down Expand Up @@ -149,7 +149,7 @@ mod test {
"568a51c3253bbd2d46e3923b35df0489712df11453fd04dd71341120356952c0"
)),
);
assert!(res.is_ok(), "{:?}", res);
assert!(res.is_ok(), "{res:?}");
}

#[test]
Expand Down
Loading