Skip to content

Commit

Permalink
feat(workspace): kona-proof (#818)
Browse files Browse the repository at this point in the history
* feat(workspace): Introduce `kona-proof` crate

* ignore `kona-proof`

fix
  • Loading branch information
clabby authored Nov 15, 2024
1 parent 1953014 commit 4a3b928
Show file tree
Hide file tree
Showing 32 changed files with 279 additions and 91 deletions.
3 changes: 1 addition & 2 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ ignore:
- "**/test_utils*"
- "**/test_util*"
- "**/tests*"
- "crates/derive-alloy/src/alloy_providers.rs"
- "crates/derive-alloy/src/beacon_client.rs"
- "crates/proof-sdk/proof"
- "crates/mpt/src/noop.rs"

# Make comments less noisy
Expand Down
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ kona-executor = { path = "crates/executor", version = "0.0.5", default-features
kona-common = { path = "crates/proof-sdk/common", version = "0.0.4", default-features = false }
kona-common-proc = { path = "crates/proof-sdk/common-proc", version = "0.0.5", default-features = false }
kona-preimage = { path = "crates/proof-sdk/preimage", version = "0.0.4", default-features = false }
kona-proof = { path = "crates/proof-sdk/proof", version = "0.0.1", default-features = false }

# Alloy
alloy-rlp = { version = "0.3.9", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kona-driver.workspace = true
kona-preimage.workspace = true
kona-executor.workspace = true
kona-common-proc.workspace = true
kona-proof.workspace = true

# Alloy
alloy-rlp.workspace = true
Expand Down
22 changes: 0 additions & 22 deletions bin/client/src/fault/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Contains the accelerated version of the `ecPairing` precompile.
use crate::fault::{HINT_WRITER, ORACLE_READER};
use crate::{HINT_WRITER, ORACLE_READER};
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{keccak256, Address, Bytes};
use kona_client::{errors::OracleProviderError, HintType};
use kona_preimage::{
errors::PreimageOracleError, HintWriterClient, PreimageKey, PreimageKeyType,
PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{
bn128::pair::{ISTANBUL_PAIR_BASE, ISTANBUL_PAIR_PER_POINT},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Contains the accelerated version of the `ecrecover` precompile.
use crate::fault::{HINT_WRITER, ORACLE_READER};
use crate::{HINT_WRITER, ORACLE_READER};
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{keccak256, Address, Bytes};
use kona_client::{errors::OracleProviderError, HintType};
use kona_preimage::{
errors::PreimageOracleError, HintWriterClient, PreimageKey, PreimageKeyType,
PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{u64_to_address, Error as PrecompileError, PrecompileWithAddress},
primitives::{Precompile, PrecompileOutput, PrecompileResult},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Contains the accelerated version of the KZG point evaluation precompile.
use crate::fault::{HINT_WRITER, ORACLE_READER};
use crate::{HINT_WRITER, ORACLE_READER};
use alloc::{string::ToString, vec::Vec};
use alloy_primitives::{keccak256, Address, Bytes};
use kona_client::{errors::OracleProviderError, HintType};
use kona_preimage::{
errors::PreimageOracleError, HintWriterClient, PreimageKey, PreimageKeyType,
PreimageOracleClient,
};
use kona_proof::{errors::OracleProviderError, HintType};
use revm::{
precompile::{u64_to_address, Error as PrecompileError, PrecompileWithAddress},
primitives::{Precompile, PrecompileOutput, PrecompileResult},
Expand Down
File renamed without changes.
30 changes: 23 additions & 7 deletions bin/client/src/kona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,37 @@
extern crate alloc;

use alloc::{string::String, sync::Arc};
use kona_client::{
use kona_client::PipeHandle;
use kona_common::{io, FileDescriptor};
use kona_common_proc::client_entry;
use kona_driver::{Driver, DriverError};
use kona_preimage::{HintWriter, OracleReader};
use kona_proof::{
executor::KonaExecutorConstructor,
l1::{OracleBlobProvider, OracleL1ChainProvider, OraclePipeline},
l2::OracleL2ChainProvider,
sync::new_pipeline_cursor,
BootInfo, CachingOracle,
};
use kona_common::io;
use kona_common_proc::client_entry;
use kona_driver::{Driver, DriverError};

pub(crate) mod fault;
use fault::{fpvm_handle_register, HINT_WRITER, ORACLE_READER};
use tracing::{error, info, warn};

mod handler;
use handler::fpvm_handle_register;

/// The global preimage oracle reader pipe.
static ORACLE_READER_PIPE: PipeHandle =
PipeHandle::new(FileDescriptor::PreimageRead, FileDescriptor::PreimageWrite);

/// The global hint writer pipe.
static HINT_WRITER_PIPE: PipeHandle =
PipeHandle::new(FileDescriptor::HintRead, FileDescriptor::HintWrite);

/// The global preimage oracle reader.
static ORACLE_READER: OracleReader<PipeHandle> = OracleReader::new(ORACLE_READER_PIPE);

/// The global hint writer.
static HINT_WRITER: HintWriter<PipeHandle> = HintWriter::new(HINT_WRITER_PIPE);

/// The size of the LRU cache in the oracle.
const ORACLE_LRU_SIZE: usize = 1024;

Expand Down
19 changes: 0 additions & 19 deletions bin/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,5 @@

extern crate alloc;

pub mod l1;

pub mod l2;

pub mod sync;

pub mod errors;

pub mod executor;

mod hint;
pub use hint::HintType;

pub mod boot;
pub use boot::BootInfo;

mod pipe;
pub use pipe::PipeHandle;

mod caching_oracle;
pub use caching_oracle::{CachingOracle, FlushableCache};
1 change: 1 addition & 0 deletions bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kona-client.workspace = true
kona-derive.workspace = true
kona-common.workspace = true
kona-preimage.workspace = true
kona-proof.workspace = true

# Alloy
alloy-rlp.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use alloy_rpc_types::{
Block, BlockNumberOrTag, BlockTransactions, BlockTransactionsKind, Transaction,
};
use anyhow::{anyhow, Result};
use kona_client::HintType;
use kona_derive::sources::IndexedBlobHash;
use kona_preimage::{PreimageKey, PreimageKeyType};
use kona_proof::HintType;
use op_alloy_protocol::BlockInfo;
use std::sync::Arc;
use tokio::sync::RwLock;
Expand Down
4 changes: 2 additions & 2 deletions bin/host/src/kv/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use super::KeyValueStore;
use crate::cli::HostCli;
use alloy_primitives::B256;
use anyhow::Result;
use kona_client::boot::{
use kona_preimage::PreimageKey;
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,
};
use kona_preimage::PreimageKey;

/// The default chain ID to use if none is provided.
const DEFAULT_CHAIN_ID: u64 = 0xbeefbabe;
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy_provider::ReqwestProvider;
use alloy_rpc_client::RpcClient;
use alloy_transport_http::Http;
use anyhow::{anyhow, Result};
use kona_client::HintType;
use kona_proof::HintType;
use os_pipe::{PipeReader, PipeWriter};
use reqwest::Client;
use tokio::task::JoinHandle;
Expand Down
55 changes: 55 additions & 0 deletions crates/proof-sdk/proof/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.0.4](https://github.com/anton-rs/kona/compare/kona-common-v0.0.3...kona-common-v0.0.4) - 2024-10-25

### Added

- remove thiserror ([#735](https://github.com/anton-rs/kona/pull/735))
- *(preimage/common)* Migrate to `thiserror` ([#543](https://github.com/anton-rs/kona/pull/543))

### Fixed

- *(workspace)* hoist and fix lints ([#577](https://github.com/anton-rs/kona/pull/577))

### Other

- re-org imports ([#711](https://github.com/anton-rs/kona/pull/711))
- *(preimage)* Test Coverage ([#634](https://github.com/anton-rs/kona/pull/634))
- test coverage for common ([#629](https://github.com/anton-rs/kona/pull/629))
- doc logos ([#609](https://github.com/anton-rs/kona/pull/609))
- *(workspace)* Allow stdlib in `cfg(test)` ([#548](https://github.com/anton-rs/kona/pull/548))

## [0.0.3](https://github.com/anton-rs/kona/compare/kona-common-v0.0.2...kona-common-v0.0.3) - 2024-09-04

### Added
- add zkvm target for io ([#394](https://github.com/anton-rs/kona/pull/394))

### Other
- *(workspace)* Update for `anton-rs` org transfer ([#474](https://github.com/anton-rs/kona/pull/474))
- *(workspace)* Hoist Dependencies ([#466](https://github.com/anton-rs/kona/pull/466))
- *(bin)* Remove `kt` ([#461](https://github.com/anton-rs/kona/pull/461))
- *(common)* Remove need for cursors in `NativeIO` ([#416](https://github.com/anton-rs/kona/pull/416))

## [0.0.2](https://github.com/anton-rs/kona/compare/kona-common-v0.0.1...kona-common-v0.0.2) - 2024-06-22

### Added
- *(client)* Derivation integration ([#257](https://github.com/anton-rs/kona/pull/257))
- *(client/host)* Oracle-backed Blob fetcher ([#255](https://github.com/anton-rs/kona/pull/255))
- *(host)* Host program scaffold ([#184](https://github.com/anton-rs/kona/pull/184))
- *(preimage)* `OracleServer` + `HintReader` ([#96](https://github.com/anton-rs/kona/pull/96))
- *(common)* Move from `RegisterSize` to native ptr size type ([#95](https://github.com/anton-rs/kona/pull/95))
- *(workspace)* Add `rustfmt.toml`

### Fixed
- *(common)* Pipe IO support ([#282](https://github.com/anton-rs/kona/pull/282))

### Other
- *(common)* Use `Box::leak` rather than `mem::forget` ([#180](https://github.com/anton-rs/kona/pull/180))
- Add simple blocking async executor ([#38](https://github.com/anton-rs/kona/pull/38))
- Make versions of packages independent ([#36](https://github.com/anton-rs/kona/pull/36))
41 changes: 41 additions & 0 deletions crates/proof-sdk/proof/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "kona-proof"
description = "OP Stack Proof SDK"
version = "0.0.1"
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true

[lints]
workspace = true

[dependencies]
# Workspace
kona-mpt.workspace = true
kona-derive.workspace = true
kona-driver.workspace = true
kona-preimage.workspace = true
kona-executor.workspace = true

# Alloy
alloy-rlp.workspace = true
alloy-eips.workspace = true
alloy-consensus.workspace = true
alloy-primitives.workspace = true

# Op Alloy
op-alloy-protocol.workspace = true
op-alloy-consensus.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-genesis = { workspace = true, features = ["serde"] }

# General
lru.workspace = true
spin.workspace = true
serde.workspace = true
tracing.workspace = true
serde_json.workspace = true
async-trait.workspace = true
thiserror.workspace = true
8 changes: 8 additions & 0 deletions crates/proof-sdk/proof/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# `kona-proof`

<a href="https://github.com/anton-rs/kona/actions/workflows/rust_ci.yaml"><img src="https://github.com/anton-rs/kona/actions/workflows/rust_ci.yaml/badge.svg?label=ci" alt="CI"></a>
<a href="https://crates.io/crates/kona-proof"><img src="https://img.shields.io/crates/v/kona-proof.svg?label=kona-proof&labelColor=2a2f35" alt="Kona Proof SDK"></a>
<a href="https://github.com/anton-rs/kona/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/License-MIT-d1d1f6.svg?label=license&labelColor=2a2f35" alt="License"></a>
<a href="https://img.shields.io/codecov/c/github/anton-rs/kona"><img src="https://img.shields.io/codecov/c/github/anton-rs/kona" alt="Codecov"></a>

`kona-proof` is an OP Stack state transition proof SDK.
Loading

0 comments on commit 4a3b928

Please sign in to comment.