Skip to content
Closed
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
87 changes: 87 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 @@ -79,6 +79,7 @@ tracing-subscriber = { version = "0.3.23", features = ["std", "env-filter"] }
tracing-forest = { version = "0.3.0", features = ["ansi", "smallvec"] }
postcard = { version = "1.1.3", features = ["alloc"] }
lz4_flex = "0.13.0"
rust-embed = { version = "8.7", features = ["debug-embed"] }

[features]
prox-gaps-conjecture = ["rec_aggregation/prox-gaps-conjecture"]
Expand Down
1 change: 1 addition & 0 deletions crates/rec_aggregation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ postcard.workspace = true
lz4_flex.workspace = true
serde.workspace = true
zk-alloc.workspace = true
rust-embed = { workspace = true, features = ["debug-embed", "include-exclude"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc2 = { version = "0.6.4", default-features = false, features = ["std"] }
Expand Down
31 changes: 26 additions & 5 deletions crates/rec_aggregation/src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use lean_prover::{
WHIR_SUBSEQUENT_FOLDING_FACTOR, default_whir_config,
};
use lean_vm::*;
use rust_embed::Embed;
use std::collections::{BTreeMap, HashMap};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;
use sub_protocols::{N_VARS_TO_SEND_GKR_COEFFS, min_stacked_n_vars, total_whir_statements};
use tracing::instrument;
Expand All @@ -27,6 +28,26 @@ pub fn init_aggregation_bytecode() {
BYTECODE.get_or_init(compile_main_program_self_referential);
}

#[derive(Embed)]
#[folder = "."]
#[include = "**/*.py"]
#[exclude = "tests/*"]
struct ZkDslFiles;

fn zk_dsl_dir() -> &'static Path {
static DIR: OnceLock<PathBuf> = OnceLock::new();
DIR.get_or_init(|| {
let dir = std::env::temp_dir().join(concat!("rec_aggregation-", env!("CARGO_PKG_VERSION")));
std::fs::create_dir_all(&dir).expect("create rec_aggregation cache dir");
for name in ZkDslFiles::iter() {
let f = ZkDslFiles::get(&name).expect("embedded zkDSL file present");
std::fs::write(dir.join(name.as_ref()), &f.data).expect("write embedded zkDSL file");
}
dir
})
.as_path()
}

fn compile_main_program(program_log_size: usize, bytecode_zero_eval: F) -> Bytecode {
let bytecode_point_n_vars = program_log_size + log2_ceil_usize(N_INSTRUCTION_COLUMNS);
let claim_data_size = (bytecode_point_n_vars + 1) * DIMENSION;
Expand All @@ -39,11 +60,11 @@ fn compile_main_program(program_log_size: usize, bytecode_zero_eval: F) -> Bytec
let input_data_size_padded = input_data_size.next_multiple_of(DIGEST_LEN);
let replacements = build_replacements(program_log_size, bytecode_zero_eval, input_data_size_padded);

let filepath = Path::new(env!("CARGO_MANIFEST_DIR"))
let filepath = zk_dsl_dir()
.join("main.py")
.to_str()
.unwrap()
.to_string();
.into_os_string()
.into_string()
.unwrap();
compile_program_with_flags(&ProgramSource::Filepath(filepath), CompilationFlags { replacements })
}

Expand Down