Skip to content

Commit

Permalink
runner init
Browse files Browse the repository at this point in the history
  • Loading branch information
neotheprogramist committed Dec 22, 2023
1 parent ffb6739 commit fb69e46
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
target
.snfoundry_cache/

# Generated by Cargo
# will have compiled files and executables
**/debug/
**/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
**/Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Scarb
**/Scarb.lock

# vscode
**/.vscode/
12 changes: 12 additions & 0 deletions runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "runner"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.76"
clap = { version = "4.4.11", features = ["derive"] }
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
20 changes: 20 additions & 0 deletions runner/resources/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
[
[
[
12,
[
24,
9
]
],
[
3,
[
24,
9
]
]
]
]
]
35 changes: 35 additions & 0 deletions runner/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::fs::File;
use std::io::BufReader;

use clap::Parser;
use serde_json::Value;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Path to the input file
#[clap(default_value = "resources/input.json")]
path: String,
}

fn main() -> anyhow::Result<()> {
let args = Cli::parse();
let file = File::open(args.path)?;
let reader = BufReader::new(file);

let v: Value = serde_json::from_reader(reader)?;

let flattened = flatten_recursively(&v);

println!("{:?}", flattened.collect::<Vec<u64>>());

Ok(())
}

fn flatten_recursively(v: &Value) -> Box<dyn Iterator<Item = u64> + '_> {
match v {
Value::Array(array) => Box::new(array.iter().flat_map(flatten_recursively)),
Value::Number(v) => Box::new(std::iter::once(v.as_u64().unwrap())),
_ => Box::new(std::iter::empty()),
}
}
2 changes: 2 additions & 0 deletions src/input_structs.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod stark_config;
mod stark_proof;
55 changes: 55 additions & 0 deletions src/input_structs/stark_config.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#[derive(Drop)]
struct StarkConfig {
traces: TracesConfig,
// composition: TableCommitmentConfig,
// fri: FriConfig,
// proof_of_work: ProofOfWorkConfig,
// // Log2 of the trace domain size.
// log_trace_domain_size: felt252,
// // Number of queries to the last component, FRI.
// n_queries: felt252,
// // Log2 of the number of cosets composing the evaluation domain, where the coset size is the
// // trace length.
// log_n_cosets: felt252,
// // Number of layers that use a verifier friendly hash in each commitment.
// n_verifier_friendly_commitment_layers: felt252,
}

#[derive(Drop)]
struct TracesConfig {
original: TableCommitmentConfig,
interaction: TableCommitmentConfig,
}

#[derive(Drop)]
struct TableCommitmentConfig {
columns: felt252,
vector: VectorCommitmentConfig
}

#[derive(Drop)]
struct VectorCommitmentConfig {
height: felt252,
verifier_friendly_commitment_layers: felt252,
}

#[derive(Drop)]
struct FriConfig {
// Log2 of the size of the input layer to FRI.
log_input_size: felt252,
// Number of layers in the FRI. Inner + last layer.
n_layers: felt252,
// Array of size n_layers - 1, each entry is a configuration of a table commitment for the
// corresponding inner layer.
inner_layers: TableCommitmentConfig,
// Array of size n_layers, each entry represents the FRI step size,
// i.e. the number of FRI-foldings between layer i and i+1.
fri_step_sizes: felt252,
log_last_layer_degree_bound: felt252,
}

#[derive(Drop)]
struct ProofOfWorkConfig {
// Proof of work difficulty (number of bits required to be 0).
n_bits: felt252,
}
9 changes: 9 additions & 0 deletions src/input_structs/stark_proof.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use cairo_verifier::input_structs::stark_config::StarkConfig;

#[derive(Drop)]
struct StarkProof {
config: StarkConfig,
// public_input: PublicInput,
// unsent_commitment: StarkUnsentCommitment,
// witness: StarkWitness,
}
7 changes: 7 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
mod channel;
mod common;
mod input_structs;
mod structs;

use cairo_verifier::input_structs::stark_proof::StarkProof;

fn main(stark_proof: StarkProof) -> (felt252, felt252) {
(stark_proof.config.traces.original.columns, stark_proof.config.traces.interaction.columns)
}

0 comments on commit fb69e46

Please sign in to comment.