Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cust-commits to instruction observer #189

Merged
merged 1 commit into from
Dec 16, 2024
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
56 changes: 36 additions & 20 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 pil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
proofman-common = { workspace = true }
proofman-macros = { workspace = true }
serde = { version = "1.0.204", features = ["derive"] }

[features]
default = []
Expand Down
20 changes: 19 additions & 1 deletion pil/src/pil_helpers/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,27 @@ pub const BINARY_EXTENSION_TABLE_AIR_IDS: &[usize] = &[8];

pub const SPECIFIED_RANGES_AIR_IDS: &[usize] = &[9];


//PUBLICS
use serde::Deserialize;
use serde::Serialize;
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct ZiskPublics {
#[serde(default)]
pub rom_root: [u64; 4],

}

values!(ZiskPublicValues<F> {
rom_root: [F; 4],
});

trace!(MainTrace<F> {
a: [F; 2], b: [F; 2], c: [F; 2], flag: F, pc: F, a_src_imm: F, a_src_mem: F, a_offset_imm0: F, a_imm1: F, a_src_step: F, b_src_imm: F, b_src_mem: F, b_offset_imm0: F, b_imm1: F, b_src_ind: F, ind_width: F, is_external_op: F, op: F, store_ra: F, store_mem: F, store_ind: F, store_offset: F, set_pc: F, jmp_offset1: F, jmp_offset2: F, m32: F, addr1: F, __debug_operation_bus_enabled: F,
}, 0, 0, 2097152 );

trace!(RomTrace<F> {
line: F, a_offset_imm0: F, a_imm1: F, b_offset_imm0: F, b_imm1: F, ind_width: F, op: F, store_offset: F, jmp_offset1: F, jmp_offset2: F, flags: F, multiplicity: F,
multiplicity: F,
}, 0, 1, 1048576 );

trace!(ArithTrace<F> {
Expand Down Expand Up @@ -76,6 +90,10 @@ trace!(SpecifiedRangesTrace<F> {
mul: [F; 1],
}, 0, 9, 16777216 );

trace!(RomRomTrace<F> {
line: F, a_offset_imm0: F, a_imm1: F, b_offset_imm0: F, b_imm1: F, ind_width: F, op: F, store_offset: F, jmp_offset1: F, jmp_offset2: F, flags: F,
}, 0, 1, 1048576, 0 );

values!(MainAirValues<F> {
main_last_segment: F, main_segment: F,
});
5 changes: 3 additions & 2 deletions rom-merkle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ edition = "2021"
sm-rom = { path = "../state-machines/rom" }
log = { workspace = true }
proofman-common = { workspace = true }
zisk-core = { path = "../core" }
proofman-util = { workspace = true }
zisk-pil = { path="../pil" }

p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" }
p3-field = { workspace = true }
clap = { version = "4.5.13", features = ["derive", "env"] }
env_logger = "0.11"
sysinfo = "0.33"
sysinfo = "0.32"
colored = "2"
72 changes: 36 additions & 36 deletions rom-merkle/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
use clap::{Arg, Command};
use colored::Colorize;
// use proofman_common::{GlobalInfo, ProofType, SetupCtx};
use std::path::Path;
use p3_goldilocks::Goldilocks;
use proofman_common::{get_custom_commit_trace, GlobalInfo, ProofType, SetupCtx};
use proofman_util::create_buffer_fast;
use sm_rom::RomSM;
use std::{path::Path, sync::Arc};
use sysinfo::System;
// use zisk_core::Riscv2zisk;
use zisk_pil::RomRomTrace;

fn main() {
let matches = Command::new("ROM Handler")
.version("1.0")
.about("Compute the Merkle Root of a ROM file")
.arg(Arg::new("rom").value_name("FILE").help("The ROM file path").required(true).index(1))
.arg(
Arg::new("rom").long("rom").value_name("FILE").help("The ROM file path").required(true),
)
.arg(
Arg::new("proving_key")
.long("proving-key")
.value_name("FILE")
.help("The proving key folder path")
.required(true)
.index(2),
.required(true),
)
.arg(
Arg::new("global_info")
Arg::new("rom_buffer")
.long("rom-buffer")
.value_name("FILE")
.help("The global info file path")
.required(true)
.index(3),
.help("The rom buffer path")
.required(true),
)
.get_matches();

// Get the value of the `rom` argument as a path
let rom_path_str = matches.get_one::<String>("rom").expect("ROM path is required");
let rom_path = Path::new(rom_path_str);
// let proving_key_path_str =
// matches.get_one::<String>("proving_key").expect("Proving key path is required");
// let proving_key_path = Path::new(proving_key_path_str);
// let global_info_path_str =
// matches.get_one::<String>("global_info").expect("Global info path is required");
// let global_info_path = Path::new(global_info_path_str);
let proving_key_path_str =
matches.get_one::<String>("proving_key").expect("Proving key path is required");
let proving_key_path = Path::new(proving_key_path_str);
let rom_buffer_str =
matches.get_one::<String>("rom_buffer").expect("Buffer file path is required");

env_logger::builder()
.format_timestamp(None)
Expand Down Expand Up @@ -76,29 +80,25 @@ fn main() {
std::process::exit(1);
}

// If all checks pass, continue with the program
println!("ROM Path is valid: {}", rom_path.display());

// let _buffer_allocator: Arc<StarkBufferAllocator> =
// Arc::new(StarkBufferAllocator::new(proving_key_path.to_path_buf()));
// let global_info = GlobalInfo::new(global_info_path);
// let _sctx = Arc::new(SetupCtx::new(&global_info, &ProofType::Basic));
let global_info = GlobalInfo::new(proving_key_path);
let sctx = Arc::new(SetupCtx::new(&global_info, &ProofType::Basic));

// // Get the ELF file path as a string
// let elf_filename: String = rom_path.to_str().unwrap().into();
// println!("Proving ROM for ELF file={}", elf_filename);
let mut custom_rom_trace: RomRomTrace<Goldilocks> = RomRomTrace::new();
let setup = sctx.get_setup(custom_rom_trace.airgroup_id(), custom_rom_trace.air_id);

// // Create an instance of the RISCV -> ZisK program converter
// let riscv2zisk = Riscv2zisk::new(elf_filename, String::new(), String::new(), String::new());
RomSM::compute_custom_trace_rom(rom_path.to_path_buf(), &mut custom_rom_trace);

// // Convert program to rom
// let _rom = riscv2zisk.run().expect("RomSM::prover() failed running rom");
let n_ext = (1 << setup.stark_info.stark_struct.n_bits_ext) as usize;
let n_cols = custom_rom_trace.num_rows();

// // Compute the trace
// // RomSM::<Goldilocks>::prove_instance(wcm, rom, plan, buffer, trace_rows);
let buffer_ext = create_buffer_fast(n_ext * n_cols);

// // Compute LDE and Merkelize and get the root of the rom
// // TODO: Implement the logic to compute the trace

log::info!("ROM proof successful");
get_custom_commit_trace(
custom_rom_trace.commit_id.unwrap() as u64,
0,
setup,
custom_rom_trace.get_buffer(),
buffer_ext,
rom_buffer_str.as_str(),
);
}
Loading
Loading