diff --git a/Cargo.lock b/Cargo.lock index 7fdf3730..1a64dc1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,9 +198,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.34" +version = "1.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "0f57c4b4da2a9d619dd035f27316d7a426305b75be93d09e92f2b9229c34feaf" dependencies = [ "jobserver", "libc", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "pil-std-lib" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "log", "num-bigint", @@ -1492,7 +1492,7 @@ dependencies = [ [[package]] name = "pilout" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "bytes", "log", @@ -1612,7 +1612,7 @@ dependencies = [ [[package]] name = "proofman" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "colored", "env_logger", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "proofman-common" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "env_logger", "log", @@ -1651,7 +1651,7 @@ dependencies = [ [[package]] name = "proofman-hints" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "p3-field", "proofman-common", @@ -1661,7 +1661,7 @@ dependencies = [ [[package]] name = "proofman-macros" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "proc-macro2", "quote", @@ -1671,7 +1671,7 @@ dependencies = [ [[package]] name = "proofman-starks-lib-c" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "log", ] @@ -1679,7 +1679,7 @@ dependencies = [ [[package]] name = "proofman-util" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "colored", "sysinfo 0.31.4", @@ -1784,9 +1784,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e346e016eacfff12233c243718197ca12f148c84e1e84268a896699b41c71780" +checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" dependencies = [ "cfg_aliases", "libc", @@ -2313,7 +2313,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stark" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "log", "p3-field", @@ -2643,7 +2643,7 @@ dependencies = [ [[package]] name = "transcript" version = "0.1.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#e87671a5ca63cd1f312554aeca4b1e4b0a3905a9" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=develop#483a285ae3f8c9eea2269450ee3f7417480bef96" dependencies = [ "proofman-starks-lib-c", ] diff --git a/emulator/src/emu_full_trace.rs b/emulator/src/emu_full_trace.rs index 67b49842..343e0c05 100644 --- a/emulator/src/emu_full_trace.rs +++ b/emulator/src/emu_full_trace.rs @@ -1,3 +1,3 @@ -use zisk_pil::Main0Row; +use zisk_pil::MainRow; -pub type EmuFullTraceStep = Main0Row; +pub type EmuFullTraceStep = MainRow; diff --git a/pil/src/pil_helpers/pilout.rs b/pil/src/pil_helpers/pilout.rs index e16e3936..6a7829f7 100644 --- a/pil/src/pil_helpers/pilout.rs +++ b/pil/src/pil_helpers/pilout.rs @@ -2,72 +2,42 @@ // Manual modifications are not recommended and may be overwritten. use proofman_common::WitnessPilout; -pub const PILOUT_HASH: &[u8] = b"ZiskContinuations1-hash"; +pub const PILOUT_HASH: &[u8] = b"Zisk-hash"; //AIRGROUP CONSTANTS -pub const MAIN_AIRGROUP_ID: usize = 0; - -pub const ROM_AIRGROUP_ID: usize = 1; - -pub const BINARY_AIRGROUP_ID: usize = 2; - -pub const BINARY_TABLE_AIRGROUP_ID: usize = 3; - -pub const BINARY_EXTENSION_AIRGROUP_ID: usize = 4; - -pub const BINARY_EXTENSION_TABLE_AIRGROUP_ID: usize = 5; - -pub const SPECIFIED_RANGES_AIRGROUP_ID: usize = 6; +pub const ZISK_AIRGROUP_ID: usize = 0; //AIR CONSTANTS pub const MAIN_AIR_IDS: &[usize] = &[0]; -pub const ROM_AIR_IDS: &[usize] = &[0]; +pub const ROM_AIR_IDS: &[usize] = &[1]; -pub const BINARY_AIR_IDS: &[usize] = &[0]; +pub const BINARY_AIR_IDS: &[usize] = &[2]; -pub const BINARY_TABLE_AIR_IDS: &[usize] = &[0]; +pub const BINARY_TABLE_AIR_IDS: &[usize] = &[3]; -pub const BINARY_EXTENSION_AIR_IDS: &[usize] = &[0]; +pub const BINARY_EXTENSION_AIR_IDS: &[usize] = &[4]; -pub const BINARY_EXTENSION_TABLE_AIR_IDS: &[usize] = &[0]; +pub const BINARY_EXTENSION_TABLE_AIR_IDS: &[usize] = &[5]; -pub const SPECIFIED_RANGES_AIR_IDS: &[usize] = &[0]; +pub const SPECIFIED_RANGES_AIR_IDS: &[usize] = &[6]; pub struct Pilout; impl Pilout { pub fn pilout() -> WitnessPilout { - let mut pilout = WitnessPilout::new("ZiskContinuations1", 2, PILOUT_HASH.to_vec()); + let mut pilout = WitnessPilout::new("Zisk", 2, PILOUT_HASH.to_vec()); - let air_group = pilout.add_air_group(Some("Main")); + let air_group = pilout.add_air_group(Some("Zisk")); air_group.add_air(Some("Main"), 2097152); - - let air_group = pilout.add_air_group(Some("Rom")); - air_group.add_air(Some("Rom"), 1048576); - - let air_group = pilout.add_air_group(Some("Binary")); - air_group.add_air(Some("Binary"), 2097152); - - let air_group = pilout.add_air_group(Some("BinaryTable")); - air_group.add_air(Some("BinaryTable"), 4194304); - - let air_group = pilout.add_air_group(Some("BinaryExtension")); - air_group.add_air(Some("BinaryExtension"), 2097152); - - let air_group = pilout.add_air_group(Some("BinaryExtensionTable")); - air_group.add_air(Some("BinaryExtensionTable"), 4194304); - - let air_group = pilout.add_air_group(Some("SpecifiedRanges")); - air_group.add_air(Some("SpecifiedRanges"), 16777216); pilout diff --git a/pil/src/pil_helpers/traces.rs b/pil/src/pil_helpers/traces.rs index 67d7db98..aea9c202 100644 --- a/pil/src/pil_helpers/traces.rs +++ b/pil/src/pil_helpers/traces.rs @@ -3,30 +3,30 @@ use proofman_common as common; pub use proofman_macros::trace; -trace!(Main0Row, Main0Trace { +trace!(MainRow, MainTrace { 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, }); -trace!(Rom0Row, Rom0Trace { +trace!(RomRow, RomTrace { 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, }); -trace!(Binary0Row, Binary0Trace { +trace!(BinaryRow, BinaryTrace { m_op: F, mode32: F, free_in_a: [F; 8], free_in_b: [F; 8], free_in_c: [F; 8], carry: [F; 8], use_last_carry: F, op_is_min_max: F, multiplicity: F, main_step: F, }); -trace!(BinaryTable0Row, BinaryTable0Trace { +trace!(BinaryTableRow, BinaryTableTrace { multiplicity: F, }); -trace!(BinaryExtension0Row, BinaryExtension0Trace { +trace!(BinaryExtensionRow, BinaryExtensionTrace { op: F, in1: [F; 8], in2_low: F, out: [[F; 2]; 8], op_is_shift: F, in2: [F; 2], main_step: F, multiplicity: F, }); -trace!(BinaryExtensionTable0Row, BinaryExtensionTable0Trace { +trace!(BinaryExtensionTableRow, BinaryExtensionTableTrace { multiplicity: F, }); -trace!(SpecifiedRanges0Row, SpecifiedRanges0Trace { +trace!(SpecifiedRangesRow, SpecifiedRangesTrace { mul: [F; 1], }); diff --git a/pil/zisk.pil b/pil/zisk.pil index 69cd09bb..91feb604 100644 --- a/pil/zisk.pil +++ b/pil/zisk.pil @@ -9,30 +9,12 @@ require "binary/pil/binary_extension_table.pil" // require "mem/pil/mem.pil" const int OPERATION_BUS_ID = 5000; -airgroup Main { +airgroup Zisk { Main(N: 2**21, RC: 2, operation_bus_id: OPERATION_BUS_ID); -} - -airgroup Rom { Rom(N: 2**20); -} - -// airgroup Mem { -// Mem(N: 2**21, RC: 2); -// } - -airgroup Binary { + // Mem(N: 2**21, RC: 2); Binary(N: 2**21, operation_bus_id: OPERATION_BUS_ID); -} - -airgroup BinaryTable { BinaryTable(disable_fixed: 0); -} - -airgroup BinaryExtension { BinaryExtension(N: 2**21, operation_bus_id: OPERATION_BUS_ID); -} - -airgroup BinaryExtensionTable { BinaryExtensionTable(disable_fixed: 0); } \ No newline at end of file diff --git a/state-machines/arith/src/arith_traces.rs b/state-machines/arith/src/arith_traces.rs index 20562a6e..6552f02d 100644 --- a/state-machines/arith/src/arith_traces.rs +++ b/state-machines/arith/src/arith_traces.rs @@ -1,6 +1,6 @@ use proofman_common as common; pub use proofman_macros::trace; -trace!(Arith320Row, Arith320Trace { fake: F }); -trace!(Arith640Row, Arith640Trace { fake: F }); -trace!(Arith32640Row, Arith32640Trace { fake: F }); +trace!(Arith32Row, Arith32Trace { fake: F }); +trace!(Arith64Row, Arith64Trace { fake: F }); +trace!(Arith3264Row, Arith3264Trace { fake: F }); diff --git a/state-machines/binary/src/binary.rs b/state-machines/binary/src/binary.rs index 0acc615d..7dcec2c8 100644 --- a/state-machines/binary/src/binary.rs +++ b/state-machines/binary/src/binary.rs @@ -11,9 +11,8 @@ use rayon::Scope; use sm_common::{OpResult, Provable}; use zisk_core::ZiskRequiredOperation; use zisk_pil::{ - BINARY_AIRGROUP_ID, BINARY_AIR_IDS, BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS, - BINARY_EXTENSION_TABLE_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS, BINARY_TABLE_AIRGROUP_ID, - BINARY_TABLE_AIR_IDS, + BINARY_AIR_IDS, BINARY_EXTENSION_AIR_IDS, BINARY_EXTENSION_TABLE_AIR_IDS, BINARY_TABLE_AIR_IDS, + ZISK_AIRGROUP_ID, }; const PROVE_CHUNK_SIZE: usize = 1 << 16; @@ -35,24 +34,24 @@ pub struct BinarySM { impl BinarySM { pub fn new(wcm: Arc>, std: Arc>) -> Arc { let binary_basic_table_sm = - BinaryBasicTableSM::new(wcm.clone(), BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS); + BinaryBasicTableSM::new(wcm.clone(), ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS); let binary_basic_sm = BinaryBasicSM::new( wcm.clone(), binary_basic_table_sm, - BINARY_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_AIR_IDS, ); let binary_extension_table_sm = BinaryExtensionTableSM::new( wcm.clone(), - BINARY_EXTENSION_TABLE_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS, ); let binary_extension_sm = BinaryExtensionSM::new( wcm.clone(), std, binary_extension_table_sm, - BINARY_EXTENSION_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS, ); diff --git a/state-machines/binary/src/binary_basic.rs b/state-machines/binary/src/binary_basic.rs index ac4ddcb1..14c486d6 100644 --- a/state-machines/binary/src/binary_basic.rs +++ b/state-machines/binary/src/binary_basic.rs @@ -144,9 +144,9 @@ impl BinaryBasicSM { pub fn process_slice( operation: &ZiskRequiredOperation, multiplicity: &mut [u64], - ) -> Binary0Row { + ) -> BinaryRow { // Create an empty trace - let mut row: Binary0Row = Default::default(); + let mut row: BinaryRow = Default::default(); // Execute the opcode let c: u64; @@ -657,9 +657,8 @@ impl BinaryBasicSM { ) { timer_start_trace!(BINARY_TRACE); let pctx = wcm.get_pctx(); - let air = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]); - let air_binary_table = - pctx.pilout.get_air(BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]); + let air_binary_table = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]); assert!(operations.len() <= air.num_rows()); info!( @@ -672,7 +671,7 @@ impl BinaryBasicSM { let mut multiplicity_table = vec![0u64; air_binary_table.num_rows()]; let mut trace_buffer = - Binary0Trace::::map_buffer(prover_buffer, air.num_rows(), offset as usize).unwrap(); + BinaryTrace::::map_buffer(prover_buffer, air.num_rows(), offset as usize).unwrap(); for (i, operation) in operations.iter().enumerate() { let row = Self::process_slice(operation, &mut multiplicity_table); @@ -681,7 +680,7 @@ impl BinaryBasicSM { timer_stop_and_log_trace!(BINARY_TRACE); timer_start_trace!(BINARY_PADDING); - let padding_row = Binary0Row:: { + let padding_row = BinaryRow:: { m_op: F::from_canonical_u8(0x20), multiplicity: F::zero(), main_step: F::zero(), /* TODO: remove, since main_step is just for @@ -729,7 +728,7 @@ impl Provable for BinaryBasicSM { inputs.extend_from_slice(operations); let pctx = self.wcm.get_pctx(); - let air = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]); while inputs.len() >= air.num_rows() || (drain && !inputs.is_empty()) { let num_drained = std::cmp::min(air.num_rows(), inputs.len()); @@ -743,7 +742,7 @@ impl Provable for BinaryBasicSM { let (mut prover_buffer, offset) = create_prover_buffer( &wcm.get_ectx(), &wcm.get_sctx(), - BINARY_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0], ); @@ -757,7 +756,7 @@ impl Provable for BinaryBasicSM { let air_instance = AirInstance::new( sctx, - BINARY_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0], None, prover_buffer, diff --git a/state-machines/binary/src/binary_basic_table.rs b/state-machines/binary/src/binary_basic_table.rs index df028e77..028e8cbd 100644 --- a/state-machines/binary/src/binary_basic_table.rs +++ b/state-machines/binary/src/binary_basic_table.rs @@ -10,7 +10,7 @@ use proofman_common::AirInstance; use rayon::prelude::*; use sm_common::create_prover_buffer; use zisk_core::{zisk_ops::ZiskOp, P2_16, P2_17, P2_18, P2_19, P2_8}; -use zisk_pil::{BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS}; +use zisk_pil::{BINARY_TABLE_AIR_IDS, ZISK_AIRGROUP_ID}; #[derive(Debug, Clone, PartialEq, Copy)] #[repr(u8)] @@ -53,7 +53,7 @@ impl BinaryBasicTableSM { pub fn new(wcm: Arc>, airgroup_id: usize, air_ids: &[usize]) -> Arc { let pctx = wcm.get_pctx(); - let air = pctx.pilout.get_air(BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0]); let binary_basic_table = Self { wcm: wcm.clone(), @@ -222,7 +222,7 @@ impl BinaryBasicTableSM { let mut multiplicity = self.multiplicity.lock().unwrap(); let (is_myne, instance_global_idx) = - dctx.add_instance(BINARY_TABLE_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0], 1); + dctx.add_instance(ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0], 1); let owner: usize = dctx.owner(instance_global_idx); let mut multiplicity_ = std::mem::take(&mut *multiplicity); @@ -233,7 +233,7 @@ impl BinaryBasicTableSM { let (mut prover_buffer, offset) = create_prover_buffer( &self.wcm.get_ectx(), &self.wcm.get_sctx(), - BINARY_TABLE_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0], ); prover_buffer[offset as usize..offset as usize + self.num_rows] @@ -248,7 +248,7 @@ impl BinaryBasicTableSM { ); let air_instance = AirInstance::new( self.wcm.get_sctx(), - BINARY_TABLE_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_TABLE_AIR_IDS[0], None, prover_buffer, diff --git a/state-machines/binary/src/binary_extension.rs b/state-machines/binary/src/binary_extension.rs index dbd8f409..238a2b4e 100644 --- a/state-machines/binary/src/binary_extension.rs +++ b/state-machines/binary/src/binary_extension.rs @@ -149,7 +149,7 @@ impl BinaryExtensionSM { operation: &ZiskRequiredOperation, multiplicity: &mut [u64], range_check: &mut HashMap, - ) -> BinaryExtension0Row { + ) -> BinaryExtensionRow { // Get the opcode let op = operation.opcode; @@ -158,7 +158,7 @@ impl BinaryExtensionSM { // Create an empty trace let mut row = - BinaryExtension0Row:: { op: F::from_canonical_u8(op), ..Default::default() }; + BinaryExtensionRow:: { op: F::from_canonical_u8(op), ..Default::default() }; // Set if the opcode is a shift operation let op_is_shift = Self::opcode_is_shift(opcode); @@ -389,10 +389,9 @@ impl BinaryExtensionSM { timer_start_debug!(BINARY_EXTENSION_TRACE); let pctx = wcm.get_pctx(); - let air = pctx.pilout.get_air(BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); - let air_binary_extension_table = pctx - .pilout - .get_air(BINARY_EXTENSION_TABLE_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); + let air_binary_extension_table = + pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0]); assert!(operations.len() <= air.num_rows()); info!( @@ -406,7 +405,7 @@ impl BinaryExtensionSM { let mut multiplicity_table = vec![0u64; air_binary_extension_table.num_rows()]; let mut range_check: HashMap = HashMap::new(); let mut trace_buffer = - BinaryExtension0Trace::::map_buffer(prover_buffer, air.num_rows(), offset as usize) + BinaryExtensionTrace::::map_buffer(prover_buffer, air.num_rows(), offset as usize) .unwrap(); for (i, operation) in operations.iter().enumerate() { @@ -417,7 +416,7 @@ impl BinaryExtensionSM { timer_start_debug!(BINARY_EXTENSION_PADDING); let padding_row = - BinaryExtension0Row:: { op: F::from_canonical_u64(0x25), ..Default::default() }; + BinaryExtensionRow:: { op: F::from_canonical_u64(0x25), ..Default::default() }; for i in operations.len()..air.num_rows() { trace_buffer[i] = padding_row; @@ -467,8 +466,7 @@ impl Provable for BinaryExtensio inputs.extend_from_slice(operations); let pctx = self.wcm.get_pctx(); - let air = - pctx.pilout.get_air(BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); while inputs.len() >= air.num_rows() || (drain && !inputs.is_empty()) { let num_drained = std::cmp::min(air.num_rows(), inputs.len()); @@ -484,7 +482,7 @@ impl Provable for BinaryExtensio let (mut prover_buffer, offset) = create_prover_buffer( &wcm.get_ectx(), &wcm.get_sctx(), - BINARY_EXTENSION_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0], ); @@ -499,7 +497,7 @@ impl Provable for BinaryExtensio let air_instance = AirInstance::new( sctx, - BINARY_EXTENSION_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0], None, prover_buffer, diff --git a/state-machines/binary/src/binary_extension_table.rs b/state-machines/binary/src/binary_extension_table.rs index 8c88018b..e48a8fcf 100644 --- a/state-machines/binary/src/binary_extension_table.rs +++ b/state-machines/binary/src/binary_extension_table.rs @@ -10,7 +10,7 @@ use proofman_common::AirInstance; use rayon::prelude::*; use sm_common::create_prover_buffer; use zisk_core::{zisk_ops::ZiskOp, P2_11, P2_19, P2_8}; -use zisk_pil::{BINARY_EXTENSION_TABLE_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS}; +use zisk_pil::{BINARY_EXTENSION_TABLE_AIR_IDS, ZISK_AIRGROUP_ID}; #[derive(Debug, Clone, PartialEq, Copy)] #[repr(u8)] @@ -47,9 +47,7 @@ impl BinaryExtensionTableSM { pub fn new(wcm: Arc>, airgroup_id: usize, air_ids: &[usize]) -> Arc { let pctx = wcm.get_pctx(); - let air = pctx - .pilout - .get_air(BINARY_EXTENSION_TABLE_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0]); let binary_extension_table = Self { wcm: wcm.clone(), @@ -130,11 +128,8 @@ impl BinaryExtensionTableSM { let mut multiplicity = self.multiplicity.lock().unwrap(); - let (is_myne, instance_global_idx) = dctx.add_instance( - BINARY_EXTENSION_TABLE_AIRGROUP_ID, - BINARY_EXTENSION_TABLE_AIR_IDS[0], - 1, - ); + let (is_myne, instance_global_idx) = + dctx.add_instance(ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0], 1); let owner = dctx.owner(instance_global_idx); let mut multiplicity_ = std::mem::take(&mut *multiplicity); @@ -145,7 +140,7 @@ impl BinaryExtensionTableSM { let (mut prover_buffer, offset) = create_prover_buffer( &self.wcm.get_ectx(), &self.wcm.get_sctx(), - BINARY_EXTENSION_TABLE_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0], ); @@ -162,7 +157,7 @@ impl BinaryExtensionTableSM { let air_instance = AirInstance::new( self.wcm.get_sctx(), - BINARY_EXTENSION_TABLE_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_TABLE_AIR_IDS[0], None, prover_buffer, diff --git a/state-machines/freq-ops/src/freq_ops_trace.rs b/state-machines/freq-ops/src/freq_ops_trace.rs index 5c6d6bc1..4ac5308b 100644 --- a/state-machines/freq-ops/src/freq_ops_trace.rs +++ b/state-machines/freq-ops/src/freq_ops_trace.rs @@ -1,4 +1,4 @@ use proofman_common as common; pub use proofman_macros::trace; -trace!(FreqOps0Row, FreqOps0Trace { fake: F }); +trace!(FreqOpsRow, FreqOpsTrace { fake: F }); diff --git a/state-machines/main/pil/main.pil b/state-machines/main/pil/main.pil index e4d406f9..027bee94 100644 --- a/state-machines/main/pil/main.pil +++ b/state-machines/main/pil/main.pil @@ -275,5 +275,5 @@ airtemplate Main(int N = 2**21, int RC = 2, int stack_enabled = 0, const int ope op, store_offset, jmp_offset1, jmp_offset2, rom_flags], sel: 1 - SEGMENT_L1); direct_update(MAIN_CONTINUATION_ID, cols: [0, 0, 4096, 0, 0], bus_type: PIOP_BUS_SUM, proves: 1); - direct_update(MAIN_CONTINUATION_ID, cols: [0, 1, 4312, 0, 0], bus_type: PIOP_BUS_SUM, proves: 0); + direct_update(MAIN_CONTINUATION_ID, cols: [0, 1, 0x10000000, 0, 0], bus_type: PIOP_BUS_SUM, proves: 0); } \ No newline at end of file diff --git a/state-machines/main/src/main_sm.rs b/state-machines/main/src/main_sm.rs index 0e2fe78f..3c8c0d6c 100644 --- a/state-machines/main/src/main_sm.rs +++ b/state-machines/main/src/main_sm.rs @@ -14,8 +14,7 @@ use proofman::WitnessComponent; use sm_arith::ArithSM; use sm_mem::MemSM; use zisk_pil::{ - Main0Row, Main0Trace, BINARY_AIRGROUP_ID, BINARY_AIR_IDS, BINARY_EXTENSION_AIRGROUP_ID, - BINARY_EXTENSION_AIR_IDS, MAIN_AIRGROUP_ID, MAIN_AIR_IDS, + MainRow, MainTrace, BINARY_AIR_IDS, BINARY_EXTENSION_AIR_IDS, MAIN_AIR_IDS, ZISK_AIRGROUP_ID, }; use ziskemu::{Emu, EmuTrace, ZiskEmulator}; @@ -60,7 +59,7 @@ impl MainSM { ) -> Arc { let main_sm = Arc::new(Self { wcm: wcm.clone(), arith_sm, binary_sm, mem_sm }); - wcm.register_component(main_sm.clone(), Some(MAIN_AIRGROUP_ID), Some(MAIN_AIR_IDS)); + wcm.register_component(main_sm.clone(), Some(ZISK_AIRGROUP_ID), Some(MAIN_AIR_IDS)); // For all the secondary state machines, register the main state machine as a predecessor main_sm.mem_sm.register_predecessor(); @@ -81,7 +80,7 @@ impl MainSM { let segment_trace = &vec_traces[segment_id]; let offset = iectx.offset; - let air = pctx.pilout.get_air(MAIN_AIRGROUP_ID, MAIN_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0]); let filled = segment_trace.steps.len() + 1; info!( "{}: ยทยทยท Creating Main segment #{} [{} / {} rows filled {:.2}%]", @@ -94,12 +93,12 @@ impl MainSM { // Set Row 0 of the current segment let row0 = if segment_id == 0 { - Main0Row:: { + MainRow:: { pc: F::from_canonical_u64(ROM_ENTRY), op: F::from_canonical_u8(ZiskOp::CopyB.code()), a_src_imm: F::one(), b_src_imm: F::one(), - ..Main0Row::default() + ..MainRow::default() } } else { let emu_trace_previous = vec_traces[segment_id - 1].steps.last().unwrap(); @@ -107,7 +106,7 @@ impl MainSM { Emu::from_emu_trace_start(zisk_rom, &vec_traces[segment_id - 1].last_state); let row_previous = emu.step_slice_full_trace(emu_trace_previous); - Main0Row:: { + MainRow:: { set_pc: row_previous.set_pc, jmp_offset1: row_previous.jmp_offset1, jmp_offset2: if row_previous.flag == F::one() { @@ -127,21 +126,21 @@ impl MainSM { pc: row_previous.pc, a_src_imm: F::one(), b_src_imm: F::one(), - ..Main0Row::default() + ..MainRow::default() } }; let mut emu = Emu::from_emu_trace_start(zisk_rom, &segment_trace.start_state); - let rng = offset as usize..(offset as usize + Main0Row::::ROW_SIZE); + let rng = offset as usize..(offset as usize + MainRow::::ROW_SIZE); iectx.prover_buffer[rng].copy_from_slice(row0.as_slice()); // Set Rows 1 to N of the current segment (N = maximum number of air rows) let total_rows = segment_trace.steps.len(); const SLICE_ROWS: usize = 4096; - let mut partial_trace = Main0Trace::::new(SLICE_ROWS); + let mut partial_trace = MainTrace::::new(SLICE_ROWS); - let mut last_row = Main0Row::::default(); + let mut last_row = MainRow::::default(); for slice in (0..(air.num_rows())).step_by(SLICE_ROWS) { // process the steps of the chunk let slice_start = std::cmp::min(slice, total_rows); @@ -165,7 +164,7 @@ impl MainSM { //copy the chunk to the prover buffer let partial_buffer = partial_trace.buffer.as_ref().unwrap(); - let buffer_offset_slice = offset as usize + (slice + 1) * Main0Row::::ROW_SIZE; + let buffer_offset_slice = offset as usize + (slice + 1) * MainRow::::ROW_SIZE; let rng = buffer_offset_slice..buffer_offset_slice + partial_buffer.len(); iectx.prover_buffer[rng].copy_from_slice(partial_buffer); @@ -175,7 +174,7 @@ impl MainSM { let sctx = self.wcm.get_sctx(); let mut air_instance = AirInstance::new( sctx.clone(), - MAIN_AIRGROUP_ID, + ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0], Some(segment_id), buffer, @@ -197,7 +196,7 @@ impl MainSM { iectx: &mut InstanceExtensionCtx, pctx: &ProofCtx, ) { - let air = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]); timer_start_debug!(PROCESS_BINARY); let inputs = ZiskEmulator::process_slice_required::( @@ -217,7 +216,7 @@ impl MainSM { let buffer = std::mem::take(&mut iectx.prover_buffer); iectx.air_instance = Some(AirInstance::new( self.wcm.get_sctx(), - BINARY_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0], None, buffer, @@ -232,7 +231,7 @@ impl MainSM { iectx: &mut InstanceExtensionCtx, pctx: &ProofCtx, ) { - let air = pctx.pilout.get_air(BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); + let air = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); let inputs = ZiskEmulator::process_slice_required::( zisk_rom, @@ -247,7 +246,7 @@ impl MainSM { let buffer = std::mem::take(&mut iectx.prover_buffer); iectx.air_instance = Some(AirInstance::new( self.wcm.get_sctx(), - BINARY_EXTENSION_AIRGROUP_ID, + ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0], None, buffer, diff --git a/state-machines/mem/src/mem_traces.rs b/state-machines/mem/src/mem_traces.rs index e4830fc6..c80a8c74 100644 --- a/state-machines/mem/src/mem_traces.rs +++ b/state-machines/mem/src/mem_traces.rs @@ -1,5 +1,5 @@ use proofman_common as common; pub use proofman_macros::trace; -trace!(MemALigned0Row, MemALigned0Trace { fake: F }); -trace!(MemUnaLigned0Row, MemUnaLigned0Trace { fake: F}); +trace!(MemALignedRow, MemALignedTrace { fake: F }); +trace!(MemUnaLignedRow, MemUnaLignedTrace { fake: F}); diff --git a/state-machines/quick-ops/src/quick_ops_trace.rs b/state-machines/quick-ops/src/quick_ops_trace.rs index 91a9121c..61ebfef6 100644 --- a/state-machines/quick-ops/src/quick_ops_trace.rs +++ b/state-machines/quick-ops/src/quick_ops_trace.rs @@ -1,4 +1,4 @@ use proofman_common as common; pub use proofman_macros::trace; -trace!(QuickOps0Row, QuickOps0Trace { fake: F }); +trace!(QuickOpsRow, QuickOpsTrace { fake: F }); diff --git a/state-machines/rom/src/rom.rs b/state-machines/rom/src/rom.rs index ac135e83..083c5539 100644 --- a/state-machines/rom/src/rom.rs +++ b/state-machines/rom/src/rom.rs @@ -6,9 +6,7 @@ use proofman_common::{AirInstance, BufferAllocator, SetupCtx}; use proofman_util::create_buffer_fast; use zisk_core::{Riscv2zisk, ZiskPcHistogram, ZiskRom, SRC_IMM}; -use zisk_pil::{ - Pilout, Rom0Row, Rom0Trace, MAIN_AIRGROUP_ID, MAIN_AIR_IDS, ROM_AIRGROUP_ID, ROM_AIR_IDS, -}; +use zisk_pil::{Pilout, RomRow, RomTrace, MAIN_AIR_IDS, ROM_AIR_IDS, ZISK_AIRGROUP_ID}; //use ziskemu::ZiskEmulatorErr; use std::error::Error; @@ -22,7 +20,7 @@ impl RomSM { let rom_sm = Arc::new(rom_sm); let rom_air_ids = ROM_AIR_IDS; - wcm.register_component(rom_sm.clone(), Some(ROM_AIRGROUP_ID), Some(rom_air_ids)); + wcm.register_component(rom_sm.clone(), Some(ZISK_AIRGROUP_ID), Some(rom_air_ids)); rom_sm } @@ -40,15 +38,15 @@ impl RomSM { } let main_trace_len = - self.wcm.get_pctx().pilout.get_air(MAIN_AIRGROUP_ID, MAIN_AIR_IDS[0]).num_rows() as u64; + self.wcm.get_pctx().pilout.get_air(ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0]).num_rows() as u64; let (prover_buffer, _, air_id) = Self::compute_trace_rom(rom, buffer_allocator, &sctx, pc_histogram, main_trace_len)?; let air_instance = - AirInstance::new(sctx.clone(), ROM_AIRGROUP_ID, air_id, None, prover_buffer); + AirInstance::new(sctx.clone(), ZISK_AIRGROUP_ID, air_id, None, prover_buffer); let (is_mine, instance_gid) = - self.wcm.get_ectx().dctx.write().unwrap().add_instance(ROM_AIRGROUP_ID, air_id, 1); + self.wcm.get_ectx().dctx.write().unwrap().add_instance(ZISK_AIRGROUP_ID, air_id, 1); if is_mine { self.wcm .get_pctx() @@ -94,9 +92,9 @@ impl RomSM { ) -> Result<(Vec, u64, usize), Box> { let pilout = Pilout::pilout(); let sizes = ( - pilout.get_air(ROM_AIRGROUP_ID, ROM_AIR_IDS[0]).num_rows(), - // pilout.get_air(ROM_AIRGROUP_ID, ROM_M_AIR_IDS[0]).num_rows(), - // pilout.get_air(ROM_AIRGROUP_ID, ROM_L_AIR_IDS[0]).num_rows(), + pilout.get_air(ZISK_AIRGROUP_ID, ROM_AIR_IDS[0]).num_rows(), + // pilout.get_air(ZISK_AIRGROUP_ID, ROM_M_AIR_IDS[0]).num_rows(), + // pilout.get_air(ZISK_AIRGROUP_ID, ROM_L_AIR_IDS[0]).num_rows(), ); let number_of_instructions = rom.insts.len(); @@ -156,14 +154,14 @@ impl RomSM { // Allocate a prover buffer let (buffer_size, offsets) = buffer_allocator - .get_buffer_info(sctx, ROM_AIRGROUP_ID, ROM_AIR_IDS[0]) + .get_buffer_info(sctx, ZISK_AIRGROUP_ID, ROM_AIR_IDS[0]) .unwrap_or_else(|err| panic!("Error getting buffer info: {}", err)); let mut prover_buffer = create_buffer_fast(buffer_size as usize); // Create an empty ROM trace let mut rom_trace = - Rom0Trace::::map_buffer(&mut prover_buffer, trace_size, offsets[0] as usize) - .expect("RomSM::compute_trace() failed mapping buffer to ROMS0Trace"); + RomTrace::::map_buffer(&mut prover_buffer, trace_size, offsets[0] as usize) + .expect("RomSM::compute_trace() failed mapping buffer to ROMSRow"); // For every instruction in the rom, fill its corresponding ROM trace for (i, inst_builder) in rom.insts.clone().into_iter().enumerate() { @@ -252,7 +250,7 @@ impl RomSM { // Padd with zeroes for i in number_of_instructions..trace_size { - rom_trace[i] = Rom0Row::default(); + rom_trace[i] = RomRow::default(); } Ok((prover_buffer, offsets[0], ROM_AIR_IDS[0])) @@ -272,14 +270,14 @@ impl RomSM { // // Allocate a prover buffer // let (buffer_size, offsets) = buffer_allocator - // .get_buffer_info(sctx, ROM_AIRGROUP_ID, ROM_M_AIR_IDS[0]) + // .get_buffer_info(sctx, ZISK_AIRGROUP_ID, ROM_M_AIR_IDS[0]) // .unwrap_or_else(|err| panic!("Error getting buffer info: {}", err)); // let mut prover_buffer = create_buffer_fast(buffer_size as usize); // // Create an empty ROM trace // let mut rom_trace = // RomM1Trace::::map_buffer(&mut prover_buffer, trace_size, offsets[0] as usize) - // .expect("RomSM::compute_trace() failed mapping buffer to ROMM0Trace"); + // .expect("RomSM::compute_trace() failed mapping buffer to ROMMRow"); // // For every instruction in the rom, fill its corresponding ROM trace // for (i, inst_builder) in rom.insts.clone().into_iter().enumerate() { @@ -371,14 +369,14 @@ impl RomSM { // // Allocate a prover buffer // let (buffer_size, offsets) = buffer_allocator - // .get_buffer_info(sctx, ROM_AIRGROUP_ID, ROM_L_AIR_IDS[0]) + // .get_buffer_info(sctx, ZISK_AIRGROUP_ID, ROM_L_AIR_IDS[0]) // .unwrap_or_else(|err| panic!("Error getting buffer info: {}", err)); // let mut prover_buffer = create_buffer_fast(buffer_size as usize); // // Create an empty ROM trace // let mut rom_trace = // RomL2Trace::::map_buffer(&mut prover_buffer, trace_size, offsets[0] as usize) - // .expect("RomSM::compute_trace() failed mapping buffer to ROML0Trace"); + // .expect("RomSM::compute_trace() failed mapping buffer to ROMLRow"); // // For every instruction in the rom, fill its corresponding ROM trace // for (i, inst_builder) in rom.insts.clone().into_iter().enumerate() { diff --git a/witness-computation/src/executor.rs b/witness-computation/src/executor.rs index 2398fbd5..5705aede 100644 --- a/witness-computation/src/executor.rs +++ b/witness-computation/src/executor.rs @@ -18,10 +18,7 @@ use std::{ sync::Arc, }; use zisk_core::{Riscv2zisk, ZiskOperationType, ZiskRom, ZISK_OPERATION_TYPE_VARIANTS}; -use zisk_pil::{ - BINARY_AIRGROUP_ID, BINARY_AIR_IDS, BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS, - MAIN_AIRGROUP_ID, MAIN_AIR_IDS, -}; +use zisk_pil::{BINARY_AIR_IDS, BINARY_EXTENSION_AIR_IDS, MAIN_AIR_IDS, ZISK_AIRGROUP_ID}; use ziskemu::{EmuOptions, ZiskEmulator}; pub struct ZiskExecutor { @@ -104,7 +101,7 @@ impl ZiskExecutor { ectx: Arc, sctx: Arc, ) { - let air_main = pctx.pilout.get_air(MAIN_AIRGROUP_ID, MAIN_AIR_IDS[0]); + let air_main = pctx.pilout.get_air(ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0]); // Prepare the settings for the emulator let emu_options = EmuOptions { @@ -128,9 +125,8 @@ impl ZiskExecutor { // machine. We aim to track the starting point of execution for every N instructions // across different operation types. Currently, we are only collecting data for // Binary and BinaryE operations. - let air_binary = pctx.pilout.get_air(BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]); - let air_binary_e = - pctx.pilout.get_air(BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); + let air_binary = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]); + let air_binary_e = pctx.pilout.get_air(ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]); let mut op_sizes = [0u64; ZISK_OPERATION_TYPE_VARIANTS]; // The starting points for the Main is allocated using None operation @@ -178,11 +174,9 @@ impl ZiskExecutor { let mut main_segnent_id = 0; for emu_slice in emu_slices.points.iter() { let (airgroup_id, air_id) = match emu_slice.op_type { - ZiskOperationType::None => (MAIN_AIRGROUP_ID, MAIN_AIR_IDS[0]), - ZiskOperationType::Binary => (BINARY_AIRGROUP_ID, BINARY_AIR_IDS[0]), - ZiskOperationType::BinaryE => { - (BINARY_EXTENSION_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]) - } + ZiskOperationType::None => (ZISK_AIRGROUP_ID, MAIN_AIR_IDS[0]), + ZiskOperationType::Binary => (ZISK_AIRGROUP_ID, BINARY_AIR_IDS[0]), + ZiskOperationType::BinaryE => (ZISK_AIRGROUP_ID, BINARY_EXTENSION_AIR_IDS[0]), _ => panic!("Invalid operation type"), }; let segment_id = match emu_slice.op_type {