Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
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
184 changes: 100 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ default-members = ["bin/host", "bin/client"]
# https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html
resolver = "2"

[workspace.lints.rust]
missing-debug-implementations = "warn"
missing-docs = "warn"
unreachable-pub = "warn"
unused-must-use = "deny"
rust-2018-idioms = "deny"
unnameable-types = "warn"

[workspace.lints.rustdoc]
all = "warn"

[workspace.lints.clippy]
needless-return = "allow" # Temporary fix since this is breaking in nightly clippy
all = { level = "warn", priority = -1 }
missing-const-for-fn = "warn"
use-self = "warn"
option-if-let-else = "warn"
redundant-clone = "warn"

[profile.dev]
opt-level = 1
overflow-checks = false
Expand Down
3 changes: 3 additions & 0 deletions bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
homepage.workspace = true
publish = false

[lints]
workspace = true

[dependencies]
# Workspace
kona-mpt.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions bin/host/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct HostCli {

impl HostCli {
/// Returns `true` if the host is running in offline mode.
pub fn is_offline(&self) -> bool {
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()
Expand Down Expand Up @@ -190,7 +190,7 @@ impl HostCli {
}

/// Styles for the CLI application.
fn cli_styles() -> clap::builder::Styles {
const fn cli_styles() -> clap::builder::Styles {
clap::builder::Styles::styled()
.usage(Style::new().bold().underline().fg_color(Some(Color::Ansi(AnsiColor::Yellow))))
.header(Style::new().bold().underline().fg_color(Some(Color::Ansi(AnsiColor::Yellow))))
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/cli/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ use std::str::FromStr;
///
/// # Returns
/// * `Result<B256, String>` - Ok if successful, Err otherwise.
pub fn parse_b256(s: &str) -> Result<B256, String> {
pub(crate) fn parse_b256(s: &str) -> Result<B256, String> {
B256::from_str(s).map_err(|_| format!("Invalid B256 value: {}", s))
}
24 changes: 11 additions & 13 deletions bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where
KV: KeyValueStore + ?Sized,
{
/// Create a new [Fetcher] with the given [KeyValueStore].
pub fn new(
pub const fn new(
kv_store: Arc<RwLock<KV>>,
l1_provider: ReqwestProvider,
blob_provider: OnlineBlobProvider<OnlineBeaconClient, SimpleSlotDerivation>,
Expand Down Expand Up @@ -253,18 +253,16 @@ where
let precompile_input = hint_data[20..].to_vec();
let input_hash = keccak256(hint_data.as_ref());

let result = match precompiles::execute(precompile_address, precompile_input) {
Ok(raw_res) => {
let mut res = Vec::with_capacity(1 + raw_res.len());
res.push(0x01); // success type byte
res.extend_from_slice(&raw_res);
res
}
Err(_) => {
// failure type byte
vec![0u8; 1]
}
};
let result = precompiles::execute(precompile_address, precompile_input)
.map_or_else(
|_| vec![0u8; 1],
|raw_res| {
let mut res = Vec::with_capacity(1 + raw_res.len());
res.push(0x01);
res.extend_from_slice(&raw_res);
res
},
);

// Acquire a lock on the key-value store and set the preimages.
let mut kv_lock = self.kv_store.write().await;
Expand Down
4 changes: 2 additions & 2 deletions bin/host/src/kv/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ impl Drop for DiskKeyValueStore {
impl TryFrom<DiskKeyValueStore> for MemoryKeyValueStore {
type Error = anyhow::Error;

fn try_from(disk_store: DiskKeyValueStore) -> Result<MemoryKeyValueStore> {
let mut memory_store = MemoryKeyValueStore::new();
fn try_from(disk_store: DiskKeyValueStore) -> Result<Self> {
let mut memory_store = Self::new();
let mut db_iter = disk_store.db.full_iterator(rocksdb::IteratorMode::Start);

while let Some(Ok((key, value))) = db_iter.next() {
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/kv/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct LocalKeyValueStore {

impl LocalKeyValueStore {
/// Create a new [LocalKeyValueStore] with the given [HostCli] config.
pub fn new(cfg: HostCli) -> Self {
pub const fn new(cfg: HostCli) -> Self {
Self { cfg }
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/kv/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ where
R: KeyValueStore,
{
/// Create a new [SplitKeyValueStore] with the given left and right [KeyValueStore]s.
pub fn new(local_store: L, remote_store: R) -> Self {
pub const fn new(local_store: L, remote_store: R) -> Self {
Self { local_store, remote_store }
}
}
Expand Down
2 changes: 0 additions & 2 deletions bin/host/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![doc = include_str!("../README.md")]
#![warn(missing_debug_implementations, missing_docs, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
2 changes: 2 additions & 0 deletions bin/host/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Main entrypoint for the host binary.

use anyhow::Result;
use clap::Parser;
use kona_host::{init_tracing_subscriber, start_server, start_server_and_native_client, HostCli};
Expand Down
6 changes: 3 additions & 3 deletions bin/host/src/preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
KV: KeyValueStore + ?Sized,
{
/// Create a new [OnlinePreimageFetcher] from the given [Fetcher].
pub fn new(fetcher: Arc<RwLock<Fetcher<KV>>>) -> Self {
pub const fn new(fetcher: Arc<RwLock<Fetcher<KV>>>) -> Self {
Self { inner: fetcher }
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ where
KV: KeyValueStore + ?Sized,
{
/// Create a new [OfflinePreimageFetcher] from the given [KeyValueStore].
pub fn new(kv_store: Arc<RwLock<KV>>) -> Self {
pub const fn new(kv_store: Arc<RwLock<KV>>) -> Self {
Self { inner: kv_store }
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ where
KV: KeyValueStore + ?Sized,
{
/// Create a new [OnlineHintRouter] from the given [Fetcher].
pub fn new(fetcher: Arc<RwLock<Fetcher<KV>>>) -> Self {
pub const fn new(fetcher: Arc<RwLock<Fetcher<KV>>>) -> Self {
Self { inner: fetcher }
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
/// Create a new [PreimageServer] with the given [PreimageOracleServer],
/// [HintReaderServer], and [KeyValueStore]. Holds onto the file descriptors for the pipes
/// that are created, so that the pipes are not closed until the server is dropped.
pub fn new(
pub const fn new(
oracle_server: P,
hint_reader: H,
kv_store: Arc<RwLock<KV>>,
Expand Down
3 changes: 3 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ license.workspace = true
repository.workspace = true
homepage.workspace = true

[lints]
workspace = true

[dependencies]
thiserror.workspace = true
cfg-if.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/asterisc/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{asterisc::syscall, errors::IOResult, BasicKernelInterface, FileDescr

/// Concrete implementation of the [`KernelIO`] trait for the `riscv64` target architecture.
#[derive(Debug)]
pub struct AsteriscIO;
pub(crate) struct AsteriscIO;

/// Relevant system call numbers for the `riscv64` target architecture.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/cannon/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{cannon::syscall, errors::IOResult, BasicKernelInterface, FileDescrip
/// Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target
/// architecture. Exposes a safe interface for performing IO operations within the FPVM kernel.
#[derive(Debug)]
pub struct CannonIO;
pub(crate) struct CannonIO;

/// Relevant system call numbers for the `MIPS32rel1` target architecture.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn block_on<T>(f: impl Future<Output = T>) -> T {
fn noop_clone(_: *const ()) -> RawWaker {
noop_raw_waker()
}
fn noop(_: *const ()) {}
const fn noop(_: *const ()) {}
fn noop_raw_waker() -> RawWaker {
let vtable = &RawWakerVTable::new(noop_clone, noop, noop, noop);
RawWaker::new(core::ptr::null(), vtable)
Expand Down
15 changes: 8 additions & 7 deletions crates/common/src/io.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module contains the [ClientIO] struct, which is used to perform various IO operations
//! This module contains the `ClientIO` struct, which is used to perform various IO operations
//! inside of the FPVM kernel within a `client` program.

use crate::{errors::IOResult, BasicKernelInterface, FileDescriptor};
Expand All @@ -7,16 +7,16 @@ use cfg_if::cfg_if;
cfg_if! {
if #[cfg(target_arch = "mips")] {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target architecture."]
pub type ClientIO = crate::cannon::io::CannonIO;
pub(crate) type ClientIO = crate::cannon::io::CannonIO;
} else if #[cfg(target_arch = "riscv64")] {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `riscv64` target architecture."]
pub type ClientIO = crate::asterisc::io::AsteriscIO;
pub(crate) type ClientIO = crate::asterisc::io::AsteriscIO;
} else if #[cfg(target_os = "zkvm")] {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `SP1` target architecture."]
pub type ClientIO = crate::zkvm::io::ZkvmIO;
pub(crate) type ClientIO = crate::zkvm::io::ZkvmIO;
} else {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `native` target architecture."]
pub type ClientIO = native_io::NativeIO;
pub(crate) type ClientIO = native_io::NativeIO;
}
}

Expand Down Expand Up @@ -56,8 +56,9 @@ pub fn exit(code: usize) -> ! {
ClientIO::exit(code)
}

/// Native IO Module
#[cfg(not(any(target_arch = "mips", target_arch = "riscv64", target_os = "zkvm")))]
mod native_io {
pub(crate) mod native_io {
use crate::{
errors::{IOError, IOResult},
io::FileDescriptor,
Expand All @@ -71,7 +72,7 @@ mod native_io {

/// Mock IO implementation for native tests.
#[derive(Debug)]
pub struct NativeIO;
pub(crate) struct NativeIO;

impl BasicKernelInterface for NativeIO {
fn write(fd: FileDescriptor, buf: &[u8]) -> IOResult<usize> {
Expand Down
2 changes: 0 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![doc = include_str!("../README.md")]
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(target_arch = "mips", feature(asm_experimental_arch))]
#![cfg_attr(any(target_arch = "mips", target_arch = "riscv64", target_os = "zkvm"), no_std)]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::errors::{IOError, IOResult};
/// Converts a return value from a syscall into a [IOResult] type.
#[inline(always)]
#[allow(unused)]
pub(crate) fn from_ret(value: usize) -> IOResult<usize> {
pub(crate) const fn from_ret(value: usize) -> IOResult<usize> {
if value > -4096isize as usize {
// Truncation of the error value is guaranteed to never occur due to
// the above check. This is the same check that musl uses:
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ impl From<FileDescriptor> for usize {

impl From<FileDescriptor> for i32 {
fn from(fd: FileDescriptor) -> Self {
usize::from(fd) as i32
usize::from(fd) as Self
}
}
2 changes: 1 addition & 1 deletion crates/common/src/zkvm/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{errors::IOResult, BasicKernelInterface, FileDescriptor};

/// Concrete implementation of the [`KernelIO`] trait for the `SP1` target architecture.
#[derive(Debug)]
pub struct ZkvmIO;
pub(crate) struct ZkvmIO;

impl BasicKernelInterface for ZkvmIO {
fn write(_fd: FileDescriptor, _buf: &[u8]) -> IOResult<usize> {
Expand Down
3 changes: 3 additions & 0 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ license.workspace = true
repository.workspace = true
homepage.workspace = true

[lints]
workspace = true

[dependencies]
# Alloy
alloy-eips.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
L2P: L2ChainProvider + Debug,
{
/// Create a new [StatefulAttributesBuilder] with the given epoch.
pub fn new(rcfg: Arc<RollupConfig>, sys_cfg_fetcher: L2P, receipts: L1P) -> Self {
pub const fn new(rcfg: Arc<RollupConfig>, sys_cfg_fetcher: L2P, receipts: L1P) -> Self {
Self { rollup_cfg: rcfg, config_fetcher: sys_cfg_fetcher, receipts_fetcher: receipts }
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/derive/src/batch/batch_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ pub enum BatchType {
impl From<u8> for BatchType {
fn from(val: u8) -> Self {
match val {
SINGLE_BATCH_TYPE => BatchType::Single,
SPAN_BATCH_TYPE => BatchType::Span,
SINGLE_BATCH_TYPE => Self::Single,
SPAN_BATCH_TYPE => Self::Span,
_ => panic!("Invalid batch type: {val}"),
}
}
}

impl From<&[u8]> for BatchType {
fn from(buf: &[u8]) -> Self {
BatchType::from(buf[0])
Self::from(buf[0])
}
}

impl Encodable for BatchType {
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
let val = match self {
BatchType::Single => SINGLE_BATCH_TYPE,
BatchType::Span => SPAN_BATCH_TYPE,
Self::Single => SINGLE_BATCH_TYPE,
Self::Span => SPAN_BATCH_TYPE,
};
val.encode(out);
}
Expand All @@ -47,7 +47,7 @@ impl Encodable for BatchType {
impl Decodable for BatchType {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
let val = u8::decode(buf)?;
Ok(BatchType::from(val))
Ok(Self::from(val))
}
}

Expand Down
9 changes: 5 additions & 4 deletions crates/derive/src/batch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ mod span_batch;
pub use span_batch::{
RawSpanBatch, SpanBatch, SpanBatchBits, SpanBatchEip1559TransactionData,
SpanBatchEip2930TransactionData, SpanBatchElement, SpanBatchError,
SpanBatchLegacyTransactionData, SpanBatchPayload, SpanBatchPrefix, SpanBatchTransactionData,
SpanBatchTransactions, SpanDecodingError, FJORD_MAX_SPAN_BATCH_BYTES, MAX_SPAN_BATCH_BYTES,
SpanBatchLegacyTransactionData, SpanBatchPayload, SpanBatchPrefix, SpanBatchSignature,
SpanBatchTransactionData, SpanBatchTransactions, SpanDecodingError, FJORD_MAX_SPAN_BATCH_BYTES,
MAX_SPAN_BATCH_BYTES,
};

mod single_batch;
Expand Down Expand Up @@ -92,14 +93,14 @@ impl Batch {
BatchType::Single => {
let single_batch =
SingleBatch::decode(r).map_err(PipelineEncodingError::AlloyRlpError)?;
Ok(Batch::Single(single_batch))
Ok(Self::Single(single_batch))
}
BatchType::Span => {
let mut raw_span_batch = RawSpanBatch::decode(r, cfg)?;
let span_batch = raw_span_batch
.derive(cfg.block_time, cfg.genesis.l2_time, cfg.l2_chain_id)
.map_err(PipelineEncodingError::SpanBatchError)?;
Ok(Batch::Span(span_batch))
Ok(Self::Span(span_batch))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/batch/single_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl SingleBatch {
}

/// Returns the [BlockNumHash] of the batch.
pub fn epoch(&self) -> BlockNumHash {
pub const fn epoch(&self) -> BlockNumHash {
BlockNumHash { number: self.epoch_num, hash: self.epoch_hash }
}

Expand Down
Loading