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

Updating zisk with latest proofman changes and adding airvals #132

Merged
merged 4 commits into from
Oct 24, 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
44 changes: 22 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion book/getting_started/quickstart_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Run this whenever the `.pilout` file changes:
Run this whenever the `.pilout` file changes:

```bash
node --max-old-space-size=65536 ../pil2-proofman-js/src/main_setup.js -a pil/zisk.pilout -b build -t ../pil2-stark/build/bctree
node --max-old-space-size=65536 ../pil2-proofman-js/src/main_setup.js -a pil/zisk.pilout -b build -t ../pil2-proofman/pil2-stark/build/bctree
```

### Compile Witness Computation library (`libzisk_witness.so`)
Expand Down
3 changes: 0 additions & 3 deletions emulator/src/emu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,6 @@ impl<'a> Emu<'a> {
// inc_sp: F::from_canonical_u64(inst.inc_sp),
jmp_offset1: F::from_canonical_u64(inst.jmp_offset1 as u64),
jmp_offset2: F::from_canonical_u64(inst.jmp_offset2 as u64),
main_segment: F::from_canonical_u64(0),
main_first_segment: F::from_bool(false),
main_last_segment: F::from_bool(false),
end: F::from_bool(inst_ctx.end),
m32: F::from_bool(inst.m32),
operation_bus_enabled: F::from_bool(
Expand Down
2 changes: 1 addition & 1 deletion pil/src/pil_helpers/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use proofman_common as common;
pub use proofman_macros::trace;

trace!(Main0Row, Main0Trace<F> {
main_first_segment: F, main_last_segment: F, main_segment: F, a: [F; 2], b: [F; 2], c: [F; 2], last_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, end: F, m32: F, operation_bus_enabled: F,
a: [F; 2], b: [F; 2], c: [F; 2], last_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, end: F, m32: F, operation_bus_enabled: F,
});

trace!(Binary0Row, Binary0Trace<F> {
Expand Down
5 changes: 4 additions & 1 deletion state-machines/arith/src/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ pub struct ArithSM {
arith32_sm: Arc<Arith32SM>,
arith64_sm: Arc<Arith64SM>,
arith3264_sm: Arc<Arith3264SM>,

sctx: Arc<SetupCtx>,
}

impl ArithSM {
pub fn new<F>(wcm: Arc<WitnessManager<F>>) -> Arc<Self> {
pub fn new<F>(wcm: Arc<WitnessManager<F>>, sctx: Arc<SetupCtx>) -> Arc<Self> {
let arith32_sm = Arith32SM::new(wcm.clone());
let arith64_sm = Arith64SM::new(wcm.clone());
let arith3264_sm = Arith3264SM::new(wcm.clone());
Expand All @@ -45,6 +47,7 @@ impl ArithSM {
arith32_sm,
arith64_sm,
arith3264_sm,
sctx,
};
let arith_sm = Arc::new(arith_sm);

Expand Down
17 changes: 14 additions & 3 deletions state-machines/binary/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{BinaryBasicSM, BinaryBasicTableSM, BinaryExtensionSM, BinaryExtensio
use p3_field::PrimeField;
use pil_std_lib::Std;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::SetupCtx;
use rayon::Scope;
use sm_common::{OpResult, Provable, ThreadController};
use zisk_core::ZiskRequiredOperation;
Expand All @@ -33,27 +34,36 @@ pub struct BinarySM<F: PrimeField> {
// Secondary State machines
binary_basic_sm: Arc<BinaryBasicSM<F>>,
binary_extension_sm: Arc<BinaryExtensionSM<F>>,

sctx: Arc<SetupCtx>,
}

impl<F: PrimeField> BinarySM<F> {
pub fn new(wcm: Arc<WitnessManager<F>>, std: Arc<Std<F>>) -> Arc<Self> {
let binary_basic_table_sm =
BinaryBasicTableSM::new(wcm.clone(), BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS);
pub fn new(wcm: Arc<WitnessManager<F>>, std: Arc<Std<F>>, sctx: Arc<SetupCtx>) -> Arc<Self> {
let binary_basic_table_sm = BinaryBasicTableSM::new(
wcm.clone(),
sctx.clone(),
BINARY_TABLE_AIRGROUP_ID,
BINARY_TABLE_AIR_IDS,
);
let binary_basic_sm = BinaryBasicSM::new(
wcm.clone(),
sctx.clone(),
binary_basic_table_sm,
BINARY_AIRGROUP_ID,
BINARY_AIR_IDS,
);

let binary_extension_table_sm = BinaryExtensionTableSM::new(
wcm.clone(),
sctx.clone(),
BINARY_EXTENSION_TABLE_AIRGROUP_ID,
BINARY_EXTENSION_TABLE_AIR_IDS,
);
let binary_extension_sm = BinaryExtensionSM::new(
wcm.clone(),
std,
sctx.clone(),
binary_extension_table_sm,
BINARY_EXTENSION_AIRGROUP_ID,
BINARY_EXTENSION_AIR_IDS,
Expand All @@ -66,6 +76,7 @@ impl<F: PrimeField> BinarySM<F> {
inputs_extension: Mutex::new(Vec::new()),
binary_basic_sm,
binary_extension_sm,
sctx,
};
let binary_sm = Arc::new(binary_sm);

Expand Down
9 changes: 8 additions & 1 deletion state-machines/binary/src/binary_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::{
use log::info;
use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::AirInstance;
use proofman_common::{AirInstance, SetupCtx};
use proofman_util::{timer_start_trace, timer_stop_and_log_trace};
use rayon::Scope;
use sm_common::{create_prover_buffer, OpResult, Provable, ThreadController};
Expand All @@ -30,6 +30,8 @@ pub struct BinaryBasicSM<F> {

// Secondary State machines
binary_basic_table_sm: Arc<BinaryBasicTableSM<F>>,

sctx: Arc<SetupCtx>,
}

#[derive(Debug)]
Expand All @@ -42,12 +44,14 @@ impl<F: Field> BinaryBasicSM<F> {

pub fn new(
wcm: Arc<WitnessManager<F>>,
sctx: Arc<SetupCtx>,
binary_basic_table_sm: Arc<BinaryBasicTableSM<F>>,
airgroup_id: usize,
air_ids: &[usize],
) -> Arc<Self> {
let binary_basic = Self {
wcm: wcm.clone(),
sctx,
registered_predecessors: AtomicU32::new(0),
threads_controller: Arc::new(ThreadController::new()),
inputs: Mutex::new(Vec::new()),
Expand Down Expand Up @@ -755,6 +759,8 @@ impl<F: Field> Provable<ZiskRequiredOperation, OpResult> for BinaryBasicSM<F> {
self.threads_controller.add_working_thread();
let thread_controller = self.threads_controller.clone();

let sctx = self.sctx.clone();

scope.spawn(move |scope| {
let (mut prover_buffer, offset) = create_prover_buffer(
wcm.get_ectx(),
Expand All @@ -773,6 +779,7 @@ impl<F: Field> Provable<ZiskRequiredOperation, OpResult> for BinaryBasicSM<F> {
);

let air_instance = AirInstance::new(
sctx,
BINARY_AIRGROUP_ID,
BINARY_AIR_IDS[0],
None,
Expand Down
12 changes: 10 additions & 2 deletions state-machines/binary/src/binary_basic_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::{
use log::info;
use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::AirInstance;
use proofman_common::{AirInstance, SetupCtx};
use rayon::{prelude::*, Scope};
use sm_common::create_prover_buffer;
use zisk_core::{zisk_ops::ZiskOp, P2_16, P2_17, P2_18, P2_19, P2_8};
Expand Down Expand Up @@ -34,6 +34,7 @@ pub enum BinaryBasicTableOp {

pub struct BinaryBasicTableSM<F> {
wcm: Arc<WitnessManager<F>>,
sctx: Arc<SetupCtx>,

// Count of registered predecessors
registered_predecessors: AtomicU32,
Expand All @@ -51,11 +52,17 @@ pub enum BasicTableSMErr {
impl<F: Field> BinaryBasicTableSM<F> {
const MY_NAME: &'static str = "BinaryT ";

pub fn new(wcm: Arc<WitnessManager<F>>, airgroup_id: usize, air_ids: &[usize]) -> Arc<Self> {
pub fn new(
wcm: Arc<WitnessManager<F>>,
sctx: Arc<SetupCtx>,
airgroup_id: usize,
air_ids: &[usize],
) -> Arc<Self> {
let air = wcm.get_pctx().pilout.get_air(BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]);

let binary_basic_table = Self {
wcm: wcm.clone(),
sctx,
registered_predecessors: AtomicU32::new(0),
num_rows: air.num_rows(),
multiplicity: Mutex::new(vec![0; air.num_rows()]),
Expand Down Expand Up @@ -94,6 +101,7 @@ impl<F: Field> BinaryBasicTableSM<F> {
);

let air_instance = AirInstance::new(
self.sctx.clone(),
BINARY_TABLE_AIRGROUP_ID,
BINARY_TABLE_AIR_IDS[0],
None,
Expand Down
Loading
Loading