diff --git a/bin/client/src/comms/caching_oracle.rs b/bin/client/src/fault/caching_oracle.rs similarity index 94% rename from bin/client/src/comms/caching_oracle.rs rename to bin/client/src/fault/caching_oracle.rs index 8eac4670b6..f7fe610ff9 100644 --- a/bin/client/src/comms/caching_oracle.rs +++ b/bin/client/src/fault/caching_oracle.rs @@ -3,7 +3,7 @@ //! //! [OracleReader]: kona_preimage::OracleReader -use crate::{HINT_WRITER, ORACLE_READER}; +use super::{HINT_WRITER, ORACLE_READER}; use alloc::{boxed::Box, sync::Arc, vec::Vec}; use anyhow::Result; use async_trait::async_trait; @@ -17,7 +17,7 @@ use spin::Mutex; /// /// [OracleReader]: kona_preimage::OracleReader #[derive(Debug, Clone)] -pub struct CachingOracle { +pub(crate) struct CachingOracle { /// The spin-locked cache that stores the responses from the oracle. cache: Arc>>>, } @@ -27,7 +27,7 @@ impl CachingOracle { /// responses in the cache. /// /// [OracleReader]: kona_preimage::OracleReader - pub fn new(cache_size: usize) -> Self { + pub(crate) fn new(cache_size: usize) -> Self { Self { cache: Arc::new(Mutex::new(LruCache::new( NonZeroUsize::new(cache_size).expect("N must be greater than 0"), diff --git a/bin/client/src/comms/mod.rs b/bin/client/src/fault/mod.rs similarity index 58% rename from bin/client/src/comms/mod.rs rename to bin/client/src/fault/mod.rs index 9627a174bc..b6689c0d10 100644 --- a/bin/client/src/comms/mod.rs +++ b/bin/client/src/fault/mod.rs @@ -1,10 +1,13 @@ -//! Contains the host <-> client communication utilities. +//! Contains FPVM-specific constructs for the `kona-client` program. use kona_common::FileDescriptor; use kona_preimage::{HintWriter, OracleReader, PipeHandle}; mod caching_oracle; -pub use caching_oracle::CachingOracle; +pub(crate) use caching_oracle::CachingOracle; + +mod precompiles; +pub(crate) use precompiles::FPVMPrecompileOverride; /// The global preimage oracle reader pipe. static ORACLE_READER_PIPE: PipeHandle = @@ -15,7 +18,7 @@ static HINT_WRITER_PIPE: PipeHandle = PipeHandle::new(FileDescriptor::HintRead, FileDescriptor::HintWrite); /// The global preimage oracle reader. -pub static ORACLE_READER: OracleReader = OracleReader::new(ORACLE_READER_PIPE); +pub(crate) static ORACLE_READER: OracleReader = OracleReader::new(ORACLE_READER_PIPE); /// The global hint writer. -pub static HINT_WRITER: HintWriter = HintWriter::new(HINT_WRITER_PIPE); +pub(crate) static HINT_WRITER: HintWriter = HintWriter::new(HINT_WRITER_PIPE); diff --git a/bin/client/src/l2/precompiles/bn128_pair.rs b/bin/client/src/fault/precompiles/bn128_pair.rs similarity index 96% rename from bin/client/src/l2/precompiles/bn128_pair.rs rename to bin/client/src/fault/precompiles/bn128_pair.rs index 75c1dcffd6..091be7e977 100644 --- a/bin/client/src/l2/precompiles/bn128_pair.rs +++ b/bin/client/src/fault/precompiles/bn128_pair.rs @@ -1,8 +1,10 @@ //! Contains the accelerated version of the `ecPairing` precompile. +use crate::fault::{HINT_WRITER, ORACLE_READER}; use alloc::{string::ToString, vec::Vec}; use alloy_primitives::{keccak256, Address, Bytes}; use anyhow::ensure; +use kona_client::HintType; use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient}; use revm::{ precompile::{ @@ -12,8 +14,6 @@ use revm::{ primitives::{Precompile, PrecompileOutput, PrecompileResult}, }; -use crate::{HintType, HINT_WRITER, ORACLE_READER}; - const ECPAIRING_ADDRESS: Address = u64_to_address(8); const PAIR_ELEMENT_LEN: usize = 64 + 128; diff --git a/bin/client/src/l2/precompiles/ecrecover.rs b/bin/client/src/fault/precompiles/ecrecover.rs similarity index 96% rename from bin/client/src/l2/precompiles/ecrecover.rs rename to bin/client/src/fault/precompiles/ecrecover.rs index bbe96d7a81..3c8c78a202 100644 --- a/bin/client/src/l2/precompiles/ecrecover.rs +++ b/bin/client/src/fault/precompiles/ecrecover.rs @@ -1,16 +1,16 @@ //! Contains the accelerated version of the `ecrecover` precompile. +use crate::fault::{HINT_WRITER, ORACLE_READER}; use alloc::{string::ToString, vec::Vec}; use alloy_primitives::{keccak256, Address, Bytes}; use anyhow::ensure; +use kona_client::HintType; use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient}; use revm::{ precompile::{u64_to_address, Error as PrecompileError, PrecompileWithAddress}, primitives::{Precompile, PrecompileOutput, PrecompileResult}, }; -use crate::{HintType, HINT_WRITER, ORACLE_READER}; - const ECRECOVER_ADDRESS: Address = u64_to_address(1); pub(crate) const FPVM_ECRECOVER: PrecompileWithAddress = diff --git a/bin/client/src/l2/precompiles/kzg_point_eval.rs b/bin/client/src/fault/precompiles/kzg_point_eval.rs similarity index 96% rename from bin/client/src/l2/precompiles/kzg_point_eval.rs rename to bin/client/src/fault/precompiles/kzg_point_eval.rs index 38ae7fc390..91eff01d56 100644 --- a/bin/client/src/l2/precompiles/kzg_point_eval.rs +++ b/bin/client/src/fault/precompiles/kzg_point_eval.rs @@ -1,16 +1,16 @@ //! Contains the accelerated version of the KZG point evaluation precompile. +use crate::fault::{HINT_WRITER, ORACLE_READER}; use alloc::{string::ToString, vec::Vec}; use alloy_primitives::{keccak256, Address, Bytes}; use anyhow::ensure; +use kona_client::HintType; use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient}; use revm::{ precompile::{u64_to_address, Error as PrecompileError, PrecompileWithAddress}, primitives::{Precompile, PrecompileOutput, PrecompileResult}, }; -use crate::{HintType, HINT_WRITER, ORACLE_READER}; - const POINT_EVAL_ADDRESS: Address = u64_to_address(0x0A); pub(crate) const FPVM_KZG_POINT_EVAL: PrecompileWithAddress = diff --git a/bin/client/src/l2/precompiles/mod.rs b/bin/client/src/fault/precompiles/mod.rs similarity index 97% rename from bin/client/src/l2/precompiles/mod.rs rename to bin/client/src/fault/precompiles/mod.rs index e041f58fe5..1d8e6082f0 100644 --- a/bin/client/src/l2/precompiles/mod.rs +++ b/bin/client/src/fault/precompiles/mod.rs @@ -14,7 +14,7 @@ mod kzg_point_eval; /// The [PrecompileOverride] implementation for the FPVM-accelerated precompiles. #[derive(Debug)] -pub struct FPVMPrecompileOverride +pub(crate) struct FPVMPrecompileOverride where F: TrieDBFetcher, H: TrieDBHinter, diff --git a/bin/client/src/kona.rs b/bin/client/src/kona.rs index bba1039c17..5fa4ae162d 100644 --- a/bin/client/src/kona.rs +++ b/bin/client/src/kona.rs @@ -5,18 +5,21 @@ #![no_std] #![cfg_attr(any(target_arch = "mips", target_arch = "riscv64"), no_main)] +extern crate alloc; + use alloc::sync::Arc; use alloy_consensus::Header; use kona_client::{ l1::{DerivationDriver, OracleBlobProvider, OracleL1ChainProvider}, - l2::{FPVMPrecompileOverride, OracleL2ChainProvider}, - BootInfo, CachingOracle, + l2::OracleL2ChainProvider, + BootInfo, }; use kona_common_proc::client_entry; use kona_executor::StatelessL2BlockExecutor; use kona_primitives::L2AttributesWithParent; -extern crate alloc; +pub(crate) mod fault; +use fault::{CachingOracle, FPVMPrecompileOverride}; /// The size of the LRU cache in the oracle. const ORACLE_LRU_SIZE: usize = 1024; diff --git a/bin/client/src/l2/mod.rs b/bin/client/src/l2/mod.rs index c2db9a8841..459e4dfe87 100644 --- a/bin/client/src/l2/mod.rs +++ b/bin/client/src/l2/mod.rs @@ -2,6 +2,3 @@ mod chain_provider; pub use chain_provider::OracleL2ChainProvider; - -mod precompiles; -pub use precompiles::FPVMPrecompileOverride; diff --git a/bin/client/src/lib.rs b/bin/client/src/lib.rs index 668e226430..3c11a076f8 100644 --- a/bin/client/src/lib.rs +++ b/bin/client/src/lib.rs @@ -10,14 +10,8 @@ pub mod l1; pub mod l2; -pub mod hint; +mod hint; pub use hint::HintType; -mod comms; -pub use comms::{CachingOracle, HINT_WRITER, ORACLE_READER}; - -mod boot; -pub use boot::{ - BootInfo, L1_HEAD_KEY, L2_CHAIN_ID_KEY, L2_CLAIM_BLOCK_NUMBER_KEY, L2_CLAIM_KEY, - L2_OUTPUT_ROOT_KEY, L2_ROLLUP_CONFIG_KEY, -}; +pub mod boot; +pub use boot::BootInfo; diff --git a/bin/host/src/kv/local.rs b/bin/host/src/kv/local.rs index 2815d81088..23dce446de 100644 --- a/bin/host/src/kv/local.rs +++ b/bin/host/src/kv/local.rs @@ -3,7 +3,7 @@ use super::KeyValueStore; use crate::cli::HostCli; use alloy_primitives::B256; -use kona_client::{ +use kona_client::boot::{ L1_HEAD_KEY, L2_CHAIN_ID_KEY, L2_CLAIM_BLOCK_NUMBER_KEY, L2_CLAIM_KEY, L2_OUTPUT_ROOT_KEY, L2_ROLLUP_CONFIG_KEY, };