From 9e911a1be9be6f032a8ab38690f9841b413cedc7 Mon Sep 17 00:00:00 2001 From: Hadas Date: Wed, 17 Jan 2024 19:33:41 -0500 Subject: [PATCH] merge conflicts --- alu_u32/Cargo.toml | 2 +- alu_u32/src/add/mod.rs | 2 +- alu_u32/src/bitwise/mod.rs | 2 +- alu_u32/src/div/mod.rs | 4 +- alu_u32/src/lt/mod.rs | 4 +- alu_u32/src/mul/mod.rs | 2 +- alu_u32/src/shift/mod.rs | 2 +- alu_u32/src/sub/mod.rs | 3 +- basic/src/lib.rs | 98 +++++++++++---------- cpu/Cargo.toml | 2 +- cpu/src/lib.rs | 2 +- machine/src/__internal/check_constraints.rs | 3 +- machine/src/__internal/debug_builder.rs | 3 +- machine/src/__internal/folding_builder.rs | 2 +- machine/src/chip.rs | 3 +- machine/src/lib.rs | 2 +- memory/Cargo.toml | 2 +- memory/src/lib.rs | 4 +- native_field/Cargo.toml | 2 +- native_field/src/lib.rs | 3 +- output/Cargo.toml | 2 +- output/src/lib.rs | 2 +- program/Cargo.toml | 2 +- program/src/lib.rs | 2 +- range/Cargo.toml | 2 +- range/src/lib.rs | 3 +- 26 files changed, 85 insertions(+), 75 deletions(-) diff --git a/alu_u32/Cargo.toml b/alu_u32/Cargo.toml index 52b96966..7123abb7 100644 --- a/alu_u32/Cargo.toml +++ b/alu_u32/Cargo.toml @@ -12,7 +12,7 @@ p3-baby-bear = { path = "../../Plonky3/baby-bear" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark" } valida-bus = { path = "../bus" } valida-derive = { path = "../derive" } valida-machine = { path = "../machine" } diff --git a/alu_u32/src/add/mod.rs b/alu_u32/src/add/mod.rs index f3f1db0b..8a382fb0 100644 --- a/alu_u32/src/add/mod.rs +++ b/alu_u32/src/add/mod.rs @@ -14,7 +14,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; use valida_util::pad_to_power_of_two; pub mod columns; diff --git a/alu_u32/src/bitwise/mod.rs b/alu_u32/src/bitwise/mod.rs index 5d16f176..ffa4bc4c 100644 --- a/alu_u32/src/bitwise/mod.rs +++ b/alu_u32/src/bitwise/mod.rs @@ -13,7 +13,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; use valida_util::pad_to_power_of_two; pub mod columns; diff --git a/alu_u32/src/div/mod.rs b/alu_u32/src/div/mod.rs index 410cb0c8..60cce76b 100644 --- a/alu_u32/src/div/mod.rs +++ b/alu_u32/src/div/mod.rs @@ -15,9 +15,9 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; -use valida_util::pad_to_power_of_two; +use valida_util::pad_to_power_of_two; +use p3_uni_stark::StarkConfig; pub mod columns; pub mod stark; diff --git a/alu_u32/src/lt/mod.rs b/alu_u32/src/lt/mod.rs index 2dd34959..364ec7b5 100644 --- a/alu_u32/src/lt/mod.rs +++ b/alu_u32/src/lt/mod.rs @@ -16,9 +16,9 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; -use valida_util::pad_to_power_of_two; +use valida_util::pad_to_power_of_two; +use p3_uni_stark::StarkConfig; pub mod columns; pub mod stark; diff --git a/alu_u32/src/mul/mod.rs b/alu_u32/src/mul/mod.rs index 45d4c800..c43155ee 100644 --- a/alu_u32/src/mul/mod.rs +++ b/alu_u32/src/mul/mod.rs @@ -13,7 +13,7 @@ use core::borrow::BorrowMut; use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; pub mod columns; pub mod stark; diff --git a/alu_u32/src/shift/mod.rs b/alu_u32/src/shift/mod.rs index b9a0452a..6f5b2df3 100644 --- a/alu_u32/src/shift/mod.rs +++ b/alu_u32/src/shift/mod.rs @@ -15,7 +15,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; use valida_util::pad_to_power_of_two; pub mod columns; diff --git a/alu_u32/src/sub/mod.rs b/alu_u32/src/sub/mod.rs index bd92797f..d935acc2 100644 --- a/alu_u32/src/sub/mod.rs +++ b/alu_u32/src/sub/mod.rs @@ -14,7 +14,8 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; + use valida_util::pad_to_power_of_two; pub mod columns; diff --git a/basic/src/lib.rs b/basic/src/lib.rs index 1dcacee2..55128a79 100644 --- a/basic/src/lib.rs +++ b/basic/src/lib.rs @@ -16,7 +16,7 @@ use p3_uni_stark::{ ProverConstraintFolder, ProverData, StarkConfig, SymbolicAirBuilder, }; use p3_util::log2_ceil_usize; - +use p3_field::PrimeField32; use valida_alu_u32::{ add::{Add32Chip, Add32Instruction, MachineWithAdd32Chip}, bitwise::{ @@ -53,7 +53,7 @@ use valida_program::{MachineWithProgramChip, ProgramChip}; use valida_range::{MachineWithRangeChip, RangeCheckerChip}; #[derive(Default)] -pub struct BasicMachine> { +pub struct BasicMachine { // Core instructions load32: Load32Instruction, @@ -276,86 +276,85 @@ impl MachineWithRangeChip for BasicMachi } } -impl> Machine for BasicMachine { - type F = F; - type EF = EF; +impl Machine for BasicMachine { + fn run(&mut self, program: &ProgramROM, advice: &mut Adv) { loop { - let pc = self.cpu().pc; + let pc = self.cpu.pc; let instruction = program.get_instruction(pc); let opcode = instruction.opcode; let ops = instruction.operands; match opcode { - >::OPCODE => { + >::OPCODE => { Load32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Store32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { JalInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { JalvInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { BeqInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { BneInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Imm32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Add32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Sub32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Mul32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Mulhs32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Mulhu32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Div32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { SDiv32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Shl32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Shr32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Sra32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Lt32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { And32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Or32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { Xor32Instruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { ReadAdviceInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { WriteInstruction::execute_with_advice(self, ops, advice); } - >::OPCODE => { + >::OPCODE => { StopInstruction::execute_with_advice(self, ops, advice); } _ => {} @@ -363,13 +362,13 @@ impl> Machine for BasicMac self.read_word(pc as usize); - if opcode == >::OPCODE { + if opcode == >::OPCODE { break; } } - let n = self.cpu().clock.next_power_of_two() - self.cpu().clock; + let n = self.cpu.clock.next_power_of_two() - self.cpu.clock; for _ in 0..n { - self.read_word(self.cpu().pc as usize); + self.read_word(self.cpu.pc as usize); } } fn add_chip_trace( @@ -395,16 +394,16 @@ impl> Machine for BasicMac } fn prove(&self, config: &SC, challenger: &mut SC::Challenger) -> MachineProof where - SC: StarkConfig, + SC: StarkConfig, { let mut trace_commitments = Vec::new(); let mut quotient_commitments = Vec::new(); let mut log_degrees = Vec::new(); let mut log_quotient_degrees = Vec::new(); - - let air = &self.cpu; +/* + let air = &self.cpu(); assert_eq!(air.operations.len() > 0, true); - let trace = air.generate_trace(self); + let trace = air.generate_trace(air, self); self.add_chip_trace( config, challenger, @@ -415,10 +414,10 @@ impl> Machine for BasicMac air, trace, ); - +*/ if self.add_u32.operations.len() > 0 { let air = &self.add_u32; - let trace = air.generate_trace(self); + let trace = , SC>>::generate_trace(air,self); self.add_chip_trace( config, @@ -433,7 +432,8 @@ impl> Machine for BasicMac } if self.sub_u32.operations.len() > 0 { let air = &self.sub_u32; - let trace = air.generate_trace(self); + let trace = , SC>>::generate_trace(air, self); + self.add_chip_trace( config, challenger, @@ -447,7 +447,8 @@ impl> Machine for BasicMac } if self.mul_u32.operations.len() > 0 { let air = &self.mul_u32; - let trace = air.generate_trace(self); + let trace =, SC>>::generate_trace(air, self); + self.add_chip_trace( config, challenger, @@ -461,7 +462,8 @@ impl> Machine for BasicMac } if self.div_u32.operations.len() > 0 { let air = &self.div_u32; - let trace = air.generate_trace(self); + + let trace = , SC>>::generate_trace(air, self); self.add_chip_trace( config, challenger, @@ -475,7 +477,9 @@ impl> Machine for BasicMac } if self.shift_u32.operations.len() > 0 { let air = &self.shift_u32; - let trace = air.generate_trace(self); + let trace = , SC>>::generate_trace(air, self); + + self.add_chip_trace( config, challenger, @@ -489,7 +493,8 @@ impl> Machine for BasicMac } if self.lt_u32.operations.len() > 0 { let air = &self.lt_u32; - let trace = air.generate_trace(self); + let trace = , SC>>::generate_trace(air, self); + self.add_chip_trace( config, challenger, @@ -504,7 +509,8 @@ impl> Machine for BasicMac if self.bitwise_u32.operations.len() > 0 { let air = &self.bitwise_u32; - let trace = air.generate_trace(self); + let trace = , SC>>::generate_trace(air, self); + self.add_chip_trace( config, challenger, @@ -551,7 +557,7 @@ impl> Machine for BasicMac fn verify(proof: &MachineProof) -> Result<(), ()> where - SC: StarkConfig, + SC: StarkConfig, { Ok(()) } diff --git a/cpu/Cargo.toml b/cpu/Cargo.toml index 35de0dc3..b2f883b1 100644 --- a/cpu/Cargo.toml +++ b/cpu/Cargo.toml @@ -10,7 +10,7 @@ p3-baby-bear = { path = "../../Plonky3/baby-bear" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark"} valida-bus = { path = "../bus" } valida-machine = { path = "../machine" } valida-memory = { path = "../memory" } diff --git a/cpu/src/lib.rs b/cpu/src/lib.rs index 6fef97d7..f2ff0c1c 100644 --- a/cpu/src/lib.rs +++ b/cpu/src/lib.rs @@ -23,7 +23,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; pub mod columns; pub mod stark; diff --git a/machine/src/__internal/check_constraints.rs b/machine/src/__internal/check_constraints.rs index 424c7af5..4fcaf766 100644 --- a/machine/src/__internal/check_constraints.rs +++ b/machine/src/__internal/check_constraints.rs @@ -1,6 +1,7 @@ use crate::__internal::DebugConstraintBuilder; use crate::chip::eval_permutation_constraints; -use crate::config::StarkConfig; +use p3_uni_stark::StarkConfig; + use crate::{Chip, Machine}; use p3_air::{Air, TwoRowMatrixView}; use p3_field::{AbstractField, Field}; diff --git a/machine/src/__internal/debug_builder.rs b/machine/src/__internal/debug_builder.rs index 6cfcaa08..37be734f 100644 --- a/machine/src/__internal/debug_builder.rs +++ b/machine/src/__internal/debug_builder.rs @@ -1,8 +1,7 @@ -use crate::config::StarkConfig; use crate::{Machine, ValidaAirBuilder}; use p3_air::{AirBuilder, PairBuilder, PermutationAirBuilder, TwoRowMatrixView}; use p3_field::AbstractField; - +use p3_uni_stark::StarkConfig; /// An `AirBuilder` which asserts that each constraint is zero, allowing any failed constraints to /// be detected early. pub struct DebugConstraintBuilder<'a, M: Machine, SC: StarkConfig> { diff --git a/machine/src/__internal/folding_builder.rs b/machine/src/__internal/folding_builder.rs index 85ecfea3..0f646d91 100644 --- a/machine/src/__internal/folding_builder.rs +++ b/machine/src/__internal/folding_builder.rs @@ -1,6 +1,6 @@ use crate::{Machine, ValidaAirBuilder}; use p3_air::{AirBuilder, PairBuilder, PermutationAirBuilder, TwoRowMatrixView}; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; pub struct ConstraintFolder<'a, M: Machine, SC: StarkConfig> { pub(crate) machine: &'a M, diff --git a/machine/src/chip.rs b/machine/src/chip.rs index 7719a36b..49d16220 100644 --- a/machine/src/chip.rs +++ b/machine/src/chip.rs @@ -4,7 +4,8 @@ use alloc::vec; use alloc::vec::Vec; use valida_util::batch_multiplicative_inverse; -use crate::config::StarkConfig; +//use crate::config::StarkConfig; +use p3_uni_stark::StarkConfig; use p3_air::{Air, AirBuilder, PairBuilder, PermutationAirBuilder, VirtualPairCol}; use p3_field::{AbstractExtensionField, AbstractField, ExtensionField, Field, Powers}; use p3_matrix::{dense::RowMajorMatrix, Matrix, MatrixRowSlices}; diff --git a/machine/src/lib.rs b/machine/src/lib.rs index bdc1e6c9..4faf352a 100644 --- a/machine/src/lib.rs +++ b/machine/src/lib.rs @@ -177,7 +177,7 @@ pub trait Machine { fn prove(&self, config: &SC, challenger: &mut SC::Challenger) -> MachineProof where - SC: StarkConfig; + SC: StarkConfig; fn verify>(proof: &MachineProof) -> Result<(), ()>; } diff --git a/memory/Cargo.toml b/memory/Cargo.toml index cf010ded..cb4c1a2e 100644 --- a/memory/Cargo.toml +++ b/memory/Cargo.toml @@ -10,7 +10,7 @@ p3-baby-bear = { path = "../../Plonky3/baby-bear" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark" } valida-bus = { path = "../bus" } valida-machine = { path = "../machine" } valida-derive = { path = "../derive" } diff --git a/memory/src/lib.rs b/memory/src/lib.rs index 360c8b56..3e9f46d9 100644 --- a/memory/src/lib.rs +++ b/memory/src/lib.rs @@ -10,12 +10,12 @@ use core::mem::transmute; use valida_bus::MachineWithMemBus; use valida_machine::{BusArgument, Chip, Interaction, Machine, Word}; use valida_util::batch_multiplicative_inverse; - +use p3_uni_stark::StarkConfig; use p3_air::VirtualPairCol; use p3_field::{Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; + pub mod columns; pub mod stark; diff --git a/native_field/Cargo.toml b/native_field/Cargo.toml index ea2fd887..7229c013 100644 --- a/native_field/Cargo.toml +++ b/native_field/Cargo.toml @@ -11,7 +11,7 @@ p3-air = { path = "../../Plonky3/air" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark" } valida-bus = { path = "../bus" } valida-derive = { path = "../derive" } valida-machine = { path = "../machine" } diff --git a/native_field/src/lib.rs b/native_field/src/lib.rs index 382db7ea..66b67b53 100644 --- a/native_field/src/lib.rs +++ b/native_field/src/lib.rs @@ -17,7 +17,8 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field, PrimeField32}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; + pub mod columns; pub mod stark; diff --git a/output/Cargo.toml b/output/Cargo.toml index 755842be..a147be2c 100644 --- a/output/Cargo.toml +++ b/output/Cargo.toml @@ -10,7 +10,7 @@ p3-baby-bear = { path = "../../Plonky3/baby-bear" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark"} valida-bus = { path = "../bus" } valida-cpu = { path = "../cpu" } valida-machine = { path = "../machine" } diff --git a/output/src/lib.rs b/output/src/lib.rs index 31fc6179..158e24cb 100644 --- a/output/src/lib.rs +++ b/output/src/lib.rs @@ -12,7 +12,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::*; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; use valida_util::pad_to_power_of_two; pub mod columns; diff --git a/program/Cargo.toml b/program/Cargo.toml index 7c1f984d..82c42f03 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" p3-air = { path = "../../Plonky3/air" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } - +p3-uni-stark = {path = "../../Plonky3/uni-stark"} valida-bus = { path = "../bus" } valida-derive = { path = "../derive" } valida-machine = { path = "../machine" } diff --git a/program/src/lib.rs b/program/src/lib.rs index 151300cf..bc49796b 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -12,7 +12,7 @@ use valida_util::pad_to_power_of_two; use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; pub mod columns; pub mod stark; diff --git a/range/Cargo.toml b/range/Cargo.toml index 9b72e6e2..81f49ece 100644 --- a/range/Cargo.toml +++ b/range/Cargo.toml @@ -10,7 +10,7 @@ p3-baby-bear = { path = "../../Plonky3/baby-bear" } p3-field = { path = "../../Plonky3/field" } p3-matrix = { path = "../../Plonky3/matrix" } p3-maybe-rayon = { path = "../../Plonky3/maybe-rayon" } - +p3-uni-stark = { path = "../../Plonky3/uni-stark" } valida-bus = { path = "../bus" } valida-machine = { path = "../machine" } valida-util = { path = "../util" } diff --git a/range/src/lib.rs b/range/src/lib.rs index aa988357..45bd3bc8 100644 --- a/range/src/lib.rs +++ b/range/src/lib.rs @@ -14,7 +14,8 @@ use valida_machine::{Chip, Machine, Word}; use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; -use valida_machine::config::StarkConfig; +use p3_uni_stark::StarkConfig; + pub mod columns; pub mod stark;