Skip to content

Commit

Permalink
Adapting to new changes pil2-proofman and moving to 0.0.7 (#139)
Browse files Browse the repository at this point in the history
* Adapting to new changes pil2-proofman and updating to 0.0.7
  • Loading branch information
RogerTaule authored Nov 6, 2024
1 parent fa59710 commit 885a181
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 67 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ opt-level = 3
opt-level = 3

[workspace.dependencies]
proofman-common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
proofman-macros = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
proofman-util = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
pil-std-lib = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
stark = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" }
proofman-common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
proofman-macros = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
proofman-util = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
pil-std-lib = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
stark = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", rev = "0.0.7" }
#Local development
#proofman-common = { path = "../pil2-proofman/common" }
#proofman-macros = { path = "../pil2-proofman/macros" }
#proofman-util = { path = "../pil2-proofman/util" }
#proofman = { path = "../pil2-proofman/proofman" }
#pil-std-lib = { path = "../pil2-proofman/pil2-components/lib/std/rs" }
#stark = { path = "../pil2-proofman/provers/stark" }
# proofman-common = { path = "../pil2-proofman/common" }
# proofman-macros = { path = "../pil2-proofman/macros" }
# proofman-util = { path = "../pil2-proofman/util" }
# proofman = { path = "../pil2-proofman/proofman" }
# pil-std-lib = { path = "../pil2-proofman/pil2-components/lib/std/rs" }
# stark = { path = "../pil2-proofman/provers/stark" }

p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" }
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion rom-merkle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn main() {
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<SetupCtx> = Arc::new(SetupCtx::new(&global_info, &ProofType::Basic));
let sctx = Arc::new(SetupCtx::new(&global_info, &ProofType::Basic));

if let Err(e) =
RomSM::<Goldilocks>::compute_trace(rom_path.to_path_buf(), buffer_allocator, &sctx)
Expand Down
4 changes: 2 additions & 2 deletions state-machines/arith/src/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl<F> WitnessComponent<F> for ArithSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/arith/src/arith_32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl<F> WitnessComponent<F> for Arith32SM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/arith/src/arith_3264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl<F> WitnessComponent<F> for Arith3264SM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/arith/src/arith_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl<F> WitnessComponent<F> for Arith64SM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub use temp::*;
pub use worker::*;

pub fn create_prover_buffer<F>(
ectx: &ExecutionCtx,
sctx: &SetupCtx,
ectx: &ExecutionCtx<F>,
sctx: &SetupCtx<F>,
airgroup_id: usize,
air_id: usize,
) -> (Vec<F>, u64) {
Expand Down
4 changes: 2 additions & 2 deletions state-machines/freq-ops/src/freq_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ impl<F> WitnessComponent<F> for FreqOpsSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/mem/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl<F> WitnessComponent<F> for MemSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/mem/src/mem_aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl<F> WitnessComponent<F> for MemAlignedSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/mem/src/mem_unaligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl<F> WitnessComponent<F> for MemUnalignedSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions state-machines/quick-ops/src/quick_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl<F> WitnessComponent<F> for QuickOpsSM {
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_ectx: Arc<ExecutionCtx>,
_sctx: Arc<SetupCtx>,
_ectx: Arc<ExecutionCtx<F>>,
_sctx: Arc<SetupCtx<F>>,
) {
}
}
Expand Down
12 changes: 6 additions & 6 deletions state-machines/rom/src/rom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl<F: Field> RomSM<F> {
}
pub fn compute_trace(
rom_path: PathBuf,
buffer_allocator: Arc<dyn BufferAllocator>,
sctx: &SetupCtx,
buffer_allocator: Arc<dyn BufferAllocator<F>>,
sctx: &SetupCtx<F>,
) -> Result<(Vec<F>, u64, usize), Box<dyn Error + Send>> {
// Get the ELF file path as a string
let elf_filename: String = rom_path.to_str().unwrap().into();
Expand All @@ -85,8 +85,8 @@ impl<F: Field> RomSM<F> {

pub fn compute_trace_rom(
rom: &ZiskRom,
buffer_allocator: Arc<dyn BufferAllocator>,
sctx: &SetupCtx,
buffer_allocator: Arc<dyn BufferAllocator<F>>,
sctx: &SetupCtx<F>,
pc_histogram: ZiskPcHistogram,
main_trace_len: u64,
) -> Result<(Vec<F>, u64, usize), Box<dyn Error + Send>> {
Expand Down Expand Up @@ -144,8 +144,8 @@ impl<F: Field> RomSM<F> {
rom_s_size: usize,
rom: &zisk_core::ZiskRom,
number_of_instructions: usize,
buffer_allocator: Arc<dyn BufferAllocator>,
sctx: &SetupCtx,
buffer_allocator: Arc<dyn BufferAllocator<F>>,
sctx: &SetupCtx<F>,
pc_histogram: ZiskPcHistogram,
main_trace_len: u64,
) -> Result<(Vec<F>, u64, usize), Box<dyn Error + Send>> {
Expand Down
4 changes: 2 additions & 2 deletions witness-computation/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ impl<F: PrimeField> ZiskExecutor<F> {
rom_path: &Path,
public_inputs_path: &Path,
pctx: Arc<ProofCtx<F>>,
ectx: Arc<ExecutionCtx>,
sctx: Arc<SetupCtx>,
ectx: Arc<ExecutionCtx<F>>,
sctx: Arc<SetupCtx<F>>,
) {
let air_main = pctx.pilout.get_air(ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0]);

Expand Down
25 changes: 14 additions & 11 deletions witness-computation/src/zisk_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zisk_pil::*;
use p3_field::PrimeField;
use p3_goldilocks::Goldilocks;
use proofman::{WitnessLibrary, WitnessManager};
use proofman_common::{initialize_logger, ExecutionCtx, ProofCtx, SetupCtx, WitnessPilout};
use proofman_common::{ExecutionCtx, ProofCtx, SetupCtx, WitnessPilout};

use crate::ZiskExecutor;

Expand Down Expand Up @@ -45,7 +45,12 @@ impl<F: PrimeField> ZiskWitness<F> {
})
}

fn initialize(&mut self, pctx: Arc<ProofCtx<F>>, ectx: Arc<ExecutionCtx>, sctx: Arc<SetupCtx>) {
fn initialize(
&mut self,
pctx: Arc<ProofCtx<F>>,
ectx: Arc<ExecutionCtx<F>>,
sctx: Arc<SetupCtx<F>>,
) {
let wcm = WitnessManager::new(pctx, ectx, sctx);
let wcm = Arc::new(wcm);

Expand All @@ -58,8 +63,8 @@ impl<F: PrimeField> WitnessLibrary<F> for ZiskWitness<F> {
fn start_proof(
&mut self,
pctx: Arc<ProofCtx<F>>,
ectx: Arc<ExecutionCtx>,
sctx: Arc<SetupCtx>,
ectx: Arc<ExecutionCtx<F>>,
sctx: Arc<SetupCtx<F>>,
) {
self.initialize(pctx.clone(), ectx.clone(), sctx.clone());

Expand All @@ -69,7 +74,7 @@ impl<F: PrimeField> WitnessLibrary<F> for ZiskWitness<F> {
fn end_proof(&mut self) {
self.wcm.get().unwrap().end_proof();
}
fn execute(&self, pctx: Arc<ProofCtx<F>>, ectx: Arc<ExecutionCtx>, sctx: Arc<SetupCtx>) {
fn execute(&self, pctx: Arc<ProofCtx<F>>, ectx: Arc<ExecutionCtx<F>>, sctx: Arc<SetupCtx<F>>) {
timer_start_info!(EXECUTE);
self.executor.get().unwrap().execute(
&self.rom_path,
Expand All @@ -85,8 +90,8 @@ impl<F: PrimeField> WitnessLibrary<F> for ZiskWitness<F> {
&mut self,
stage: u32,
pctx: Arc<ProofCtx<F>>,
ectx: Arc<ExecutionCtx>,
sctx: Arc<SetupCtx>,
ectx: Arc<ExecutionCtx<F>>,
sctx: Arc<SetupCtx<F>>,
) {
self.wcm.get().unwrap().calculate_witness(stage, pctx, ectx, sctx);
}
Expand All @@ -98,14 +103,12 @@ impl<F: PrimeField> WitnessLibrary<F> for ZiskWitness<F> {

#[no_mangle]
pub extern "Rust" fn init_library(
ectx: Arc<ExecutionCtx>,
rom_path: Option<PathBuf>,
public_inputs_path: Option<PathBuf>,
) -> Result<Box<dyn WitnessLibrary<Goldilocks>>, Box<dyn Error>> {
let rom_path = ectx.rom_path.clone().ok_or("ROM path is required")?;
let rom_path = rom_path.clone().ok_or("ROM path is required")?;
let public_inputs = public_inputs_path.ok_or("Public inputs path is required")?;

initialize_logger(ectx.verbose_mode);

let zisk_witness = ZiskWitness::new(rom_path, public_inputs)?;
Ok(Box::new(zisk_witness))
}

0 comments on commit 885a181

Please sign in to comment.