Skip to content

Commit

Permalink
align with last commits in pil2-proofman
Browse files Browse the repository at this point in the history
  • Loading branch information
xavi-pinsach committed Dec 14, 2024
1 parent 567b607 commit d65c344
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 95 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions pil/src/pil_helpers/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use proofman_macros::values;
#[allow(dead_code)]
type FieldExtension<F> = [F; 3];

pub const PILOUT_HASH: &[u8] = b"ZiskArith-hash";
pub const PILOUT_HASH: &[u8] = b"Zisk-hash";

//AIRGROUP CONSTANTS

Expand Down Expand Up @@ -77,5 +77,5 @@ trace!(SpecifiedRangesTrace<F> {
}, 0, 9, 16777216 );

values!(MainAirValues<F> {
main_last_segment: FieldExtension<F>, main_segment: FieldExtension<F>,
main_last_segment: F, main_segment: F,
});
2 changes: 1 addition & 1 deletion state-machines/arith/src/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<F: PrimeField> ComponentProvider<F> for ArithSM<F> {
}

fn get_planner(&self) -> Box<dyn Planner> {
Box::new(ArithPlanner::<F>::new())
Box::new(ArithPlanner::<F>::default())
}

fn get_instance(&self, iectx: InstanceExpanderCtx) -> Box<dyn Instance<F>> {
Expand Down
12 changes: 2 additions & 10 deletions state-machines/arith/src/arith_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ use zisk_pil::{
ArithTrace, ARITH_AIR_IDS, ARITH_RANGE_TABLE_AIR_IDS, ARITH_TABLE_AIR_IDS, ZISK_AIRGROUP_ID,
};

pub struct ArithPlanner<F: PrimeField> {
_phantom: std::marker::PhantomData<F>,
}
pub struct ArithPlanner<F: PrimeField>(std::marker::PhantomData<F>);

impl<F: PrimeField> Default for ArithPlanner<F> {
fn default() -> Self {
Self::new()
}
}

impl<F: PrimeField> ArithPlanner<F> {
pub fn new() -> Self {
Self { _phantom: std::marker::PhantomData }
Self(std::marker::PhantomData)
}
}

Expand Down
2 changes: 1 addition & 1 deletion state-machines/binary/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<F: PrimeField> ComponentProvider<F> for BinarySM<F> {
}

fn get_planner(&self) -> Box<dyn Planner> {
Box::new(BinaryPlanner::<F>::new())
Box::new(BinaryPlanner::<F>::default())
}

fn get_instance(&self, iectx: InstanceExpanderCtx) -> Box<dyn Instance<F>> {
Expand Down
2 changes: 1 addition & 1 deletion state-machines/binary/src/binary_basic_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<F: PrimeField> Instance<F> for BinaryBasicInstance<F> {
) -> Result<(), Box<dyn std::error::Error + Send>> {
self.inputs = InputsCollector::collect(
self.iectx.plan.check_point.unwrap(),
BinaryTrace::<F>::NUM_ROWS,
self.trace.num_rows(),
zisk_rom,
min_traces,
zisk_core::ZiskOperationType::Binary,
Expand Down
12 changes: 2 additions & 10 deletions state-machines/binary/src/binary_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ use zisk_pil::{
BINARY_EXTENSION_TABLE_AIR_IDS, BINARY_TABLE_AIR_IDS, ZISK_AIRGROUP_ID,
};

pub struct BinaryPlanner<F: PrimeField> {
_phantom: std::marker::PhantomData<F>,
}
pub struct BinaryPlanner<F: PrimeField>(std::marker::PhantomData<F>);

impl<F: PrimeField> Default for BinaryPlanner<F> {
fn default() -> Self {
Self::new()
}
}

impl<F: PrimeField> BinaryPlanner<F> {
pub fn new() -> Self {
Self { _phantom: std::marker::PhantomData }
Self(std::marker::PhantomData)
}
}

Expand Down
5 changes: 2 additions & 3 deletions state-machines/main/pil/main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,5 @@ airtemplate Main(int N = 2**21, int RC = 2, int stack_enabled = 0, const int ope
lookup_assumes(ROM_BUS_ID, [pc, a_offset_imm0, a_imm1, b_offset_imm0, b_imm1, ind_width,
op, store_offset, jmp_offset1, jmp_offset2, rom_flags], sel: 1 - SEGMENT_L1);

direct_global_update(MAIN_CONTINUATION_ID, cols: [0, 0, 4096, 0, 0], bus_type: PIOP_BUS_SUM, proves: 1);
direct_global_update(MAIN_CONTINUATION_ID, cols: [0, 1, 0x10000000, 0, 0], bus_type: PIOP_BUS_SUM, proves: 0);
}
direct_global_update_proves(MAIN_CONTINUATION_ID, cols: [0, 0, 4096, 0, 0, 0, 0, 0], bus_type: PIOP_BUS_SUM);
direct_global_update_assumes(MAIN_CONTINUATION_ID, cols: [0, 1, 0x1000_0000, 0, 0, 0, 0, 0], bus_type: PIOP_BUS_SUM);}
4 changes: 2 additions & 2 deletions state-machines/main/src/main_sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl<F: PrimeField> MainSM<F> {
let main_segment = F::from_canonical_usize(current_segment);

let mut main_air_values = MainAirValues::<F>::new();
main_air_values.main_last_segment[0] = main_last_segment;
main_air_values.main_segment[0] = main_segment;
main_air_values.main_last_segment = main_last_segment;
main_air_values.main_segment = main_segment;

let air_instance = AirInstance::new_from_trace(
FromTrace::new(&mut main_instance.main_trace).with_air_values(&mut main_air_values),
Expand Down
14 changes: 2 additions & 12 deletions state-machines/mem/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use sm_common::{MemOp, MemUnalignedOp, OpResult, Provable};
use zisk_core::ZiskRequiredMemory;

use proofman::{WitnessComponent, WitnessManager};
use proofman_common::{ProofCtx, SetupCtx};

#[allow(dead_code)]
const PROVE_CHUNK_SIZE: usize = 1 << 12;
Expand Down Expand Up @@ -43,7 +42,7 @@ impl MemSM {
};
let mem_sm = Arc::new(mem_sm);

wcm.register_proxy_component(mem_sm.clone());
wcm.register_component(mem_sm.clone());

// For all the secondary state machines, register the main state machine as a predecessor
mem_sm.mem_aligned_sm.register_predecessor();
Expand All @@ -66,16 +65,7 @@ impl MemSM {
}
}

impl<F> WitnessComponent<F> for MemSM {
fn calculate_witness(
&self,
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_sctx: Arc<SetupCtx>,
) {
}
}
impl<F> WitnessComponent<F> for MemSM {}

impl Provable<ZiskRequiredMemory, OpResult> for MemSM {
fn calculate(
Expand Down
15 changes: 2 additions & 13 deletions state-machines/mem/src/mem_aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use std::sync::{

use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::{ProofCtx, SetupCtx};
use rayon::Scope;
use sm_common::{MemOp, OpResult, Provable};
use zisk_pil::{MEM_AIRGROUP_ID, MEM_ALIGN_AIR_IDS};

const PROVE_CHUNK_SIZE: usize = 1 << 12;

Expand All @@ -27,7 +25,7 @@ impl MemAlignedSM {
Self { registered_predecessors: AtomicU32::new(0), inputs: Mutex::new(Vec::new()) };
let mem_aligned_sm = Arc::new(mem_aligned_sm);

wcm.register_component(mem_aligned_sm.clone(), MEM_AIRGROUP_ID, MEM_ALIGN_AIR_IDS[0]);
wcm.register_component(mem_aligned_sm.clone());

mem_aligned_sm
}
Expand Down Expand Up @@ -58,16 +56,7 @@ impl MemAlignedSM {
}
}

impl<F> WitnessComponent<F> for MemAlignedSM {
fn calculate_witness(
&self,
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_sctx: Arc<SetupCtx>,
) {
}
}
impl<F> WitnessComponent<F> for MemAlignedSM {}

impl Provable<MemOp, OpResult> for MemAlignedSM {
fn calculate(&self, operation: MemOp) -> Result<OpResult, Box<dyn std::error::Error>> {
Expand Down
15 changes: 2 additions & 13 deletions state-machines/mem/src/mem_unaligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use std::sync::{

use p3_field::Field;
use proofman::{WitnessComponent, WitnessManager};
use proofman_common::{ProofCtx, SetupCtx};
use rayon::Scope;
use sm_common::{MemUnalignedOp, OpResult, Provable};
use zisk_pil::{MEM_AIRGROUP_ID, MEM_UNALIGNED_AIR_IDS};

const PROVE_CHUNK_SIZE: usize = 1 << 12;

Expand All @@ -27,7 +25,7 @@ impl MemUnalignedSM {
Self { registered_predecessors: AtomicU32::new(0), inputs: Mutex::new(Vec::new()) };
let mem_aligned_sm = Arc::new(mem_aligned_sm);

wcm.register_component(mem_aligned_sm.clone(), MEM_AIRGROUP_ID, MEM_UNALIGNED_AIR_IDS[0]);
wcm.register_component(mem_aligned_sm.clone());

mem_aligned_sm
}
Expand Down Expand Up @@ -60,16 +58,7 @@ impl MemUnalignedSM {
}
}

impl<F> WitnessComponent<F> for MemUnalignedSM {
fn calculate_witness(
&self,
_stage: u32,
_air_instance: Option<usize>,
_pctx: Arc<ProofCtx<F>>,
_sctx: Arc<SetupCtx>,
) {
}
}
impl<F> WitnessComponent<F> for MemUnalignedSM {}

impl Provable<MemUnalignedOp, OpResult> for MemUnalignedSM {
fn calculate(&self, operation: MemUnalignedOp) -> Result<OpResult, Box<dyn std::error::Error>> {
Expand Down
Loading

0 comments on commit d65c344

Please sign in to comment.