Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Jan 22, 2025
1 parent 99cfa82 commit 6f2749a
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 25 deletions.
6 changes: 3 additions & 3 deletions bin/host/src/interop/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ pub struct InteropHostCli {
impl InteropHostCli {
/// Returns `true` if the host is running in offline mode.
pub const fn is_offline(&self) -> bool {
self.l1_node_address.is_none()
&& self.l2_node_addresses.is_none()
&& self.l1_beacon_address.is_none()
self.l1_node_address.is_none() &&
self.l2_node_addresses.is_none() &&
self.l1_beacon_address.is_none()
}

/// Returns the active L2 chain ID based on the agreed L2 pre-state.
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/interop/local_kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use super::InteropHostCli;
use alloy_primitives::{keccak256, B256};
use anyhow::Result;
use kona_preimage_server::KeyValueStore;
use kona_preimage::PreimageKey;
use kona_preimage_server::KeyValueStore;
use kona_proof_interop::boot::{
L1_HEAD_KEY, L2_AGREED_PRE_STATE_KEY, L2_CHAIN_ID_KEY, L2_CLAIMED_POST_STATE_KEY,
L2_CLAIMED_TIMESTAMP_KEY, L2_ROLLUP_CONFIG_KEY,
Expand Down
12 changes: 8 additions & 4 deletions bin/host/src/interop/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ pub struct InteropProviders {
impl HostOrchestrator for InteropHostCli {
type Providers = InteropProviders;

async fn create_providers(&self) -> Result<Self::Providers> {
async fn create_providers(&self) -> Result<Option<Self::Providers>> {
if self.is_offline() {
return Ok(None);
}

let l1_provider =
http_provider(self.l1_node_address.as_ref().ok_or(anyhow!("Provider must be set"))?);

Expand All @@ -51,15 +55,15 @@ impl HostOrchestrator for InteropHostCli {
l2_providers.insert(chain_id, l2_provider);
}

Ok(InteropProviders { l1_provider, blob_provider, l2_providers })
Ok(Some(InteropProviders { l1_provider, blob_provider, l2_providers }))
}

fn create_fetcher(
&self,
providers: Self::Providers,
providers: Option<Self::Providers>,
kv_store: SharedKeyValueStore,
) -> Option<Arc<RwLock<impl Fetcher + Send + Sync + 'static>>> {
(!self.is_offline()).then(|| {
providers.map(|providers| {
// TODO: Don't pass the whole cfg to the interop fetcher.
Arc::new(RwLock::new(InteropFetcher::new(
self.clone(),
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use tracing::info;
pub mod cli;
pub mod eth;
pub mod interop;
pub mod single;
pub mod orchestrator;
pub mod single;

#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<()> {
Expand Down
9 changes: 6 additions & 3 deletions bin/host/src/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Contains the [HostOrchestrator] trait, which defines entry points for the host to run a given module.
//! Contains the [HostOrchestrator] trait, which defines entry points for the host to run a given
//! module.
use anyhow::Result;
use async_trait::async_trait;
Expand Down Expand Up @@ -41,15 +42,17 @@ pub trait HostOrchestrator {
type Providers;

/// Instantiates the providers for the host's fetcher.
async fn create_providers(&self) -> Result<Self::Providers>;
async fn create_providers(&self) -> Result<Option<Self::Providers>>;

/// Constructs the [KeyValueStore] for the host.
///
/// [KeyValueStore]: kona_preimage_server::KeyValueStore
fn create_key_value_store(&self) -> Result<SharedKeyValueStore>;

/// Creates a [Fetcher] for the host program's preimage server.
fn create_fetcher(
&self,
providers: Self::Providers,
providers: Option<Self::Providers>,
kv_store: SharedKeyValueStore,
) -> Option<Arc<RwLock<impl Fetcher + Send + Sync + 'static>>>;

Expand Down
6 changes: 3 additions & 3 deletions bin/host/src/single/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pub struct SingleChainHostCli {
impl SingleChainHostCli {
/// Returns `true` if the host is running in offline mode.
pub const fn is_offline(&self) -> bool {
self.l1_node_address.is_none()
&& self.l2_node_address.is_none()
&& self.l1_beacon_address.is_none()
self.l1_node_address.is_none() &&
self.l2_node_address.is_none() &&
self.l1_beacon_address.is_none()
}

/// Reads the [RollupConfig] from the file system and returns it as a string.
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/single/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use alloy_rpc_types::{
Transaction,
};
use anyhow::{anyhow, Result};
use kona_preimage_server::KeyValueStore;
use kona_preimage::{
errors::{PreimageOracleError, PreimageOracleResult},
HintRouter, PreimageFetcher, PreimageKey, PreimageKeyType,
};
use kona_preimage_server::KeyValueStore;
use kona_proof::{Hint, HintType};
use maili_protocol::BlockInfo;
use op_alloy_rpc_types_engine::OpPayloadAttributes;
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/single/local_kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use super::SingleChainHostCli;
use alloy_primitives::B256;
use anyhow::Result;
use kona_preimage_server::KeyValueStore;
use kona_preimage::PreimageKey;
use kona_preimage_server::KeyValueStore;
use kona_proof::boot::{
L1_HEAD_KEY, L2_CHAIN_ID_KEY, L2_CLAIM_BLOCK_NUMBER_KEY, L2_CLAIM_KEY, L2_OUTPUT_ROOT_KEY,
L2_ROLLUP_CONFIG_KEY,
Expand Down
12 changes: 8 additions & 4 deletions bin/host/src/single/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ pub struct SingleChainProviders {
impl HostOrchestrator for SingleChainHostCli {
type Providers = SingleChainProviders;

async fn create_providers(&self) -> Result<Self::Providers> {
async fn create_providers(&self) -> Result<Option<Self::Providers>> {
if self.is_offline() {
return Ok(None);
}

let blob_provider = OnlineBlobProvider::new_http(
self.l1_beacon_address.clone().ok_or(anyhow!("Beacon API URL must be set"))?,
)
Expand All @@ -42,15 +46,15 @@ impl HostOrchestrator for SingleChainHostCli {
self.l2_node_address.as_ref().ok_or(anyhow!("L2 node address must be set"))?,
);

Ok(SingleChainProviders { l1_provider, blob_provider, l2_provider })
Ok(Some(SingleChainProviders { l1_provider, blob_provider, l2_provider }))
}

fn create_fetcher(
&self,
providers: Self::Providers,
providers: Option<Self::Providers>,
kv_store: SharedKeyValueStore,
) -> Option<Arc<RwLock<impl Fetcher + Send + Sync + 'static>>> {
(!self.is_offline()).then(|| {
providers.map(|providers| {
Arc::new(RwLock::new(SingleChainFetcher::new(
kv_store,
providers.l1_provider,
Expand Down
2 changes: 1 addition & 1 deletion build/asterisc/asterisc-repro.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends git

# Build kona-client on the selected tag
RUN git checkout $CLIENT_TAG && \
cargo build -Zbuild-std=core,alloc --workspace --bin kona --locked --profile release-client-lto --exclude kona-host --exclude kona-derive-alloy && \
cargo build -Zbuild-std=core,alloc --workspace --bin kona --locked --profile release-client-lto --exclude kona-preimage-server --exclude kona-host && \
mv ./target/riscv64imac-unknown-none-elf/release-client-lto/kona /kona-client-elf

################################################################
Expand Down
3 changes: 2 additions & 1 deletion crates/proof-sdk/preimage-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ where
H: HintReaderServer,
{
loop {
// Route the next hint. This `await` will yield to the runtime if no progress can be made.
// Route the next hint. This `await` will yield to the runtime if no progress can be
// made.
match server.next_hint(router).await {
Ok(_) => continue,
Err(PreimageOracleError::IOError(_)) => return Ok(()),
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ build-cannon *args='':
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
ghcr.io/op-rs/kona/cannon-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host
ghcr.io/op-rs/kona/cannon-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-preimage-server --exclude kona-host

# Build for the `asterisc` target. Any crates that require the stdlib are excluded from the build for this target.
build-asterisc *args='':
Expand All @@ -114,7 +114,7 @@ build-asterisc *args='':
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
ghcr.io/op-rs/kona/asterisc-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host
ghcr.io/op-rs/kona/asterisc-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-preimage-server --exclude kona-host

# Build the `kona-client` prestate artifacts for the latest release.
build-client-prestate-asterisc-artifacts kona_tag asterisc_tag out='./prestate-artifacts-asterisc':
Expand Down

0 comments on commit 6f2749a

Please sign in to comment.