-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
235 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "cannon" | ||
description = "An implementation of the OP Stack's native BE MIPS32 VM in Rust" | ||
edition = "2021" | ||
|
||
version.workspace = true | ||
authors.workspace = true | ||
|
||
[dependencies] | ||
# External | ||
tracing = "0.1.37" | ||
anyhow = "1.0.75" | ||
serde = { version = "1.0.188", features = ["derive"] } | ||
serde_json = "1.0.107" | ||
alloy-primitives = "0.4.0" | ||
tokio = { version = "1.32.0", features = ["macros"] } | ||
flate2 = "1.0.27" | ||
|
||
# Local | ||
cannon-mipsevm = { path = "../mipsevm" } | ||
preimage-oracle = { path = "../preimage" } | ||
|
||
[dev-dependencies] | ||
proptest = "1.2.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
use crate::Kernel; | ||
|
||
/// The [KernelBuilder] struct is a helper for building a [Kernel] struct. | ||
pub struct KernelBuilder { | ||
/// The path to the input JSON state. | ||
input: String, | ||
/// The path to the output JSON state. | ||
output: Option<String>, | ||
/// The step to generate an output proof at. | ||
proof_at: Option<u64>, | ||
/// Format for proof data output file names. Proof data is written to stdout | ||
/// if this is not specified. | ||
proof_format: Option<String>, | ||
/// The step pattern to generate state snapshots at. | ||
snapshot_at: Option<String>, | ||
/// Format for snapshot data output file names. | ||
snapshot_format: Option<String>, | ||
/// The instruction step to stop running at. | ||
stop_at: Option<u64>, | ||
/// The pattern to print information at. | ||
info_at: Option<String>, | ||
/// An L1 RPC endpoint | ||
l1_endpoint: String, | ||
/// An L2 RPC endpoint | ||
l2_endpoint: String, | ||
} | ||
|
||
impl KernelBuilder { | ||
/// Builds the [Kernel] struct from the information contained within the [KernelBuilder]. | ||
pub fn build(self) -> Kernel { | ||
Kernel::new( | ||
self.input, | ||
self.output, | ||
self.proof_at, | ||
self.proof_format, | ||
self.snapshot_at, | ||
self.snapshot_format, | ||
self.stop_at, | ||
self.info_at, | ||
self.l1_endpoint, | ||
self.l2_endpoint, | ||
) | ||
} | ||
|
||
pub fn with_input(mut self, input: String) -> Self { | ||
self.input = input; | ||
self | ||
} | ||
|
||
pub fn with_output(mut self, output: String) -> Self { | ||
self.output = Some(output); | ||
self | ||
} | ||
|
||
pub fn with_proof_at(mut self, proof_at: u64) -> Self { | ||
self.proof_at = Some(proof_at); | ||
self | ||
} | ||
|
||
pub fn with_proof_format(mut self, proof_format: String) -> Self { | ||
self.proof_format = Some(proof_format); | ||
self | ||
} | ||
|
||
pub fn with_snapshot_at(mut self, snapshot_at: String) -> Self { | ||
self.snapshot_at = Some(snapshot_at); | ||
self | ||
} | ||
|
||
pub fn with_snapshot_format(mut self, snapshot_format: String) -> Self { | ||
self.snapshot_format = Some(snapshot_format); | ||
self | ||
} | ||
|
||
pub fn with_stop_at(mut self, stop_at: u64) -> Self { | ||
self.stop_at = Some(stop_at); | ||
self | ||
} | ||
|
||
pub fn with_info_at(mut self, info_at: String) -> Self { | ||
self.info_at = Some(info_at); | ||
self | ||
} | ||
|
||
pub fn with_l1_endpoint(mut self, l1_endpoint: String) -> Self { | ||
self.l1_endpoint = l1_endpoint; | ||
self | ||
} | ||
|
||
pub fn with_l2_endpoint(mut self, l2_endpoint: String) -> Self { | ||
self.l2_endpoint = l2_endpoint; | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! This module contains the [Kernel] struct and its associated methods. | ||
|
||
/// The [Kernel] struct contains the configuration for a Cannon kernel as well as | ||
/// the [PreimageOracle] and [InstrumentedState] instances that form it. | ||
#[allow(dead_code)] | ||
pub struct Kernel { | ||
// ins_state: InstrumentedState, | ||
// preimage_oracle: PreimageOracle, | ||
/// The path to the input JSON state. | ||
input: String, | ||
/// The path to the output JSON state. | ||
output: Option<String>, | ||
/// The step to generate an output proof at. | ||
proof_at: Option<u64>, | ||
/// Format for proof data output file names. Proof data is written to stdout | ||
/// if this is not specified. | ||
proof_format: Option<String>, | ||
/// The step pattern to generate state snapshots at. | ||
snapshot_at: Option<String>, | ||
/// Format for snapshot data output file names. | ||
snapshot_format: Option<String>, | ||
/// The instruction step to stop running at. | ||
stop_at: Option<u64>, | ||
/// The pattern to print information at. | ||
info_at: Option<String>, | ||
/// An L1 RPC endpoint | ||
l1_endpoint: String, | ||
/// An L2 RPC endpoint | ||
l2_endpoint: String, | ||
} | ||
|
||
impl Kernel { | ||
#[allow(clippy::too_many_arguments)] | ||
pub fn new( | ||
input: String, | ||
output: Option<String>, | ||
proof_at: Option<u64>, | ||
proof_format: Option<String>, | ||
snapshot_at: Option<String>, | ||
snapshot_format: Option<String>, | ||
stop_at: Option<u64>, | ||
info_at: Option<String>, | ||
l1_endpoint: String, | ||
l2_endpoint: String, | ||
) -> Self { | ||
Self { | ||
input, | ||
output, | ||
proof_at, | ||
proof_format, | ||
snapshot_at, | ||
snapshot_format, | ||
stop_at, | ||
info_at, | ||
l1_endpoint, | ||
l2_endpoint, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![doc = include_str!("../README.md")] | ||
|
||
mod builder; | ||
pub use builder::KernelBuilder; | ||
|
||
mod kernel; | ||
pub use kernel::Kernel; | ||
|
||
pub mod compressor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters